Completed
Push — master ( c1ab59...d1d834 )
by cam
04:22
created
ecrire/inc/filtres.php 2 patches
Indentation   +2230 added lines, -2230 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/charsets');
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
  * @return string Fonction PHP correspondante du filtre
43 43
  */
44 44
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
45
-	include_spip('public/parametrer'); // inclure les fichiers fonctions
46
-	return chercher_filtre($fonc, $default);
45
+    include_spip('public/parametrer'); // inclure les fichiers fonctions
46
+    return chercher_filtre($fonc, $default);
47 47
 }
48 48
 
49 49
 /**
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
  *     Fonction PHP correspondante du filtre demandé
76 76
  */
77 77
 function chercher_filtre($fonc, $default = null) {
78
-	if (!$fonc) {
79
-		return $default;
80
-	}
81
-	// Cas des types mime, sans confondre avec les appels de fonction de classe
82
-	// Foo::Bar
83
-	// qui peuvent etre avec un namespace : space\Foo::Bar
84
-	if (preg_match(',^[\w]+/,', $fonc)) {
85
-		$nom = preg_replace(',\W,', '_', $fonc);
86
-		$f = chercher_filtre($nom);
87
-		// cas du sous-type MIME sans filtre associe, passer au type:
88
-		// si filtre_text_plain pas defini, passe a filtre_text
89
-		if (!$f and $nom !== $fonc) {
90
-			$f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
-		}
92
-
93
-		return $f;
94
-	}
95
-
96
-	include_fichiers_fonctions();
97
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
98
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99
-		// fonction ou name\space\fonction
100
-		if (is_callable($f)) {
101
-			return $f;
102
-		}
103
-		// méthode statique d'une classe Classe::methode ou name\space\Classe::methode
104
-		elseif (false === strpos($f, '::') and is_callable(array($f))) {
105
-			return $f;
106
-		}
107
-	}
108
-
109
-	return $default;
78
+    if (!$fonc) {
79
+        return $default;
80
+    }
81
+    // Cas des types mime, sans confondre avec les appels de fonction de classe
82
+    // Foo::Bar
83
+    // qui peuvent etre avec un namespace : space\Foo::Bar
84
+    if (preg_match(',^[\w]+/,', $fonc)) {
85
+        $nom = preg_replace(',\W,', '_', $fonc);
86
+        $f = chercher_filtre($nom);
87
+        // cas du sous-type MIME sans filtre associe, passer au type:
88
+        // si filtre_text_plain pas defini, passe a filtre_text
89
+        if (!$f and $nom !== $fonc) {
90
+            $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
+        }
92
+
93
+        return $f;
94
+    }
95
+
96
+    include_fichiers_fonctions();
97
+    foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
98
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99
+        // fonction ou name\space\fonction
100
+        if (is_callable($f)) {
101
+            return $f;
102
+        }
103
+        // méthode statique d'une classe Classe::methode ou name\space\Classe::methode
104
+        elseif (false === strpos($f, '::') and is_callable(array($f))) {
105
+            return $f;
106
+        }
107
+    }
108
+
109
+    return $default;
110 110
 }
111 111
 
112 112
 /**
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
  *     Chaîne vide sinon (filtre introuvable).
131 131
  **/
132 132
 function appliquer_filtre($arg, $filtre, $force = null) {
133
-	$f = chercher_filtre($filtre);
134
-	if (!$f) {
135
-		if (!$force) {
136
-			return '';
137
-		} else {
138
-			return $arg;
139
-		}
140
-	}
133
+    $f = chercher_filtre($filtre);
134
+    if (!$f) {
135
+        if (!$force) {
136
+            return '';
137
+        } else {
138
+            return $arg;
139
+        }
140
+    }
141 141
 
142
-	$args = func_get_args();
143
-	array_shift($args); // enlever $arg
144
-	array_shift($args); // enlever $filtre
145
-	array_unshift($args, $arg); // remettre $arg
146
-	return call_user_func_array($f, $args);
142
+    $args = func_get_args();
143
+    array_shift($args); // enlever $arg
144
+    array_shift($args); // enlever $filtre
145
+    array_unshift($args, $arg); // remettre $arg
146
+    return call_user_func_array($f, $args);
147 147
 }
148 148
 
149 149
 /**
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
  *     Version de SPIP
160 160
  **/
161 161
 function spip_version() {
162
-	$version = $GLOBALS['spip_version_affichee'];
163
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
164
-		$version .= " $vcs_version";
165
-	}
162
+    $version = $GLOBALS['spip_version_affichee'];
163
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
164
+        $version .= " $vcs_version";
165
+    }
166 166
 
167
-	return $version;
167
+    return $version;
168 168
 }
169 169
 
170 170
 /**
@@ -177,19 +177,19 @@  discard block
 block discarded – undo
177 177
  *    - string|null si $raw = false
178 178
  */
179 179
 function version_vcs_courante($dir, $raw = false) {
180
-	$desc = decrire_version_git($dir);
181
-	if ($desc === null) {
182
-		$desc = decrire_version_svn($dir);
183
-	}
184
-	if ($desc === null or $raw) {
185
-		return $desc;
186
-	}
187
-	// affichage "GIT [master: abcdef]"
188
-	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189
-	if ($desc['branch']) {
190
-		$commit = $desc['branch'] . ': ' . $commit;
191
-	}
192
-	return "{$desc['vcs']} [$commit]";
180
+    $desc = decrire_version_git($dir);
181
+    if ($desc === null) {
182
+        $desc = decrire_version_svn($dir);
183
+    }
184
+    if ($desc === null or $raw) {
185
+        return $desc;
186
+    }
187
+    // affichage "GIT [master: abcdef]"
188
+    $commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189
+    if ($desc['branch']) {
190
+        $commit = $desc['branch'] . ': ' . $commit;
191
+    }
192
+    return "{$desc['vcs']} [$commit]";
193 193
 }
194 194
 
195 195
 /**
@@ -201,24 +201,24 @@  discard block
 block discarded – undo
201 201
  *      array ['branch' => xx, 'commit' => yy] sinon.
202 202
  **/
203 203
 function decrire_version_git($dir) {
204
-	if (!$dir) {
205
-		$dir = '.';
206
-	}
204
+    if (!$dir) {
205
+        $dir = '.';
206
+    }
207 207
 
208
-	// version installee par GIT
209
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
210
-		$currentHead = trim(substr($c, 4));
211
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
212
-			return [
213
-				'vcs' => 'GIT',
214
-				'branch' => basename($currentHead),
215
-				'commit' => trim($hash),
216
-				'commit_short' => substr(trim($hash), 0, 8),
217
-			];
218
-		}
219
-	}
208
+    // version installee par GIT
209
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
210
+        $currentHead = trim(substr($c, 4));
211
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
212
+            return [
213
+                'vcs' => 'GIT',
214
+                'branch' => basename($currentHead),
215
+                'commit' => trim($hash),
216
+                'commit_short' => substr(trim($hash), 0, 8),
217
+            ];
218
+        }
219
+    }
220 220
 
221
-	return null;
221
+    return null;
222 222
 }
223 223
 
224 224
 
@@ -231,25 +231,25 @@  discard block
 block discarded – undo
231 231
  *      array ['commit' => yy, 'date' => xx, 'author' => xx] sinon.
232 232
  **/
233 233
 function decrire_version_svn($dir) {
234
-	if (!$dir) {
235
-		$dir = '.';
236
-	}
237
-	// version installee par SVN
238
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
-		$db = new SQLite3($dir . '/.svn/wc.db');
240
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241
-		if ($result) {
242
-			$row = $result->fetchArray();
243
-			if ($row['changed_revision'] != "") {
244
-				return [
245
-					'vcs' => 'SVN',
246
-					'branch' => '',
247
-					'commit' => $row['changed_revision'],
248
-				];
249
-			}
250
-		}
251
-	}
252
-	return null;
234
+    if (!$dir) {
235
+        $dir = '.';
236
+    }
237
+    // version installee par SVN
238
+    if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
+        $db = new SQLite3($dir . '/.svn/wc.db');
240
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241
+        if ($result) {
242
+            $row = $result->fetchArray();
243
+            if ($row['changed_revision'] != "") {
244
+                return [
245
+                    'vcs' => 'SVN',
246
+                    'branch' => '',
247
+                    'commit' => $row['changed_revision'],
248
+                ];
249
+            }
250
+        }
251
+    }
252
+    return null;
253 253
 }
254 254
 
255 255
 /**
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
  *
268 268
  **/
269 269
 function version_svn_courante($dir) {
270
-	if ($desc = decrire_version_svn($dir)) {
271
-		return -$desc['commit'];
272
-	}
273
-	return 0;
270
+    if ($desc = decrire_version_svn($dir)) {
271
+        return -$desc['commit'];
272
+    }
273
+    return 0;
274 274
 }
275 275
 
276 276
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -314,18 +314,18 @@  discard block
 block discarded – undo
314 314
  *     Code HTML retourné par le filtre
315 315
  **/
316 316
 function filtrer($filtre) {
317
-	$tous = func_get_args();
318
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
319
-		return image_filtrer($tous);
320
-	} elseif ($f = chercher_filtre($filtre)) {
321
-		array_shift($tous);
322
-		return call_user_func_array($f, $tous);
323
-	} else {
324
-		// le filtre n'existe pas, on provoque une erreur
325
-		$msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
326
-		erreur_squelette($msg);
327
-		return '';
328
-	}
317
+    $tous = func_get_args();
318
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
319
+        return image_filtrer($tous);
320
+    } elseif ($f = chercher_filtre($filtre)) {
321
+        array_shift($tous);
322
+        return call_user_func_array($f, $tous);
323
+    } else {
324
+        // le filtre n'existe pas, on provoque une erreur
325
+        $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
326
+        erreur_squelette($msg);
327
+        return '';
328
+    }
329 329
 }
330 330
 
331 331
 /**
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
343 343
  */
344 344
 function trouver_filtre_matrice($filtre) {
345
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
346
-		find_in_path($f, '', true);
347
-		$GLOBALS['spip_matrice'][$filtre] = true;
348
-	}
349
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
345
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
346
+        find_in_path($f, '', true);
347
+        $GLOBALS['spip_matrice'][$filtre] = true;
348
+    }
349
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
350 350
 }
351 351
 
352 352
 
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
  * @return mixed
375 375
  */
376 376
 function filtre_set(&$Pile, $val, $key, $continue = null) {
377
-	$Pile['vars'][$key] = $val;
378
-	return $continue ? $val : '';
377
+    $Pile['vars'][$key] = $val;
378
+    return $continue ? $val : '';
379 379
 }
380 380
 
381 381
 /**
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
402 402
  */
403 403
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
404
-	$Pile[0][$key] = $val;
405
-	return $continue ? $val : '';
404
+    $Pile[0][$key] = $val;
405
+    return $continue ? $val : '';
406 406
 }
407 407
 
408 408
 /**
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
  * @return string
412 412
  */
413 413
 function filtre_sanitize_env(&$Pile, $keys) {
414
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
415
-	return '';
414
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
415
+    return '';
416 416
 }
417 417
 
418 418
 
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
  * @return mixed Retourne la valeur (sans la modifier).
436 436
  */
437 437
 function filtre_debug($val, $key = null) {
438
-	$debug = (
439
-		is_null($key) ? '' : (var_export($key, true) . " = ")
440
-		) . var_export($val, true);
438
+    $debug = (
439
+        is_null($key) ? '' : (var_export($key, true) . " = ")
440
+        ) . var_export($val, true);
441 441
 
442
-	include_spip('inc/autoriser');
443
-	if (autoriser('webmestre')) {
444
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
445
-	}
442
+    include_spip('inc/autoriser');
443
+    if (autoriser('webmestre')) {
444
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
445
+    }
446 446
 
447
-	spip_log($debug, 'debug');
447
+    spip_log($debug, 'debug');
448 448
 
449
-	return $val;
449
+    return $val;
450 450
 }
451 451
 
452 452
 
@@ -474,82 +474,82 @@  discard block
 block discarded – undo
474 474
  *     Texte qui a reçu les filtres
475 475
  **/
476 476
 function image_filtrer($args) {
477
-	$filtre = array_shift($args); # enlever $filtre
478
-	$texte = array_shift($args);
479
-	if (!strlen($texte)) {
480
-		return;
481
-	}
482
-	find_in_path('filtres_images_mini.php', 'inc/', true);
483
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
484
-	// Cas du nom de fichier local
485
-	$is_file = trim($texte);
486
-	if (strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
487
-		  or strpbrk($is_file, "<>\n\r\t") !== false
488
-		  or strpos($is_file, '/') === 0
489
-	) {
490
-		$is_file = false;
491
-	}
492
-	if ($is_file) {
493
-		$is_local_file = function($path) {
494
-			if (strpos($path, "?") !== false) {
495
-				$path = supprimer_timestamp($path);
496
-				// remove ?24px added by find_in_theme on .svg files
497
-				$path = preg_replace(",\?[[:digit:]]+(px)$,", "", $path);
498
-			}
499
-			return file_exists($path);
500
-		};
501
-		if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
502
-			array_unshift($args, "<img src='$is_file' />");
503
-			$res = call_user_func_array($filtre, $args);
504
-			statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
505
-			return $res;
506
-		}
507
-	}
508
-
509
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
510
-	if (preg_match_all(
511
-		',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
512
-		$texte, $tags, PREG_SET_ORDER)) {
513
-		foreach ($tags as $tag) {
514
-			$class = extraire_attribut($tag[3], 'class');
515
-			if (!$class or
516
-				(strpos($class, 'filtre_inactif') === false
517
-					// compat historique a virer en 3.2
518
-					and strpos($class, 'no_image_filtrer') === false)
519
-			) {
520
-				array_unshift($args, $tag[3]);
521
-				if ($reduit = call_user_func_array($filtre, $args)) {
522
-					// En cas de span spip_documents, modifier le style=...width:
523
-					if ($tag[1]) {
524
-						$w = extraire_attribut($reduit, 'width');
525
-						if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
526
-							$w = $regs[1];
527
-						}
528
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
529
-							$style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
530
-							$replace = inserer_attribut($tag[1], 'style', $style);
531
-							$texte = str_replace($tag[1], $replace, $texte);
532
-						}
533
-					}
534
-					// traiter aussi un eventuel mouseover
535
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
536
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
537
-							$srcover = $match[1];
538
-							array_shift($args);
539
-							array_unshift($args, "<img src='" . $match[1] . "' />");
540
-							$srcover_filter = call_user_func_array($filtre, $args);
541
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
542
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
543
-						}
544
-					}
545
-					$texte = str_replace($tag[3], $reduit, $texte);
546
-				}
547
-				array_shift($args);
548
-			}
549
-		}
550
-	}
551
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
552
-	return $texte;
477
+    $filtre = array_shift($args); # enlever $filtre
478
+    $texte = array_shift($args);
479
+    if (!strlen($texte)) {
480
+        return;
481
+    }
482
+    find_in_path('filtres_images_mini.php', 'inc/', true);
483
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
484
+    // Cas du nom de fichier local
485
+    $is_file = trim($texte);
486
+    if (strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
487
+          or strpbrk($is_file, "<>\n\r\t") !== false
488
+          or strpos($is_file, '/') === 0
489
+    ) {
490
+        $is_file = false;
491
+    }
492
+    if ($is_file) {
493
+        $is_local_file = function($path) {
494
+            if (strpos($path, "?") !== false) {
495
+                $path = supprimer_timestamp($path);
496
+                // remove ?24px added by find_in_theme on .svg files
497
+                $path = preg_replace(",\?[[:digit:]]+(px)$,", "", $path);
498
+            }
499
+            return file_exists($path);
500
+        };
501
+        if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
502
+            array_unshift($args, "<img src='$is_file' />");
503
+            $res = call_user_func_array($filtre, $args);
504
+            statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
505
+            return $res;
506
+        }
507
+    }
508
+
509
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
510
+    if (preg_match_all(
511
+        ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
512
+        $texte, $tags, PREG_SET_ORDER)) {
513
+        foreach ($tags as $tag) {
514
+            $class = extraire_attribut($tag[3], 'class');
515
+            if (!$class or
516
+                (strpos($class, 'filtre_inactif') === false
517
+                    // compat historique a virer en 3.2
518
+                    and strpos($class, 'no_image_filtrer') === false)
519
+            ) {
520
+                array_unshift($args, $tag[3]);
521
+                if ($reduit = call_user_func_array($filtre, $args)) {
522
+                    // En cas de span spip_documents, modifier le style=...width:
523
+                    if ($tag[1]) {
524
+                        $w = extraire_attribut($reduit, 'width');
525
+                        if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
526
+                            $w = $regs[1];
527
+                        }
528
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
529
+                            $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
530
+                            $replace = inserer_attribut($tag[1], 'style', $style);
531
+                            $texte = str_replace($tag[1], $replace, $texte);
532
+                        }
533
+                    }
534
+                    // traiter aussi un eventuel mouseover
535
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
536
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
537
+                            $srcover = $match[1];
538
+                            array_shift($args);
539
+                            array_unshift($args, "<img src='" . $match[1] . "' />");
540
+                            $srcover_filter = call_user_func_array($filtre, $args);
541
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
542
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
543
+                        }
544
+                    }
545
+                    $texte = str_replace($tag[3], $reduit, $texte);
546
+                }
547
+                array_shift($args);
548
+            }
549
+        }
550
+    }
551
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
552
+    return $texte;
553 553
 }
554 554
 
555 555
 /**
@@ -564,77 +564,77 @@  discard block
 block discarded – undo
564 564
  **/
565 565
 function taille_image($img, $force_refresh = false) {
566 566
 
567
-	static $largeur_img = array(), $hauteur_img = array();
568
-	$srcWidth = 0;
569
-	$srcHeight = 0;
570
-
571
-	$src = extraire_attribut($img, 'src');
572
-
573
-	if (!$src) {
574
-		$src = $img;
575
-	} else {
576
-		$srcWidth = extraire_attribut($img, 'width');
577
-		$srcHeight = extraire_attribut($img, 'height');
578
-	}
579
-
580
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
581
-	// la copie locale a toutes les chances d'etre la ou de resservir
582
-	if (tester_url_absolue($src)) {
583
-		include_spip('inc/distant');
584
-		$fichier = copie_locale($src);
585
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
586
-	}
587
-	if (($p = strpos($src, '?')) !== false) {
588
-		$src = substr($src, 0, $p);
589
-	}
590
-
591
-	$srcsize = false;
592
-	if (isset($largeur_img[$src]) and !$force_refresh) {
593
-		$srcWidth = $largeur_img[$src];
594
-	}
595
-	if (isset($hauteur_img[$src]) and !$force_refresh) {
596
-		$srcHeight = $hauteur_img[$src];
597
-	}
598
-	if (!$srcWidth or !$srcHeight) {
599
-
600
-		if (file_exists($src)
601
-			and $srcsize = spip_getimagesize($src)
602
-		) {
603
-			if (!$srcWidth) {
604
-				$largeur_img[$src] = $srcWidth = $srcsize[0];
605
-			}
606
-			if (!$srcHeight) {
607
-				$hauteur_img[$src] = $srcHeight = $srcsize[1];
608
-			}
609
-		}
610
-		elseif(strpos($src, "<svg") !== false) {
611
-			include_spip('inc/svg');
612
-			if ($attrs = svg_lire_attributs($src)){
613
-				list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
614
-				if (!$srcWidth){
615
-					$largeur_img[$src] = $srcWidth = $width;
616
-				}
617
-				if (!$srcHeight){
618
-					$hauteur_img[$src] = $srcHeight = $height;
619
-				}
620
-			}
621
-		}
622
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
623
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
624
-		elseif (@file_exists($f = "$src.src")
625
-			and lire_fichier($f, $valeurs)
626
-			and $valeurs = unserialize($valeurs)
627
-		) {
628
-			if (!$srcWidth) {
629
-				$largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
630
-			}
631
-			if (!$srcHeight) {
632
-				$hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
633
-			}
634
-		}
635
-	}
636
-
637
-	return array($srcHeight, $srcWidth);
567
+    static $largeur_img = array(), $hauteur_img = array();
568
+    $srcWidth = 0;
569
+    $srcHeight = 0;
570
+
571
+    $src = extraire_attribut($img, 'src');
572
+
573
+    if (!$src) {
574
+        $src = $img;
575
+    } else {
576
+        $srcWidth = extraire_attribut($img, 'width');
577
+        $srcHeight = extraire_attribut($img, 'height');
578
+    }
579
+
580
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
581
+    // la copie locale a toutes les chances d'etre la ou de resservir
582
+    if (tester_url_absolue($src)) {
583
+        include_spip('inc/distant');
584
+        $fichier = copie_locale($src);
585
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
586
+    }
587
+    if (($p = strpos($src, '?')) !== false) {
588
+        $src = substr($src, 0, $p);
589
+    }
590
+
591
+    $srcsize = false;
592
+    if (isset($largeur_img[$src]) and !$force_refresh) {
593
+        $srcWidth = $largeur_img[$src];
594
+    }
595
+    if (isset($hauteur_img[$src]) and !$force_refresh) {
596
+        $srcHeight = $hauteur_img[$src];
597
+    }
598
+    if (!$srcWidth or !$srcHeight) {
599
+
600
+        if (file_exists($src)
601
+            and $srcsize = spip_getimagesize($src)
602
+        ) {
603
+            if (!$srcWidth) {
604
+                $largeur_img[$src] = $srcWidth = $srcsize[0];
605
+            }
606
+            if (!$srcHeight) {
607
+                $hauteur_img[$src] = $srcHeight = $srcsize[1];
608
+            }
609
+        }
610
+        elseif(strpos($src, "<svg") !== false) {
611
+            include_spip('inc/svg');
612
+            if ($attrs = svg_lire_attributs($src)){
613
+                list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
614
+                if (!$srcWidth){
615
+                    $largeur_img[$src] = $srcWidth = $width;
616
+                }
617
+                if (!$srcHeight){
618
+                    $hauteur_img[$src] = $srcHeight = $height;
619
+                }
620
+            }
621
+        }
622
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
623
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
624
+        elseif (@file_exists($f = "$src.src")
625
+            and lire_fichier($f, $valeurs)
626
+            and $valeurs = unserialize($valeurs)
627
+        ) {
628
+            if (!$srcWidth) {
629
+                $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
630
+            }
631
+            if (!$srcHeight) {
632
+                $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
633
+            }
634
+        }
635
+    }
636
+
637
+    return array($srcHeight, $srcWidth);
638 638
 }
639 639
 
640 640
 
@@ -652,12 +652,12 @@  discard block
 block discarded – undo
652 652
  *     Largeur en pixels, NULL ou 0 si aucune image.
653 653
  **/
654 654
 function largeur($img) {
655
-	if (!$img) {
656
-		return;
657
-	}
658
-	list($h, $l) = taille_image($img);
655
+    if (!$img) {
656
+        return;
657
+    }
658
+    list($h, $l) = taille_image($img);
659 659
 
660
-	return $l;
660
+    return $l;
661 661
 }
662 662
 
663 663
 /**
@@ -674,12 +674,12 @@  discard block
 block discarded – undo
674 674
  *     Hauteur en pixels, NULL ou 0 si aucune image.
675 675
  **/
676 676
 function hauteur($img) {
677
-	if (!$img) {
678
-		return;
679
-	}
680
-	list($h, $l) = taille_image($img);
677
+    if (!$img) {
678
+        return;
679
+    }
680
+    list($h, $l) = taille_image($img);
681 681
 
682
-	return $h;
682
+    return $h;
683 683
 }
684 684
 
685 685
 
@@ -699,11 +699,11 @@  discard block
 block discarded – undo
699 699
  * @return string
700 700
  **/
701 701
 function corriger_entites_html($texte) {
702
-	if (strpos($texte, '&amp;') === false) {
703
-		return $texte;
704
-	}
702
+    if (strpos($texte, '&amp;') === false) {
703
+        return $texte;
704
+    }
705 705
 
706
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
706
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
707 707
 }
708 708
 
709 709
 /**
@@ -718,11 +718,11 @@  discard block
 block discarded – undo
718 718
  * @return string
719 719
  **/
720 720
 function corriger_toutes_entites_html($texte) {
721
-	if (strpos($texte, '&amp;') === false) {
722
-		return $texte;
723
-	}
721
+    if (strpos($texte, '&amp;') === false) {
722
+        return $texte;
723
+    }
724 724
 
725
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
725
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
726 726
 }
727 727
 
728 728
 /**
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
  * @return string
733 733
  **/
734 734
 function proteger_amp($texte) {
735
-	return str_replace('&', '&amp;', $texte);
735
+    return str_replace('&', '&amp;', $texte);
736 736
 }
737 737
 
738 738
 
@@ -763,20 +763,20 @@  discard block
 block discarded – undo
763 763
  * @return mixed|string
764 764
  */
765 765
 function entites_html($texte, $tout = false, $quote = true) {
766
-	if (!is_string($texte) or !$texte
767
-		or strpbrk($texte, "&\"'<>") == false
768
-	) {
769
-		return $texte;
770
-	}
771
-	include_spip('inc/texte');
772
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
773
-	$flags |= ENT_HTML401;
774
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
775
-	if ($tout) {
776
-		return corriger_toutes_entites_html($texte);
777
-	} else {
778
-		return corriger_entites_html($texte);
779
-	}
766
+    if (!is_string($texte) or !$texte
767
+        or strpbrk($texte, "&\"'<>") == false
768
+    ) {
769
+        return $texte;
770
+    }
771
+    include_spip('inc/texte');
772
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
773
+    $flags |= ENT_HTML401;
774
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
775
+    if ($tout) {
776
+        return corriger_toutes_entites_html($texte);
777
+    } else {
778
+        return corriger_entites_html($texte);
779
+    }
780 780
 }
781 781
 
782 782
 /**
@@ -795,37 +795,37 @@  discard block
 block discarded – undo
795 795
  *     Texte converti
796 796
  **/
797 797
 function filtrer_entites($texte) {
798
-	if (strpos($texte, '&') === false) {
799
-		return $texte;
800
-	}
801
-	// filtrer
802
-	$texte = html2unicode($texte);
803
-	// remettre le tout dans le charset cible
804
-	$texte = unicode2charset($texte);
805
-	// cas particulier des " et ' qu'il faut filtrer aussi
806
-	// (on le faisait deja avec un &quot;)
807
-	if (strpos($texte, "&#") !== false) {
808
-		$texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
809
-	}
798
+    if (strpos($texte, '&') === false) {
799
+        return $texte;
800
+    }
801
+    // filtrer
802
+    $texte = html2unicode($texte);
803
+    // remettre le tout dans le charset cible
804
+    $texte = unicode2charset($texte);
805
+    // cas particulier des " et ' qu'il faut filtrer aussi
806
+    // (on le faisait deja avec un &quot;)
807
+    if (strpos($texte, "&#") !== false) {
808
+        $texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
809
+    }
810 810
 
811
-	return $texte;
811
+    return $texte;
812 812
 }
813 813
 
814 814
 
815 815
 if (!function_exists('filtre_filtrer_entites_dist')) {
816
-	/**
817
-	 * Version sécurisée de filtrer_entites
818
-	 * 
819
-	 * @uses interdire_scripts()
820
-	 * @uses filtrer_entites()
821
-	 * 
822
-	 * @param string $t
823
-	 * @return string
824
-	 */
825
-	function filtre_filtrer_entites_dist($t) {
826
-		include_spip('inc/texte');
827
-		return interdire_scripts(filtrer_entites($t));
828
-	}
816
+    /**
817
+     * Version sécurisée de filtrer_entites
818
+     * 
819
+     * @uses interdire_scripts()
820
+     * @uses filtrer_entites()
821
+     * 
822
+     * @param string $t
823
+     * @return string
824
+     */
825
+    function filtre_filtrer_entites_dist($t) {
826
+        include_spip('inc/texte');
827
+        return interdire_scripts(filtrer_entites($t));
828
+    }
829 829
 }
830 830
 
831 831
 
@@ -840,18 +840,18 @@  discard block
 block discarded – undo
840 840
  * @return string|array
841 841
  **/
842 842
 function supprimer_caracteres_illegaux($texte) {
843
-	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";
844
-	static $to = null;
843
+    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";
844
+    static $to = null;
845 845
 
846
-	if (is_array($texte)) {
847
-		return array_map('supprimer_caracteres_illegaux', $texte);
848
-	}
846
+    if (is_array($texte)) {
847
+        return array_map('supprimer_caracteres_illegaux', $texte);
848
+    }
849 849
 
850
-	if (!$to) {
851
-		$to = str_repeat('-', strlen($from));
852
-	}
850
+    if (!$to) {
851
+        $to = str_repeat('-', strlen($from));
852
+    }
853 853
 
854
-	return strtr($texte, $from, $to);
854
+    return strtr($texte, $from, $to);
855 855
 }
856 856
 
857 857
 /**
@@ -863,10 +863,10 @@  discard block
 block discarded – undo
863 863
  * @return string|array
864 864
  **/
865 865
 function corriger_caracteres($texte) {
866
-	$texte = corriger_caracteres_windows($texte);
867
-	$texte = supprimer_caracteres_illegaux($texte);
866
+    $texte = corriger_caracteres_windows($texte);
867
+    $texte = supprimer_caracteres_illegaux($texte);
868 868
 
869
-	return $texte;
869
+    return $texte;
870 870
 }
871 871
 
872 872
 /**
@@ -884,40 +884,40 @@  discard block
 block discarded – undo
884 884
  */
885 885
 function texte_backend($texte) {
886 886
 
887
-	static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
887
+    static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
888 888
 
889
-	// si on a des liens ou des images, les passer en absolu
890
-	$texte = liens_absolus($texte);
889
+    // si on a des liens ou des images, les passer en absolu
890
+    $texte = liens_absolus($texte);
891 891
 
892
-	// echapper les tags &gt; &lt;
893
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
892
+    // echapper les tags &gt; &lt;
893
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
894 894
 
895
-	// importer les &eacute;
896
-	$texte = filtrer_entites($texte);
895
+    // importer les &eacute;
896
+    $texte = filtrer_entites($texte);
897 897
 
898
-	// " -> &quot; et tout ce genre de choses
899
-	$u = $GLOBALS['meta']['pcre_u'];
900
-	$texte = str_replace("&nbsp;", " ", $texte);
901
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
902
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
903
-	$texte = entites_html($texte, false, false);
904
-	// mais bien echapper les double quotes !
905
-	$texte = str_replace('"', '&#034;', $texte);
898
+    // " -> &quot; et tout ce genre de choses
899
+    $u = $GLOBALS['meta']['pcre_u'];
900
+    $texte = str_replace("&nbsp;", " ", $texte);
901
+    $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
902
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
903
+    $texte = entites_html($texte, false, false);
904
+    // mais bien echapper les double quotes !
905
+    $texte = str_replace('"', '&#034;', $texte);
906 906
 
907
-	// verifier le charset
908
-	$texte = charset2unicode($texte);
907
+    // verifier le charset
908
+    $texte = charset2unicode($texte);
909 909
 
910
-	// Caracteres problematiques en iso-latin 1
911
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
912
-		$texte = str_replace(chr(156), '&#156;', $texte);
913
-		$texte = str_replace(chr(140), '&#140;', $texte);
914
-		$texte = str_replace(chr(159), '&#159;', $texte);
915
-	}
910
+    // Caracteres problematiques en iso-latin 1
911
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
912
+        $texte = str_replace(chr(156), '&#156;', $texte);
913
+        $texte = str_replace(chr(140), '&#140;', $texte);
914
+        $texte = str_replace(chr(159), '&#159;', $texte);
915
+    }
916 916
 
917
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
918
-	// et le caractere apostrophe alourdit les squelettes avec PHP
919
-	// ==> on les remplace par l'entite HTML
920
-	return str_replace($apostrophe, "'", $texte);
917
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
918
+    // et le caractere apostrophe alourdit les squelettes avec PHP
919
+    // ==> on les remplace par l'entite HTML
920
+    return str_replace($apostrophe, "'", $texte);
921 921
 }
922 922
 
923 923
 /**
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
  *     Texte encodé et quote pour XML
935 935
  */
936 936
 function texte_backendq($texte) {
937
-	return addslashes(texte_backend($texte));
937
+    return addslashes(texte_backend($texte));
938 938
 }
939 939
 
940 940
 
@@ -957,9 +957,9 @@  discard block
 block discarded – undo
957 957
  *     Numéro de titre, sinon chaîne vide
958 958
  **/
959 959
 function supprimer_numero($texte) {
960
-	return preg_replace(
961
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
962
-		"", $texte);
960
+    return preg_replace(
961
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
962
+        "", $texte);
963 963
 }
964 964
 
965 965
 /**
@@ -982,13 +982,13 @@  discard block
 block discarded – undo
982 982
  *     Numéro de titre, sinon chaîne vide
983 983
  **/
984 984
 function recuperer_numero($texte) {
985
-	if (preg_match(
986
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
987
-		$texte, $regs)) {
988
-		return strval($regs[1]);
989
-	} else {
990
-		return '';
991
-	}
985
+    if (preg_match(
986
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
987
+        $texte, $regs)) {
988
+        return strval($regs[1]);
989
+    } else {
990
+        return '';
991
+    }
992 992
 }
993 993
 
994 994
 /**
@@ -1015,13 +1015,13 @@  discard block
 block discarded – undo
1015 1015
  *     Texte converti
1016 1016
  **/
1017 1017
 function supprimer_tags($texte, $rempl = "") {
1018
-	$texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
1019
-	// ne pas oublier un < final non ferme car coupe
1020
-	$texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
1021
-	// mais qui peut aussi etre un simple signe plus petit que
1022
-	$texte = str_replace('<', '&lt;', $texte);
1018
+    $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
1019
+    // ne pas oublier un < final non ferme car coupe
1020
+    $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
1021
+    // mais qui peut aussi etre un simple signe plus petit que
1022
+    $texte = str_replace('<', '&lt;', $texte);
1023 1023
 
1024
-	return $texte;
1024
+    return $texte;
1025 1025
 }
1026 1026
 
1027 1027
 /**
@@ -1044,9 +1044,9 @@  discard block
 block discarded – undo
1044 1044
  *     Texte converti
1045 1045
  **/
1046 1046
 function echapper_tags($texte, $rempl = "") {
1047
-	$texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1047
+    $texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1048 1048
 
1049
-	return $texte;
1049
+    return $texte;
1050 1050
 }
1051 1051
 
1052 1052
 /**
@@ -1067,18 +1067,18 @@  discard block
 block discarded – undo
1067 1067
  *     Texte converti
1068 1068
  **/
1069 1069
 function textebrut($texte) {
1070
-	$u = $GLOBALS['meta']['pcre_u'];
1071
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1072
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1073
-	$texte = preg_replace("/^\n+/", "", $texte);
1074
-	$texte = preg_replace("/\n+$/", "", $texte);
1075
-	$texte = preg_replace("/\n +/", "\n", $texte);
1076
-	$texte = supprimer_tags($texte);
1077
-	$texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1078
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1079
-	$texte = str_replace("&#8217;", "'", $texte);
1070
+    $u = $GLOBALS['meta']['pcre_u'];
1071
+    $texte = preg_replace('/\s+/S' . $u, " ", $texte);
1072
+    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1073
+    $texte = preg_replace("/^\n+/", "", $texte);
1074
+    $texte = preg_replace("/\n+$/", "", $texte);
1075
+    $texte = preg_replace("/\n +/", "\n", $texte);
1076
+    $texte = supprimer_tags($texte);
1077
+    $texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1078
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1079
+    $texte = str_replace("&#8217;", "'", $texte);
1080 1080
 
1081
-	return $texte;
1081
+    return $texte;
1082 1082
 }
1083 1083
 
1084 1084
 
@@ -1094,17 +1094,17 @@  discard block
 block discarded – undo
1094 1094
  *     Texte avec liens ouvrants
1095 1095
  **/
1096 1096
 function liens_ouvrants($texte) {
1097
-	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1098
-		$texte, $liens, PREG_PATTERN_ORDER)) {
1099
-		foreach ($liens[0] as $a) {
1100
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1101
-			$ablank = inserer_attribut($a, 'rel', $rel);
1102
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1103
-			$texte = str_replace($a, $ablank, $texte);
1104
-		}
1105
-	}
1097
+    if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1098
+        $texte, $liens, PREG_PATTERN_ORDER)) {
1099
+        foreach ($liens[0] as $a) {
1100
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1101
+            $ablank = inserer_attribut($a, 'rel', $rel);
1102
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1103
+            $texte = str_replace($a, $ablank, $texte);
1104
+        }
1105
+    }
1106 1106
 
1107
-	return $texte;
1107
+    return $texte;
1108 1108
 }
1109 1109
 
1110 1110
 /**
@@ -1114,22 +1114,22 @@  discard block
 block discarded – undo
1114 1114
  * @return string
1115 1115
  */
1116 1116
 function liens_nofollow($texte) {
1117
-	if (stripos($texte, "<a") === false) {
1118
-		return $texte;
1119
-	}
1117
+    if (stripos($texte, "<a") === false) {
1118
+        return $texte;
1119
+    }
1120 1120
 
1121
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1122
-		foreach ($regs[0] as $a) {
1123
-			$rel = extraire_attribut($a, "rel");
1124
-			if (strpos($rel, "nofollow") === false) {
1125
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1126
-				$anofollow = inserer_attribut($a, "rel", $rel);
1127
-				$texte = str_replace($a, $anofollow, $texte);
1128
-			}
1129
-		}
1130
-	}
1121
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1122
+        foreach ($regs[0] as $a) {
1123
+            $rel = extraire_attribut($a, "rel");
1124
+            if (strpos($rel, "nofollow") === false) {
1125
+                $rel = "nofollow" . ($rel ? " $rel" : "");
1126
+                $anofollow = inserer_attribut($a, "rel", $rel);
1127
+                $texte = str_replace($a, $anofollow, $texte);
1128
+            }
1129
+        }
1130
+    }
1131 1131
 
1132
-	return $texte;
1132
+    return $texte;
1133 1133
 }
1134 1134
 
1135 1135
 /**
@@ -1148,12 +1148,12 @@  discard block
 block discarded – undo
1148 1148
  *     Texte sans paraghaphes
1149 1149
  **/
1150 1150
 function PtoBR($texte) {
1151
-	$u = $GLOBALS['meta']['pcre_u'];
1152
-	$texte = preg_replace("@</p>@iS", "\n", $texte);
1153
-	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1154
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1151
+    $u = $GLOBALS['meta']['pcre_u'];
1152
+    $texte = preg_replace("@</p>@iS", "\n", $texte);
1153
+    $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1154
+    $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1155 1155
 
1156
-	return $texte;
1156
+    return $texte;
1157 1157
 }
1158 1158
 
1159 1159
 
@@ -1177,14 +1177,14 @@  discard block
 block discarded – undo
1177 1177
  * @return string Texte encadré du style CSS
1178 1178
  */
1179 1179
 function lignes_longues($texte) {
1180
-	if (!strlen(trim($texte))) {
1181
-		return $texte;
1182
-	}
1183
-	include_spip('inc/texte');
1184
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1185
-		'div' : 'span';
1180
+    if (!strlen(trim($texte))) {
1181
+        return $texte;
1182
+    }
1183
+    include_spip('inc/texte');
1184
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1185
+        'div' : 'span';
1186 1186
 
1187
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1187
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1188 1188
 }
1189 1189
 
1190 1190
 /**
@@ -1203,30 +1203,30 @@  discard block
 block discarded – undo
1203 1203
  * @return string Texte en majuscule
1204 1204
  */
1205 1205
 function majuscules($texte) {
1206
-	if (!strlen($texte)) {
1207
-		return '';
1208
-	}
1206
+    if (!strlen($texte)) {
1207
+        return '';
1208
+    }
1209 1209
 
1210
-	// Cas du turc
1211
-	if ($GLOBALS['spip_lang'] == 'tr') {
1212
-		# remplacer hors des tags et des entites
1213
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1214
-			foreach ($regs as $n => $match) {
1215
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1216
-			}
1217
-		}
1210
+    // Cas du turc
1211
+    if ($GLOBALS['spip_lang'] == 'tr') {
1212
+        # remplacer hors des tags et des entites
1213
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1214
+            foreach ($regs as $n => $match) {
1215
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1216
+            }
1217
+        }
1218 1218
 
1219
-		$texte = str_replace('i', '&#304;', $texte);
1219
+        $texte = str_replace('i', '&#304;', $texte);
1220 1220
 
1221
-		if ($regs) {
1222
-			foreach ($regs as $n => $match) {
1223
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1224
-			}
1225
-		}
1226
-	}
1221
+        if ($regs) {
1222
+            foreach ($regs as $n => $match) {
1223
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1224
+            }
1225
+        }
1226
+    }
1227 1227
 
1228
-	// Cas general
1229
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1228
+    // Cas general
1229
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1244,29 +1244,29 @@  discard block
 block discarded – undo
1244 1244
  * @return string
1245 1245
  **/
1246 1246
 function taille_en_octets($taille) {
1247
-	if (!defined('_KILOBYTE')) {
1248
-		/**
1249
-		 * Définit le nombre d'octets dans un Kilobyte
1250
-		 *
1251
-		 * @var int
1252
-		 **/
1253
-		define('_KILOBYTE', 1024);
1254
-	}
1247
+    if (!defined('_KILOBYTE')) {
1248
+        /**
1249
+         * Définit le nombre d'octets dans un Kilobyte
1250
+         *
1251
+         * @var int
1252
+         **/
1253
+        define('_KILOBYTE', 1024);
1254
+    }
1255 1255
 
1256
-	if ($taille < 1) {
1257
-		return '';
1258
-	}
1259
-	if ($taille < _KILOBYTE) {
1260
-		$taille = _T('taille_octets', array('taille' => $taille));
1261
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1262
-		$taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1263
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1264
-		$taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1265
-	} else {
1266
-		$taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1267
-	}
1256
+    if ($taille < 1) {
1257
+        return '';
1258
+    }
1259
+    if ($taille < _KILOBYTE) {
1260
+        $taille = _T('taille_octets', array('taille' => $taille));
1261
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1262
+        $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1263
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1264
+        $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1265
+    } else {
1266
+        $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1267
+    }
1268 1268
 
1269
-	return $taille;
1269
+    return $taille;
1270 1270
 }
1271 1271
 
1272 1272
 
@@ -1288,15 +1288,15 @@  discard block
 block discarded – undo
1288 1288
  *     Texte prêt pour être utilisé en attribut HTML
1289 1289
  **/
1290 1290
 function attribut_html($texte, $textebrut = true) {
1291
-	$u = $GLOBALS['meta']['pcre_u'];
1292
-	if ($textebrut) {
1293
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1294
-	}
1295
-	$texte = texte_backend($texte);
1296
-	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1291
+    $u = $GLOBALS['meta']['pcre_u'];
1292
+    if ($textebrut) {
1293
+        $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1294
+    }
1295
+    $texte = texte_backend($texte);
1296
+    $texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1297 1297
 
1298
-	return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1299
-		$texte);
1298
+    return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1299
+        $texte);
1300 1300
 }
1301 1301
 
1302 1302
 
@@ -1316,12 +1316,12 @@  discard block
 block discarded – undo
1316 1316
  *     URL ou chaîne vide
1317 1317
  **/
1318 1318
 function vider_url($url, $entites = true) {
1319
-	# un message pour abs_url
1320
-	$GLOBALS['mode_abs_url'] = 'url';
1321
-	$url = trim($url);
1322
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1319
+    # un message pour abs_url
1320
+    $GLOBALS['mode_abs_url'] = 'url';
1321
+    $url = trim($url);
1322
+    $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1323 1323
 
1324
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1324
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1325 1325
 }
1326 1326
 
1327 1327
 
@@ -1336,10 +1336,10 @@  discard block
 block discarded – undo
1336 1336
  * @return string Adresse email maquillée
1337 1337
  **/
1338 1338
 function antispam($texte) {
1339
-	include_spip('inc/acces');
1340
-	$masque = creer_pass_aleatoire(3);
1339
+    include_spip('inc/acces');
1340
+    $masque = creer_pass_aleatoire(3);
1341 1341
 
1342
-	return preg_replace("/@/", " $masque ", $texte);
1342
+    return preg_replace("/@/", " $masque ", $texte);
1343 1343
 }
1344 1344
 
1345 1345
 /**
@@ -1371,12 +1371,12 @@  discard block
 block discarded – undo
1371 1371
  *     True si on a le droit d'accès, false sinon.
1372 1372
  **/
1373 1373
 function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') {
1374
-	include_spip('inc/acces');
1375
-	if ($op) {
1376
-		$dir .= " $op $args";
1377
-	}
1374
+    include_spip('inc/acces');
1375
+    if ($op) {
1376
+        $dir .= " $op $args";
1377
+    }
1378 1378
 
1379
-	return verifier_low_sec($id_auteur, $cle, $dir);
1379
+    return verifier_low_sec($id_auteur, $cle, $dir);
1380 1380
 }
1381 1381
 
1382 1382
 /**
@@ -1401,11 +1401,11 @@  discard block
 block discarded – undo
1401 1401
  *     Retourne $texte, sinon $sinon.
1402 1402
  **/
1403 1403
 function sinon($texte, $sinon = '') {
1404
-	if ($texte or (!is_array($texte) and strlen($texte))) {
1405
-		return $texte;
1406
-	} else {
1407
-		return $sinon;
1408
-	}
1404
+    if ($texte or (!is_array($texte) and strlen($texte))) {
1405
+        return $texte;
1406
+    } else {
1407
+        return $sinon;
1408
+    }
1409 1409
 }
1410 1410
 
1411 1411
 /**
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
  * @return mixed
1430 1430
  **/
1431 1431
 function choixsivide($a, $vide, $pasvide) {
1432
-	return $a ? $pasvide : $vide;
1432
+    return $a ? $pasvide : $vide;
1433 1433
 }
1434 1434
 
1435 1435
 /**
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
  * @return mixed
1454 1454
  **/
1455 1455
 function choixsiegal($a1, $a2, $v, $f) {
1456
-	return ($a1 == $a2) ? $v : $f;
1456
+    return ($a1 == $a2) ? $v : $f;
1457 1457
 }
1458 1458
 
1459 1459
 //
@@ -1472,13 +1472,13 @@  discard block
 block discarded – undo
1472 1472
  * @return string
1473 1473
  **/
1474 1474
 function filtrer_ical($texte) {
1475
-	#include_spip('inc/charsets');
1476
-	$texte = html2unicode($texte);
1477
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1478
-	$texte = preg_replace("/\n/", " ", $texte);
1479
-	$texte = preg_replace("/,/", "\,", $texte);
1475
+    #include_spip('inc/charsets');
1476
+    $texte = html2unicode($texte);
1477
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1478
+    $texte = preg_replace("/\n/", " ", $texte);
1479
+    $texte = preg_replace("/,/", "\,", $texte);
1480 1480
 
1481
-	return $texte;
1481
+    return $texte;
1482 1482
 }
1483 1483
 
1484 1484
 
@@ -1503,53 +1503,53 @@  discard block
 block discarded – undo
1503 1503
  * @return string
1504 1504
  **/
1505 1505
 function post_autobr($texte, $delim = "\n_ ") {
1506
-	if (!function_exists('echappe_html')) {
1507
-		include_spip('inc/texte_mini');
1508
-	}
1509
-	$texte = str_replace("\r\n", "\r", $texte);
1510
-	$texte = str_replace("\r", "\n", $texte);
1511
-
1512
-	if (preg_match(",\n+$,", $texte, $fin)) {
1513
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1514
-	} else {
1515
-		$fin = '';
1516
-	}
1517
-
1518
-	$texte = echappe_html($texte, '', true);
1519
-
1520
-	// echapper les modeles
1521
-	if (strpos($texte, "<") !== false) {
1522
-		include_spip('inc/lien');
1523
-		if (defined('_PREG_MODELE')) {
1524
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1525
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1526
-		}
1527
-	}
1528
-
1529
-	$debut = '';
1530
-	$suite = $texte;
1531
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1532
-		$debut .= substr($suite, 0, $t - 1);
1533
-		$suite = substr($suite, $t);
1534
-		$car = substr($suite, 0, 1);
1535
-		if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1536
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1537
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1538
-		) {
1539
-			$debut .= $delim;
1540
-		} else {
1541
-			$debut .= "\n";
1542
-		}
1543
-		if (preg_match(",^\n+,", $suite, $regs)) {
1544
-			$debut .= $regs[0];
1545
-			$suite = substr($suite, strlen($regs[0]));
1546
-		}
1547
-	}
1548
-	$texte = $debut . $suite;
1549
-
1550
-	$texte = echappe_retour($texte);
1551
-
1552
-	return $texte . $fin;
1506
+    if (!function_exists('echappe_html')) {
1507
+        include_spip('inc/texte_mini');
1508
+    }
1509
+    $texte = str_replace("\r\n", "\r", $texte);
1510
+    $texte = str_replace("\r", "\n", $texte);
1511
+
1512
+    if (preg_match(",\n+$,", $texte, $fin)) {
1513
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1514
+    } else {
1515
+        $fin = '';
1516
+    }
1517
+
1518
+    $texte = echappe_html($texte, '', true);
1519
+
1520
+    // echapper les modeles
1521
+    if (strpos($texte, "<") !== false) {
1522
+        include_spip('inc/lien');
1523
+        if (defined('_PREG_MODELE')) {
1524
+            $preg_modeles = "@" . _PREG_MODELE . "@imsS";
1525
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1526
+        }
1527
+    }
1528
+
1529
+    $debut = '';
1530
+    $suite = $texte;
1531
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1532
+        $debut .= substr($suite, 0, $t - 1);
1533
+        $suite = substr($suite, $t);
1534
+        $car = substr($suite, 0, 1);
1535
+        if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1536
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1537
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1538
+        ) {
1539
+            $debut .= $delim;
1540
+        } else {
1541
+            $debut .= "\n";
1542
+        }
1543
+        if (preg_match(",^\n+,", $suite, $regs)) {
1544
+            $debut .= $regs[0];
1545
+            $suite = substr($suite, strlen($regs[0]));
1546
+        }
1547
+    }
1548
+    $texte = $debut . $suite;
1549
+
1550
+    $texte = echappe_retour($texte);
1551
+
1552
+    return $texte . $fin;
1553 1553
 }
1554 1554
 
1555 1555
 
@@ -1590,46 +1590,46 @@  discard block
 block discarded – undo
1590 1590
  * @return string
1591 1591
  **/
1592 1592
 function extraire_idiome($letexte, $lang = null, $options = array()) {
1593
-	static $traduire = false;
1594
-	if ($letexte
1595
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1596
-	) {
1597
-		if (!$traduire) {
1598
-			$traduire = charger_fonction('traduire', 'inc');
1599
-			include_spip('inc/lang');
1600
-		}
1601
-		if (!$lang) {
1602
-			$lang = $GLOBALS['spip_lang'];
1603
-		}
1604
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1605
-		if (is_bool($options)) {
1606
-			$options = array('echappe_span' => $options);
1607
-		}
1608
-		if (!isset($options['echappe_span'])) {
1609
-			$options = array_merge($options, array('echappe_span' => false));
1610
-		}
1611
-
1612
-		foreach ($regs as $reg) {
1613
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1614
-			$desc = $traduire($cle, $lang, true);
1615
-			$l = $desc->langue;
1616
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1617
-			if (strlen($desc->texte)) {
1618
-				$trad = code_echappement($desc->texte, 'idiome', false);
1619
-				if ($l !== $lang) {
1620
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1621
-				}
1622
-				if (lang_dir($l) !== lang_dir($lang)) {
1623
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1624
-				}
1625
-				if (!$options['echappe_span']) {
1626
-					$trad = echappe_retour($trad, 'idiome');
1627
-				}
1628
-				$letexte = str_replace($reg[0], $trad, $letexte);
1629
-			}
1630
-		}
1631
-	}
1632
-	return $letexte;
1593
+    static $traduire = false;
1594
+    if ($letexte
1595
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1596
+    ) {
1597
+        if (!$traduire) {
1598
+            $traduire = charger_fonction('traduire', 'inc');
1599
+            include_spip('inc/lang');
1600
+        }
1601
+        if (!$lang) {
1602
+            $lang = $GLOBALS['spip_lang'];
1603
+        }
1604
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1605
+        if (is_bool($options)) {
1606
+            $options = array('echappe_span' => $options);
1607
+        }
1608
+        if (!isset($options['echappe_span'])) {
1609
+            $options = array_merge($options, array('echappe_span' => false));
1610
+        }
1611
+
1612
+        foreach ($regs as $reg) {
1613
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1614
+            $desc = $traduire($cle, $lang, true);
1615
+            $l = $desc->langue;
1616
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1617
+            if (strlen($desc->texte)) {
1618
+                $trad = code_echappement($desc->texte, 'idiome', false);
1619
+                if ($l !== $lang) {
1620
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1621
+                }
1622
+                if (lang_dir($l) !== lang_dir($lang)) {
1623
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1624
+                }
1625
+                if (!$options['echappe_span']) {
1626
+                    $trad = echappe_retour($trad, 'idiome');
1627
+                }
1628
+                $letexte = str_replace($reg[0], $trad, $letexte);
1629
+            }
1630
+        }
1631
+    }
1632
+    return $letexte;
1633 1633
 }
1634 1634
 
1635 1635
 /**
@@ -1681,67 +1681,67 @@  discard block
 block discarded – undo
1681 1681
  **/
1682 1682
 function extraire_multi($letexte, $lang = null, $options = array()) {
1683 1683
 
1684
-	if ($letexte
1685
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1686
-	) {
1687
-		if (!$lang) {
1688
-			$lang = $GLOBALS['spip_lang'];
1689
-		}
1690
-
1691
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1692
-		if (is_bool($options)) {
1693
-			$options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1694
-		}
1695
-		if (!isset($options['echappe_span'])) {
1696
-			$options = array_merge($options, array('echappe_span' => false));
1697
-		}
1698
-		if (!isset($options['lang_defaut'])) {
1699
-			$options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1700
-		}
1701
-
1702
-		include_spip('inc/lang');
1703
-		foreach ($regs as $reg) {
1704
-			// chercher la version de la langue courante
1705
-			$trads = extraire_trads($reg[1]);
1706
-			if ($l = approcher_langue($trads, $lang)) {
1707
-				$trad = $trads[$l];
1708
-			} else {
1709
-				if ($options['lang_defaut'] == 'aucune') {
1710
-					$trad = '';
1711
-				} else {
1712
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1713
-					// ou la premiere dispo
1714
-					// mais typographier le texte selon les regles de celle-ci
1715
-					// Attention aux blocs multi sur plusieurs lignes
1716
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1717
-						$l = key($trads);
1718
-					}
1719
-					$trad = $trads[$l];
1720
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1721
-					$trad = $typographie($trad);
1722
-					// Tester si on echappe en span ou en div
1723
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1724
-					include_spip('inc/texte');
1725
-					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1726
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1727
-					if ($mode === 'div') {
1728
-						$trad = rtrim($trad) . "\n\n";
1729
-					}
1730
-					$trad = code_echappement($trad, 'multi', false, $mode);
1731
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1732
-					if (lang_dir($l) !== lang_dir($lang)) {
1733
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1734
-					}
1735
-					if (!$options['echappe_span']) {
1736
-						$trad = echappe_retour($trad, 'multi');
1737
-					}
1738
-				}
1739
-			}
1740
-			$letexte = str_replace($reg[0], $trad, $letexte);
1741
-		}
1742
-	}
1743
-
1744
-	return $letexte;
1684
+    if ($letexte
1685
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1686
+    ) {
1687
+        if (!$lang) {
1688
+            $lang = $GLOBALS['spip_lang'];
1689
+        }
1690
+
1691
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1692
+        if (is_bool($options)) {
1693
+            $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1694
+        }
1695
+        if (!isset($options['echappe_span'])) {
1696
+            $options = array_merge($options, array('echappe_span' => false));
1697
+        }
1698
+        if (!isset($options['lang_defaut'])) {
1699
+            $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1700
+        }
1701
+
1702
+        include_spip('inc/lang');
1703
+        foreach ($regs as $reg) {
1704
+            // chercher la version de la langue courante
1705
+            $trads = extraire_trads($reg[1]);
1706
+            if ($l = approcher_langue($trads, $lang)) {
1707
+                $trad = $trads[$l];
1708
+            } else {
1709
+                if ($options['lang_defaut'] == 'aucune') {
1710
+                    $trad = '';
1711
+                } else {
1712
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1713
+                    // ou la premiere dispo
1714
+                    // mais typographier le texte selon les regles de celle-ci
1715
+                    // Attention aux blocs multi sur plusieurs lignes
1716
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1717
+                        $l = key($trads);
1718
+                    }
1719
+                    $trad = $trads[$l];
1720
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1721
+                    $trad = $typographie($trad);
1722
+                    // Tester si on echappe en span ou en div
1723
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1724
+                    include_spip('inc/texte');
1725
+                    $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1726
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1727
+                    if ($mode === 'div') {
1728
+                        $trad = rtrim($trad) . "\n\n";
1729
+                    }
1730
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1731
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1732
+                    if (lang_dir($l) !== lang_dir($lang)) {
1733
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1734
+                    }
1735
+                    if (!$options['echappe_span']) {
1736
+                        $trad = echappe_retour($trad, 'multi');
1737
+                    }
1738
+                }
1739
+            }
1740
+            $letexte = str_replace($reg[0], $trad, $letexte);
1741
+        }
1742
+    }
1743
+
1744
+    return $letexte;
1745 1745
 }
1746 1746
 
1747 1747
 /**
@@ -1757,20 +1757,20 @@  discard block
 block discarded – undo
1757 1757
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1758 1758
  **/
1759 1759
 function extraire_trads($bloc) {
1760
-	$lang = '';
1760
+    $lang = '';
1761 1761
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1762 1762
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1763
-	while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1764
-		$texte = trim($regs[1]);
1765
-		if ($texte or $lang) {
1766
-			$trads[$lang] = $texte;
1767
-		}
1768
-		$bloc = substr($bloc, strlen($regs[0]));
1769
-		$lang = $regs[2];
1770
-	}
1771
-	$trads[$lang] = $bloc;
1763
+    while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1764
+        $texte = trim($regs[1]);
1765
+        if ($texte or $lang) {
1766
+            $trads[$lang] = $texte;
1767
+        }
1768
+        $bloc = substr($bloc, strlen($regs[0]));
1769
+        $lang = $regs[2];
1770
+    }
1771
+    $trads[$lang] = $bloc;
1772 1772
 
1773
-	return $trads;
1773
+    return $trads;
1774 1774
 }
1775 1775
 
1776 1776
 
@@ -1781,7 +1781,7 @@  discard block
 block discarded – undo
1781 1781
  * @return string L'initiale en majuscule
1782 1782
  */
1783 1783
 function filtre_initiale($nom) {
1784
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1784
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1785 1785
 }
1786 1786
 
1787 1787
 
@@ -1826,33 +1826,33 @@  discard block
 block discarded – undo
1826 1826
  *      - null (interne) : si on empile
1827 1827
  **/
1828 1828
 function unique($donnee, $famille = '', $cpt = false) {
1829
-	static $mem = array();
1830
-	// permettre de vider la pile et de la restaurer
1831
-	// pour le calcul de introduction...
1832
-	if ($famille == '_spip_raz_') {
1833
-		$tmp = $mem;
1834
-		$mem = array();
1835
-
1836
-		return $tmp;
1837
-	} elseif ($famille == '_spip_set_') {
1838
-		$mem = $donnee;
1839
-
1840
-		return;
1841
-	}
1842
-	// eviter une notice
1843
-	if (!isset($mem[$famille])) {
1844
-		$mem[$famille] = array();
1845
-	}
1846
-	if ($cpt) {
1847
-		return count($mem[$famille]);
1848
-	}
1849
-	// eviter une notice
1850
-	if (!isset($mem[$famille][$donnee])) {
1851
-		$mem[$famille][$donnee] = 0;
1852
-	}
1853
-	if (!($mem[$famille][$donnee]++)) {
1854
-		return $donnee;
1855
-	}
1829
+    static $mem = array();
1830
+    // permettre de vider la pile et de la restaurer
1831
+    // pour le calcul de introduction...
1832
+    if ($famille == '_spip_raz_') {
1833
+        $tmp = $mem;
1834
+        $mem = array();
1835
+
1836
+        return $tmp;
1837
+    } elseif ($famille == '_spip_set_') {
1838
+        $mem = $donnee;
1839
+
1840
+        return;
1841
+    }
1842
+    // eviter une notice
1843
+    if (!isset($mem[$famille])) {
1844
+        $mem[$famille] = array();
1845
+    }
1846
+    if ($cpt) {
1847
+        return count($mem[$famille]);
1848
+    }
1849
+    // eviter une notice
1850
+    if (!isset($mem[$famille][$donnee])) {
1851
+        $mem[$famille][$donnee] = 0;
1852
+    }
1853
+    if (!($mem[$famille][$donnee]++)) {
1854
+        return $donnee;
1855
+    }
1856 1856
 }
1857 1857
 
1858 1858
 
@@ -1880,18 +1880,18 @@  discard block
 block discarded – undo
1880 1880
  *     Une des valeurs en fonction du compteur.
1881 1881
  **/
1882 1882
 function alterner($i) {
1883
-	// recuperer les arguments (attention fonctions un peu space)
1884
-	$num = func_num_args();
1885
-	$args = func_get_args();
1883
+    // recuperer les arguments (attention fonctions un peu space)
1884
+    $num = func_num_args();
1885
+    $args = func_get_args();
1886 1886
 
1887
-	if ($num == 2 && is_array($args[1])) {
1888
-		$args = $args[1];
1889
-		array_unshift($args, '');
1890
-		$num = count($args);
1891
-	}
1887
+    if ($num == 2 && is_array($args[1])) {
1888
+        $args = $args[1];
1889
+        array_unshift($args, '');
1890
+        $num = count($args);
1891
+    }
1892 1892
 
1893
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1894
-	return $args[(intval($i) - 1) % ($num - 1) + 1];
1893
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1894
+    return $args[(intval($i) - 1) % ($num - 1) + 1];
1895 1895
 }
1896 1896
 
1897 1897
 
@@ -1916,46 +1916,46 @@  discard block
 block discarded – undo
1916 1916
  *     - Tableau complet (si 2e argument)
1917 1917
  **/
1918 1918
 function extraire_attribut($balise, $attribut, $complet = false) {
1919
-	if (is_array($balise)) {
1920
-		array_walk(
1921
-			$balise,
1922
-			function(&$a, $key, $t){
1923
-				$a = extraire_attribut($a, $t);
1924
-			},
1925
-			$attribut
1926
-		);
1927
-
1928
-		return $balise;
1929
-	}
1930
-	if (preg_match(
1931
-		',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1932
-		. $attribut
1933
-		. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1934
-
1935
-		$balise, $r)) {
1936
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1937
-			$r[4] = substr($r[3], 1, -1);
1938
-			$r[3] = $r[3][0];
1939
-		} elseif ($r[3] !== '') {
1940
-			$r[4] = $r[3];
1941
-			$r[3] = '';
1942
-		} else {
1943
-			$r[4] = trim($r[2]);
1944
-		}
1945
-		$att = $r[4];
1946
-		if (strpos($att, "&#") !== false) {
1947
-			$att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1948
-		}
1949
-		$att = filtrer_entites($att);
1950
-	} else {
1951
-		$att = null;
1952
-	}
1953
-
1954
-	if ($complet) {
1955
-		return array($att, $r);
1956
-	} else {
1957
-		return $att;
1958
-	}
1919
+    if (is_array($balise)) {
1920
+        array_walk(
1921
+            $balise,
1922
+            function(&$a, $key, $t){
1923
+                $a = extraire_attribut($a, $t);
1924
+            },
1925
+            $attribut
1926
+        );
1927
+
1928
+        return $balise;
1929
+    }
1930
+    if (preg_match(
1931
+        ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1932
+        . $attribut
1933
+        . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1934
+
1935
+        $balise, $r)) {
1936
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1937
+            $r[4] = substr($r[3], 1, -1);
1938
+            $r[3] = $r[3][0];
1939
+        } elseif ($r[3] !== '') {
1940
+            $r[4] = $r[3];
1941
+            $r[3] = '';
1942
+        } else {
1943
+            $r[4] = trim($r[2]);
1944
+        }
1945
+        $att = $r[4];
1946
+        if (strpos($att, "&#") !== false) {
1947
+            $att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1948
+        }
1949
+        $att = filtrer_entites($att);
1950
+    } else {
1951
+        $att = null;
1952
+    }
1953
+
1954
+    if ($complet) {
1955
+        return array($att, $r);
1956
+    } else {
1957
+        return $att;
1958
+    }
1959 1959
 }
1960 1960
 
1961 1961
 /**
@@ -1987,37 +1987,37 @@  discard block
 block discarded – undo
1987 1987
  *     Code html modifié
1988 1988
  **/
1989 1989
 function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) {
1990
-	// preparer l'attribut
1991
-	// supprimer les &nbsp; etc mais pas les balises html
1992
-	// qui ont un sens dans un attribut value d'un input
1993
-	if ($proteger) {
1994
-		$val = attribut_html($val, false);
1995
-	}
1996
-
1997
-	// echapper les ' pour eviter tout bug
1998
-	$val = str_replace("'", "&#039;", $val);
1999
-	if ($vider and strlen($val) == 0) {
2000
-		$insert = '';
2001
-	} else {
2002
-		$insert = " $attribut='$val'";
2003
-	}
2004
-
2005
-	list($old, $r) = extraire_attribut($balise, $attribut, true);
2006
-
2007
-	if ($old !== null) {
2008
-		// Remplacer l'ancien attribut du meme nom
2009
-		$balise = $r[1] . $insert . $r[5];
2010
-	} else {
2011
-		// preferer une balise " />" (comme <img />)
2012
-		if (preg_match(',/>,', $balise)) {
2013
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2014
-		} // sinon une balise <a ...> ... </a>
2015
-		else {
2016
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2017
-		}
2018
-	}
2019
-
2020
-	return $balise;
1990
+    // preparer l'attribut
1991
+    // supprimer les &nbsp; etc mais pas les balises html
1992
+    // qui ont un sens dans un attribut value d'un input
1993
+    if ($proteger) {
1994
+        $val = attribut_html($val, false);
1995
+    }
1996
+
1997
+    // echapper les ' pour eviter tout bug
1998
+    $val = str_replace("'", "&#039;", $val);
1999
+    if ($vider and strlen($val) == 0) {
2000
+        $insert = '';
2001
+    } else {
2002
+        $insert = " $attribut='$val'";
2003
+    }
2004
+
2005
+    list($old, $r) = extraire_attribut($balise, $attribut, true);
2006
+
2007
+    if ($old !== null) {
2008
+        // Remplacer l'ancien attribut du meme nom
2009
+        $balise = $r[1] . $insert . $r[5];
2010
+    } else {
2011
+        // preferer une balise " />" (comme <img />)
2012
+        if (preg_match(',/>,', $balise)) {
2013
+            $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2014
+        } // sinon une balise <a ...> ... </a>
2015
+        else {
2016
+            $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2017
+        }
2018
+    }
2019
+
2020
+    return $balise;
2021 2021
 }
2022 2022
 
2023 2023
 /**
@@ -2035,7 +2035,7 @@  discard block
 block discarded – undo
2035 2035
  * @return string Code HTML sans l'attribut
2036 2036
  **/
2037 2037
 function vider_attribut($balise, $attribut) {
2038
-	return inserer_attribut($balise, $attribut, '', false, true);
2038
+    return inserer_attribut($balise, $attribut, '', false, true);
2039 2039
 }
2040 2040
 
2041 2041
 /**
@@ -2047,50 +2047,50 @@  discard block
 block discarded – undo
2047 2047
  * @return string
2048 2048
  */
2049 2049
 function modifier_class($balise, $class, $operation='ajouter') {
2050
-	if (is_string($class)) {
2051
-		$class = explode(' ', trim($class));
2052
-	}
2053
-	$class = array_filter($class);
2054
-
2055
-	// si la ou les classes ont des caracteres invalides on ne fait rien
2056
-	if (preg_match(",[^\w-],", implode('', $class))) {
2057
-		return $balise;
2058
-	}
2059
-
2060
-	if ($class) {
2061
-		$class = array_unique($class);
2062
-		$class_courante = extraire_attribut($balise, 'class');
2063
-
2064
-		$class_new = $class_courante;
2065
-		foreach ($class as $c) {
2066
-			if ($c) {
2067
-				$is_class_presente = false;
2068
-				if (strpos($class_courante, $c) !== false
2069
-					and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) {
2070
-					$is_class_presente = true;
2071
-				}
2072
-				if (in_array($operation, ['ajouter', 'commuter'])
2073
-					and !$is_class_presente) {
2074
-					$class_new = rtrim($class_new) . " " . $c;
2075
-				}
2076
-				elseif (in_array($operation, ['supprimer', 'commuter'])
2077
-					and $is_class_presente) {
2078
-					$class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new));
2079
-				}
2080
-			}
2081
-		}
2082
-
2083
-		if ($class_new !== $class_courante) {
2084
-			if (strlen($class_new)) {
2085
-				$balise = inserer_attribut($balise, 'class', $class_new);
2086
-			}
2087
-			elseif ($class_courante) {
2088
-				$balise = vider_attribut($balise, 'class');
2089
-			}
2090
-		}
2091
-	}
2092
-
2093
-	return $balise;
2050
+    if (is_string($class)) {
2051
+        $class = explode(' ', trim($class));
2052
+    }
2053
+    $class = array_filter($class);
2054
+
2055
+    // si la ou les classes ont des caracteres invalides on ne fait rien
2056
+    if (preg_match(",[^\w-],", implode('', $class))) {
2057
+        return $balise;
2058
+    }
2059
+
2060
+    if ($class) {
2061
+        $class = array_unique($class);
2062
+        $class_courante = extraire_attribut($balise, 'class');
2063
+
2064
+        $class_new = $class_courante;
2065
+        foreach ($class as $c) {
2066
+            if ($c) {
2067
+                $is_class_presente = false;
2068
+                if (strpos($class_courante, $c) !== false
2069
+                    and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) {
2070
+                    $is_class_presente = true;
2071
+                }
2072
+                if (in_array($operation, ['ajouter', 'commuter'])
2073
+                    and !$is_class_presente) {
2074
+                    $class_new = rtrim($class_new) . " " . $c;
2075
+                }
2076
+                elseif (in_array($operation, ['supprimer', 'commuter'])
2077
+                    and $is_class_presente) {
2078
+                    $class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new));
2079
+                }
2080
+            }
2081
+        }
2082
+
2083
+        if ($class_new !== $class_courante) {
2084
+            if (strlen($class_new)) {
2085
+                $balise = inserer_attribut($balise, 'class', $class_new);
2086
+            }
2087
+            elseif ($class_courante) {
2088
+                $balise = vider_attribut($balise, 'class');
2089
+            }
2090
+        }
2091
+    }
2092
+
2093
+    return $balise;
2094 2094
 }
2095 2095
 
2096 2096
 /**
@@ -2100,7 +2100,7 @@  discard block
 block discarded – undo
2100 2100
  * @return string
2101 2101
  */
2102 2102
 function ajouter_class($balise, $class){
2103
-	return modifier_class($balise, $class, 'ajouter');
2103
+    return modifier_class($balise, $class, 'ajouter');
2104 2104
 }
2105 2105
 
2106 2106
 /**
@@ -2110,7 +2110,7 @@  discard block
 block discarded – undo
2110 2110
  * @return string
2111 2111
  */
2112 2112
 function supprimer_class($balise, $class){
2113
-	return modifier_class($balise, $class, 'supprimer');
2113
+    return modifier_class($balise, $class, 'supprimer');
2114 2114
 }
2115 2115
 
2116 2116
 /**
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
  * @return string
2122 2122
  */
2123 2123
 function commuter_class($balise, $class){
2124
-	return modifier_class($balise, $class, 'commuter');
2124
+    return modifier_class($balise, $class, 'commuter');
2125 2125
 }
2126 2126
 
2127 2127
 /**
@@ -2132,9 +2132,9 @@  discard block
 block discarded – undo
2132 2132
  * @return string
2133 2133
  */
2134 2134
 function tester_config($id, $mode = '') {
2135
-	include_spip('action/inscrire_auteur');
2135
+    include_spip('action/inscrire_auteur');
2136 2136
 
2137
-	return tester_statut_inscription($mode, $id);
2137
+    return tester_statut_inscription($mode, $id);
2138 2138
 }
2139 2139
 
2140 2140
 //
@@ -2159,7 +2159,7 @@  discard block
 block discarded – undo
2159 2159
  * @return int $a+$b
2160 2160
  **/
2161 2161
 function plus($a, $b) {
2162
-	return $a + $b;
2162
+    return $a + $b;
2163 2163
 }
2164 2164
 function strplus($a, $b) {return strize('plus', $a, $b);}
2165 2165
 /**
@@ -2178,7 +2178,7 @@  discard block
 block discarded – undo
2178 2178
  * @return int $a-$b
2179 2179
  **/
2180 2180
 function moins($a, $b) {
2181
-	return $a - $b;
2181
+    return $a - $b;
2182 2182
 }
2183 2183
 function strmoins($a, $b) {return strize('moins', $a, $b);}
2184 2184
 
@@ -2199,7 +2199,7 @@  discard block
 block discarded – undo
2199 2199
  * @return int $a*$b
2200 2200
  **/
2201 2201
 function mult($a, $b) {
2202
-	return $a * $b;
2202
+    return $a * $b;
2203 2203
 }
2204 2204
 function strmult($a, $b) {return strize('mult', $a, $b);}
2205 2205
 
@@ -2220,7 +2220,7 @@  discard block
 block discarded – undo
2220 2220
  * @return int $a/$b (ou 0 si $b est nul)
2221 2221
  **/
2222 2222
 function div($a, $b) {
2223
-	return $b ? $a / $b : 0;
2223
+    return $b ? $a / $b : 0;
2224 2224
 }
2225 2225
 function strdiv($a, $b) {return strize('div', $a, $b);}
2226 2226
 
@@ -2242,7 +2242,7 @@  discard block
 block discarded – undo
2242 2242
  * @return int ($nb % $mod) + $add
2243 2243
  **/
2244 2244
 function modulo($nb, $mod, $add = 0) {
2245
-	return ($mod ? $nb % $mod : 0) + $add;
2245
+    return ($mod ? $nb % $mod : 0) + $add;
2246 2246
 }
2247 2247
 
2248 2248
 
@@ -2257,24 +2257,24 @@  discard block
 block discarded – undo
2257 2257
  *      - true sinon
2258 2258
  **/
2259 2259
 function nom_acceptable($nom) {
2260
-	if (!is_string($nom)) {
2261
-		return false;
2262
-	}
2263
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2264
-		define('_TAGS_NOM_AUTEUR', '');
2265
-	}
2266
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2267
-	foreach ($tags_acceptes as $tag) {
2268
-		if (strlen($tag)) {
2269
-			$remp1[] = '<' . trim($tag) . '>';
2270
-			$remp1[] = '</' . trim($tag) . '>';
2271
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2272
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2273
-		}
2274
-	}
2275
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2260
+    if (!is_string($nom)) {
2261
+        return false;
2262
+    }
2263
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2264
+        define('_TAGS_NOM_AUTEUR', '');
2265
+    }
2266
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2267
+    foreach ($tags_acceptes as $tag) {
2268
+        if (strlen($tag)) {
2269
+            $remp1[] = '<' . trim($tag) . '>';
2270
+            $remp1[] = '</' . trim($tag) . '>';
2271
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2272
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2273
+        }
2274
+    }
2275
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2276 2276
 
2277
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2277
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2278 2278
 }
2279 2279
 
2280 2280
 
@@ -2290,14 +2290,14 @@  discard block
 block discarded – undo
2290 2290
  *      - renvoie un tableau si l'entree est un tableau
2291 2291
  **/
2292 2292
 function email_valide($adresses) {
2293
-	if (is_array($adresses)) {
2294
-		$adresses = array_map('email_valide', $adresses);
2295
-		$adresses = array_filter($adresses);
2296
-		return $adresses;
2297
-	}
2293
+    if (is_array($adresses)) {
2294
+        $adresses = array_map('email_valide', $adresses);
2295
+        $adresses = array_filter($adresses);
2296
+        return $adresses;
2297
+    }
2298 2298
 
2299
-	$email_valide = charger_fonction('email_valide', 'inc');
2300
-	return $email_valide($adresses);
2299
+    $email_valide = charger_fonction('email_valide', 'inc');
2300
+    return $email_valide($adresses);
2301 2301
 }
2302 2302
 
2303 2303
 /**
@@ -2311,20 +2311,20 @@  discard block
 block discarded – undo
2311 2311
  * @return string Texte
2312 2312
  **/
2313 2313
 function afficher_enclosures($tags) {
2314
-	$s = array();
2315
-	foreach (extraire_balises($tags, 'a') as $tag) {
2316
-		if (extraire_attribut($tag, 'rel') == 'enclosure'
2317
-			and $t = extraire_attribut($tag, 'href')
2318
-		) {
2319
-			$s[] = preg_replace(',>[^<]+</a>,S',
2320
-				'>'
2321
-				. http_img_pack('attachment-16.png', $t,
2322
-					'title="' . attribut_html($t) . '"')
2323
-				. '</a>', $tag);
2324
-		}
2325
-	}
2314
+    $s = array();
2315
+    foreach (extraire_balises($tags, 'a') as $tag) {
2316
+        if (extraire_attribut($tag, 'rel') == 'enclosure'
2317
+            and $t = extraire_attribut($tag, 'href')
2318
+        ) {
2319
+            $s[] = preg_replace(',>[^<]+</a>,S',
2320
+                '>'
2321
+                . http_img_pack('attachment-16.png', $t,
2322
+                    'title="' . attribut_html($t) . '"')
2323
+                . '</a>', $tag);
2324
+        }
2325
+    }
2326 2326
 
2327
-	return join('&nbsp;', $s);
2327
+    return join('&nbsp;', $s);
2328 2328
 }
2329 2329
 
2330 2330
 /**
@@ -2339,15 +2339,15 @@  discard block
 block discarded – undo
2339 2339
  * @return string Liens trouvés
2340 2340
  **/
2341 2341
 function afficher_tags($tags, $rels = 'tag,directory') {
2342
-	$s = array();
2343
-	foreach (extraire_balises($tags, 'a') as $tag) {
2344
-		$rel = extraire_attribut($tag, 'rel');
2345
-		if (strstr(",$rels,", ",$rel,")) {
2346
-			$s[] = $tag;
2347
-		}
2348
-	}
2342
+    $s = array();
2343
+    foreach (extraire_balises($tags, 'a') as $tag) {
2344
+        $rel = extraire_attribut($tag, 'rel');
2345
+        if (strstr(",$rels,", ",$rel,")) {
2346
+            $s[] = $tag;
2347
+        }
2348
+    }
2349 2349
 
2350
-	return join(', ', $s);
2350
+    return join(', ', $s);
2351 2351
 }
2352 2352
 
2353 2353
 
@@ -2369,21 +2369,21 @@  discard block
 block discarded – undo
2369 2369
  * @return string Tag HTML `<a>` avec microformat.
2370 2370
  **/
2371 2371
 function enclosure2microformat($e) {
2372
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2373
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2374
-	}
2375
-	$type = extraire_attribut($e, 'type');
2376
-	if (!$length = extraire_attribut($e, 'length')) {
2377
-		# <media:content : longeur dans fileSize. On tente.
2378
-		$length = extraire_attribut($e, 'fileSize');
2379
-	}
2380
-	$fichier = basename($url);
2372
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2373
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2374
+    }
2375
+    $type = extraire_attribut($e, 'type');
2376
+    if (!$length = extraire_attribut($e, 'length')) {
2377
+        # <media:content : longeur dans fileSize. On tente.
2378
+        $length = extraire_attribut($e, 'fileSize');
2379
+    }
2380
+    $fichier = basename($url);
2381 2381
 
2382
-	return '<a rel="enclosure"'
2383
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2384
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2385
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2386
-	. '>' . $fichier . '</a>';
2382
+    return '<a rel="enclosure"'
2383
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2384
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2385
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2386
+    . '>' . $fichier . '</a>';
2387 2387
 }
2388 2388
 
2389 2389
 /**
@@ -2401,24 +2401,24 @@  discard block
 block discarded – undo
2401 2401
  * @return string Tags RSS `<enclosure>`.
2402 2402
  **/
2403 2403
 function microformat2enclosure($tags) {
2404
-	$enclosures = array();
2405
-	foreach (extraire_balises($tags, 'a') as $e) {
2406
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2407
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2408
-			$type = extraire_attribut($e, 'type');
2409
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2410
-				$length = intval(extraire_attribut($e, 'length'));
2411
-			} # vieux data
2412
-			$fichier = basename($url);
2413
-			$enclosures[] = '<enclosure'
2414
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2415
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2416
-				. ($length ? ' length="' . $length . '"' : '')
2417
-				. ' />';
2418
-		}
2419
-	}
2404
+    $enclosures = array();
2405
+    foreach (extraire_balises($tags, 'a') as $e) {
2406
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2407
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2408
+            $type = extraire_attribut($e, 'type');
2409
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2410
+                $length = intval(extraire_attribut($e, 'length'));
2411
+            } # vieux data
2412
+            $fichier = basename($url);
2413
+            $enclosures[] = '<enclosure'
2414
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2415
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2416
+                . ($length ? ' length="' . $length . '"' : '')
2417
+                . ' />';
2418
+        }
2419
+    }
2420 2420
 
2421
-	return join("\n", $enclosures);
2421
+    return join("\n", $enclosures);
2422 2422
 }
2423 2423
 
2424 2424
 
@@ -2434,16 +2434,16 @@  discard block
 block discarded – undo
2434 2434
  * @return string Tags RSS Atom `<dc:subject>`.
2435 2435
  **/
2436 2436
 function tags2dcsubject($tags) {
2437
-	$subjects = '';
2438
-	foreach (extraire_balises($tags, 'a') as $e) {
2439
-		if (extraire_attribut($e, rel) == 'tag') {
2440
-			$subjects .= '<dc:subject>'
2441
-				. texte_backend(textebrut($e))
2442
-				. '</dc:subject>' . "\n";
2443
-		}
2444
-	}
2437
+    $subjects = '';
2438
+    foreach (extraire_balises($tags, 'a') as $e) {
2439
+        if (extraire_attribut($e, rel) == 'tag') {
2440
+            $subjects .= '<dc:subject>'
2441
+                . texte_backend(textebrut($e))
2442
+                . '</dc:subject>' . "\n";
2443
+        }
2444
+    }
2445 2445
 
2446
-	return $subjects;
2446
+    return $subjects;
2447 2447
 }
2448 2448
 
2449 2449
 /**
@@ -2472,23 +2472,23 @@  discard block
 block discarded – undo
2472 2472
  *     - Tableau de résultats, si tableau en entrée.
2473 2473
  **/
2474 2474
 function extraire_balise($texte, $tag = 'a') {
2475
-	if (is_array($texte)) {
2476
-		array_walk(
2477
-			$texte,
2478
-			function(&$a, $key, $t){
2479
-				$a = extraire_balise($a, $t);
2480
-			},
2481
-			$tag
2482
-		);
2475
+    if (is_array($texte)) {
2476
+        array_walk(
2477
+            $texte,
2478
+            function(&$a, $key, $t){
2479
+                $a = extraire_balise($a, $t);
2480
+            },
2481
+            $tag
2482
+        );
2483 2483
 
2484
-		return $texte;
2485
-	}
2484
+        return $texte;
2485
+    }
2486 2486
 
2487
-	if (preg_match(
2488
-		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2489
-		$texte, $regs)) {
2490
-		return $regs[0];
2491
-	}
2487
+    if (preg_match(
2488
+        ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2489
+        $texte, $regs)) {
2490
+        return $regs[0];
2491
+    }
2492 2492
 }
2493 2493
 
2494 2494
 /**
@@ -2516,25 +2516,25 @@  discard block
 block discarded – undo
2516 2516
  *     - Tableau de résultats, si tableau en entrée.
2517 2517
  **/
2518 2518
 function extraire_balises($texte, $tag = 'a') {
2519
-	if (is_array($texte)) {
2520
-		array_walk(
2521
-			$texte,
2522
-			function(&$a, $key, $t){
2523
-				$a = extraire_balises($a, $t);
2524
-			},
2525
-			$tag
2526
-		);
2519
+    if (is_array($texte)) {
2520
+        array_walk(
2521
+            $texte,
2522
+            function(&$a, $key, $t){
2523
+                $a = extraire_balises($a, $t);
2524
+            },
2525
+            $tag
2526
+        );
2527 2527
 
2528
-		return $texte;
2529
-	}
2528
+        return $texte;
2529
+    }
2530 2530
 
2531
-	if (preg_match_all(
2532
-		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2533
-		$texte, $regs, PREG_PATTERN_ORDER)) {
2534
-		return $regs[0];
2535
-	} else {
2536
-		return array();
2537
-	}
2531
+    if (preg_match_all(
2532
+        ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2533
+        $texte, $regs, PREG_PATTERN_ORDER)) {
2534
+        return $regs[0];
2535
+    } else {
2536
+        return array();
2537
+    }
2538 2538
 }
2539 2539
 
2540 2540
 /**
@@ -2563,11 +2563,11 @@  discard block
 block discarded – undo
2563 2563
  *     - `$def` si on n'a pas transmis de tableau
2564 2564
  **/
2565 2565
 function in_any($val, $vals, $def = '') {
2566
-	if (!is_array($vals) and $v = unserialize($vals)) {
2567
-		$vals = $v;
2568
-	}
2566
+    if (!is_array($vals) and $v = unserialize($vals)) {
2567
+        $vals = $v;
2568
+    }
2569 2569
 
2570
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2570
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2571 2571
 }
2572 2572
 
2573 2573
 
@@ -2588,12 +2588,12 @@  discard block
 block discarded – undo
2588 2588
  *     Résultat du calcul
2589 2589
  **/
2590 2590
 function valeur_numerique($expr) {
2591
-	$a = 0;
2592
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2593
-		eval("\$a = $expr;");
2594
-	}
2591
+    $a = 0;
2592
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2593
+        eval("\$a = $expr;");
2594
+    }
2595 2595
 
2596
-	return intval($a);
2596
+    return intval($a);
2597 2597
 }
2598 2598
 
2599 2599
 /**
@@ -2612,7 +2612,7 @@  discard block
 block discarded – undo
2612 2612
  *      Retourne `$a*$b/$c`
2613 2613
  **/
2614 2614
 function regledetrois($a, $b, $c) {
2615
-	return round($a * $b / $c);
2615
+    return round($a * $b / $c);
2616 2616
 }
2617 2617
 
2618 2618
 
@@ -2636,76 +2636,76 @@  discard block
 block discarded – undo
2636 2636
  **/
2637 2637
 function form_hidden($action) {
2638 2638
 
2639
-	$contexte = array();
2640
-	include_spip('inc/urls');
2641
-	if ($p = urls_decoder_url($action, '')
2642
-		and reset($p)
2643
-	) {
2644
-		$fond = array_shift($p);
2645
-		if ($fond != '404') {
2646
-			$contexte = array_shift($p);
2647
-			$contexte['page'] = $fond;
2648
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2649
-		}
2650
-	}
2651
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2652
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2653
-		unset($contexte['type']);
2654
-	}
2655
-	if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2656
-		unset($contexte['type-page']);
2657
-	}
2658
-
2659
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2660
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2661
-	$values = array();
2662
-
2663
-	// d'abord avec celles de l'url
2664
-	if (false !== ($p = strpos($action, '?'))) {
2665
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2666
-			$c = explode('=', $c, 2);
2667
-			$var = array_shift($c);
2668
-			$val = array_shift($c);
2669
-			if ($var) {
2670
-				$val = rawurldecode($val);
2671
-				$var = rawurldecode($var); // decoder les [] eventuels
2672
-				if (preg_match(',\[\]$,S', $var)) {
2673
-					$values[] = array($var, $val);
2674
-				} else {
2675
-					if (!isset($values[$var])) {
2676
-						$values[$var] = array($var, $val);
2677
-					}
2678
-				}
2679
-			}
2680
-		}
2681
-	}
2682
-
2683
-	// ensuite avec celles du contexte, sans doublonner !
2684
-	foreach ($contexte as $var => $val) {
2685
-		if (preg_match(',\[\]$,S', $var)) {
2686
-			$values[] = array($var, $val);
2687
-		} else {
2688
-			if (!isset($values[$var])) {
2689
-				$values[$var] = array($var, $val);
2690
-			}
2691
-		}
2692
-	}
2693
-
2694
-	// puis on rassemble le tout
2695
-	$hidden = array();
2696
-	foreach ($values as $value) {
2697
-		list($var, $val) = $value;
2698
-		$hidden[] = '<input name="'
2699
-			. entites_html($var)
2700
-			. '"'
2701
-			. (is_null($val)
2702
-				? ''
2703
-				: ' value="' . entites_html($val) . '"'
2704
-			)
2705
-			. ' type="hidden"' . "\n/>";
2706
-	}
2707
-
2708
-	return join("", $hidden);
2639
+    $contexte = array();
2640
+    include_spip('inc/urls');
2641
+    if ($p = urls_decoder_url($action, '')
2642
+        and reset($p)
2643
+    ) {
2644
+        $fond = array_shift($p);
2645
+        if ($fond != '404') {
2646
+            $contexte = array_shift($p);
2647
+            $contexte['page'] = $fond;
2648
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2649
+        }
2650
+    }
2651
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2652
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2653
+        unset($contexte['type']);
2654
+    }
2655
+    if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2656
+        unset($contexte['type-page']);
2657
+    }
2658
+
2659
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2660
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2661
+    $values = array();
2662
+
2663
+    // d'abord avec celles de l'url
2664
+    if (false !== ($p = strpos($action, '?'))) {
2665
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2666
+            $c = explode('=', $c, 2);
2667
+            $var = array_shift($c);
2668
+            $val = array_shift($c);
2669
+            if ($var) {
2670
+                $val = rawurldecode($val);
2671
+                $var = rawurldecode($var); // decoder les [] eventuels
2672
+                if (preg_match(',\[\]$,S', $var)) {
2673
+                    $values[] = array($var, $val);
2674
+                } else {
2675
+                    if (!isset($values[$var])) {
2676
+                        $values[$var] = array($var, $val);
2677
+                    }
2678
+                }
2679
+            }
2680
+        }
2681
+    }
2682
+
2683
+    // ensuite avec celles du contexte, sans doublonner !
2684
+    foreach ($contexte as $var => $val) {
2685
+        if (preg_match(',\[\]$,S', $var)) {
2686
+            $values[] = array($var, $val);
2687
+        } else {
2688
+            if (!isset($values[$var])) {
2689
+                $values[$var] = array($var, $val);
2690
+            }
2691
+        }
2692
+    }
2693
+
2694
+    // puis on rassemble le tout
2695
+    $hidden = array();
2696
+    foreach ($values as $value) {
2697
+        list($var, $val) = $value;
2698
+        $hidden[] = '<input name="'
2699
+            . entites_html($var)
2700
+            . '"'
2701
+            . (is_null($val)
2702
+                ? ''
2703
+                : ' value="' . entites_html($val) . '"'
2704
+            )
2705
+            . ' type="hidden"' . "\n/>";
2706
+    }
2707
+
2708
+    return join("", $hidden);
2709 2709
 }
2710 2710
 
2711 2711
 /**
@@ -2723,15 +2723,15 @@  discard block
 block discarded – undo
2723 2723
  *     Liste (première page, dernière page).
2724 2724
  **/
2725 2725
 function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) {
2726
-	if ($max <= 0 or $max >= $nombre) {
2727
-		return array(1, $nombre);
2728
-	}
2726
+    if ($max <= 0 or $max >= $nombre) {
2727
+        return array(1, $nombre);
2728
+    }
2729 2729
 
2730
-	$premiere = max(1, $courante - floor(($max - 1) / 2));
2731
-	$derniere = min($nombre, $premiere + $max - 2);
2732
-	$premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2730
+    $premiere = max(1, $courante - floor(($max - 1) / 2));
2731
+    $derniere = min($nombre, $premiere + $max - 2);
2732
+    $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2733 2733
 
2734
-	return array($premiere, $derniere);
2734
+    return array($premiere, $derniere);
2735 2735
 }
2736 2736
 
2737 2737
 
@@ -2753,7 +2753,7 @@  discard block
 block discarded – undo
2753 2753
  *    - la première valeur du tableau sinon.
2754 2754
  **/
2755 2755
 function filtre_reset($array) {
2756
-	return !is_array($array) ? null : reset($array);
2756
+    return !is_array($array) ? null : reset($array);
2757 2757
 }
2758 2758
 
2759 2759
 /**
@@ -2774,7 +2774,7 @@  discard block
 block discarded – undo
2774 2774
  *    - la dernière valeur du tableau sinon.
2775 2775
  **/
2776 2776
 function filtre_end($array) {
2777
-	return !is_array($array) ? null : end($array);
2777
+    return !is_array($array) ? null : end($array);
2778 2778
 }
2779 2779
 
2780 2780
 /**
@@ -2794,11 +2794,11 @@  discard block
 block discarded – undo
2794 2794
  *
2795 2795
  **/
2796 2796
 function filtre_push($array, $val) {
2797
-	if (!is_array($array) or !array_push($array, $val)) {
2798
-		return '';
2799
-	}
2797
+    if (!is_array($array) or !array_push($array, $val)) {
2798
+        return '';
2799
+    }
2800 2800
 
2801
-	return $array;
2801
+    return $array;
2802 2802
 }
2803 2803
 
2804 2804
 /**
@@ -2817,7 +2817,7 @@  discard block
 block discarded – undo
2817 2817
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2818 2818
  **/
2819 2819
 function filtre_find($array, $val) {
2820
-	return (is_array($array) and in_array($val, $array));
2820
+    return (is_array($array) and in_array($val, $array));
2821 2821
 }
2822 2822
 
2823 2823
 
@@ -2834,15 +2834,15 @@  discard block
 block discarded – undo
2834 2834
  *     Contenu avec urls en absolus
2835 2835
  **/
2836 2836
 function urls_absolues_css($contenu, $source) {
2837
-	$path = suivre_lien(url_absolue($source), './');
2837
+    $path = suivre_lien(url_absolue($source), './');
2838 2838
 
2839
-	return preg_replace_callback(
2840
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2841
-		function($x) use ($path) {
2842
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2843
-		},
2844
-		$contenu
2845
-	);
2839
+    return preg_replace_callback(
2840
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2841
+        function($x) use ($path) {
2842
+            return "url('" . suivre_lien($path, $x[1]) . "')";
2843
+        },
2844
+        $contenu
2845
+    );
2846 2846
 }
2847 2847
 
2848 2848
 
@@ -2871,118 +2871,118 @@  discard block
 block discarded – undo
2871 2871
  *     Chemin du fichier CSS inversé
2872 2872
  **/
2873 2873
 function direction_css($css, $voulue = '') {
2874
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2875
-		return $css;
2876
-	}
2877
-
2878
-	// si on a precise le sens voulu en argument, le prendre en compte
2879
-	if ($voulue = strtolower($voulue)) {
2880
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2881
-			$voulue = lang_dir($voulue);
2882
-		}
2883
-	} else {
2884
-		$voulue = lang_dir();
2885
-	}
2886
-
2887
-	$r = count($r) > 1;
2888
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2889
-	$dir = $r ? 'rtl' : 'ltr';
2890
-	$ndir = $r ? 'ltr' : 'rtl';
2891
-
2892
-	if ($voulue == $dir) {
2893
-		return $css;
2894
-	}
2895
-
2896
-	if (
2897
-		// url absolue
2898
-		preg_match(",^https?:,i", $css)
2899
-		// ou qui contient un ?
2900
-		or (($p = strpos($css, '?')) !== false)
2901
-	) {
2902
-		$distant = true;
2903
-		$cssf = parse_url($css);
2904
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2905
-		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2906
-	} else {
2907
-		$distant = false;
2908
-		$cssf = $css;
2909
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2910
-		//propose (rien a faire dans ce cas)
2911
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2912
-		if (@file_exists($f)) {
2913
-			return $f;
2914
-		}
2915
-	}
2916
-
2917
-	// 2.
2918
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2919
-	$f = $dir_var
2920
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2921
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2922
-
2923
-	// la css peut etre distante (url absolue !)
2924
-	if ($distant) {
2925
-		include_spip('inc/distant');
2926
-		$res = recuperer_url($css);
2927
-		if (!$res or !$contenu = $res['page']) {
2928
-			return $css;
2929
-		}
2930
-	} else {
2931
-		if ((@filemtime($f) > @filemtime($css))
2932
-			and (_VAR_MODE != 'recalcul')
2933
-		) {
2934
-			return $f;
2935
-		}
2936
-		if (!lire_fichier($css, $contenu)) {
2937
-			return $css;
2938
-		}
2939
-	}
2940
-
2941
-
2942
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2943
-	include_spip("lib/csstidy/class.csstidy");
2944
-	$parser = new csstidy();
2945
-	$parser->set_cfg('optimise_shorthands', 0);
2946
-	$parser->set_cfg('reverse_left_and_right', true);
2947
-	$parser->parse($contenu);
2948
-
2949
-	$contenu = $parser->print->plain();
2950
-
2951
-
2952
-	// reperer les @import auxquels il faut propager le direction_css
2953
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2954
-	$src = array();
2955
-	$src_direction_css = array();
2956
-	$src_faux_abs = array();
2957
-	$d = dirname($css);
2958
-	foreach ($regs[1] as $k => $import_css) {
2959
-		$css_direction = direction_css("$d/$import_css", $voulue);
2960
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2961
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2962
-			$css_direction = substr($css_direction, strlen($d) + 1);
2963
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2964
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2965
-			$css_direction = substr($css_direction, strlen($dir_var));
2966
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2967
-			$css_direction = "/@@@@@@/" . $css_direction;
2968
-		}
2969
-		$src[] = $regs[0][$k];
2970
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2971
-	}
2972
-	$contenu = str_replace($src, $src_direction_css, $contenu);
2973
-
2974
-	$contenu = urls_absolues_css($contenu, $css);
2975
-
2976
-	// virer les fausses url absolues que l'on a mis dans les import
2977
-	if (count($src_faux_abs)) {
2978
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2979
-	}
2980
-
2981
-	if (!ecrire_fichier($f, $contenu)) {
2982
-		return $css;
2983
-	}
2984
-
2985
-	return $f;
2874
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2875
+        return $css;
2876
+    }
2877
+
2878
+    // si on a precise le sens voulu en argument, le prendre en compte
2879
+    if ($voulue = strtolower($voulue)) {
2880
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2881
+            $voulue = lang_dir($voulue);
2882
+        }
2883
+    } else {
2884
+        $voulue = lang_dir();
2885
+    }
2886
+
2887
+    $r = count($r) > 1;
2888
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2889
+    $dir = $r ? 'rtl' : 'ltr';
2890
+    $ndir = $r ? 'ltr' : 'rtl';
2891
+
2892
+    if ($voulue == $dir) {
2893
+        return $css;
2894
+    }
2895
+
2896
+    if (
2897
+        // url absolue
2898
+        preg_match(",^https?:,i", $css)
2899
+        // ou qui contient un ?
2900
+        or (($p = strpos($css, '?')) !== false)
2901
+    ) {
2902
+        $distant = true;
2903
+        $cssf = parse_url($css);
2904
+        $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2905
+        $cssf = preg_replace(',[?:&=],', "_", $cssf);
2906
+    } else {
2907
+        $distant = false;
2908
+        $cssf = $css;
2909
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2910
+        //propose (rien a faire dans ce cas)
2911
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2912
+        if (@file_exists($f)) {
2913
+            return $f;
2914
+        }
2915
+    }
2916
+
2917
+    // 2.
2918
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2919
+    $f = $dir_var
2920
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2921
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2922
+
2923
+    // la css peut etre distante (url absolue !)
2924
+    if ($distant) {
2925
+        include_spip('inc/distant');
2926
+        $res = recuperer_url($css);
2927
+        if (!$res or !$contenu = $res['page']) {
2928
+            return $css;
2929
+        }
2930
+    } else {
2931
+        if ((@filemtime($f) > @filemtime($css))
2932
+            and (_VAR_MODE != 'recalcul')
2933
+        ) {
2934
+            return $f;
2935
+        }
2936
+        if (!lire_fichier($css, $contenu)) {
2937
+            return $css;
2938
+        }
2939
+    }
2940
+
2941
+
2942
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2943
+    include_spip("lib/csstidy/class.csstidy");
2944
+    $parser = new csstidy();
2945
+    $parser->set_cfg('optimise_shorthands', 0);
2946
+    $parser->set_cfg('reverse_left_and_right', true);
2947
+    $parser->parse($contenu);
2948
+
2949
+    $contenu = $parser->print->plain();
2950
+
2951
+
2952
+    // reperer les @import auxquels il faut propager le direction_css
2953
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2954
+    $src = array();
2955
+    $src_direction_css = array();
2956
+    $src_faux_abs = array();
2957
+    $d = dirname($css);
2958
+    foreach ($regs[1] as $k => $import_css) {
2959
+        $css_direction = direction_css("$d/$import_css", $voulue);
2960
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2961
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2962
+            $css_direction = substr($css_direction, strlen($d) + 1);
2963
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2964
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2965
+            $css_direction = substr($css_direction, strlen($dir_var));
2966
+            $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2967
+            $css_direction = "/@@@@@@/" . $css_direction;
2968
+        }
2969
+        $src[] = $regs[0][$k];
2970
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2971
+    }
2972
+    $contenu = str_replace($src, $src_direction_css, $contenu);
2973
+
2974
+    $contenu = urls_absolues_css($contenu, $css);
2975
+
2976
+    // virer les fausses url absolues que l'on a mis dans les import
2977
+    if (count($src_faux_abs)) {
2978
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2979
+    }
2980
+
2981
+    if (!ecrire_fichier($f, $contenu)) {
2982
+        return $css;
2983
+    }
2984
+
2985
+    return $f;
2986 2986
 }
2987 2987
 
2988 2988
 
@@ -3005,43 +3005,43 @@  discard block
 block discarded – undo
3005 3005
  *     - Chemin ou URL du fichier CSS source sinon.
3006 3006
  **/
3007 3007
 function url_absolue_css($css) {
3008
-	if (!preg_match(',\.css$,i', $css, $r)) {
3009
-		return $css;
3010
-	}
3008
+    if (!preg_match(',\.css$,i', $css, $r)) {
3009
+        return $css;
3010
+    }
3011 3011
 
3012
-	$url_absolue_css = url_absolue($css);
3012
+    $url_absolue_css = url_absolue($css);
3013 3013
 
3014
-	$f = basename($css, '.css');
3015
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3016
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3017
-		. '.css';
3014
+    $f = basename($css, '.css');
3015
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3016
+        . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3017
+        . '.css';
3018 3018
 
3019
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3020
-		return $f;
3021
-	}
3019
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3020
+        return $f;
3021
+    }
3022 3022
 
3023
-	if ($url_absolue_css == $css) {
3024
-		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3025
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3026
-		) {
3027
-			include_spip('inc/distant');
3028
-			if (!$contenu = recuperer_page($css)) {
3029
-				return $css;
3030
-			}
3031
-		}
3032
-	} elseif (!lire_fichier($css, $contenu)) {
3033
-		return $css;
3034
-	}
3023
+    if ($url_absolue_css == $css) {
3024
+        if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3025
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3026
+        ) {
3027
+            include_spip('inc/distant');
3028
+            if (!$contenu = recuperer_page($css)) {
3029
+                return $css;
3030
+            }
3031
+        }
3032
+    } elseif (!lire_fichier($css, $contenu)) {
3033
+        return $css;
3034
+    }
3035 3035
 
3036
-	// passer les url relatives a la css d'origine en url absolues
3037
-	$contenu = urls_absolues_css($contenu, $css);
3036
+    // passer les url relatives a la css d'origine en url absolues
3037
+    $contenu = urls_absolues_css($contenu, $css);
3038 3038
 
3039
-	// ecrire la css
3040
-	if (!ecrire_fichier($f, $contenu)) {
3041
-		return $css;
3042
-	}
3039
+    // ecrire la css
3040
+    if (!ecrire_fichier($f, $contenu)) {
3041
+        return $css;
3042
+    }
3043 3043
 
3044
-	return $f;
3044
+    return $f;
3045 3045
 }
3046 3046
 
3047 3047
 
@@ -3075,24 +3075,24 @@  discard block
 block discarded – undo
3075 3075
  *     Valeur trouvée ou valeur par défaut.
3076 3076
  **/
3077 3077
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3078
-	foreach (explode('/', $cle) as $k) {
3078
+    foreach (explode('/', $cle) as $k) {
3079 3079
 
3080
-		$table = is_string($table) ? @unserialize($table) : $table;
3080
+        $table = is_string($table) ? @unserialize($table) : $table;
3081 3081
 
3082
-		if (is_object($table)) {
3083
-			$table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3084
-		} elseif (is_array($table)) {
3085
-			if ($conserver_null) {
3086
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3087
-			} else {
3088
-				$table = isset($table[$k]) ? $table[$k] : $defaut;
3089
-			}
3090
-		} else {
3091
-			$table = $defaut;
3092
-		}
3093
-	}
3082
+        if (is_object($table)) {
3083
+            $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3084
+        } elseif (is_array($table)) {
3085
+            if ($conserver_null) {
3086
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3087
+            } else {
3088
+                $table = isset($table[$k]) ? $table[$k] : $defaut;
3089
+            }
3090
+        } else {
3091
+            $table = $defaut;
3092
+        }
3093
+    }
3094 3094
 
3095
-	return $table;
3095
+    return $table;
3096 3096
 }
3097 3097
 
3098 3098
 /**
@@ -3125,22 +3125,22 @@  discard block
 block discarded – undo
3125 3125
  *     - string : expression trouvée.
3126 3126
  **/
3127 3127
 function filtre_match_dist($texte, $expression, $modif = "UimsS", $capte = 0) {
3128
-	if (intval($modif) and $capte == 0) {
3129
-		$capte = $modif;
3130
-		$modif = "UimsS";
3131
-	}
3132
-	$expression = str_replace("\/", "/", $expression);
3133
-	$expression = str_replace("/", "\/", $expression);
3128
+    if (intval($modif) and $capte == 0) {
3129
+        $capte = $modif;
3130
+        $modif = "UimsS";
3131
+    }
3132
+    $expression = str_replace("\/", "/", $expression);
3133
+    $expression = str_replace("/", "\/", $expression);
3134 3134
 
3135
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3136
-		if (isset($r[$capte])) {
3137
-			return $r[$capte];
3138
-		} else {
3139
-			return true;
3140
-		}
3141
-	}
3135
+    if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3136
+        if (isset($r[$capte])) {
3137
+            return $r[$capte];
3138
+        } else {
3139
+            return true;
3140
+        }
3141
+    }
3142 3142
 
3143
-	return false;
3143
+    return false;
3144 3144
 }
3145 3145
 
3146 3146
 
@@ -3167,10 +3167,10 @@  discard block
 block discarded – undo
3167 3167
  *     Texte
3168 3168
  **/
3169 3169
 function replace($texte, $expression, $replace = '', $modif = "UimsS") {
3170
-	$expression = str_replace("\/", "/", $expression);
3171
-	$expression = str_replace("/", "\/", $expression);
3170
+    $expression = str_replace("\/", "/", $expression);
3171
+    $expression = str_replace("/", "\/", $expression);
3172 3172
 
3173
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3173
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3174 3174
 }
3175 3175
 
3176 3176
 
@@ -3188,21 +3188,21 @@  discard block
 block discarded – undo
3188 3188
  **/
3189 3189
 function traiter_doublons_documents(&$doublons, $letexte) {
3190 3190
 
3191
-	// Verifier dans le texte & les notes (pas beau, helas)
3192
-	$t = $letexte . $GLOBALS['les_notes'];
3191
+    // Verifier dans le texte & les notes (pas beau, helas)
3192
+    $t = $letexte . $GLOBALS['les_notes'];
3193 3193
 
3194
-	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3195
-		and preg_match_all(
3196
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3197
-			$t, $matches, PREG_PATTERN_ORDER)
3198
-	) {
3199
-		if (!isset($doublons['documents'])) {
3200
-			$doublons['documents'] = "";
3201
-		}
3202
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3203
-	}
3194
+    if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3195
+        and preg_match_all(
3196
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3197
+            $t, $matches, PREG_PATTERN_ORDER)
3198
+    ) {
3199
+        if (!isset($doublons['documents'])) {
3200
+            $doublons['documents'] = "";
3201
+        }
3202
+        $doublons['documents'] .= "," . join(',', $matches[1]);
3203
+    }
3204 3204
 
3205
-	return $letexte;
3205
+    return $letexte;
3206 3206
 }
3207 3207
 
3208 3208
 /**
@@ -3216,7 +3216,7 @@  discard block
 block discarded – undo
3216 3216
  * @return string Chaîne vide
3217 3217
  **/
3218 3218
 function vide($texte) {
3219
-	return "";
3219
+    return "";
3220 3220
 }
3221 3221
 
3222 3222
 //
@@ -3245,23 +3245,23 @@  discard block
 block discarded – undo
3245 3245
  *      Code HTML résultant
3246 3246
  **/
3247 3247
 function env_to_params($env, $ignore_params = array()) {
3248
-	$ignore_params = array_merge(
3249
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3250
-		$ignore_params
3251
-	);
3252
-	if (!is_array($env)) {
3253
-		$env = unserialize($env);
3254
-	}
3255
-	$texte = "";
3256
-	if ($env) {
3257
-		foreach ($env as $i => $j) {
3258
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3259
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3260
-			}
3261
-		}
3262
-	}
3263
-
3264
-	return $texte;
3248
+    $ignore_params = array_merge(
3249
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3250
+        $ignore_params
3251
+    );
3252
+    if (!is_array($env)) {
3253
+        $env = unserialize($env);
3254
+    }
3255
+    $texte = "";
3256
+    if ($env) {
3257
+        foreach ($env as $i => $j) {
3258
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3259
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3260
+            }
3261
+        }
3262
+    }
3263
+
3264
+    return $texte;
3265 3265
 }
3266 3266
 
3267 3267
 /**
@@ -3284,23 +3284,23 @@  discard block
 block discarded – undo
3284 3284
  *      Code HTML résultant
3285 3285
  **/
3286 3286
 function env_to_attributs($env, $ignore_params = array()) {
3287
-	$ignore_params = array_merge(
3288
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3289
-		$ignore_params
3290
-	);
3291
-	if (!is_array($env)) {
3292
-		$env = unserialize($env);
3293
-	}
3294
-	$texte = "";
3295
-	if ($env) {
3296
-		foreach ($env as $i => $j) {
3297
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3298
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3299
-			}
3300
-		}
3301
-	}
3287
+    $ignore_params = array_merge(
3288
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3289
+        $ignore_params
3290
+    );
3291
+    if (!is_array($env)) {
3292
+        $env = unserialize($env);
3293
+    }
3294
+    $texte = "";
3295
+    if ($env) {
3296
+        foreach ($env as $i => $j) {
3297
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3298
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3299
+            }
3300
+        }
3301
+    }
3302 3302
 
3303
-	return $texte;
3303
+    return $texte;
3304 3304
 }
3305 3305
 
3306 3306
 
@@ -3317,9 +3317,9 @@  discard block
 block discarded – undo
3317 3317
  * @return string Chaînes concaténés
3318 3318
  **/
3319 3319
 function concat() {
3320
-	$args = func_get_args();
3320
+    $args = func_get_args();
3321 3321
 
3322
-	return join('', $args);
3322
+    return join('', $args);
3323 3323
 }
3324 3324
 
3325 3325
 
@@ -3339,23 +3339,23 @@  discard block
 block discarded – undo
3339 3339
  *     Contenu du ou des fichiers, concaténé
3340 3340
  **/
3341 3341
 function charge_scripts($files, $script = true) {
3342
-	$flux = "";
3343
-	foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3344
-		if (!is_string($file)) {
3345
-			continue;
3346
-		}
3347
-		if ($script) {
3348
-			$file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3349
-		}
3350
-		if ($file) {
3351
-			$path = find_in_path($file);
3352
-			if ($path) {
3353
-				$flux .= spip_file_get_contents($path);
3354
-			}
3355
-		}
3356
-	}
3342
+    $flux = "";
3343
+    foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3344
+        if (!is_string($file)) {
3345
+            continue;
3346
+        }
3347
+        if ($script) {
3348
+            $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3349
+        }
3350
+        if ($file) {
3351
+            $path = find_in_path($file);
3352
+            if ($path) {
3353
+                $flux .= spip_file_get_contents($path);
3354
+            }
3355
+        }
3356
+    }
3357 3357
 
3358
-	return $flux;
3358
+    return $flux;
3359 3359
 }
3360 3360
 
3361 3361
 
@@ -3377,64 +3377,64 @@  discard block
 block discarded – undo
3377 3377
  */
3378 3378
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) {
3379 3379
 
3380
-	$img_file = $img;
3381
-	if ($p = strpos($img_file, '?')) {
3382
-		$img_file = substr($img_file,0, $p);
3383
-	}
3384
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3385
-		$img_file = chemin_image($img);
3386
-	}
3387
-	else {
3388
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3389
-			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3390
-			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3391
-			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3392
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3393
-			  and file_exists($variante_svg_generique)) {
3394
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3395
-					$img_file = $variante_svg_size;
3396
-				}
3397
-				else {
3398
-					$img_file = $variante_svg_generique;
3399
-				}
3400
-			}
3401
-		}
3402
-	}
3403
-	if (stripos($atts, 'width') === false) {
3404
-		// utiliser directement l'info de taille presente dans le nom
3405
-		if ((!isset($options['utiliser_suffixe_size'])
3406
-				or $options['utiliser_suffixe_size'] == true
3407
-			  or strpos($img_file, '-xx.svg') !== false)
3408
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3409
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3410
-		) {
3411
-			$largeur = $hauteur = intval($regs[1]);
3412
-		} else {
3413
-			$taille = taille_image($img_file);
3414
-			list($hauteur, $largeur) = $taille;
3415
-			if (!$hauteur or !$largeur) {
3416
-				return "";
3417
-			}
3418
-		}
3419
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3420
-	}
3421
-
3422
-	if (file_exists($img_file)) {
3423
-		$img_file = timestamp($img_file);
3424
-	}
3425
-	if ($alt === false) {
3426
-		$alt = '';
3427
-	}
3428
-	elseif($alt or $alt==='') {
3429
-		$alt = " alt='".attribut_html($alt)."'";
3430
-	}
3431
-	else {
3432
-		$alt = " alt='".attribut_html($title)."'";
3433
-	}
3434
-	return "<img src='$img_file'$alt"
3435
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3436
-	. " " . ltrim($atts)
3437
-	. " />";
3380
+    $img_file = $img;
3381
+    if ($p = strpos($img_file, '?')) {
3382
+        $img_file = substr($img_file,0, $p);
3383
+    }
3384
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3385
+        $img_file = chemin_image($img);
3386
+    }
3387
+    else {
3388
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3389
+            // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3390
+            // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3391
+            if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3392
+              and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3393
+              and file_exists($variante_svg_generique)) {
3394
+                if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3395
+                    $img_file = $variante_svg_size;
3396
+                }
3397
+                else {
3398
+                    $img_file = $variante_svg_generique;
3399
+                }
3400
+            }
3401
+        }
3402
+    }
3403
+    if (stripos($atts, 'width') === false) {
3404
+        // utiliser directement l'info de taille presente dans le nom
3405
+        if ((!isset($options['utiliser_suffixe_size'])
3406
+                or $options['utiliser_suffixe_size'] == true
3407
+              or strpos($img_file, '-xx.svg') !== false)
3408
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3409
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3410
+        ) {
3411
+            $largeur = $hauteur = intval($regs[1]);
3412
+        } else {
3413
+            $taille = taille_image($img_file);
3414
+            list($hauteur, $largeur) = $taille;
3415
+            if (!$hauteur or !$largeur) {
3416
+                return "";
3417
+            }
3418
+        }
3419
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3420
+    }
3421
+
3422
+    if (file_exists($img_file)) {
3423
+        $img_file = timestamp($img_file);
3424
+    }
3425
+    if ($alt === false) {
3426
+        $alt = '';
3427
+    }
3428
+    elseif($alt or $alt==='') {
3429
+        $alt = " alt='".attribut_html($alt)."'";
3430
+    }
3431
+    else {
3432
+        $alt = " alt='".attribut_html($title)."'";
3433
+    }
3434
+    return "<img src='$img_file'$alt"
3435
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3436
+    . " " . ltrim($atts)
3437
+    . " />";
3438 3438
 }
3439 3439
 
3440 3440
 /**
@@ -3446,68 +3446,68 @@  discard block
 block discarded – undo
3446 3446
  * @return string
3447 3447
  */
3448 3448
 function http_style_background($img, $att = '', $size=null) {
3449
-	if ($size and is_numeric($size)){
3450
-		$size = trim($size) . "px";
3451
-	}
3452
-	return " style='background" .
3453
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3454
-		. ($size ? "background-size:{$size};" : '')
3455
-		. "'";
3449
+    if ($size and is_numeric($size)){
3450
+        $size = trim($size) . "px";
3451
+    }
3452
+    return " style='background" .
3453
+        ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3454
+        . ($size ? "background-size:{$size};" : '')
3455
+        . "'";
3456 3456
 }
3457 3457
 
3458 3458
 
3459 3459
 function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) {
3460
-	$args = [$alt_or_size, $class_or_size, $size];
3461
-	while (is_null(end($args)) and count($args)) {
3462
-		array_pop($args);
3463
-	}
3464
-	if (!count($args)) {
3465
-		return [null, null, null];
3466
-	}
3467
-	if (count($args) < 3) {
3468
-		$maybe_size = array_pop($args);
3469
-		// @2x
3470
-		// @1.5x
3471
-		// 512
3472
-		// 512x*
3473
-		// 512x300
3474
-		if (!strlen($maybe_size)
3475
-			or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))) {
3476
-			$args[] = $maybe_size;
3477
-			$maybe_size = null;
3478
-		}
3479
-		while (count($args)<2) {
3480
-			$args[] = null; // default alt or class
3481
-		}
3482
-		$args[] = $maybe_size;
3483
-	}
3484
-	return $args;
3460
+    $args = [$alt_or_size, $class_or_size, $size];
3461
+    while (is_null(end($args)) and count($args)) {
3462
+        array_pop($args);
3463
+    }
3464
+    if (!count($args)) {
3465
+        return [null, null, null];
3466
+    }
3467
+    if (count($args) < 3) {
3468
+        $maybe_size = array_pop($args);
3469
+        // @2x
3470
+        // @1.5x
3471
+        // 512
3472
+        // 512x*
3473
+        // 512x300
3474
+        if (!strlen($maybe_size)
3475
+            or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))) {
3476
+            $args[] = $maybe_size;
3477
+            $maybe_size = null;
3478
+        }
3479
+        while (count($args)<2) {
3480
+            $args[] = null; // default alt or class
3481
+        }
3482
+        $args[] = $maybe_size;
3483
+    }
3484
+    return $args;
3485 3485
 }
3486 3486
 
3487 3487
 function helper_filtre_balise_img_svg_size($img, $size) {
3488
-	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3489
-	if (strpos($size, '@') === 0 and substr($size,-1) === 'x') {
3490
-		$coef = floatval(substr($size, 1, -1));
3491
-		list($h, $w) = taille_image($img);
3492
-		$height = intval(round($h / $coef));
3493
-		$width = intval(round($w / $coef));
3494
-	}
3495
-	// sinon c'est une valeur seule si image caree ou largeurxhauteur
3496
-	else {
3497
-		$size = explode('x', $size, 2);
3498
-		$size = array_map('trim', $size);
3499
-		$height = $width = intval(array_shift($size));
3500
-
3501
-		if (count($size) and reset($size)) {
3502
-			$height = array_shift($size);
3503
-			if ($height === '*') {
3504
-				list($h, $w) = taille_image($img);
3505
-				$height = intval(round($h * $width / $w));
3506
-			}
3507
-		}
3508
-	}
3509
-
3510
-	return [$width, $height];
3488
+    // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3489
+    if (strpos($size, '@') === 0 and substr($size,-1) === 'x') {
3490
+        $coef = floatval(substr($size, 1, -1));
3491
+        list($h, $w) = taille_image($img);
3492
+        $height = intval(round($h / $coef));
3493
+        $width = intval(round($w / $coef));
3494
+    }
3495
+    // sinon c'est une valeur seule si image caree ou largeurxhauteur
3496
+    else {
3497
+        $size = explode('x', $size, 2);
3498
+        $size = array_map('trim', $size);
3499
+        $height = $width = intval(array_shift($size));
3500
+
3501
+        if (count($size) and reset($size)) {
3502
+            $height = array_shift($size);
3503
+            if ($height === '*') {
3504
+                list($h, $w) = taille_image($img);
3505
+                $height = intval(round($h * $width / $w));
3506
+            }
3507
+        }
3508
+    }
3509
+
3510
+    return [$width, $height];
3511 3511
 }
3512 3512
 
3513 3513
 /**
@@ -3543,38 +3543,38 @@  discard block
 block discarded – undo
3543 3543
  */
3544 3544
 function filtre_balise_img_dist($img, $alt = '', $class = null, $size=null) {
3545 3545
 
3546
-	list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3546
+    list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3547 3547
 
3548
-	$img = trim($img);
3549
-	if (strpos($img, '<img') === 0) {
3550
-		if (!is_null($alt)) {
3551
-			$img = inserer_attribut($img, 'alt', $alt);
3552
-		}
3553
-		if (!is_null($class)) {
3554
-			if (strlen($class)) {
3555
-				$img = inserer_attribut($img, 'class', $class);
3556
-			}
3557
-			else {
3558
-				$img = vider_attribut($img, 'class');
3559
-			}
3560
-		}
3561
-	}
3562
-	else {
3563
-		$img = http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3564
-				array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3565
-		if (is_null($alt)) {
3566
-			$img = vider_attribut($img, 'alt');
3567
-		}
3568
-	}
3548
+    $img = trim($img);
3549
+    if (strpos($img, '<img') === 0) {
3550
+        if (!is_null($alt)) {
3551
+            $img = inserer_attribut($img, 'alt', $alt);
3552
+        }
3553
+        if (!is_null($class)) {
3554
+            if (strlen($class)) {
3555
+                $img = inserer_attribut($img, 'class', $class);
3556
+            }
3557
+            else {
3558
+                $img = vider_attribut($img, 'class');
3559
+            }
3560
+        }
3561
+    }
3562
+    else {
3563
+        $img = http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3564
+                array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3565
+        if (is_null($alt)) {
3566
+            $img = vider_attribut($img, 'alt');
3567
+        }
3568
+    }
3569 3569
 
3570
-	if ($img and !is_null($size) and strlen($size = trim($size))) {
3571
-		list($width, $height) = helper_filtre_balise_img_svg_size($img, $size);
3570
+    if ($img and !is_null($size) and strlen($size = trim($size))) {
3571
+        list($width, $height) = helper_filtre_balise_img_svg_size($img, $size);
3572 3572
 
3573
-		$img = inserer_attribut($img, 'width', $width);
3574
-		$img = inserer_attribut($img, 'height', $height);
3575
-	}
3573
+        $img = inserer_attribut($img, 'width', $width);
3574
+        $img = inserer_attribut($img, 'height', $height);
3575
+    }
3576 3576
 
3577
-	return $img;
3577
+    return $img;
3578 3578
 }
3579 3579
 
3580 3580
 
@@ -3608,67 +3608,67 @@  discard block
 block discarded – undo
3608 3608
  */
3609 3609
 function filtre_balise_svg_dist($img, $alt = '', $class = null, $size=null) {
3610 3610
 
3611
-	$img = trim($img);
3612
-	$img_file = $img;
3613
-	if (strpos($img, '<svg') === false){
3614
-		if ($p = strpos($img_file, '?')){
3615
-			$img_file = substr($img_file, 0, $p);
3616
-		}
3611
+    $img = trim($img);
3612
+    $img_file = $img;
3613
+    if (strpos($img, '<svg') === false){
3614
+        if ($p = strpos($img_file, '?')){
3615
+            $img_file = substr($img_file, 0, $p);
3616
+        }
3617 3617
 
3618
-		if (!$img_file or !$svg = file_get_contents($img_file)){
3619
-			return '';
3620
-		}
3621
-	}
3618
+        if (!$img_file or !$svg = file_get_contents($img_file)){
3619
+            return '';
3620
+        }
3621
+    }
3622 3622
 
3623
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3624
-		return '';
3625
-	}
3623
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3624
+        return '';
3625
+    }
3626 3626
 
3627
-	list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3627
+    list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3628 3628
 
3629
-	$balise_svg = $match[0];
3630
-	$balise_svg_source = $balise_svg;
3629
+    $balise_svg = $match[0];
3630
+    $balise_svg_source = $balise_svg;
3631 3631
 
3632
-	// entete XML à supprimer
3633
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3632
+    // entete XML à supprimer
3633
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3634 3634
 
3635
-	// IE est toujours mon ami
3636
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3635
+    // IE est toujours mon ami
3636
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3637 3637
 
3638
-	// regler la classe
3639
-	if (!is_null($class)) {
3640
-		if (strlen($class)) {
3641
-			$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3642
-		}
3643
-		else {
3644
-			$balise_svg = vider_attribut($balise_svg, 'class');
3645
-		}
3646
-	}
3638
+    // regler la classe
3639
+    if (!is_null($class)) {
3640
+        if (strlen($class)) {
3641
+            $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3642
+        }
3643
+        else {
3644
+            $balise_svg = vider_attribut($balise_svg, 'class');
3645
+        }
3646
+    }
3647 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
-	}
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 3659
 
3660
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3660
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3661 3661
 
3662
-	if (!is_null($size) and strlen($size = trim($size))) {
3663
-		list($width, $height) = helper_filtre_balise_img_svg_size($svg, $size);
3662
+    if (!is_null($size) and strlen($size = trim($size))) {
3663
+        list($width, $height) = helper_filtre_balise_img_svg_size($svg, $size);
3664 3664
 
3665
-		if (!function_exists('svg_redimensionner')) {
3666
-			include_spip('inc/svg');
3667
-		}
3668
-		$svg = svg_redimensionner($svg, $width, $height);
3669
-	}
3665
+        if (!function_exists('svg_redimensionner')) {
3666
+            include_spip('inc/svg');
3667
+        }
3668
+        $svg = svg_redimensionner($svg, $width, $height);
3669
+    }
3670 3670
 
3671
-	return $svg;
3671
+    return $svg;
3672 3672
 }
3673 3673
 
3674 3674
 
@@ -3691,17 +3691,17 @@  discard block
 block discarded – undo
3691 3691
  *     Code HTML résultant
3692 3692
  **/
3693 3693
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3694
-	$texte = '';
3695
-	if (is_array($tableau)) {
3696
-		foreach ($tableau as $k => $v) {
3697
-			$res = recuperer_fond('modeles/' . $modele,
3698
-				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3699
-			);
3700
-			$texte .= $res;
3701
-		}
3702
-	}
3694
+    $texte = '';
3695
+    if (is_array($tableau)) {
3696
+        foreach ($tableau as $k => $v) {
3697
+            $res = recuperer_fond('modeles/' . $modele,
3698
+                array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3699
+            );
3700
+            $texte .= $res;
3701
+        }
3702
+    }
3703 3703
 
3704
-	return $texte;
3704
+    return $texte;
3705 3705
 }
3706 3706
 
3707 3707
 
@@ -3726,37 +3726,37 @@  discard block
 block discarded – undo
3726 3726
  *         - tout : retourne toutes les informations du plugin actif
3727 3727
  **/
3728 3728
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3729
-	include_spip('inc/plugin');
3730
-	$plugin = strtoupper($plugin);
3731
-	$plugins_actifs = liste_plugin_actifs();
3732
-
3733
-	if (!$plugin) {
3734
-		return serialize(array_keys($plugins_actifs));
3735
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3736
-		return '';
3737
-	} elseif (($type_info == 'est_actif') and !$reload) {
3738
-		return $plugins_actifs[$plugin] ? 1 : 0;
3739
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3740
-		return $plugins_actifs[$plugin][$type_info];
3741
-	} else {
3742
-		$get_infos = charger_fonction('get_infos', 'plugins');
3743
-		// On prend en compte les extensions
3744
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3745
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3746
-		} else {
3747
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3748
-		}
3749
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3750
-			return '';
3751
-		}
3752
-		if ($type_info == 'tout') {
3753
-			return $infos;
3754
-		} elseif ($type_info == 'est_actif') {
3755
-			return $infos ? 1 : 0;
3756
-		} else {
3757
-			return strval($infos[$type_info]);
3758
-		}
3759
-	}
3729
+    include_spip('inc/plugin');
3730
+    $plugin = strtoupper($plugin);
3731
+    $plugins_actifs = liste_plugin_actifs();
3732
+
3733
+    if (!$plugin) {
3734
+        return serialize(array_keys($plugins_actifs));
3735
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3736
+        return '';
3737
+    } elseif (($type_info == 'est_actif') and !$reload) {
3738
+        return $plugins_actifs[$plugin] ? 1 : 0;
3739
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3740
+        return $plugins_actifs[$plugin][$type_info];
3741
+    } else {
3742
+        $get_infos = charger_fonction('get_infos', 'plugins');
3743
+        // On prend en compte les extensions
3744
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3745
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3746
+        } else {
3747
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3748
+        }
3749
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3750
+            return '';
3751
+        }
3752
+        if ($type_info == 'tout') {
3753
+            return $infos;
3754
+        } elseif ($type_info == 'est_actif') {
3755
+            return $infos ? 1 : 0;
3756
+        } else {
3757
+            return strval($infos[$type_info]);
3758
+        }
3759
+    }
3760 3760
 }
3761 3761
 
3762 3762
 
@@ -3783,9 +3783,9 @@  discard block
 block discarded – undo
3783 3783
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3784 3784
  */
3785 3785
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3786
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3786
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3787 3787
 
3788
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3788
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3789 3789
 }
3790 3790
 
3791 3791
 
@@ -3815,13 +3815,13 @@  discard block
 block discarded – undo
3815 3815
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3816 3816
  */
3817 3817
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3818
-	static $puce_statut = null;
3819
-	if (!$puce_statut) {
3820
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3821
-	}
3818
+    static $puce_statut = null;
3819
+    if (!$puce_statut) {
3820
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3821
+    }
3822 3822
 
3823
-	return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3824
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3823
+    return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3824
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3825 3825
 }
3826 3826
 
3827 3827
 
@@ -3848,100 +3848,100 @@  discard block
 block discarded – undo
3848 3848
  *   hash du contexte
3849 3849
  */
3850 3850
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3851
-	if (is_string($c)
3852
-		and @unserialize($c) !== false
3853
-	) {
3854
-		$c = unserialize($c);
3855
-	}
3856
-
3857
-	// supprimer les parametres debut_x
3858
-	// pour que la pagination ajax ne soit pas plantee
3859
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3860
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3861
-	if (is_array($c)) {
3862
-		foreach ($c as $k => $v) {
3863
-			if (strpos($k, 'debut_') === 0) {
3864
-				unset($c[$k]);
3865
-			}
3866
-		}
3867
-	}
3868
-
3869
-	if (!function_exists('calculer_cle_action')) {
3870
-		include_spip("inc/securiser_action");
3871
-	}
3872
-
3873
-	$c = serialize($c);
3874
-	$cle = calculer_cle_action($form . $c);
3875
-	$c = "$cle:$c";
3876
-
3877
-	// on ne stocke pas les contextes dans des fichiers en cache
3878
-	// par defaut, sauf si cette configuration a été forcée
3879
-	// OU que la longueur de l’argument géneré est plus long
3880
-	// que ce qui est toléré.
3881
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3882
-	if (!$cache_contextes_ajax) {
3883
-		$env = $c;
3884
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3885
-			$env = gzdeflate($env);
3886
-			// https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3887
-			if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3888
-				$cache_contextes_ajax = true;
3889
-				spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3890
-			}
3891
-		}
3892
-		$env = _xor($env);
3893
-		$env = base64_encode($env);
3894
-		$len = strlen($env);
3895
-		// Si l’url est trop longue pour le navigateur
3896
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3897
-		if ($len > $max_len) {
3898
-			$cache_contextes_ajax = true;
3899
-			spip_log("Contextes AJAX forces en fichiers !"
3900
-				. " Cela arrive lorsque la valeur du contexte" 
3901
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3902
-				, _LOG_AVERTISSEMENT);
3903
-		}
3904
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3905
-		elseif (
3906
-			$max_len = @ini_get('suhosin.get.max_value_length')
3907
-			and $max_len < $len
3908
-		) {
3909
-			$cache_contextes_ajax = true;
3910
-			spip_log("Contextes AJAX forces en fichiers !"
3911
-				. " Cela arrive lorsque la valeur du contexte"
3912
-				. " depasse la longueur maximale autorisee par Suhosin"
3913
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3914
-				. " Vous devriez modifier les parametres de Suhosin"
3915
-				. " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3916
-		} 
3917
-
3918
-	}
3919
-
3920
-	if ($cache_contextes_ajax) {
3921
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3922
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3923
-		$md5 = md5($c);
3924
-		ecrire_fichier("$dir/c$md5", $c);
3925
-		$env = $md5;
3926
-	}
3927
-
3928
-	if ($emboite === null) {
3929
-		return $env;
3930
-	}
3931
-	if (!trim($emboite)) {
3932
-		return "";
3933
-	}
3934
-	// toujours encoder l'url source dans le bloc ajax
3935
-	$r = self();
3936
-	$r = ' data-origin="' . $r . '"';
3937
-	$class = 'ajaxbloc';
3938
-	if ($ajaxid and is_string($ajaxid)) {
3939
-		// ajaxid est normalement conforme a un nom de classe css
3940
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3941
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3942
-	}
3943
-
3944
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3851
+    if (is_string($c)
3852
+        and @unserialize($c) !== false
3853
+    ) {
3854
+        $c = unserialize($c);
3855
+    }
3856
+
3857
+    // supprimer les parametres debut_x
3858
+    // pour que la pagination ajax ne soit pas plantee
3859
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3860
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3861
+    if (is_array($c)) {
3862
+        foreach ($c as $k => $v) {
3863
+            if (strpos($k, 'debut_') === 0) {
3864
+                unset($c[$k]);
3865
+            }
3866
+        }
3867
+    }
3868
+
3869
+    if (!function_exists('calculer_cle_action')) {
3870
+        include_spip("inc/securiser_action");
3871
+    }
3872
+
3873
+    $c = serialize($c);
3874
+    $cle = calculer_cle_action($form . $c);
3875
+    $c = "$cle:$c";
3876
+
3877
+    // on ne stocke pas les contextes dans des fichiers en cache
3878
+    // par defaut, sauf si cette configuration a été forcée
3879
+    // OU que la longueur de l’argument géneré est plus long
3880
+    // que ce qui est toléré.
3881
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3882
+    if (!$cache_contextes_ajax) {
3883
+        $env = $c;
3884
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3885
+            $env = gzdeflate($env);
3886
+            // https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3887
+            if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3888
+                $cache_contextes_ajax = true;
3889
+                spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3890
+            }
3891
+        }
3892
+        $env = _xor($env);
3893
+        $env = base64_encode($env);
3894
+        $len = strlen($env);
3895
+        // Si l’url est trop longue pour le navigateur
3896
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3897
+        if ($len > $max_len) {
3898
+            $cache_contextes_ajax = true;
3899
+            spip_log("Contextes AJAX forces en fichiers !"
3900
+                . " Cela arrive lorsque la valeur du contexte" 
3901
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3902
+                , _LOG_AVERTISSEMENT);
3903
+        }
3904
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3905
+        elseif (
3906
+            $max_len = @ini_get('suhosin.get.max_value_length')
3907
+            and $max_len < $len
3908
+        ) {
3909
+            $cache_contextes_ajax = true;
3910
+            spip_log("Contextes AJAX forces en fichiers !"
3911
+                . " Cela arrive lorsque la valeur du contexte"
3912
+                . " depasse la longueur maximale autorisee par Suhosin"
3913
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3914
+                . " Vous devriez modifier les parametres de Suhosin"
3915
+                . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3916
+        } 
3917
+
3918
+    }
3919
+
3920
+    if ($cache_contextes_ajax) {
3921
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3922
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3923
+        $md5 = md5($c);
3924
+        ecrire_fichier("$dir/c$md5", $c);
3925
+        $env = $md5;
3926
+    }
3927
+
3928
+    if ($emboite === null) {
3929
+        return $env;
3930
+    }
3931
+    if (!trim($emboite)) {
3932
+        return "";
3933
+    }
3934
+    // toujours encoder l'url source dans le bloc ajax
3935
+    $r = self();
3936
+    $r = ' data-origin="' . $r . '"';
3937
+    $class = 'ajaxbloc';
3938
+    if ($ajaxid and is_string($ajaxid)) {
3939
+        // ajaxid est normalement conforme a un nom de classe css
3940
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3941
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3942
+    }
3943
+
3944
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3945 3945
 }
3946 3946
 
3947 3947
 /**
@@ -3961,36 +3961,36 @@  discard block
 block discarded – undo
3961 3961
  *   - false : erreur de décodage
3962 3962
  */
3963 3963
 function decoder_contexte_ajax($c, $form = '') {
3964
-	if (!function_exists('calculer_cle_action')) {
3965
-		include_spip("inc/securiser_action");
3966
-	}
3967
-	if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3968
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3969
-		and lire_fichier("$dir/c$c", $contexte)
3970
-	) {
3971
-		$c = $contexte;
3972
-	} else {
3973
-		$c = @base64_decode($c);
3974
-		$c = _xor($c);
3975
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3976
-			$c = @gzinflate($c);
3977
-		}
3978
-	}
3979
-
3980
-	// extraire la signature en debut de contexte
3981
-	// et la verifier avant de deserializer
3982
-	// format : signature:donneesserializees
3983
-	if ($p = strpos($c,":")){
3984
-		$cle = substr($c,0,$p);
3985
-		$c = substr($c,$p+1);
3986
-
3987
-		if ($cle == calculer_cle_action($form . $c)) {
3988
-			$env = @unserialize($c);
3989
-			return $env;
3990
-		}
3991
-	}
3992
-
3993
-	return false;
3964
+    if (!function_exists('calculer_cle_action')) {
3965
+        include_spip("inc/securiser_action");
3966
+    }
3967
+    if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3968
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3969
+        and lire_fichier("$dir/c$c", $contexte)
3970
+    ) {
3971
+        $c = $contexte;
3972
+    } else {
3973
+        $c = @base64_decode($c);
3974
+        $c = _xor($c);
3975
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3976
+            $c = @gzinflate($c);
3977
+        }
3978
+    }
3979
+
3980
+    // extraire la signature en debut de contexte
3981
+    // et la verifier avant de deserializer
3982
+    // format : signature:donneesserializees
3983
+    if ($p = strpos($c,":")){
3984
+        $cle = substr($c,0,$p);
3985
+        $c = substr($c,$p+1);
3986
+
3987
+        if ($cle == calculer_cle_action($form . $c)) {
3988
+            $env = @unserialize($c);
3989
+            return $env;
3990
+        }
3991
+    }
3992
+
3993
+    return false;
3994 3994
 }
3995 3995
 
3996 3996
 
@@ -4008,20 +4008,20 @@  discard block
 block discarded – undo
4008 4008
  *    Message décrypté ou encrypté
4009 4009
  **/
4010 4010
 function _xor($message, $key = null) {
4011
-	if (is_null($key)) {
4012
-		if (!function_exists('calculer_cle_action')) {
4013
-			include_spip("inc/securiser_action");
4014
-		}
4015
-		$key = pack("H*", calculer_cle_action('_xor'));
4016
-	}
4011
+    if (is_null($key)) {
4012
+        if (!function_exists('calculer_cle_action')) {
4013
+            include_spip("inc/securiser_action");
4014
+        }
4015
+        $key = pack("H*", calculer_cle_action('_xor'));
4016
+    }
4017 4017
 
4018
-	$keylen = strlen($key);
4019
-	$messagelen = strlen($message);
4020
-	for ($i = 0; $i < $messagelen; $i++) {
4021
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4022
-	}
4018
+    $keylen = strlen($key);
4019
+    $messagelen = strlen($message);
4020
+    for ($i = 0; $i < $messagelen; $i++) {
4021
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4022
+    }
4023 4023
 
4024
-	return $message;
4024
+    return $message;
4025 4025
 }
4026 4026
 
4027 4027
 /**
@@ -4084,37 +4084,37 @@  discard block
 block discarded – undo
4084 4084
  *   Code HTML
4085 4085
  */
4086 4086
 function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') {
4087
-	if ($on) {
4088
-		$bal = 'strong';
4089
-		$class = "";
4090
-		$att = "";
4091
-		// si $on passe la balise et optionnelement une ou ++classe
4092
-		// a.active span.selected.active etc....
4093
-		if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
4094
-			$on = explode(".", $on);
4095
-			// on verifie que c'est exactement une des 3 balises a, span ou strong
4096
-			if (in_array(reset($on), array('a', 'span', 'strong'))){
4097
-				$bal = array_shift($on);
4098
-				$class = implode(" ", $on);
4099
-				if ($bal=="a"){
4100
-					$att = 'href="#" ';
4101
-				}
4102
-			}
4103
-		}
4104
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4105
-	} else {
4106
-		$bal = 'a';
4107
-		$att = "href='$url'"
4108
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4109
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4110
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4111
-			. $evt;
4112
-	}
4113
-	if ($libelle === null) {
4114
-		$libelle = $url;
4115
-	}
4116
-
4117
-	return "<$bal $att>$libelle</$bal>";
4087
+    if ($on) {
4088
+        $bal = 'strong';
4089
+        $class = "";
4090
+        $att = "";
4091
+        // si $on passe la balise et optionnelement une ou ++classe
4092
+        // a.active span.selected.active etc....
4093
+        if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
4094
+            $on = explode(".", $on);
4095
+            // on verifie que c'est exactement une des 3 balises a, span ou strong
4096
+            if (in_array(reset($on), array('a', 'span', 'strong'))){
4097
+                $bal = array_shift($on);
4098
+                $class = implode(" ", $on);
4099
+                if ($bal=="a"){
4100
+                    $att = 'href="#" ';
4101
+                }
4102
+            }
4103
+        }
4104
+        $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4105
+    } else {
4106
+        $bal = 'a';
4107
+        $att = "href='$url'"
4108
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
4109
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
4110
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4111
+            . $evt;
4112
+    }
4113
+    if ($libelle === null) {
4114
+        $libelle = $url;
4115
+    }
4116
+
4117
+    return "<$bal $att>$libelle</$bal>";
4118 4118
 }
4119 4119
 
4120 4120
 
@@ -4131,37 +4131,37 @@  discard block
 block discarded – undo
4131 4131
  * @return string : la chaine de langue finale en utilisant la fonction _T()
4132 4132
  */
4133 4133
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) {
4134
-	static $local_singulier_ou_pluriel = array();
4134
+    static $local_singulier_ou_pluriel = array();
4135 4135
 
4136
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4137
-	if (!is_numeric($nb) or $nb == 0) {
4138
-		return "";
4139
-	}
4140
-	if (!is_array($vars)) {
4141
-		return "";
4142
-	}
4136
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4137
+    if (!is_numeric($nb) or $nb == 0) {
4138
+        return "";
4139
+    }
4140
+    if (!is_array($vars)) {
4141
+        return "";
4142
+    }
4143 4143
 
4144
-	$langue = $GLOBALS['spip_lang'];
4145
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
4146
-		$local_singulier_ou_pluriel[$langue] = false;
4147
-		if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
4148
-		  or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) {
4149
-			$local_singulier_ou_pluriel[$langue] = $f;
4150
-		}
4151
-	}
4144
+    $langue = $GLOBALS['spip_lang'];
4145
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
4146
+        $local_singulier_ou_pluriel[$langue] = false;
4147
+        if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
4148
+          or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) {
4149
+            $local_singulier_ou_pluriel[$langue] = $f;
4150
+        }
4151
+    }
4152 4152
 
4153
-	// si on a une surcharge on l'utilise
4154
-	if ($local_singulier_ou_pluriel[$langue]) {
4155
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4156
-	}
4153
+    // si on a une surcharge on l'utilise
4154
+    if ($local_singulier_ou_pluriel[$langue]) {
4155
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4156
+    }
4157 4157
 
4158
-	// sinon traitement par defaut
4159
-	$vars[$var] = $nb;
4160
-	if ($nb >= 2) {
4161
-		return _T($chaine_plusieurs, $vars);
4162
-	} else {
4163
-		return _T($chaine_un, $vars);
4164
-	}
4158
+    // sinon traitement par defaut
4159
+    $vars[$var] = $nb;
4160
+    if ($nb >= 2) {
4161
+        return _T($chaine_plusieurs, $vars);
4162
+    } else {
4163
+        return _T($chaine_un, $vars);
4164
+    }
4165 4165
 }
4166 4166
 
4167 4167
 
@@ -4186,56 +4186,56 @@  discard block
 block discarded – undo
4186 4186
  * @return string
4187 4187
  */
4188 4188
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4189
-	if (in_array($fonction, array("del", "supprimer.gif"))) {
4190
-		$class .= ' danger';
4191
-	} elseif ($fonction == "rien.gif") {
4192
-		$fonction = "";
4193
-	} elseif ($fonction == "delsafe") {
4194
-		$fonction = "del";
4195
-	}
4196
-
4197
-	$fond_origine = $fond;
4198
-	// remappage des icone : article-24.png+new => article-new-24.png
4199
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4200
-		list($fond, $fonction) = $icone_renommer($fond, $fonction);
4201
-	}
4202
-
4203
-	// ajouter le type d'objet dans la class de l'icone
4204
-	$class .= " " . substr(basename($fond), 0, -4);
4205
-
4206
-	$alt = attribut_html($texte);
4207
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4208
-
4209
-	$ajax = "";
4210
-	if (strpos($class, "ajax") !== false) {
4211
-		$ajax = "ajax";
4212
-		if (strpos($class, "preload") !== false) {
4213
-			$ajax .= " preload";
4214
-		}
4215
-		if (strpos($class, "nocache") !== false) {
4216
-			$ajax .= " nocache";
4217
-		}
4218
-		$ajax = " class='$ajax'";
4219
-	}
4220
-
4221
-	$size = 24;
4222
-	if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4223
-	  or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4224
-		$size = $match[1];
4225
-	}
4226
-
4227
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4228
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4229
-
4230
-	if ($type == 'lien') {
4231
-		return "<span class='icone s$size $class'>"
4232
-		. "<a href='$lien'$title$ajax$javascript>"
4233
-		. $icone
4234
-		. "<b>$texte</b>"
4235
-		. "</a></span>\n";
4236
-	} else {
4237
-		return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4238
-	}
4189
+    if (in_array($fonction, array("del", "supprimer.gif"))) {
4190
+        $class .= ' danger';
4191
+    } elseif ($fonction == "rien.gif") {
4192
+        $fonction = "";
4193
+    } elseif ($fonction == "delsafe") {
4194
+        $fonction = "del";
4195
+    }
4196
+
4197
+    $fond_origine = $fond;
4198
+    // remappage des icone : article-24.png+new => article-new-24.png
4199
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4200
+        list($fond, $fonction) = $icone_renommer($fond, $fonction);
4201
+    }
4202
+
4203
+    // ajouter le type d'objet dans la class de l'icone
4204
+    $class .= " " . substr(basename($fond), 0, -4);
4205
+
4206
+    $alt = attribut_html($texte);
4207
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4208
+
4209
+    $ajax = "";
4210
+    if (strpos($class, "ajax") !== false) {
4211
+        $ajax = "ajax";
4212
+        if (strpos($class, "preload") !== false) {
4213
+            $ajax .= " preload";
4214
+        }
4215
+        if (strpos($class, "nocache") !== false) {
4216
+            $ajax .= " nocache";
4217
+        }
4218
+        $ajax = " class='$ajax'";
4219
+    }
4220
+
4221
+    $size = 24;
4222
+    if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4223
+      or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4224
+        $size = $match[1];
4225
+    }
4226
+
4227
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4228
+    $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4229
+
4230
+    if ($type == 'lien') {
4231
+        return "<span class='icone s$size $class'>"
4232
+        . "<a href='$lien'$title$ajax$javascript>"
4233
+        . $icone
4234
+        . "<b>$texte</b>"
4235
+        . "</a></span>\n";
4236
+    } else {
4237
+        return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4238
+    }
4239 4239
 }
4240 4240
 
4241 4241
 /**
@@ -4259,7 +4259,7 @@  discard block
 block discarded – undo
4259 4259
  *     Code HTML du lien
4260 4260
  **/
4261 4261
 function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4262
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4262
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4263 4263
 }
4264 4264
 
4265 4265
 /**
@@ -4294,7 +4294,7 @@  discard block
 block discarded – undo
4294 4294
  *     Code HTML du lien
4295 4295
  **/
4296 4296
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4297
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4297
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4298 4298
 }
4299 4299
 
4300 4300
 /**
@@ -4339,7 +4339,7 @@  discard block
 block discarded – undo
4339 4339
  *     Code HTML du lien
4340 4340
  **/
4341 4341
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4342
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4342
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4343 4343
 }
4344 4344
 
4345 4345
 /**
@@ -4370,7 +4370,7 @@  discard block
 block discarded – undo
4370 4370
  *     Code HTML du lien
4371 4371
  **/
4372 4372
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") {
4373
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4373
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4374 4374
 }
4375 4375
 
4376 4376
 /**
@@ -4400,7 +4400,7 @@  discard block
 block discarded – undo
4400 4400
  *     Code HTML du lien
4401 4401
  */
4402 4402
 function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") {
4403
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4403
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4404 4404
 }
4405 4405
 
4406 4406
 
@@ -4448,26 +4448,26 @@  discard block
 block discarded – undo
4448 4448
  * @return string Code CSS
4449 4449
  */
4450 4450
 function bando_images_background() {
4451
-	include_spip('inc/bandeau');
4452
-	// recuperer tous les boutons et leurs images
4453
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4451
+    include_spip('inc/bandeau');
4452
+    // recuperer tous les boutons et leurs images
4453
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4454 4454
 
4455
-	$res = "";
4456
-	foreach ($boutons as $page => $detail) {
4457
-		if ($detail->icone and strlen(trim($detail->icone))) {
4458
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4459
-		}
4460
-		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4461
-		if (is_array($detail->sousmenu)) {
4462
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4463
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4464
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4465
-				}
4466
-			}
4467
-		}
4468
-	}
4455
+    $res = "";
4456
+    foreach ($boutons as $page => $detail) {
4457
+        if ($detail->icone and strlen(trim($detail->icone))) {
4458
+            $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4459
+        }
4460
+        $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4461
+        if (is_array($detail->sousmenu)) {
4462
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4463
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4464
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4465
+                }
4466
+            }
4467
+        }
4468
+    }
4469 4469
 
4470
-	return $res;
4470
+    return $res;
4471 4471
 }
4472 4472
 
4473 4473
 /**
@@ -4486,19 +4486,19 @@  discard block
 block discarded – undo
4486 4486
  * @return string
4487 4487
  */
4488 4488
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4489
-	if ($confirm) {
4490
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4491
-		if ($callback) {
4492
-			$callback = "$confirm?($callback):false";
4493
-		} else {
4494
-			$callback = $confirm;
4495
-		}
4496
-	}
4497
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4498
-	$title = $title ? " title='$title'" : "";
4489
+    if ($confirm) {
4490
+        $confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4491
+        if ($callback) {
4492
+            $callback = "$confirm?($callback):false";
4493
+        } else {
4494
+            $callback = $confirm;
4495
+        }
4496
+    }
4497
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4498
+    $title = $title ? " title='$title'" : "";
4499 4499
 
4500
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4501
-	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4500
+    return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4501
+    . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4502 4502
 }
4503 4503
 
4504 4504
 /**
@@ -4519,78 +4519,78 @@  discard block
 block discarded – undo
4519 4519
  * @return string
4520 4520
  */
4521 4521
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") {
4522
-	static $trouver_table = null;
4523
-	static $objets;
4524
-
4525
-	// On verifie qu'on a tout ce qu'il faut
4526
-	$id_objet = intval($id_objet);
4527
-	if (!($id_objet and $type_objet and $info)) {
4528
-		return '';
4529
-	}
4530
-
4531
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4532
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4533
-		return '';
4534
-	}
4535
-
4536
-	// Si on demande l'url, on retourne direct la fonction
4537
-	if ($info == 'url') {
4538
-		return generer_url_entite($id_objet, $type_objet);
4539
-	}
4540
-
4541
-	// Sinon on va tout chercher dans la table et on garde en memoire
4542
-	$demande_titre = ($info == 'titre');
4543
-
4544
-	// 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
4545
-	if (!isset($objets[$type_objet][$id_objet])
4546
-		or
4547
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4548
-	) {
4549
-		if (!$trouver_table) {
4550
-			$trouver_table = charger_fonction('trouver_table', 'base');
4551
-		}
4552
-		$desc = $trouver_table(table_objet_sql($type_objet));
4553
-		if (!$desc) {
4554
-			return $objets[$type_objet] = false;
4555
-		}
4556
-
4557
-		// Si on demande le titre, on le gere en interne
4558
-		$champ_titre = "";
4559
-		if ($demande_titre) {
4560
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4561
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4562
-		}
4563
-		include_spip('base/abstract_sql');
4564
-		include_spip('base/connect_sql');
4565
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4566
-			'*' . $champ_titre,
4567
-			$desc['table_sql'],
4568
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4569
-		);
4570
-	}
4571
-
4572
-	// Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4573
-	if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4574
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4575
-	} // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4576
-	else {
4577
-		if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4578
-			$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4579
-		} // Sinon on prend directement le champ SQL tel quel
4580
-		else {
4581
-			$info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4582
-		}
4583
-	}
4584
-
4585
-	// On va ensuite appliquer les traitements automatiques si besoin
4586
-	if (!$etoile) {
4587
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4588
-		// mais ce fonctionnement est a ameliorer !
4589
-		$info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4590
-			array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4591
-	}
4592
-
4593
-	return $info_generee;
4522
+    static $trouver_table = null;
4523
+    static $objets;
4524
+
4525
+    // On verifie qu'on a tout ce qu'il faut
4526
+    $id_objet = intval($id_objet);
4527
+    if (!($id_objet and $type_objet and $info)) {
4528
+        return '';
4529
+    }
4530
+
4531
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4532
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4533
+        return '';
4534
+    }
4535
+
4536
+    // Si on demande l'url, on retourne direct la fonction
4537
+    if ($info == 'url') {
4538
+        return generer_url_entite($id_objet, $type_objet);
4539
+    }
4540
+
4541
+    // Sinon on va tout chercher dans la table et on garde en memoire
4542
+    $demande_titre = ($info == 'titre');
4543
+
4544
+    // 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
4545
+    if (!isset($objets[$type_objet][$id_objet])
4546
+        or
4547
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4548
+    ) {
4549
+        if (!$trouver_table) {
4550
+            $trouver_table = charger_fonction('trouver_table', 'base');
4551
+        }
4552
+        $desc = $trouver_table(table_objet_sql($type_objet));
4553
+        if (!$desc) {
4554
+            return $objets[$type_objet] = false;
4555
+        }
4556
+
4557
+        // Si on demande le titre, on le gere en interne
4558
+        $champ_titre = "";
4559
+        if ($demande_titre) {
4560
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4561
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4562
+        }
4563
+        include_spip('base/abstract_sql');
4564
+        include_spip('base/connect_sql');
4565
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4566
+            '*' . $champ_titre,
4567
+            $desc['table_sql'],
4568
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4569
+        );
4570
+    }
4571
+
4572
+    // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4573
+    if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4574
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4575
+    } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4576
+    else {
4577
+        if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4578
+            $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4579
+        } // Sinon on prend directement le champ SQL tel quel
4580
+        else {
4581
+            $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4582
+        }
4583
+    }
4584
+
4585
+    // On va ensuite appliquer les traitements automatiques si besoin
4586
+    if (!$etoile) {
4587
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4588
+        // mais ce fonctionnement est a ameliorer !
4589
+        $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4590
+            array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4591
+    }
4592
+
4593
+    return $info_generee;
4594 4594
 }
4595 4595
 
4596 4596
 /**
@@ -4604,44 +4604,44 @@  discard block
 block discarded – undo
4604 4604
  * @return string
4605 4605
  */
4606 4606
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') {
4607
-	if (!$champ) {
4608
-		return $texte;
4609
-	}
4607
+    if (!$champ) {
4608
+        return $texte;
4609
+    }
4610 4610
 	
4611
-	// On charge toujours les filtres de texte car la majorité des traitements les utilisent
4612
-	// et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4613
-	include_spip('inc/texte');
4611
+    // On charge toujours les filtres de texte car la majorité des traitements les utilisent
4612
+    // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4613
+    include_spip('inc/texte');
4614 4614
 	
4615
-	$champ = strtoupper($champ);
4616
-	$traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4617
-	if (!$traitements or !is_array($traitements)) {
4618
-		return $texte;
4619
-	}
4615
+    $champ = strtoupper($champ);
4616
+    $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4617
+    if (!$traitements or !is_array($traitements)) {
4618
+        return $texte;
4619
+    }
4620 4620
 
4621
-	$traitement = '';
4622
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4623
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4624
-		$table_objet = table_objet($table_objet);
4625
-		if (isset($traitements[$table_objet])) {
4626
-			$traitement = $traitements[$table_objet];
4627
-		}
4628
-	}
4629
-	if (!$traitement and isset($traitements[0])) {
4630
-		$traitement = $traitements[0];
4631
-	}
4632
-	// (sinon prendre le premier de la liste par defaut ?)
4621
+    $traitement = '';
4622
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4623
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4624
+        $table_objet = table_objet($table_objet);
4625
+        if (isset($traitements[$table_objet])) {
4626
+            $traitement = $traitements[$table_objet];
4627
+        }
4628
+    }
4629
+    if (!$traitement and isset($traitements[0])) {
4630
+        $traitement = $traitements[0];
4631
+    }
4632
+    // (sinon prendre le premier de la liste par defaut ?)
4633 4633
 
4634
-	if (!$traitement) {
4635
-		return $texte;
4636
-	}
4634
+    if (!$traitement) {
4635
+        return $texte;
4636
+    }
4637 4637
 
4638
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4638
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4639 4639
 
4640
-	// Fournir $connect et $Pile[0] au traitement si besoin
4641
-	$Pile = array(0 => $env);
4642
-	eval("\$texte = $traitement;");
4640
+    // Fournir $connect et $Pile[0] au traitement si besoin
4641
+    $Pile = array(0 => $env);
4642
+    eval("\$texte = $traitement;");
4643 4643
 
4644
-	return $texte;
4644
+    return $texte;
4645 4645
 }
4646 4646
 
4647 4647
 
@@ -4655,21 +4655,21 @@  discard block
 block discarded – undo
4655 4655
  * @return string
4656 4656
  */
4657 4657
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4658
-	include_spip('inc/liens');
4659
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4660
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4661
-	// le raccourcis n'est plus valide
4662
-	$titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4663
-	// on essaye avec generer_info_entite ?
4664
-	if (!strlen($titre) and !$connect) {
4665
-		$titre = generer_info_entite($id_objet, $objet, 'titre');
4666
-	}
4667
-	if (!strlen($titre)) {
4668
-		$titre = _T('info_sans_titre');
4669
-	}
4670
-	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4658
+    include_spip('inc/liens');
4659
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4660
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4661
+    // le raccourcis n'est plus valide
4662
+    $titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4663
+    // on essaye avec generer_info_entite ?
4664
+    if (!strlen($titre) and !$connect) {
4665
+        $titre = generer_info_entite($id_objet, $objet, 'titre');
4666
+    }
4667
+    if (!strlen($titre)) {
4668
+        $titre = _T('info_sans_titre');
4669
+    }
4670
+    $url = generer_url_entite($id_objet, $objet, '', '', $connect);
4671 4671
 
4672
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4672
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4673 4673
 }
4674 4674
 
4675 4675
 
@@ -4686,15 +4686,15 @@  discard block
 block discarded – undo
4686 4686
  * @return string
4687 4687
  */
4688 4688
 function wrap($texte, $wrap) {
4689
-	$balises = extraire_balises($wrap);
4690
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4691
-		$texte = $wrap . $texte;
4692
-		$regs = array_reverse($regs[1]);
4693
-		$wrap = "</" . implode("></", $regs) . ">";
4694
-		$texte = $texte . $wrap;
4695
-	}
4689
+    $balises = extraire_balises($wrap);
4690
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4691
+        $texte = $wrap . $texte;
4692
+        $regs = array_reverse($regs[1]);
4693
+        $wrap = "</" . implode("></", $regs) . ">";
4694
+        $texte = $texte . $wrap;
4695
+    }
4696 4696
 
4697
-	return $texte;
4697
+    return $texte;
4698 4698
 }
4699 4699
 
4700 4700
 
@@ -4714,43 +4714,43 @@  discard block
 block discarded – undo
4714 4714
  * @return array|mixed|string
4715 4715
  */
4716 4716
 function filtre_print_dist($u, $join = "<br />", $indent = 0) {
4717
-	if (is_string($u)) {
4718
-		$u = typo($u);
4717
+    if (is_string($u)) {
4718
+        $u = typo($u);
4719 4719
 
4720
-		return $u;
4721
-	}
4720
+        return $u;
4721
+    }
4722 4722
 
4723
-	// caster $u en array si besoin
4724
-	if (is_object($u)) {
4725
-		$u = (array)$u;
4726
-	}
4723
+    // caster $u en array si besoin
4724
+    if (is_object($u)) {
4725
+        $u = (array)$u;
4726
+    }
4727 4727
 
4728
-	if (is_array($u)) {
4729
-		$out = "";
4730
-		// toutes les cles sont numeriques ?
4731
-		// et aucun enfant n'est un tableau
4732
-		// liste simple separee par des virgules
4733
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4734
-		$array_values = array_map('is_array', $u);
4735
-		$object_values = array_map('is_object', $u);
4736
-		if (array_sum($numeric_keys) == count($numeric_keys)
4737
-			and !array_sum($array_values)
4738
-			and !array_sum($object_values)
4739
-		) {
4740
-			return join(", ", array_map('filtre_print_dist', $u));
4741
-		}
4728
+    if (is_array($u)) {
4729
+        $out = "";
4730
+        // toutes les cles sont numeriques ?
4731
+        // et aucun enfant n'est un tableau
4732
+        // liste simple separee par des virgules
4733
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4734
+        $array_values = array_map('is_array', $u);
4735
+        $object_values = array_map('is_object', $u);
4736
+        if (array_sum($numeric_keys) == count($numeric_keys)
4737
+            and !array_sum($array_values)
4738
+            and !array_sum($object_values)
4739
+        ) {
4740
+            return join(", ", array_map('filtre_print_dist', $u));
4741
+        }
4742 4742
 
4743
-		// sinon on passe a la ligne et on indente
4744
-		$i_str = str_pad("", $indent, " ");
4745
-		foreach ($u as $k => $v) {
4746
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4747
-		}
4743
+        // sinon on passe a la ligne et on indente
4744
+        $i_str = str_pad("", $indent, " ");
4745
+        foreach ($u as $k => $v) {
4746
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4747
+        }
4748 4748
 
4749
-		return $out;
4750
-	}
4749
+        return $out;
4750
+    }
4751 4751
 
4752
-	// on sait pas quoi faire...
4753
-	return $u;
4752
+    // on sait pas quoi faire...
4753
+    return $u;
4754 4754
 }
4755 4755
 
4756 4756
 
@@ -4763,10 +4763,10 @@  discard block
 block discarded – undo
4763 4763
  * @return string|array
4764 4764
  */
4765 4765
 function objet_info($objet, $info) {
4766
-	$table = table_objet_sql($objet);
4767
-	$infos = lister_tables_objets_sql($table);
4766
+    $table = table_objet_sql($objet);
4767
+    $infos = lister_tables_objets_sql($table);
4768 4768
 
4769
-	return (isset($infos[$info]) ? $infos[$info] : '');
4769
+    return (isset($infos[$info]) ? $infos[$info] : '');
4770 4770
 }
4771 4771
 
4772 4772
 /**
@@ -4781,11 +4781,11 @@  discard block
 block discarded – undo
4781 4781
  *     Texte traduit du comptage, tel que '3 articles'
4782 4782
  */
4783 4783
 function objet_afficher_nb($nb, $objet) {
4784
-	if (!$nb) {
4785
-		return _T(objet_info($objet, 'info_aucun_objet'));
4786
-	} else {
4787
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4788
-	}
4784
+    if (!$nb) {
4785
+        return _T(objet_info($objet, 'info_aucun_objet'));
4786
+    } else {
4787
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4788
+    }
4789 4789
 }
4790 4790
 
4791 4791
 /**
@@ -4797,11 +4797,11 @@  discard block
 block discarded – undo
4797 4797
  * @return string
4798 4798
  */
4799 4799
 function objet_icone($objet, $taille = 24, $class='') {
4800
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4801
-	$icone = chemin_image($icone);
4802
-	$balise_img = charger_filtre('balise_img');
4800
+    $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4801
+    $icone = chemin_image($icone);
4802
+    $balise_img = charger_filtre('balise_img');
4803 4803
 
4804
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4804
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4805 4805
 }
4806 4806
 
4807 4807
 /**
@@ -4822,12 +4822,12 @@  discard block
 block discarded – undo
4822 4822
  * @return string
4823 4823
  */
4824 4824
 function objet_T($objet, $chaine, $args = array(), $options = array()){
4825
-	$chaine = explode(':',$chaine);
4826
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4827
-		return $t;
4828
-	}
4829
-	$chaine = implode(':',$chaine);
4830
-	return _T($chaine, $args, $options);
4825
+    $chaine = explode(':',$chaine);
4826
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4827
+        return $t;
4828
+    }
4829
+    $chaine = implode(':',$chaine);
4830
+    return _T($chaine, $args, $options);
4831 4831
 }
4832 4832
 
4833 4833
 /**
@@ -4841,17 +4841,17 @@  discard block
 block discarded – undo
4841 4841
  * @return string      Code HTML
4842 4842
  */
4843 4843
 function insert_head_css_conditionnel($flux) {
4844
-	if (strpos($flux, '<!-- insert_head_css -->') === false
4845
-		and $p = strpos($flux, '<!-- insert_head -->')
4846
-	) {
4847
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4848
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4849
-			$p = $p1;
4850
-		}
4851
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4852
-	}
4844
+    if (strpos($flux, '<!-- insert_head_css -->') === false
4845
+        and $p = strpos($flux, '<!-- insert_head -->')
4846
+    ) {
4847
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4848
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4849
+            $p = $p1;
4850
+        }
4851
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4852
+    }
4853 4853
 
4854
-	return $flux;
4854
+    return $flux;
4855 4855
 }
4856 4856
 
4857 4857
 /**
@@ -4872,69 +4872,69 @@  discard block
 block discarded – undo
4872 4872
  * @return string
4873 4873
  */
4874 4874
 function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') {
4875
-	if (isset($contexte['format'])) {
4876
-		$extension = $contexte['format'];
4877
-		unset($contexte['format']);
4878
-	} else {
4879
-		$extension = "html";
4880
-		if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4881
-			$extension = $m[1];
4882
-		}
4883
-	}
4884
-	// recuperer le contenu produit par le squelette
4885
-	$options['raw'] = true;
4886
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4887
-
4888
-	// calculer le nom de la css
4889
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4890
-	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4891
-	$contexte_implicite = calculer_contexte_implicite();
4892
-
4893
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4894
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4895
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4896
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4897
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4898
-	}
4899
-	else {
4900
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4901
-		ksort($contexte);
4902
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4903
-	}
4904
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4905
-
4906
-	// mettre a jour le fichier si il n'existe pas
4907
-	// ou trop ancien
4908
-	// le dernier fichier produit est toujours suffixe par .last
4909
-	// et recopie sur le fichier cible uniquement si il change
4910
-	if (!file_exists($filename)
4911
-		or !file_exists($filename . ".last")
4912
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4913
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4914
-	) {
4915
-		$contenu = $cache['texte'];
4916
-		// passer les urls en absolu si c'est une css
4917
-		if ($extension == "css") {
4918
-			$contenu = urls_absolues_css($contenu,
4919
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4920
-		}
4921
-
4922
-		$comment = '';
4923
-		// ne pas insérer de commentaire si c'est du json
4924
-		if ($extension != "json") {
4925
-			$comment = "/* #PRODUIRE{fond=$fond";
4926
-			foreach ($contexte as $k => $v) {
4927
-				$comment .= ",$k=$v";
4928
-			}
4929
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4930
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4931
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4932
-		}
4933
-		// et ecrire le fichier si il change
4934
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4935
-	}
4936
-
4937
-	return timestamp($filename);
4875
+    if (isset($contexte['format'])) {
4876
+        $extension = $contexte['format'];
4877
+        unset($contexte['format']);
4878
+    } else {
4879
+        $extension = "html";
4880
+        if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4881
+            $extension = $m[1];
4882
+        }
4883
+    }
4884
+    // recuperer le contenu produit par le squelette
4885
+    $options['raw'] = true;
4886
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4887
+
4888
+    // calculer le nom de la css
4889
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4890
+    $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4891
+    $contexte_implicite = calculer_contexte_implicite();
4892
+
4893
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4894
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4895
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4896
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4897
+        $hash = md5($contexte_implicite['host'] . '::'. $cache);
4898
+    }
4899
+    else {
4900
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4901
+        ksort($contexte);
4902
+        $hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4903
+    }
4904
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4905
+
4906
+    // mettre a jour le fichier si il n'existe pas
4907
+    // ou trop ancien
4908
+    // le dernier fichier produit est toujours suffixe par .last
4909
+    // et recopie sur le fichier cible uniquement si il change
4910
+    if (!file_exists($filename)
4911
+        or !file_exists($filename . ".last")
4912
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4913
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4914
+    ) {
4915
+        $contenu = $cache['texte'];
4916
+        // passer les urls en absolu si c'est une css
4917
+        if ($extension == "css") {
4918
+            $contenu = urls_absolues_css($contenu,
4919
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4920
+        }
4921
+
4922
+        $comment = '';
4923
+        // ne pas insérer de commentaire si c'est du json
4924
+        if ($extension != "json") {
4925
+            $comment = "/* #PRODUIRE{fond=$fond";
4926
+            foreach ($contexte as $k => $v) {
4927
+                $comment .= ",$k=$v";
4928
+            }
4929
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4930
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4931
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
4932
+        }
4933
+        // et ecrire le fichier si il change
4934
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4935
+    }
4936
+
4937
+    return timestamp($filename);
4938 4938
 }
4939 4939
 
4940 4940
 /**
@@ -4947,14 +4947,14 @@  discard block
 block discarded – undo
4947 4947
  *    $fichier auquel on a ajouté le timestamp
4948 4948
  */
4949 4949
 function timestamp($fichier) {
4950
-	if (!$fichier
4951
-		or !file_exists($fichier)
4952
-		or !$m = filemtime($fichier)
4953
-	) {
4954
-		return $fichier;
4955
-	}
4950
+    if (!$fichier
4951
+        or !file_exists($fichier)
4952
+        or !$m = filemtime($fichier)
4953
+    ) {
4954
+        return $fichier;
4955
+    }
4956 4956
 
4957
-	return "$fichier?$m";
4957
+    return "$fichier?$m";
4958 4958
 }
4959 4959
 
4960 4960
 /**
@@ -4964,11 +4964,11 @@  discard block
 block discarded – undo
4964 4964
  * @return string
4965 4965
  */
4966 4966
 function supprimer_timestamp($url) {
4967
-	if (strpos($url, "?") === false) {
4968
-		return $url;
4969
-	}
4967
+    if (strpos($url, "?") === false) {
4968
+        return $url;
4969
+    }
4970 4970
 
4971
-	return preg_replace(",\?[[:digit:]]+$,", "", $url);
4971
+    return preg_replace(",\?[[:digit:]]+$,", "", $url);
4972 4972
 }
4973 4973
 
4974 4974
 /**
@@ -4983,9 +4983,9 @@  discard block
 block discarded – undo
4983 4983
  * @return string
4984 4984
  */
4985 4985
 function filtre_nettoyer_titre_email_dist($titre) {
4986
-	include_spip('inc/envoyer_mail');
4986
+    include_spip('inc/envoyer_mail');
4987 4987
 
4988
-	return nettoyer_titre_email($titre);
4988
+    return nettoyer_titre_email($titre);
4989 4989
 }
4990 4990
 
4991 4991
 /**
@@ -5007,19 +5007,19 @@  discard block
 block discarded – undo
5007 5007
  * @return string
5008 5008
  */
5009 5009
 function filtre_chercher_rubrique_dist(
5010
-	$titre,
5011
-	$id_objet,
5012
-	$id_parent,
5013
-	$objet,
5014
-	$id_secteur,
5015
-	$restreint,
5016
-	$actionable = false,
5017
-	$retour_sans_cadre = false
5010
+    $titre,
5011
+    $id_objet,
5012
+    $id_parent,
5013
+    $objet,
5014
+    $id_secteur,
5015
+    $restreint,
5016
+    $actionable = false,
5017
+    $retour_sans_cadre = false
5018 5018
 ) {
5019
-	include_spip('inc/filtres_ecrire');
5019
+    include_spip('inc/filtres_ecrire');
5020 5020
 
5021
-	return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
5022
-		$retour_sans_cadre);
5021
+    return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
5022
+        $retour_sans_cadre);
5023 5023
 }
5024 5024
 
5025 5025
 /**
@@ -5048,56 +5048,56 @@  discard block
 block discarded – undo
5048 5048
  *     Chaîne vide si l'accès est autorisé
5049 5049
  */
5050 5050
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
5051
-	if ($ok) {
5052
-		return '';
5053
-	}
5054
-
5055
-	// Vider tous les tampons
5056
-	$level = @ob_get_level();
5057
-	while ($level--) {
5058
-		@ob_end_clean();
5059
-	}
5060
-
5061
-	include_spip('inc/headers');
5062
-
5063
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5064
-	if ($url) {
5065
-		redirige_par_entete($url, '', $statut);
5066
-	}
5067
-
5068
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
5069
-	if (!is_numeric($statut) and is_null($message)) {
5070
-		$message = $statut;
5071
-		$statut = 0;
5072
-	}
5073
-	if (!$message) {
5074
-		$message = '';
5075
-	}
5076
-	$statut = intval($statut);
5077
-
5078
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5079
-	if (test_espace_prive()) {
5080
-		if (!$statut or !in_array($statut, array(404, 403))) {
5081
-			$statut = 403;
5082
-		}
5083
-		http_status(403);
5084
-		$echec = charger_fonction('403', 'exec');
5085
-		$echec($message);
5086
-	} else {
5087
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5088
-		if (!$statut) {
5089
-			$statut = 404;
5090
-		}
5091
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
5092
-		http_status($statut);
5093
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5094
-		if ($statut >= 400) {
5095
-			echo recuperer_fond("$statut", array('erreur' => $message));
5096
-		}
5097
-	}
5098
-
5099
-
5100
-	exit;
5051
+    if ($ok) {
5052
+        return '';
5053
+    }
5054
+
5055
+    // Vider tous les tampons
5056
+    $level = @ob_get_level();
5057
+    while ($level--) {
5058
+        @ob_end_clean();
5059
+    }
5060
+
5061
+    include_spip('inc/headers');
5062
+
5063
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5064
+    if ($url) {
5065
+        redirige_par_entete($url, '', $statut);
5066
+    }
5067
+
5068
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
5069
+    if (!is_numeric($statut) and is_null($message)) {
5070
+        $message = $statut;
5071
+        $statut = 0;
5072
+    }
5073
+    if (!$message) {
5074
+        $message = '';
5075
+    }
5076
+    $statut = intval($statut);
5077
+
5078
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5079
+    if (test_espace_prive()) {
5080
+        if (!$statut or !in_array($statut, array(404, 403))) {
5081
+            $statut = 403;
5082
+        }
5083
+        http_status(403);
5084
+        $echec = charger_fonction('403', 'exec');
5085
+        $echec($message);
5086
+    } else {
5087
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5088
+        if (!$statut) {
5089
+            $statut = 404;
5090
+        }
5091
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
5092
+        http_status($statut);
5093
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5094
+        if ($statut >= 400) {
5095
+            echo recuperer_fond("$statut", array('erreur' => $message));
5096
+        }
5097
+    }
5098
+
5099
+
5100
+    exit;
5101 5101
 }
5102 5102
 
5103 5103
 /**
@@ -5108,11 +5108,11 @@  discard block
 block discarded – undo
5108 5108
  * @return string
5109 5109
  */
5110 5110
 function filtre_compacte_dist($source, $format = null) {
5111
-	if (function_exists('compacte')) {
5112
-		return compacte($source, $format);
5113
-	}
5111
+    if (function_exists('compacte')) {
5112
+        return compacte($source, $format);
5113
+    }
5114 5114
 
5115
-	return $source;
5115
+    return $source;
5116 5116
 }
5117 5117
 
5118 5118
 
@@ -5124,31 +5124,31 @@  discard block
 block discarded – undo
5124 5124
  * @return string
5125 5125
  */
5126 5126
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
5127
-	$l = strlen($passe);
5128
-
5129
-	if ($l<=8 or !$afficher_partiellement){
5130
-		if (!$l) {
5131
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5132
-		}
5133
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
5134
-	}
5135
-
5136
-	if (is_null($portion_pourcent)) {
5137
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5138
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5139
-		}
5140
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5141
-	}
5142
-	if ($portion_pourcent >= 100) {
5143
-		return $passe;
5144
-	}
5145
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
5146
-	$e = max($e, 0);
5147
-	$mid = str_pad('',$l-2*$e,'*');
5148
-	if ($e>0 and strlen($mid)>8){
5149
-		$mid = '***...***';
5150
-	}
5151
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
5127
+    $l = strlen($passe);
5128
+
5129
+    if ($l<=8 or !$afficher_partiellement){
5130
+        if (!$l) {
5131
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5132
+        }
5133
+        return str_pad('',$afficher_partiellement ? $l : 16,'*');
5134
+    }
5135
+
5136
+    if (is_null($portion_pourcent)) {
5137
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5138
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5139
+        }
5140
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5141
+    }
5142
+    if ($portion_pourcent >= 100) {
5143
+        return $passe;
5144
+    }
5145
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
5146
+    $e = max($e, 0);
5147
+    $mid = str_pad('',$l-2*$e,'*');
5148
+    if ($e>0 and strlen($mid)>8){
5149
+        $mid = '***...***';
5150
+    }
5151
+    return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
5152 5152
 }
5153 5153
 
5154 5154
 
@@ -5169,62 +5169,62 @@  discard block
 block discarded – undo
5169 5169
  */
5170 5170
 function identifiant_slug($texte, $type = '', $options = array()) {
5171 5171
 
5172
-	$original = $texte;
5173
-	$separateur = (isset($options['separateur'])?$options['separateur']:'_');
5174
-	$longueur_maxi = (isset($options['longueur_maxi'])?$options['longueur_maxi']:60);
5175
-	$longueur_mini = (isset($options['longueur_mini'])?$options['longueur_mini']:0);
5176
-
5177
-	if (!function_exists('translitteration')) {
5178
-		include_spip('inc/charsets');
5179
-	}
5180
-
5181
-	// pas de balise html
5182
-	if (strpos($texte, '<') !== false) {
5183
-		$texte = strip_tags($texte);
5184
-	}
5185
-	if (strpos($texte, '&') !== false) {
5186
-		$texte = unicode2charset($texte);
5187
-	}
5188
-	// On enlève les espaces indésirables
5189
-	$texte = trim($texte);
5190
-
5191
-	// On enlève les accents et cie
5192
-	$texte = translitteration($texte);
5193
-
5194
-	// On remplace tout ce qui n'est pas un mot par un séparateur
5195
-	$texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5196
-
5197
-	// nettoyer les doubles occurences du separateur si besoin
5198
-	while (strpos($texte, "$separateur$separateur") !== false) {
5199
-		$texte = str_replace("$separateur$separateur", $separateur, $texte);
5200
-	}
5201
-
5202
-	// pas de separateur au debut ni a la fin
5203
-	$texte = trim($texte, $separateur);
5204
-
5205
-	// en minuscules
5206
-	$texte = strtolower($texte);
5207
-
5208
-	switch ($type) {
5209
-		case 'class':
5210
-		case 'id':
5211
-		case 'anchor':
5212
-			if (preg_match(',^\d,', $texte)) {
5213
-				$texte = substr($type, 0, 1).$texte;
5214
-			}
5215
-	}
5216
-
5217
-	if (strlen($texte)>$longueur_maxi) {
5218
-		$texte = substr($texte, 0, $longueur_maxi);
5219
-	}
5220
-
5221
-	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5222
-		if (preg_match(',^\d,', $texte)) {
5223
-			$texte = ($type ? substr($type,0,1) : "s") . $texte;
5224
-		}
5225
-		$texte .= $separateur . md5($original);
5226
-		$texte = substr($texte, 0, $longueur_mini);
5227
-	}
5228
-
5229
-	return $texte;
5172
+    $original = $texte;
5173
+    $separateur = (isset($options['separateur'])?$options['separateur']:'_');
5174
+    $longueur_maxi = (isset($options['longueur_maxi'])?$options['longueur_maxi']:60);
5175
+    $longueur_mini = (isset($options['longueur_mini'])?$options['longueur_mini']:0);
5176
+
5177
+    if (!function_exists('translitteration')) {
5178
+        include_spip('inc/charsets');
5179
+    }
5180
+
5181
+    // pas de balise html
5182
+    if (strpos($texte, '<') !== false) {
5183
+        $texte = strip_tags($texte);
5184
+    }
5185
+    if (strpos($texte, '&') !== false) {
5186
+        $texte = unicode2charset($texte);
5187
+    }
5188
+    // On enlève les espaces indésirables
5189
+    $texte = trim($texte);
5190
+
5191
+    // On enlève les accents et cie
5192
+    $texte = translitteration($texte);
5193
+
5194
+    // On remplace tout ce qui n'est pas un mot par un séparateur
5195
+    $texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5196
+
5197
+    // nettoyer les doubles occurences du separateur si besoin
5198
+    while (strpos($texte, "$separateur$separateur") !== false) {
5199
+        $texte = str_replace("$separateur$separateur", $separateur, $texte);
5200
+    }
5201
+
5202
+    // pas de separateur au debut ni a la fin
5203
+    $texte = trim($texte, $separateur);
5204
+
5205
+    // en minuscules
5206
+    $texte = strtolower($texte);
5207
+
5208
+    switch ($type) {
5209
+        case 'class':
5210
+        case 'id':
5211
+        case 'anchor':
5212
+            if (preg_match(',^\d,', $texte)) {
5213
+                $texte = substr($type, 0, 1).$texte;
5214
+            }
5215
+    }
5216
+
5217
+    if (strlen($texte)>$longueur_maxi) {
5218
+        $texte = substr($texte, 0, $longueur_maxi);
5219
+    }
5220
+
5221
+    if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5222
+        if (preg_match(',^\d,', $texte)) {
5223
+            $texte = ($type ? substr($type,0,1) : "s") . $texte;
5224
+        }
5225
+        $texte .= $separateur . md5($original);
5226
+        $texte = substr($texte, 0, $longueur_mini);
5227
+    }
5228
+
5229
+    return $texte;
5230 5230
 }
Please login to merge, or discard this patch.
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	}
95 95
 
96 96
 	include_fichiers_fonctions();
97
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
97
+	foreach (array('filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc) as $f) {
98 98
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99 99
 		// fonction ou name\space\fonction
100 100
 		if (is_callable($f)) {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	// affichage "GIT [master: abcdef]"
188 188
 	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189 189
 	if ($desc['branch']) {
190
-		$commit = $desc['branch'] . ': ' . $commit;
190
+		$commit = $desc['branch'].': '.$commit;
191 191
 	}
192 192
 	return "{$desc['vcs']} [$commit]";
193 193
 }
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	}
207 207
 
208 208
 	// version installee par GIT
209
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
209
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
210 210
 		$currentHead = trim(substr($c, 4));
211
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
211
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
212 212
 			return [
213 213
 				'vcs' => 'GIT',
214 214
 				'branch' => basename($currentHead),
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 		$dir = '.';
236 236
 	}
237 237
 	// version installee par SVN
238
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
-		$db = new SQLite3($dir . '/.svn/wc.db');
238
+	if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) {
239
+		$db = new SQLite3($dir.'/.svn/wc.db');
240 240
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241 241
 		if ($result) {
242 242
 			$row = $result->fetchArray();
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 
276 276
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
277 277
 // et laisser passer les fonctions personnelles baptisees image_...
278
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
279
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
280
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
281
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
282
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
278
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
279
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
280
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
281
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
282
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
283 283
 
284 284
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
285 285
 $GLOBALS['spip_matrice']['couleur_foncer'] = 'inc/filtres_images_mini.php';
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
  */
437 437
 function filtre_debug($val, $key = null) {
438 438
 	$debug = (
439
-		is_null($key) ? '' : (var_export($key, true) . " = ")
440
-		) . var_export($val, true);
439
+		is_null($key) ? '' : (var_export($key, true)." = ")
440
+		).var_export($val, true);
441 441
 
442 442
 	include_spip('inc/autoriser');
443 443
 	if (autoriser('webmestre')) {
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
537 537
 							$srcover = $match[1];
538 538
 							array_shift($args);
539
-							array_unshift($args, "<img src='" . $match[1] . "' />");
539
+							array_unshift($args, "<img src='".$match[1]."' />");
540 540
 							$srcover_filter = call_user_func_array($filtre, $args);
541 541
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
542 542
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
 				$hauteur_img[$src] = $srcHeight = $srcsize[1];
608 608
 			}
609 609
 		}
610
-		elseif(strpos($src, "<svg") !== false) {
610
+		elseif (strpos($src, "<svg") !== false) {
611 611
 			include_spip('inc/svg');
612
-			if ($attrs = svg_lire_attributs($src)){
612
+			if ($attrs = svg_lire_attributs($src)) {
613 613
 				list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
614
-				if (!$srcWidth){
614
+				if (!$srcWidth) {
615 615
 					$largeur_img[$src] = $srcWidth = $width;
616 616
 				}
617
-				if (!$srcHeight){
617
+				if (!$srcHeight) {
618 618
 					$hauteur_img[$src] = $srcHeight = $height;
619 619
 				}
620 620
 			}
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 	// " -> &quot; et tout ce genre de choses
899 899
 	$u = $GLOBALS['meta']['pcre_u'];
900 900
 	$texte = str_replace("&nbsp;", " ", $texte);
901
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
901
+	$texte = preg_replace('/\s{2,}/S'.$u, " ", $texte);
902 902
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
903 903
 	$texte = entites_html($texte, false, false);
904 904
 	// mais bien echapper les double quotes !
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
  **/
959 959
 function supprimer_numero($texte) {
960 960
 	return preg_replace(
961
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
961
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
962 962
 		"", $texte);
963 963
 }
964 964
 
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
  **/
984 984
 function recuperer_numero($texte) {
985 985
 	if (preg_match(
986
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
986
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
987 987
 		$texte, $regs)) {
988 988
 		return strval($regs[1]);
989 989
 	} else {
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
  **/
1069 1069
 function textebrut($texte) {
1070 1070
 	$u = $GLOBALS['meta']['pcre_u'];
1071
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1072
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1071
+	$texte = preg_replace('/\s+/S'.$u, " ", $texte);
1072
+	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
1073 1073
 	$texte = preg_replace("/^\n+/", "", $texte);
1074 1074
 	$texte = preg_replace("/\n+$/", "", $texte);
1075 1075
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1098 1098
 		$texte, $liens, PREG_PATTERN_ORDER)) {
1099 1099
 		foreach ($liens[0] as $a) {
1100
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1100
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1101 1101
 			$ablank = inserer_attribut($a, 'rel', $rel);
1102 1102
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1103 1103
 			$texte = str_replace($a, $ablank, $texte);
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 		foreach ($regs[0] as $a) {
1123 1123
 			$rel = extraire_attribut($a, "rel");
1124 1124
 			if (strpos($rel, "nofollow") === false) {
1125
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1125
+				$rel = "nofollow".($rel ? " $rel" : "");
1126 1126
 				$anofollow = inserer_attribut($a, "rel", $rel);
1127 1127
 				$texte = str_replace($a, $anofollow, $texte);
1128 1128
 			}
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 	$u = $GLOBALS['meta']['pcre_u'];
1152 1152
 	$texte = preg_replace("@</p>@iS", "\n", $texte);
1153 1153
 	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1154
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1154
+	$texte = preg_replace("@^\s*<br />@S".$u, "", $texte);
1155 1155
 
1156 1156
 	return $texte;
1157 1157
 }
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 		return $texte;
1182 1182
 	}
1183 1183
 	include_spip('inc/texte');
1184
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1184
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1185 1185
 		'div' : 'span';
1186 1186
 
1187 1187
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
 function attribut_html($texte, $textebrut = true) {
1291 1291
 	$u = $GLOBALS['meta']['pcre_u'];
1292 1292
 	if ($textebrut) {
1293
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1293
+		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte));
1294 1294
 	}
1295 1295
 	$texte = texte_backend($texte);
1296 1296
 	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 	# un message pour abs_url
1320 1320
 	$GLOBALS['mode_abs_url'] = 'url';
1321 1321
 	$url = trim($url);
1322
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1322
+	$r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS';
1323 1323
 
1324 1324
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1325 1325
 }
@@ -1521,14 +1521,14 @@  discard block
 block discarded – undo
1521 1521
 	if (strpos($texte, "<") !== false) {
1522 1522
 		include_spip('inc/lien');
1523 1523
 		if (defined('_PREG_MODELE')) {
1524
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1524
+			$preg_modeles = "@"._PREG_MODELE."@imsS";
1525 1525
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1526 1526
 		}
1527 1527
 	}
1528 1528
 
1529 1529
 	$debut = '';
1530 1530
 	$suite = $texte;
1531
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1531
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1532 1532
 		$debut .= substr($suite, 0, $t - 1);
1533 1533
 		$suite = substr($suite, $t);
1534 1534
 		$car = substr($suite, 0, 1);
@@ -1545,11 +1545,11 @@  discard block
 block discarded – undo
1545 1545
 			$suite = substr($suite, strlen($regs[0]));
1546 1546
 		}
1547 1547
 	}
1548
-	$texte = $debut . $suite;
1548
+	$texte = $debut.$suite;
1549 1549
 
1550 1550
 	$texte = echappe_retour($texte);
1551 1551
 
1552
-	return $texte . $fin;
1552
+	return $texte.$fin;
1553 1553
 }
1554 1554
 
1555 1555
 
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
 		}
1611 1611
 
1612 1612
 		foreach ($regs as $reg) {
1613
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1613
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1614 1614
 			$desc = $traduire($cle, $lang, true);
1615 1615
 			$l = $desc->langue;
1616 1616
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1723,9 +1723,9 @@  discard block
 block discarded – undo
1723 1723
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1724 1724
 					include_spip('inc/texte');
1725 1725
 					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1726
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1726
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1727 1727
 					if ($mode === 'div') {
1728
-						$trad = rtrim($trad) . "\n\n";
1728
+						$trad = rtrim($trad)."\n\n";
1729 1729
 					}
1730 1730
 					$trad = code_echappement($trad, 'multi', false, $mode);
1731 1731
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
@@ -1919,7 +1919,7 @@  discard block
 block discarded – undo
1919 1919
 	if (is_array($balise)) {
1920 1920
 		array_walk(
1921 1921
 			$balise,
1922
-			function(&$a, $key, $t){
1922
+			function(&$a, $key, $t) {
1923 1923
 				$a = extraire_attribut($a, $t);
1924 1924
 			},
1925 1925
 			$attribut
@@ -2006,14 +2006,14 @@  discard block
 block discarded – undo
2006 2006
 
2007 2007
 	if ($old !== null) {
2008 2008
 		// Remplacer l'ancien attribut du meme nom
2009
-		$balise = $r[1] . $insert . $r[5];
2009
+		$balise = $r[1].$insert.$r[5];
2010 2010
 	} else {
2011 2011
 		// preferer une balise " />" (comme <img />)
2012 2012
 		if (preg_match(',/>,', $balise)) {
2013
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2013
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
2014 2014
 		} // sinon une balise <a ...> ... </a>
2015 2015
 		else {
2016
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2016
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
2017 2017
 		}
2018 2018
 	}
2019 2019
 
@@ -2046,7 +2046,7 @@  discard block
 block discarded – undo
2046 2046
  * @param string $operation
2047 2047
  * @return string
2048 2048
  */
2049
-function modifier_class($balise, $class, $operation='ajouter') {
2049
+function modifier_class($balise, $class, $operation = 'ajouter') {
2050 2050
 	if (is_string($class)) {
2051 2051
 		$class = explode(' ', trim($class));
2052 2052
 	}
@@ -2071,7 +2071,7 @@  discard block
 block discarded – undo
2071 2071
 				}
2072 2072
 				if (in_array($operation, ['ajouter', 'commuter'])
2073 2073
 					and !$is_class_presente) {
2074
-					$class_new = rtrim($class_new) . " " . $c;
2074
+					$class_new = rtrim($class_new)." ".$c;
2075 2075
 				}
2076 2076
 				elseif (in_array($operation, ['supprimer', 'commuter'])
2077 2077
 					and $is_class_presente) {
@@ -2099,7 +2099,7 @@  discard block
 block discarded – undo
2099 2099
  * @param string|array $class
2100 2100
  * @return string
2101 2101
  */
2102
-function ajouter_class($balise, $class){
2102
+function ajouter_class($balise, $class) {
2103 2103
 	return modifier_class($balise, $class, 'ajouter');
2104 2104
 }
2105 2105
 
@@ -2109,7 +2109,7 @@  discard block
 block discarded – undo
2109 2109
  * @param string|array $class
2110 2110
  * @return string
2111 2111
  */
2112
-function supprimer_class($balise, $class){
2112
+function supprimer_class($balise, $class) {
2113 2113
 	return modifier_class($balise, $class, 'supprimer');
2114 2114
 }
2115 2115
 
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
  * @param string|array $class
2121 2121
  * @return string
2122 2122
  */
2123
-function commuter_class($balise, $class){
2123
+function commuter_class($balise, $class) {
2124 2124
 	return modifier_class($balise, $class, 'commuter');
2125 2125
 }
2126 2126
 
@@ -2140,8 +2140,8 @@  discard block
 block discarded – undo
2140 2140
 //
2141 2141
 // Quelques fonctions de calcul arithmetique
2142 2142
 //
2143
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
2144
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
2143
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
2144
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
2145 2145
 
2146 2146
 /**
2147 2147
  * Additionne 2 nombres
@@ -2161,7 +2161,7 @@  discard block
 block discarded – undo
2161 2161
 function plus($a, $b) {
2162 2162
 	return $a + $b;
2163 2163
 }
2164
-function strplus($a, $b) {return strize('plus', $a, $b);}
2164
+function strplus($a, $b) {return strize('plus', $a, $b); }
2165 2165
 /**
2166 2166
  * Soustrait 2 nombres
2167 2167
  *
@@ -2180,7 +2180,7 @@  discard block
 block discarded – undo
2180 2180
 function moins($a, $b) {
2181 2181
 	return $a - $b;
2182 2182
 }
2183
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2183
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2184 2184
 
2185 2185
 /**
2186 2186
  * Multiplie 2 nombres
@@ -2201,7 +2201,7 @@  discard block
 block discarded – undo
2201 2201
 function mult($a, $b) {
2202 2202
 	return $a * $b;
2203 2203
 }
2204
-function strmult($a, $b) {return strize('mult', $a, $b);}
2204
+function strmult($a, $b) {return strize('mult', $a, $b); }
2205 2205
 
2206 2206
 /**
2207 2207
  * Divise 2 nombres
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
 function div($a, $b) {
2223 2223
 	return $b ? $a / $b : 0;
2224 2224
 }
2225
-function strdiv($a, $b) {return strize('div', $a, $b);}
2225
+function strdiv($a, $b) {return strize('div', $a, $b); }
2226 2226
 
2227 2227
 /**
2228 2228
  * Retourne le modulo 2 nombres
@@ -2263,13 +2263,13 @@  discard block
 block discarded – undo
2263 2263
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2264 2264
 		define('_TAGS_NOM_AUTEUR', '');
2265 2265
 	}
2266
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2266
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2267 2267
 	foreach ($tags_acceptes as $tag) {
2268 2268
 		if (strlen($tag)) {
2269
-			$remp1[] = '<' . trim($tag) . '>';
2270
-			$remp1[] = '</' . trim($tag) . '>';
2271
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2272
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2269
+			$remp1[] = '<'.trim($tag).'>';
2270
+			$remp1[] = '</'.trim($tag).'>';
2271
+			$remp2[] = '\x60'.trim($tag).'\x61';
2272
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2273 2273
 		}
2274 2274
 	}
2275 2275
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2319,7 +2319,7 @@  discard block
 block discarded – undo
2319 2319
 			$s[] = preg_replace(',>[^<]+</a>,S',
2320 2320
 				'>'
2321 2321
 				. http_img_pack('attachment-16.png', $t,
2322
-					'title="' . attribut_html($t) . '"')
2322
+					'title="'.attribut_html($t).'"')
2323 2323
 				. '</a>', $tag);
2324 2324
 		}
2325 2325
 	}
@@ -2380,10 +2380,10 @@  discard block
 block discarded – undo
2380 2380
 	$fichier = basename($url);
2381 2381
 
2382 2382
 	return '<a rel="enclosure"'
2383
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2384
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2385
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2386
-	. '>' . $fichier . '</a>';
2383
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2384
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2385
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2386
+	. '>'.$fichier.'</a>';
2387 2387
 }
2388 2388
 
2389 2389
 /**
@@ -2411,9 +2411,9 @@  discard block
 block discarded – undo
2411 2411
 			} # vieux data
2412 2412
 			$fichier = basename($url);
2413 2413
 			$enclosures[] = '<enclosure'
2414
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2415
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2416
-				. ($length ? ' length="' . $length . '"' : '')
2414
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2415
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2416
+				. ($length ? ' length="'.$length.'"' : '')
2417 2417
 				. ' />';
2418 2418
 		}
2419 2419
 	}
@@ -2439,7 +2439,7 @@  discard block
 block discarded – undo
2439 2439
 		if (extraire_attribut($e, rel) == 'tag') {
2440 2440
 			$subjects .= '<dc:subject>'
2441 2441
 				. texte_backend(textebrut($e))
2442
-				. '</dc:subject>' . "\n";
2442
+				. '</dc:subject>'."\n";
2443 2443
 		}
2444 2444
 	}
2445 2445
 
@@ -2475,7 +2475,7 @@  discard block
 block discarded – undo
2475 2475
 	if (is_array($texte)) {
2476 2476
 		array_walk(
2477 2477
 			$texte,
2478
-			function(&$a, $key, $t){
2478
+			function(&$a, $key, $t) {
2479 2479
 				$a = extraire_balise($a, $t);
2480 2480
 			},
2481 2481
 			$tag
@@ -2519,7 +2519,7 @@  discard block
 block discarded – undo
2519 2519
 	if (is_array($texte)) {
2520 2520
 		array_walk(
2521 2521
 			$texte,
2522
-			function(&$a, $key, $t){
2522
+			function(&$a, $key, $t) {
2523 2523
 				$a = extraire_balises($a, $t);
2524 2524
 			},
2525 2525
 			$tag
@@ -2645,7 +2645,7 @@  discard block
 block discarded – undo
2645 2645
 		if ($fond != '404') {
2646 2646
 			$contexte = array_shift($p);
2647 2647
 			$contexte['page'] = $fond;
2648
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2648
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2649 2649
 		}
2650 2650
 	}
2651 2651
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2700,9 +2700,9 @@  discard block
 block discarded – undo
2700 2700
 			. '"'
2701 2701
 			. (is_null($val)
2702 2702
 				? ''
2703
-				: ' value="' . entites_html($val) . '"'
2703
+				: ' value="'.entites_html($val).'"'
2704 2704
 			)
2705
-			. ' type="hidden"' . "\n/>";
2705
+			. ' type="hidden"'."\n/>";
2706 2706
 	}
2707 2707
 
2708 2708
 	return join("", $hidden);
@@ -2839,7 +2839,7 @@  discard block
 block discarded – undo
2839 2839
 	return preg_replace_callback(
2840 2840
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2841 2841
 		function($x) use ($path) {
2842
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2842
+			return "url('".suivre_lien($path, $x[1])."')";
2843 2843
 		},
2844 2844
 		$contenu
2845 2845
 	);
@@ -2901,14 +2901,14 @@  discard block
 block discarded – undo
2901 2901
 	) {
2902 2902
 		$distant = true;
2903 2903
 		$cssf = parse_url($css);
2904
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2904
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2905 2905
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2906 2906
 	} else {
2907 2907
 		$distant = false;
2908 2908
 		$cssf = $css;
2909 2909
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2910 2910
 		//propose (rien a faire dans ce cas)
2911
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2911
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2912 2912
 		if (@file_exists($f)) {
2913 2913
 			return $f;
2914 2914
 		}
@@ -2918,7 +2918,7 @@  discard block
 block discarded – undo
2918 2918
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2919 2919
 	$f = $dir_var
2920 2920
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2921
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2921
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2922 2922
 
2923 2923
 	// la css peut etre distante (url absolue !)
2924 2924
 	if ($distant) {
@@ -2963,8 +2963,8 @@  discard block
 block discarded – undo
2963 2963
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2964 2964
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2965 2965
 			$css_direction = substr($css_direction, strlen($dir_var));
2966
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2967
-			$css_direction = "/@@@@@@/" . $css_direction;
2966
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
2967
+			$css_direction = "/@@@@@@/".$css_direction;
2968 2968
 		}
2969 2969
 		$src[] = $regs[0][$k];
2970 2970
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -3013,7 +3013,7 @@  discard block
 block discarded – undo
3013 3013
 
3014 3014
 	$f = basename($css, '.css');
3015 3015
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3016
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3016
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3017 3017
 		. '.css';
3018 3018
 
3019 3019
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3022,7 +3022,7 @@  discard block
 block discarded – undo
3022 3022
 
3023 3023
 	if ($url_absolue_css == $css) {
3024 3024
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3025
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3025
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3026 3026
 		) {
3027 3027
 			include_spip('inc/distant');
3028 3028
 			if (!$contenu = recuperer_page($css)) {
@@ -3132,7 +3132,7 @@  discard block
 block discarded – undo
3132 3132
 	$expression = str_replace("\/", "/", $expression);
3133 3133
 	$expression = str_replace("/", "\/", $expression);
3134 3134
 
3135
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3135
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3136 3136
 		if (isset($r[$capte])) {
3137 3137
 			return $r[$capte];
3138 3138
 		} else {
@@ -3170,7 +3170,7 @@  discard block
 block discarded – undo
3170 3170
 	$expression = str_replace("\/", "/", $expression);
3171 3171
 	$expression = str_replace("/", "\/", $expression);
3172 3172
 
3173
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3173
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3174 3174
 }
3175 3175
 
3176 3176
 
@@ -3189,7 +3189,7 @@  discard block
 block discarded – undo
3189 3189
 function traiter_doublons_documents(&$doublons, $letexte) {
3190 3190
 
3191 3191
 	// Verifier dans le texte & les notes (pas beau, helas)
3192
-	$t = $letexte . $GLOBALS['les_notes'];
3192
+	$t = $letexte.$GLOBALS['les_notes'];
3193 3193
 
3194 3194
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3195 3195
 		and preg_match_all(
@@ -3199,7 +3199,7 @@  discard block
 block discarded – undo
3199 3199
 		if (!isset($doublons['documents'])) {
3200 3200
 			$doublons['documents'] = "";
3201 3201
 		}
3202
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3202
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3203 3203
 	}
3204 3204
 
3205 3205
 	return $letexte;
@@ -3256,7 +3256,7 @@  discard block
 block discarded – undo
3256 3256
 	if ($env) {
3257 3257
 		foreach ($env as $i => $j) {
3258 3258
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3259
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3259
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3260 3260
 			}
3261 3261
 		}
3262 3262
 	}
@@ -3295,7 +3295,7 @@  discard block
 block discarded – undo
3295 3295
 	if ($env) {
3296 3296
 		foreach ($env as $i => $j) {
3297 3297
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3298
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3298
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3299 3299
 			}
3300 3300
 		}
3301 3301
 	}
@@ -3379,19 +3379,19 @@  discard block
 block discarded – undo
3379 3379
 
3380 3380
 	$img_file = $img;
3381 3381
 	if ($p = strpos($img_file, '?')) {
3382
-		$img_file = substr($img_file,0, $p);
3382
+		$img_file = substr($img_file, 0, $p);
3383 3383
 	}
3384 3384
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3385 3385
 		$img_file = chemin_image($img);
3386 3386
 	}
3387 3387
 	else {
3388
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3388
+		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3389 3389
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3390 3390
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3391 3391
 			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3392
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3392
+			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg"
3393 3393
 			  and file_exists($variante_svg_generique)) {
3394
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3394
+				if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) {
3395 3395
 					$img_file = $variante_svg_size;
3396 3396
 				}
3397 3397
 				else {
@@ -3416,7 +3416,7 @@  discard block
 block discarded – undo
3416 3416
 				return "";
3417 3417
 			}
3418 3418
 		}
3419
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3419
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3420 3420
 	}
3421 3421
 
3422 3422
 	if (file_exists($img_file)) {
@@ -3425,15 +3425,15 @@  discard block
 block discarded – undo
3425 3425
 	if ($alt === false) {
3426 3426
 		$alt = '';
3427 3427
 	}
3428
-	elseif($alt or $alt==='') {
3428
+	elseif ($alt or $alt === '') {
3429 3429
 		$alt = " alt='".attribut_html($alt)."'";
3430 3430
 	}
3431 3431
 	else {
3432 3432
 		$alt = " alt='".attribut_html($title)."'";
3433 3433
 	}
3434 3434
 	return "<img src='$img_file'$alt"
3435
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3436
-	. " " . ltrim($atts)
3435
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3436
+	. " ".ltrim($atts)
3437 3437
 	. " />";
3438 3438
 }
3439 3439
 
@@ -3445,12 +3445,12 @@  discard block
 block discarded – undo
3445 3445
  * @param string $size
3446 3446
  * @return string
3447 3447
  */
3448
-function http_style_background($img, $att = '', $size=null) {
3449
-	if ($size and is_numeric($size)){
3450
-		$size = trim($size) . "px";
3448
+function http_style_background($img, $att = '', $size = null) {
3449
+	if ($size and is_numeric($size)) {
3450
+		$size = trim($size)."px";
3451 3451
 	}
3452
-	return " style='background" .
3453
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3452
+	return " style='background".
3453
+		($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";"
3454 3454
 		. ($size ? "background-size:{$size};" : '')
3455 3455
 		. "'";
3456 3456
 }
@@ -3476,7 +3476,7 @@  discard block
 block discarded – undo
3476 3476
 			$args[] = $maybe_size;
3477 3477
 			$maybe_size = null;
3478 3478
 		}
3479
-		while (count($args)<2) {
3479
+		while (count($args) < 2) {
3480 3480
 			$args[] = null; // default alt or class
3481 3481
 		}
3482 3482
 		$args[] = $maybe_size;
@@ -3486,7 +3486,7 @@  discard block
 block discarded – undo
3486 3486
 
3487 3487
 function helper_filtre_balise_img_svg_size($img, $size) {
3488 3488
 	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3489
-	if (strpos($size, '@') === 0 and substr($size,-1) === 'x') {
3489
+	if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3490 3490
 		$coef = floatval(substr($size, 1, -1));
3491 3491
 		list($h, $w) = taille_image($img);
3492 3492
 		$height = intval(round($h / $coef));
@@ -3541,7 +3541,7 @@  discard block
 block discarded – undo
3541 3541
  * @return string
3542 3542
  *     Code HTML de la balise IMG
3543 3543
  */
3544
-function filtre_balise_img_dist($img, $alt = '', $class = null, $size=null) {
3544
+function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) {
3545 3545
 
3546 3546
 	list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3547 3547
 
@@ -3560,7 +3560,7 @@  discard block
 block discarded – undo
3560 3560
 		}
3561 3561
 	}
3562 3562
 	else {
3563
-		$img = http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3563
+		$img = http_img_pack($img, $alt, $class ? " class='".attribut_html($class)."'" : '', '',
3564 3564
 				array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3565 3565
 		if (is_null($alt)) {
3566 3566
 			$img = vider_attribut($img, 'alt');
@@ -3606,16 +3606,16 @@  discard block
 block discarded – undo
3606 3606
  * @return string
3607 3607
  *     Code HTML de la balise SVG
3608 3608
  */
3609
-function filtre_balise_svg_dist($img, $alt = '', $class = null, $size=null) {
3609
+function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) {
3610 3610
 
3611 3611
 	$img = trim($img);
3612 3612
 	$img_file = $img;
3613
-	if (strpos($img, '<svg') === false){
3614
-		if ($p = strpos($img_file, '?')){
3613
+	if (strpos($img, '<svg') === false) {
3614
+		if ($p = strpos($img_file, '?')) {
3615 3615
 			$img_file = substr($img_file, 0, $p);
3616 3616
 		}
3617 3617
 
3618
-		if (!$img_file or !$svg = file_get_contents($img_file)){
3618
+		if (!$img_file or !$svg = file_get_contents($img_file)) {
3619 3619
 			return '';
3620 3620
 		}
3621 3621
 	}
@@ -3630,7 +3630,7 @@  discard block
 block discarded – undo
3630 3630
 	$balise_svg_source = $balise_svg;
3631 3631
 
3632 3632
 	// entete XML à supprimer
3633
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3633
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3634 3634
 
3635 3635
 	// IE est toujours mon ami
3636 3636
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
@@ -3646,11 +3646,11 @@  discard block
 block discarded – undo
3646 3646
 	}
3647 3647
 
3648 3648
 	// regler le alt
3649
-	if ($alt){
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 {
@@ -3694,7 +3694,7 @@  discard block
 block discarded – undo
3694 3694
 	$texte = '';
3695 3695
 	if (is_array($tableau)) {
3696 3696
 		foreach ($tableau as $k => $v) {
3697
-			$res = recuperer_fond('modeles/' . $modele,
3697
+			$res = recuperer_fond('modeles/'.$modele,
3698 3698
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3699 3699
 			);
3700 3700
 			$texte .= $res;
@@ -3871,7 +3871,7 @@  discard block
 block discarded – undo
3871 3871
 	}
3872 3872
 
3873 3873
 	$c = serialize($c);
3874
-	$cle = calculer_cle_action($form . $c);
3874
+	$cle = calculer_cle_action($form.$c);
3875 3875
 	$c = "$cle:$c";
3876 3876
 
3877 3877
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3933,15 +3933,15 @@  discard block
 block discarded – undo
3933 3933
 	}
3934 3934
 	// toujours encoder l'url source dans le bloc ajax
3935 3935
 	$r = self();
3936
-	$r = ' data-origin="' . $r . '"';
3936
+	$r = ' data-origin="'.$r.'"';
3937 3937
 	$class = 'ajaxbloc';
3938 3938
 	if ($ajaxid and is_string($ajaxid)) {
3939 3939
 		// ajaxid est normalement conforme a un nom de classe css
3940 3940
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3941
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3941
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3942 3942
 	}
3943 3943
 
3944
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3944
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3945 3945
 }
3946 3946
 
3947 3947
 /**
@@ -3980,11 +3980,11 @@  discard block
 block discarded – undo
3980 3980
 	// extraire la signature en debut de contexte
3981 3981
 	// et la verifier avant de deserializer
3982 3982
 	// format : signature:donneesserializees
3983
-	if ($p = strpos($c,":")){
3984
-		$cle = substr($c,0,$p);
3985
-		$c = substr($c,$p+1);
3983
+	if ($p = strpos($c, ":")) {
3984
+		$cle = substr($c, 0, $p);
3985
+		$c = substr($c, $p + 1);
3986 3986
 
3987
-		if ($cle == calculer_cle_action($form . $c)) {
3987
+		if ($cle == calculer_cle_action($form.$c)) {
3988 3988
 			$env = @unserialize($c);
3989 3989
 			return $env;
3990 3990
 		}
@@ -4090,24 +4090,24 @@  discard block
 block discarded – undo
4090 4090
 		$att = "";
4091 4091
 		// si $on passe la balise et optionnelement une ou ++classe
4092 4092
 		// a.active span.selected.active etc....
4093
-		if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
4093
+		if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4094 4094
 			$on = explode(".", $on);
4095 4095
 			// on verifie que c'est exactement une des 3 balises a, span ou strong
4096
-			if (in_array(reset($on), array('a', 'span', 'strong'))){
4096
+			if (in_array(reset($on), array('a', 'span', 'strong'))) {
4097 4097
 				$bal = array_shift($on);
4098 4098
 				$class = implode(" ", $on);
4099
-				if ($bal=="a"){
4099
+				if ($bal == "a") {
4100 4100
 					$att = 'href="#" ';
4101 4101
 				}
4102 4102
 			}
4103 4103
 		}
4104
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4104
+		$att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"';
4105 4105
 	} else {
4106 4106
 		$bal = 'a';
4107 4107
 		$att = "href='$url'"
4108
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4109
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4110
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4108
+			. ($title ? " title='".attribut_html($title)."'" : '')
4109
+			. ($class ? " class='".attribut_html($class)."'" : '')
4110
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
4111 4111
 			. $evt;
4112 4112
 	}
4113 4113
 	if ($libelle === null) {
@@ -4201,7 +4201,7 @@  discard block
 block discarded – undo
4201 4201
 	}
4202 4202
 
4203 4203
 	// ajouter le type d'objet dans la class de l'icone
4204
-	$class .= " " . substr(basename($fond), 0, -4);
4204
+	$class .= " ".substr(basename($fond), 0, -4);
4205 4205
 
4206 4206
 	$alt = attribut_html($texte);
4207 4207
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -4225,7 +4225,7 @@  discard block
 block discarded – undo
4225 4225
 	}
4226 4226
 
4227 4227
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4228
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4228
+	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "")."\">$icone</span>";
4229 4229
 
4230 4230
 	if ($type == 'lien') {
4231 4231
 		return "<span class='icone s$size $class'>"
@@ -4455,13 +4455,13 @@  discard block
 block discarded – undo
4455 4455
 	$res = "";
4456 4456
 	foreach ($boutons as $page => $detail) {
4457 4457
 		if ($detail->icone and strlen(trim($detail->icone))) {
4458
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4458
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4459 4459
 		}
4460 4460
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4461 4461
 		if (is_array($detail->sousmenu)) {
4462 4462
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4463 4463
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4464
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4464
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4465 4465
 				}
4466 4466
 			}
4467 4467
 		}
@@ -4487,17 +4487,17 @@  discard block
 block discarded – undo
4487 4487
  */
4488 4488
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4489 4489
 	if ($confirm) {
4490
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4490
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4491 4491
 		if ($callback) {
4492 4492
 			$callback = "$confirm?($callback):false";
4493 4493
 		} else {
4494 4494
 			$callback = $confirm;
4495 4495
 		}
4496 4496
 	}
4497
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4497
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4498 4498
 	$title = $title ? " title='$title'" : "";
4499 4499
 
4500
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4500
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4501 4501
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4502 4502
 }
4503 4503
 
@@ -4558,14 +4558,14 @@  discard block
 block discarded – undo
4558 4558
 		$champ_titre = "";
4559 4559
 		if ($demande_titre) {
4560 4560
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4561
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4561
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4562 4562
 		}
4563 4563
 		include_spip('base/abstract_sql');
4564 4564
 		include_spip('base/connect_sql');
4565 4565
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4566
-			'*' . $champ_titre,
4566
+			'*'.$champ_titre,
4567 4567
 			$desc['table_sql'],
4568
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4568
+			id_table_objet($type_objet).' = '.intval($id_objet)
4569 4569
 		);
4570 4570
 	}
4571 4571
 
@@ -4635,7 +4635,7 @@  discard block
 block discarded – undo
4635 4635
 		return $texte;
4636 4636
 	}
4637 4637
 
4638
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4638
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4639 4639
 
4640 4640
 	// Fournir $connect et $Pile[0] au traitement si besoin
4641 4641
 	$Pile = array(0 => $env);
@@ -4669,7 +4669,7 @@  discard block
 block discarded – undo
4669 4669
 	}
4670 4670
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4671 4671
 
4672
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4672
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4673 4673
 }
4674 4674
 
4675 4675
 
@@ -4688,10 +4688,10 @@  discard block
 block discarded – undo
4688 4688
 function wrap($texte, $wrap) {
4689 4689
 	$balises = extraire_balises($wrap);
4690 4690
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4691
-		$texte = $wrap . $texte;
4691
+		$texte = $wrap.$texte;
4692 4692
 		$regs = array_reverse($regs[1]);
4693
-		$wrap = "</" . implode("></", $regs) . ">";
4694
-		$texte = $texte . $wrap;
4693
+		$wrap = "</".implode("></", $regs).">";
4694
+		$texte = $texte.$wrap;
4695 4695
 	}
4696 4696
 
4697 4697
 	return $texte;
@@ -4722,7 +4722,7 @@  discard block
 block discarded – undo
4722 4722
 
4723 4723
 	// caster $u en array si besoin
4724 4724
 	if (is_object($u)) {
4725
-		$u = (array)$u;
4725
+		$u = (array) $u;
4726 4726
 	}
4727 4727
 
4728 4728
 	if (is_array($u)) {
@@ -4743,7 +4743,7 @@  discard block
 block discarded – undo
4743 4743
 		// sinon on passe a la ligne et on indente
4744 4744
 		$i_str = str_pad("", $indent, " ");
4745 4745
 		foreach ($u as $k => $v) {
4746
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4746
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4747 4747
 		}
4748 4748
 
4749 4749
 		return $out;
@@ -4796,8 +4796,8 @@  discard block
 block discarded – undo
4796 4796
  * @param string $class
4797 4797
  * @return string
4798 4798
  */
4799
-function objet_icone($objet, $taille = 24, $class='') {
4800
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4799
+function objet_icone($objet, $taille = 24, $class = '') {
4800
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4801 4801
 	$icone = chemin_image($icone);
4802 4802
 	$balise_img = charger_filtre('balise_img');
4803 4803
 
@@ -4821,12 +4821,12 @@  discard block
 block discarded – undo
4821 4821
  * @param array $options
4822 4822
  * @return string
4823 4823
  */
4824
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4825
-	$chaine = explode(':',$chaine);
4826
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4824
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4825
+	$chaine = explode(':', $chaine);
4826
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4827 4827
 		return $t;
4828 4828
 	}
4829
-	$chaine = implode(':',$chaine);
4829
+	$chaine = implode(':', $chaine);
4830 4830
 	return _T($chaine, $args, $options);
4831 4831
 }
4832 4832
 
@@ -4886,7 +4886,7 @@  discard block
 block discarded – undo
4886 4886
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4887 4887
 
4888 4888
 	// calculer le nom de la css
4889
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4889
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4890 4890
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4891 4891
 	$contexte_implicite = calculer_contexte_implicite();
4892 4892
 
@@ -4894,22 +4894,22 @@  discard block
 block discarded – undo
4894 4894
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4895 4895
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4896 4896
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4897
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4897
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
4898 4898
 	}
4899 4899
 	else {
4900 4900
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4901 4901
 		ksort($contexte);
4902
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4902
+		$hash = md5($fond.json_encode($contexte_implicite).json_encode($contexte).$connect);
4903 4903
 	}
4904
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4904
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4905 4905
 
4906 4906
 	// mettre a jour le fichier si il n'existe pas
4907 4907
 	// ou trop ancien
4908 4908
 	// le dernier fichier produit est toujours suffixe par .last
4909 4909
 	// et recopie sur le fichier cible uniquement si il change
4910 4910
 	if (!file_exists($filename)
4911
-		or !file_exists($filename . ".last")
4912
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4911
+		or !file_exists($filename.".last")
4912
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4913 4913
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4914 4914
 	) {
4915 4915
 		$contenu = $cache['texte'];
@@ -4928,10 +4928,10 @@  discard block
 block discarded – undo
4928 4928
 			}
4929 4929
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4930 4930
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4931
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4931
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4932 4932
 		}
4933 4933
 		// et ecrire le fichier si il change
4934
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4934
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
4935 4935
 	}
4936 4936
 
4937 4937
 	return timestamp($filename);
@@ -5126,11 +5126,11 @@  discard block
 block discarded – undo
5126 5126
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
5127 5127
 	$l = strlen($passe);
5128 5128
 
5129
-	if ($l<=8 or !$afficher_partiellement){
5129
+	if ($l <= 8 or !$afficher_partiellement) {
5130 5130
 		if (!$l) {
5131 5131
 			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5132 5132
 		}
5133
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
5133
+		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5134 5134
 	}
5135 5135
 
5136 5136
 	if (is_null($portion_pourcent)) {
@@ -5144,11 +5144,11 @@  discard block
 block discarded – undo
5144 5144
 	}
5145 5145
 	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
5146 5146
 	$e = max($e, 0);
5147
-	$mid = str_pad('',$l-2*$e,'*');
5148
-	if ($e>0 and strlen($mid)>8){
5147
+	$mid = str_pad('', $l - 2 * $e, '*');
5148
+	if ($e > 0 and strlen($mid) > 8) {
5149 5149
 		$mid = '***...***';
5150 5150
 	}
5151
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
5151
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5152 5152
 }
5153 5153
 
5154 5154
 
@@ -5170,9 +5170,9 @@  discard block
 block discarded – undo
5170 5170
 function identifiant_slug($texte, $type = '', $options = array()) {
5171 5171
 
5172 5172
 	$original = $texte;
5173
-	$separateur = (isset($options['separateur'])?$options['separateur']:'_');
5174
-	$longueur_maxi = (isset($options['longueur_maxi'])?$options['longueur_maxi']:60);
5175
-	$longueur_mini = (isset($options['longueur_mini'])?$options['longueur_mini']:0);
5173
+	$separateur = (isset($options['separateur']) ? $options['separateur'] : '_');
5174
+	$longueur_maxi = (isset($options['longueur_maxi']) ? $options['longueur_maxi'] : 60);
5175
+	$longueur_mini = (isset($options['longueur_mini']) ? $options['longueur_mini'] : 0);
5176 5176
 
5177 5177
 	if (!function_exists('translitteration')) {
5178 5178
 		include_spip('inc/charsets');
@@ -5214,15 +5214,15 @@  discard block
 block discarded – undo
5214 5214
 			}
5215 5215
 	}
5216 5216
 
5217
-	if (strlen($texte)>$longueur_maxi) {
5217
+	if (strlen($texte) > $longueur_maxi) {
5218 5218
 		$texte = substr($texte, 0, $longueur_maxi);
5219 5219
 	}
5220 5220
 
5221 5221
 	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5222 5222
 		if (preg_match(',^\d,', $texte)) {
5223
-			$texte = ($type ? substr($type,0,1) : "s") . $texte;
5223
+			$texte = ($type ? substr($type, 0, 1) : "s").$texte;
5224 5224
 		}
5225
-		$texte .= $separateur . md5($original);
5225
+		$texte .= $separateur.md5($original);
5226 5226
 		$texte = substr($texte, 0, $longueur_mini);
5227 5227
 	}
5228 5228
 
Please login to merge, or discard this patch.