Completed
Push — master ( e33c69...9a669a )
by cam
04:55
created
ecrire/inc/filtres.php 2 patches
Indentation   +2216 added lines, -2216 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/charsets');
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
  * @return string Fonction PHP correspondante du filtre
43 43
  */
44 44
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
45
-	include_fichiers_fonctions(); // inclure les fichiers fonctions
46
-	return chercher_filtre($fonc, $default);
45
+    include_fichiers_fonctions(); // inclure les fichiers fonctions
46
+    return chercher_filtre($fonc, $default);
47 47
 }
48 48
 
49 49
 /**
@@ -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
 /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
  *     Chaîne vide sinon.
151 151
  **/
152 152
 function appliquer_filtre($arg, $filtre) {
153
-	$args = func_get_args();
154
-	return appliquer_filtre_sinon($arg, $filtre, $args, '');
153
+    $args = func_get_args();
154
+    return appliquer_filtre_sinon($arg, $filtre, $args, '');
155 155
 }
156 156
 
157 157
 /**
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
  *     Texte d'origine sinon
177 177
  **/
178 178
 function appliquer_si_filtre($arg, $filtre) {
179
-	$args = func_get_args();
180
-	return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
179
+    $args = func_get_args();
180
+    return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
181 181
 }
182 182
 
183 183
 /**
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
  *     Version de SPIP
194 194
  **/
195 195
 function spip_version() {
196
-	$version = $GLOBALS['spip_version_affichee'];
197
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
198
-		$version .= " $vcs_version";
199
-	}
196
+    $version = $GLOBALS['spip_version_affichee'];
197
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
198
+        $version .= " $vcs_version";
199
+    }
200 200
 
201
-	return $version;
201
+    return $version;
202 202
 }
203 203
 
204 204
 /**
@@ -211,19 +211,19 @@  discard block
 block discarded – undo
211 211
  *    - string|null si $raw = false
212 212
  */
213 213
 function version_vcs_courante($dir, $raw = false) {
214
-	$desc = decrire_version_git($dir);
215
-	if ($desc === null) {
216
-		$desc = decrire_version_svn($dir);
217
-	}
218
-	if ($desc === null or $raw) {
219
-		return $desc;
220
-	}
221
-	// affichage "GIT [master: abcdef]"
222
-	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
223
-	if ($desc['branch']) {
224
-		$commit = $desc['branch'] . ': ' . $commit;
225
-	}
226
-	return "{$desc['vcs']} [$commit]";
214
+    $desc = decrire_version_git($dir);
215
+    if ($desc === null) {
216
+        $desc = decrire_version_svn($dir);
217
+    }
218
+    if ($desc === null or $raw) {
219
+        return $desc;
220
+    }
221
+    // affichage "GIT [master: abcdef]"
222
+    $commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
223
+    if ($desc['branch']) {
224
+        $commit = $desc['branch'] . ': ' . $commit;
225
+    }
226
+    return "{$desc['vcs']} [$commit]";
227 227
 }
228 228
 
229 229
 /**
@@ -235,24 +235,24 @@  discard block
 block discarded – undo
235 235
  *      array ['branch' => xx, 'commit' => yy] sinon.
236 236
  **/
237 237
 function decrire_version_git($dir) {
238
-	if (!$dir) {
239
-		$dir = '.';
240
-	}
238
+    if (!$dir) {
239
+        $dir = '.';
240
+    }
241 241
 
242
-	// version installee par GIT
243
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
244
-		$currentHead = trim(substr($c, 4));
245
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
246
-			return [
247
-				'vcs' => 'GIT',
248
-				'branch' => basename($currentHead),
249
-				'commit' => trim($hash),
250
-				'commit_short' => substr(trim($hash), 0, 8),
251
-			];
252
-		}
253
-	}
242
+    // version installee par GIT
243
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
244
+        $currentHead = trim(substr($c, 4));
245
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
246
+            return [
247
+                'vcs' => 'GIT',
248
+                'branch' => basename($currentHead),
249
+                'commit' => trim($hash),
250
+                'commit_short' => substr(trim($hash), 0, 8),
251
+            ];
252
+        }
253
+    }
254 254
 
255
-	return null;
255
+    return null;
256 256
 }
257 257
 
258 258
 
@@ -265,25 +265,25 @@  discard block
 block discarded – undo
265 265
  *      array ['commit' => yy, 'date' => xx, 'author' => xx] sinon.
266 266
  **/
267 267
 function decrire_version_svn($dir) {
268
-	if (!$dir) {
269
-		$dir = '.';
270
-	}
271
-	// version installee par SVN
272
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
273
-		$db = new SQLite3($dir . '/.svn/wc.db');
274
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
275
-		if ($result) {
276
-			$row = $result->fetchArray();
277
-			if ($row['changed_revision'] != "") {
278
-				return [
279
-					'vcs' => 'SVN',
280
-					'branch' => '',
281
-					'commit' => $row['changed_revision'],
282
-				];
283
-			}
284
-		}
285
-	}
286
-	return null;
268
+    if (!$dir) {
269
+        $dir = '.';
270
+    }
271
+    // version installee par SVN
272
+    if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
273
+        $db = new SQLite3($dir . '/.svn/wc.db');
274
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
275
+        if ($result) {
276
+            $row = $result->fetchArray();
277
+            if ($row['changed_revision'] != "") {
278
+                return [
279
+                    'vcs' => 'SVN',
280
+                    'branch' => '',
281
+                    'commit' => $row['changed_revision'],
282
+                ];
283
+            }
284
+        }
285
+    }
286
+    return null;
287 287
 }
288 288
 
289 289
 /**
@@ -301,10 +301,10 @@  discard block
 block discarded – undo
301 301
  *
302 302
  **/
303 303
 function version_svn_courante($dir) {
304
-	if ($desc = decrire_version_svn($dir)) {
305
-		return -$desc['commit'];
306
-	}
307
-	return 0;
304
+    if ($desc = decrire_version_svn($dir)) {
305
+        return -$desc['commit'];
306
+    }
307
+    return 0;
308 308
 }
309 309
 
310 310
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -350,18 +350,18 @@  discard block
 block discarded – undo
350 350
  *     Code HTML retourné par le filtre
351 351
  **/
352 352
 function filtrer($filtre) {
353
-	$tous = func_get_args();
354
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
355
-		return image_filtrer($tous);
356
-	} elseif ($f = chercher_filtre($filtre)) {
357
-		array_shift($tous);
358
-		return call_user_func_array($f, $tous);
359
-	} else {
360
-		// le filtre n'existe pas, on provoque une erreur
361
-		$msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
362
-		erreur_squelette($msg);
363
-		return '';
364
-	}
353
+    $tous = func_get_args();
354
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
355
+        return image_filtrer($tous);
356
+    } elseif ($f = chercher_filtre($filtre)) {
357
+        array_shift($tous);
358
+        return call_user_func_array($f, $tous);
359
+    } else {
360
+        // le filtre n'existe pas, on provoque une erreur
361
+        $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
362
+        erreur_squelette($msg);
363
+        return '';
364
+    }
365 365
 }
366 366
 
367 367
 /**
@@ -378,11 +378,11 @@  discard block
 block discarded – undo
378 378
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
379 379
  */
380 380
 function trouver_filtre_matrice($filtre) {
381
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
382
-		find_in_path($f, '', true);
383
-		$GLOBALS['spip_matrice'][$filtre] = true;
384
-	}
385
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
381
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
382
+        find_in_path($f, '', true);
383
+        $GLOBALS['spip_matrice'][$filtre] = true;
384
+    }
385
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
386 386
 }
387 387
 
388 388
 
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
  * @return mixed
411 411
  */
412 412
 function filtre_set(&$Pile, $val, $key, $continue = null) {
413
-	$Pile['vars'][$key] = $val;
414
-	return $continue ? $val : '';
413
+    $Pile['vars'][$key] = $val;
414
+    return $continue ? $val : '';
415 415
 }
416 416
 
417 417
 /**
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
438 438
  */
439 439
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
440
-	$Pile[0][$key] = $val;
441
-	return $continue ? $val : '';
440
+    $Pile[0][$key] = $val;
441
+    return $continue ? $val : '';
442 442
 }
443 443
 
444 444
 /**
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
  * @return string
448 448
  */
449 449
 function filtre_sanitize_env(&$Pile, $keys) {
450
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
451
-	return '';
450
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
451
+    return '';
452 452
 }
453 453
 
454 454
 
@@ -471,18 +471,18 @@  discard block
 block discarded – undo
471 471
  * @return mixed Retourne la valeur (sans la modifier).
472 472
  */
473 473
 function filtre_debug($val, $key = null) {
474
-	$debug = (
475
-		is_null($key) ? '' : (var_export($key, true) . " = ")
476
-		) . var_export($val, true);
474
+    $debug = (
475
+        is_null($key) ? '' : (var_export($key, true) . " = ")
476
+        ) . var_export($val, true);
477 477
 
478
-	include_spip('inc/autoriser');
479
-	if (autoriser('webmestre')) {
480
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
481
-	}
478
+    include_spip('inc/autoriser');
479
+    if (autoriser('webmestre')) {
480
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
481
+    }
482 482
 
483
-	spip_log($debug, 'debug');
483
+    spip_log($debug, 'debug');
484 484
 
485
-	return $val;
485
+    return $val;
486 486
 }
487 487
 
488 488
 
@@ -510,82 +510,82 @@  discard block
 block discarded – undo
510 510
  *     Texte qui a reçu les filtres
511 511
  **/
512 512
 function image_filtrer($args) {
513
-	$filtre = array_shift($args); # enlever $filtre
514
-	$texte = array_shift($args);
515
-	if (!strlen($texte)) {
516
-		return;
517
-	}
518
-	find_in_path('filtres_images_mini.php', 'inc/', true);
519
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
520
-	// Cas du nom de fichier local
521
-	$is_file = trim($texte);
522
-	if (strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
523
-		  or strpbrk($is_file, "<>\n\r\t") !== false
524
-		  or strpos($is_file, '/') === 0
525
-	) {
526
-		$is_file = false;
527
-	}
528
-	if ($is_file) {
529
-		$is_local_file = function($path) {
530
-			if (strpos($path, "?") !== false) {
531
-				$path = supprimer_timestamp($path);
532
-				// remove ?24px added by find_in_theme on .svg files
533
-				$path = preg_replace(",\?[[:digit:]]+(px)$,", "", $path);
534
-			}
535
-			return file_exists($path);
536
-		};
537
-		if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
538
-			array_unshift($args, "<img src='$is_file' />");
539
-			$res = call_user_func_array($filtre, $args);
540
-			statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
541
-			return $res;
542
-		}
543
-	}
544
-
545
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
546
-	if (preg_match_all(
547
-		',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
548
-		$texte, $tags, PREG_SET_ORDER)) {
549
-		foreach ($tags as $tag) {
550
-			$class = extraire_attribut($tag[3], 'class');
551
-			if (!$class or
552
-				(strpos($class, 'filtre_inactif') === false
553
-					// compat historique a virer en 3.2
554
-					and strpos($class, 'no_image_filtrer') === false)
555
-			) {
556
-				array_unshift($args, $tag[3]);
557
-				if ($reduit = call_user_func_array($filtre, $args)) {
558
-					// En cas de span spip_documents, modifier le style=...width:
559
-					if ($tag[1]) {
560
-						$w = extraire_attribut($reduit, 'width');
561
-						if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
562
-							$w = $regs[1];
563
-						}
564
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
565
-							$style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
566
-							$replace = inserer_attribut($tag[1], 'style', $style);
567
-							$texte = str_replace($tag[1], $replace, $texte);
568
-						}
569
-					}
570
-					// traiter aussi un eventuel mouseover
571
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
572
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
573
-							$srcover = $match[1];
574
-							array_shift($args);
575
-							array_unshift($args, "<img src='" . $match[1] . "' />");
576
-							$srcover_filter = call_user_func_array($filtre, $args);
577
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
578
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
579
-						}
580
-					}
581
-					$texte = str_replace($tag[3], $reduit, $texte);
582
-				}
583
-				array_shift($args);
584
-			}
585
-		}
586
-	}
587
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
588
-	return $texte;
513
+    $filtre = array_shift($args); # enlever $filtre
514
+    $texte = array_shift($args);
515
+    if (!strlen($texte)) {
516
+        return;
517
+    }
518
+    find_in_path('filtres_images_mini.php', 'inc/', true);
519
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
520
+    // Cas du nom de fichier local
521
+    $is_file = trim($texte);
522
+    if (strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
523
+          or strpbrk($is_file, "<>\n\r\t") !== false
524
+          or strpos($is_file, '/') === 0
525
+    ) {
526
+        $is_file = false;
527
+    }
528
+    if ($is_file) {
529
+        $is_local_file = function($path) {
530
+            if (strpos($path, "?") !== false) {
531
+                $path = supprimer_timestamp($path);
532
+                // remove ?24px added by find_in_theme on .svg files
533
+                $path = preg_replace(",\?[[:digit:]]+(px)$,", "", $path);
534
+            }
535
+            return file_exists($path);
536
+        };
537
+        if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
538
+            array_unshift($args, "<img src='$is_file' />");
539
+            $res = call_user_func_array($filtre, $args);
540
+            statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
541
+            return $res;
542
+        }
543
+    }
544
+
545
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
546
+    if (preg_match_all(
547
+        ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
548
+        $texte, $tags, PREG_SET_ORDER)) {
549
+        foreach ($tags as $tag) {
550
+            $class = extraire_attribut($tag[3], 'class');
551
+            if (!$class or
552
+                (strpos($class, 'filtre_inactif') === false
553
+                    // compat historique a virer en 3.2
554
+                    and strpos($class, 'no_image_filtrer') === false)
555
+            ) {
556
+                array_unshift($args, $tag[3]);
557
+                if ($reduit = call_user_func_array($filtre, $args)) {
558
+                    // En cas de span spip_documents, modifier le style=...width:
559
+                    if ($tag[1]) {
560
+                        $w = extraire_attribut($reduit, 'width');
561
+                        if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
562
+                            $w = $regs[1];
563
+                        }
564
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
565
+                            $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
566
+                            $replace = inserer_attribut($tag[1], 'style', $style);
567
+                            $texte = str_replace($tag[1], $replace, $texte);
568
+                        }
569
+                    }
570
+                    // traiter aussi un eventuel mouseover
571
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
572
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
573
+                            $srcover = $match[1];
574
+                            array_shift($args);
575
+                            array_unshift($args, "<img src='" . $match[1] . "' />");
576
+                            $srcover_filter = call_user_func_array($filtre, $args);
577
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
578
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
579
+                        }
580
+                    }
581
+                    $texte = str_replace($tag[3], $reduit, $texte);
582
+                }
583
+                array_shift($args);
584
+            }
585
+        }
586
+    }
587
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
588
+    return $texte;
589 589
 }
590 590
 
591 591
 /**
@@ -600,77 +600,77 @@  discard block
 block discarded – undo
600 600
  **/
601 601
 function taille_image($img, $force_refresh = false) {
602 602
 
603
-	static $largeur_img = array(), $hauteur_img = array();
604
-	$srcWidth = 0;
605
-	$srcHeight = 0;
606
-
607
-	$src = extraire_attribut($img, 'src');
608
-
609
-	if (!$src) {
610
-		$src = $img;
611
-	} else {
612
-		$srcWidth = extraire_attribut($img, 'width');
613
-		$srcHeight = extraire_attribut($img, 'height');
614
-	}
615
-
616
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
617
-	// la copie locale a toutes les chances d'etre la ou de resservir
618
-	if (tester_url_absolue($src)) {
619
-		include_spip('inc/distant');
620
-		$fichier = copie_locale($src);
621
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
622
-	}
623
-	if (($p = strpos($src, '?')) !== false) {
624
-		$src = substr($src, 0, $p);
625
-	}
626
-
627
-	$srcsize = false;
628
-	if (isset($largeur_img[$src]) and !$force_refresh) {
629
-		$srcWidth = $largeur_img[$src];
630
-	}
631
-	if (isset($hauteur_img[$src]) and !$force_refresh) {
632
-		$srcHeight = $hauteur_img[$src];
633
-	}
634
-	if (!$srcWidth or !$srcHeight) {
635
-
636
-		if (file_exists($src)
637
-			and $srcsize = spip_getimagesize($src)
638
-		) {
639
-			if (!$srcWidth) {
640
-				$largeur_img[$src] = $srcWidth = $srcsize[0];
641
-			}
642
-			if (!$srcHeight) {
643
-				$hauteur_img[$src] = $srcHeight = $srcsize[1];
644
-			}
645
-		}
646
-		elseif(strpos($src, "<svg") !== false) {
647
-			include_spip('inc/svg');
648
-			if ($attrs = svg_lire_attributs($src)){
649
-				list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
650
-				if (!$srcWidth){
651
-					$largeur_img[$src] = $srcWidth = $width;
652
-				}
653
-				if (!$srcHeight){
654
-					$hauteur_img[$src] = $srcHeight = $height;
655
-				}
656
-			}
657
-		}
658
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
659
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
660
-		elseif (@file_exists($f = "$src.src")
661
-			and lire_fichier($f, $valeurs)
662
-			and $valeurs = unserialize($valeurs)
663
-		) {
664
-			if (!$srcWidth) {
665
-				$largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
666
-			}
667
-			if (!$srcHeight) {
668
-				$hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
669
-			}
670
-		}
671
-	}
672
-
673
-	return array($srcHeight, $srcWidth);
603
+    static $largeur_img = array(), $hauteur_img = array();
604
+    $srcWidth = 0;
605
+    $srcHeight = 0;
606
+
607
+    $src = extraire_attribut($img, 'src');
608
+
609
+    if (!$src) {
610
+        $src = $img;
611
+    } else {
612
+        $srcWidth = extraire_attribut($img, 'width');
613
+        $srcHeight = extraire_attribut($img, 'height');
614
+    }
615
+
616
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
617
+    // la copie locale a toutes les chances d'etre la ou de resservir
618
+    if (tester_url_absolue($src)) {
619
+        include_spip('inc/distant');
620
+        $fichier = copie_locale($src);
621
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
622
+    }
623
+    if (($p = strpos($src, '?')) !== false) {
624
+        $src = substr($src, 0, $p);
625
+    }
626
+
627
+    $srcsize = false;
628
+    if (isset($largeur_img[$src]) and !$force_refresh) {
629
+        $srcWidth = $largeur_img[$src];
630
+    }
631
+    if (isset($hauteur_img[$src]) and !$force_refresh) {
632
+        $srcHeight = $hauteur_img[$src];
633
+    }
634
+    if (!$srcWidth or !$srcHeight) {
635
+
636
+        if (file_exists($src)
637
+            and $srcsize = spip_getimagesize($src)
638
+        ) {
639
+            if (!$srcWidth) {
640
+                $largeur_img[$src] = $srcWidth = $srcsize[0];
641
+            }
642
+            if (!$srcHeight) {
643
+                $hauteur_img[$src] = $srcHeight = $srcsize[1];
644
+            }
645
+        }
646
+        elseif(strpos($src, "<svg") !== false) {
647
+            include_spip('inc/svg');
648
+            if ($attrs = svg_lire_attributs($src)){
649
+                list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
650
+                if (!$srcWidth){
651
+                    $largeur_img[$src] = $srcWidth = $width;
652
+                }
653
+                if (!$srcHeight){
654
+                    $hauteur_img[$src] = $srcHeight = $height;
655
+                }
656
+            }
657
+        }
658
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
659
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
660
+        elseif (@file_exists($f = "$src.src")
661
+            and lire_fichier($f, $valeurs)
662
+            and $valeurs = unserialize($valeurs)
663
+        ) {
664
+            if (!$srcWidth) {
665
+                $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
666
+            }
667
+            if (!$srcHeight) {
668
+                $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
669
+            }
670
+        }
671
+    }
672
+
673
+    return array($srcHeight, $srcWidth);
674 674
 }
675 675
 
676 676
 
@@ -688,12 +688,12 @@  discard block
 block discarded – undo
688 688
  *     Largeur en pixels, NULL ou 0 si aucune image.
689 689
  **/
690 690
 function largeur($img) {
691
-	if (!$img) {
692
-		return;
693
-	}
694
-	list($h, $l) = taille_image($img);
691
+    if (!$img) {
692
+        return;
693
+    }
694
+    list($h, $l) = taille_image($img);
695 695
 
696
-	return $l;
696
+    return $l;
697 697
 }
698 698
 
699 699
 /**
@@ -710,12 +710,12 @@  discard block
 block discarded – undo
710 710
  *     Hauteur en pixels, NULL ou 0 si aucune image.
711 711
  **/
712 712
 function hauteur($img) {
713
-	if (!$img) {
714
-		return;
715
-	}
716
-	list($h, $l) = taille_image($img);
713
+    if (!$img) {
714
+        return;
715
+    }
716
+    list($h, $l) = taille_image($img);
717 717
 
718
-	return $h;
718
+    return $h;
719 719
 }
720 720
 
721 721
 
@@ -735,11 +735,11 @@  discard block
 block discarded – undo
735 735
  * @return string
736 736
  **/
737 737
 function corriger_entites_html($texte) {
738
-	if (strpos($texte, '&amp;') === false) {
739
-		return $texte;
740
-	}
738
+    if (strpos($texte, '&amp;') === false) {
739
+        return $texte;
740
+    }
741 741
 
742
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
742
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
743 743
 }
744 744
 
745 745
 /**
@@ -754,11 +754,11 @@  discard block
 block discarded – undo
754 754
  * @return string
755 755
  **/
756 756
 function corriger_toutes_entites_html($texte) {
757
-	if (strpos($texte, '&amp;') === false) {
758
-		return $texte;
759
-	}
757
+    if (strpos($texte, '&amp;') === false) {
758
+        return $texte;
759
+    }
760 760
 
761
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
761
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
762 762
 }
763 763
 
764 764
 /**
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
  * @return string
769 769
  **/
770 770
 function proteger_amp($texte) {
771
-	return str_replace('&', '&amp;', $texte);
771
+    return str_replace('&', '&amp;', $texte);
772 772
 }
773 773
 
774 774
 
@@ -799,20 +799,20 @@  discard block
 block discarded – undo
799 799
  * @return mixed|string
800 800
  */
801 801
 function entites_html($texte, $tout = false, $quote = true) {
802
-	if (!is_string($texte) or !$texte
803
-		or strpbrk($texte, "&\"'<>") == false
804
-	) {
805
-		return $texte;
806
-	}
807
-	include_spip('inc/texte');
808
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
809
-	$flags |= ENT_HTML401;
810
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
811
-	if ($tout) {
812
-		return corriger_toutes_entites_html($texte);
813
-	} else {
814
-		return corriger_entites_html($texte);
815
-	}
802
+    if (!is_string($texte) or !$texte
803
+        or strpbrk($texte, "&\"'<>") == false
804
+    ) {
805
+        return $texte;
806
+    }
807
+    include_spip('inc/texte');
808
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
809
+    $flags |= ENT_HTML401;
810
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
811
+    if ($tout) {
812
+        return corriger_toutes_entites_html($texte);
813
+    } else {
814
+        return corriger_entites_html($texte);
815
+    }
816 816
 }
817 817
 
818 818
 /**
@@ -831,37 +831,37 @@  discard block
 block discarded – undo
831 831
  *     Texte converti
832 832
  **/
833 833
 function filtrer_entites($texte) {
834
-	if (strpos($texte, '&') === false) {
835
-		return $texte;
836
-	}
837
-	// filtrer
838
-	$texte = html2unicode($texte);
839
-	// remettre le tout dans le charset cible
840
-	$texte = unicode2charset($texte);
841
-	// cas particulier des " et ' qu'il faut filtrer aussi
842
-	// (on le faisait deja avec un &quot;)
843
-	if (strpos($texte, "&#") !== false) {
844
-		$texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
845
-	}
834
+    if (strpos($texte, '&') === false) {
835
+        return $texte;
836
+    }
837
+    // filtrer
838
+    $texte = html2unicode($texte);
839
+    // remettre le tout dans le charset cible
840
+    $texte = unicode2charset($texte);
841
+    // cas particulier des " et ' qu'il faut filtrer aussi
842
+    // (on le faisait deja avec un &quot;)
843
+    if (strpos($texte, "&#") !== false) {
844
+        $texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
845
+    }
846 846
 
847
-	return $texte;
847
+    return $texte;
848 848
 }
849 849
 
850 850
 
851 851
 if (!function_exists('filtre_filtrer_entites_dist')) {
852
-	/**
853
-	 * Version sécurisée de filtrer_entites
854
-	 * 
855
-	 * @uses interdire_scripts()
856
-	 * @uses filtrer_entites()
857
-	 * 
858
-	 * @param string $t
859
-	 * @return string
860
-	 */
861
-	function filtre_filtrer_entites_dist($t) {
862
-		include_spip('inc/texte');
863
-		return interdire_scripts(filtrer_entites($t));
864
-	}
852
+    /**
853
+     * Version sécurisée de filtrer_entites
854
+     * 
855
+     * @uses interdire_scripts()
856
+     * @uses filtrer_entites()
857
+     * 
858
+     * @param string $t
859
+     * @return string
860
+     */
861
+    function filtre_filtrer_entites_dist($t) {
862
+        include_spip('inc/texte');
863
+        return interdire_scripts(filtrer_entites($t));
864
+    }
865 865
 }
866 866
 
867 867
 
@@ -876,18 +876,18 @@  discard block
 block discarded – undo
876 876
  * @return string|array
877 877
  **/
878 878
 function supprimer_caracteres_illegaux($texte) {
879
-	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";
880
-	static $to = null;
879
+    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";
880
+    static $to = null;
881 881
 
882
-	if (is_array($texte)) {
883
-		return array_map('supprimer_caracteres_illegaux', $texte);
884
-	}
882
+    if (is_array($texte)) {
883
+        return array_map('supprimer_caracteres_illegaux', $texte);
884
+    }
885 885
 
886
-	if (!$to) {
887
-		$to = str_repeat('-', strlen($from));
888
-	}
886
+    if (!$to) {
887
+        $to = str_repeat('-', strlen($from));
888
+    }
889 889
 
890
-	return strtr($texte, $from, $to);
890
+    return strtr($texte, $from, $to);
891 891
 }
892 892
 
893 893
 /**
@@ -899,10 +899,10 @@  discard block
 block discarded – undo
899 899
  * @return string|array
900 900
  **/
901 901
 function corriger_caracteres($texte) {
902
-	$texte = corriger_caracteres_windows($texte);
903
-	$texte = supprimer_caracteres_illegaux($texte);
902
+    $texte = corriger_caracteres_windows($texte);
903
+    $texte = supprimer_caracteres_illegaux($texte);
904 904
 
905
-	return $texte;
905
+    return $texte;
906 906
 }
907 907
 
908 908
 /**
@@ -920,40 +920,40 @@  discard block
 block discarded – undo
920 920
  */
921 921
 function texte_backend($texte) {
922 922
 
923
-	static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
923
+    static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
924 924
 
925
-	// si on a des liens ou des images, les passer en absolu
926
-	$texte = liens_absolus($texte);
925
+    // si on a des liens ou des images, les passer en absolu
926
+    $texte = liens_absolus($texte);
927 927
 
928
-	// echapper les tags &gt; &lt;
929
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
928
+    // echapper les tags &gt; &lt;
929
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
930 930
 
931
-	// importer les &eacute;
932
-	$texte = filtrer_entites($texte);
931
+    // importer les &eacute;
932
+    $texte = filtrer_entites($texte);
933 933
 
934
-	// " -> &quot; et tout ce genre de choses
935
-	$u = $GLOBALS['meta']['pcre_u'];
936
-	$texte = str_replace("&nbsp;", " ", $texte);
937
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
938
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
939
-	$texte = entites_html($texte, false, false);
940
-	// mais bien echapper les double quotes !
941
-	$texte = str_replace('"', '&#034;', $texte);
934
+    // " -> &quot; et tout ce genre de choses
935
+    $u = $GLOBALS['meta']['pcre_u'];
936
+    $texte = str_replace("&nbsp;", " ", $texte);
937
+    $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
938
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
939
+    $texte = entites_html($texte, false, false);
940
+    // mais bien echapper les double quotes !
941
+    $texte = str_replace('"', '&#034;', $texte);
942 942
 
943
-	// verifier le charset
944
-	$texte = charset2unicode($texte);
943
+    // verifier le charset
944
+    $texte = charset2unicode($texte);
945 945
 
946
-	// Caracteres problematiques en iso-latin 1
947
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
948
-		$texte = str_replace(chr(156), '&#156;', $texte);
949
-		$texte = str_replace(chr(140), '&#140;', $texte);
950
-		$texte = str_replace(chr(159), '&#159;', $texte);
951
-	}
946
+    // Caracteres problematiques en iso-latin 1
947
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
948
+        $texte = str_replace(chr(156), '&#156;', $texte);
949
+        $texte = str_replace(chr(140), '&#140;', $texte);
950
+        $texte = str_replace(chr(159), '&#159;', $texte);
951
+    }
952 952
 
953
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
954
-	// et le caractere apostrophe alourdit les squelettes avec PHP
955
-	// ==> on les remplace par l'entite HTML
956
-	return str_replace($apostrophe, "'", $texte);
953
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
954
+    // et le caractere apostrophe alourdit les squelettes avec PHP
955
+    // ==> on les remplace par l'entite HTML
956
+    return str_replace($apostrophe, "'", $texte);
957 957
 }
958 958
 
959 959
 /**
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
  *     Texte encodé et quote pour XML
971 971
  */
972 972
 function texte_backendq($texte) {
973
-	return addslashes(texte_backend($texte));
973
+    return addslashes(texte_backend($texte));
974 974
 }
975 975
 
976 976
 
@@ -993,9 +993,9 @@  discard block
 block discarded – undo
993 993
  *     Numéro de titre, sinon chaîne vide
994 994
  **/
995 995
 function supprimer_numero($texte) {
996
-	return preg_replace(
997
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
998
-		"", $texte);
996
+    return preg_replace(
997
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
998
+        "", $texte);
999 999
 }
1000 1000
 
1001 1001
 /**
@@ -1018,13 +1018,13 @@  discard block
 block discarded – undo
1018 1018
  *     Numéro de titre, sinon chaîne vide
1019 1019
  **/
1020 1020
 function recuperer_numero($texte) {
1021
-	if (preg_match(
1022
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
1023
-		$texte, $regs)) {
1024
-		return strval($regs[1]);
1025
-	} else {
1026
-		return '';
1027
-	}
1021
+    if (preg_match(
1022
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
1023
+        $texte, $regs)) {
1024
+        return strval($regs[1]);
1025
+    } else {
1026
+        return '';
1027
+    }
1028 1028
 }
1029 1029
 
1030 1030
 /**
@@ -1051,13 +1051,13 @@  discard block
 block discarded – undo
1051 1051
  *     Texte converti
1052 1052
  **/
1053 1053
 function supprimer_tags($texte, $rempl = "") {
1054
-	$texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
1055
-	// ne pas oublier un < final non ferme car coupe
1056
-	$texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
1057
-	// mais qui peut aussi etre un simple signe plus petit que
1058
-	$texte = str_replace('<', '&lt;', $texte);
1054
+    $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
1055
+    // ne pas oublier un < final non ferme car coupe
1056
+    $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
1057
+    // mais qui peut aussi etre un simple signe plus petit que
1058
+    $texte = str_replace('<', '&lt;', $texte);
1059 1059
 
1060
-	return $texte;
1060
+    return $texte;
1061 1061
 }
1062 1062
 
1063 1063
 /**
@@ -1080,9 +1080,9 @@  discard block
 block discarded – undo
1080 1080
  *     Texte converti
1081 1081
  **/
1082 1082
 function echapper_tags($texte, $rempl = "") {
1083
-	$texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1083
+    $texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1084 1084
 
1085
-	return $texte;
1085
+    return $texte;
1086 1086
 }
1087 1087
 
1088 1088
 /**
@@ -1103,18 +1103,18 @@  discard block
 block discarded – undo
1103 1103
  *     Texte converti
1104 1104
  **/
1105 1105
 function textebrut($texte) {
1106
-	$u = $GLOBALS['meta']['pcre_u'];
1107
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1108
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1109
-	$texte = preg_replace("/^\n+/", "", $texte);
1110
-	$texte = preg_replace("/\n+$/", "", $texte);
1111
-	$texte = preg_replace("/\n +/", "\n", $texte);
1112
-	$texte = supprimer_tags($texte);
1113
-	$texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1114
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1115
-	$texte = str_replace("&#8217;", "'", $texte);
1106
+    $u = $GLOBALS['meta']['pcre_u'];
1107
+    $texte = preg_replace('/\s+/S' . $u, " ", $texte);
1108
+    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1109
+    $texte = preg_replace("/^\n+/", "", $texte);
1110
+    $texte = preg_replace("/\n+$/", "", $texte);
1111
+    $texte = preg_replace("/\n +/", "\n", $texte);
1112
+    $texte = supprimer_tags($texte);
1113
+    $texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1114
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1115
+    $texte = str_replace("&#8217;", "'", $texte);
1116 1116
 
1117
-	return $texte;
1117
+    return $texte;
1118 1118
 }
1119 1119
 
1120 1120
 
@@ -1130,17 +1130,17 @@  discard block
 block discarded – undo
1130 1130
  *     Texte avec liens ouvrants
1131 1131
  **/
1132 1132
 function liens_ouvrants($texte) {
1133
-	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1134
-		$texte, $liens, PREG_PATTERN_ORDER)) {
1135
-		foreach ($liens[0] as $a) {
1136
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1137
-			$ablank = inserer_attribut($a, 'rel', $rel);
1138
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1139
-			$texte = str_replace($a, $ablank, $texte);
1140
-		}
1141
-	}
1133
+    if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1134
+        $texte, $liens, PREG_PATTERN_ORDER)) {
1135
+        foreach ($liens[0] as $a) {
1136
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1137
+            $ablank = inserer_attribut($a, 'rel', $rel);
1138
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1139
+            $texte = str_replace($a, $ablank, $texte);
1140
+        }
1141
+    }
1142 1142
 
1143
-	return $texte;
1143
+    return $texte;
1144 1144
 }
1145 1145
 
1146 1146
 /**
@@ -1150,22 +1150,22 @@  discard block
 block discarded – undo
1150 1150
  * @return string
1151 1151
  */
1152 1152
 function liens_nofollow($texte) {
1153
-	if (stripos($texte, "<a") === false) {
1154
-		return $texte;
1155
-	}
1153
+    if (stripos($texte, "<a") === false) {
1154
+        return $texte;
1155
+    }
1156 1156
 
1157
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1158
-		foreach ($regs[0] as $a) {
1159
-			$rel = extraire_attribut($a, "rel");
1160
-			if (strpos($rel, "nofollow") === false) {
1161
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1162
-				$anofollow = inserer_attribut($a, "rel", $rel);
1163
-				$texte = str_replace($a, $anofollow, $texte);
1164
-			}
1165
-		}
1166
-	}
1157
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1158
+        foreach ($regs[0] as $a) {
1159
+            $rel = extraire_attribut($a, "rel");
1160
+            if (strpos($rel, "nofollow") === false) {
1161
+                $rel = "nofollow" . ($rel ? " $rel" : "");
1162
+                $anofollow = inserer_attribut($a, "rel", $rel);
1163
+                $texte = str_replace($a, $anofollow, $texte);
1164
+            }
1165
+        }
1166
+    }
1167 1167
 
1168
-	return $texte;
1168
+    return $texte;
1169 1169
 }
1170 1170
 
1171 1171
 /**
@@ -1184,12 +1184,12 @@  discard block
 block discarded – undo
1184 1184
  *     Texte sans paraghaphes
1185 1185
  **/
1186 1186
 function PtoBR($texte) {
1187
-	$u = $GLOBALS['meta']['pcre_u'];
1188
-	$texte = preg_replace("@</p>@iS", "\n", $texte);
1189
-	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1190
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1187
+    $u = $GLOBALS['meta']['pcre_u'];
1188
+    $texte = preg_replace("@</p>@iS", "\n", $texte);
1189
+    $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1190
+    $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1191 1191
 
1192
-	return $texte;
1192
+    return $texte;
1193 1193
 }
1194 1194
 
1195 1195
 
@@ -1213,14 +1213,14 @@  discard block
 block discarded – undo
1213 1213
  * @return string Texte encadré du style CSS
1214 1214
  */
1215 1215
 function lignes_longues($texte) {
1216
-	if (!strlen(trim($texte))) {
1217
-		return $texte;
1218
-	}
1219
-	include_spip('inc/texte');
1220
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1221
-		'div' : 'span';
1216
+    if (!strlen(trim($texte))) {
1217
+        return $texte;
1218
+    }
1219
+    include_spip('inc/texte');
1220
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1221
+        'div' : 'span';
1222 1222
 
1223
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1223
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1224 1224
 }
1225 1225
 
1226 1226
 /**
@@ -1239,30 +1239,30 @@  discard block
 block discarded – undo
1239 1239
  * @return string Texte en majuscule
1240 1240
  */
1241 1241
 function majuscules($texte) {
1242
-	if (!strlen($texte)) {
1243
-		return '';
1244
-	}
1242
+    if (!strlen($texte)) {
1243
+        return '';
1244
+    }
1245 1245
 
1246
-	// Cas du turc
1247
-	if ($GLOBALS['spip_lang'] == 'tr') {
1248
-		# remplacer hors des tags et des entites
1249
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1250
-			foreach ($regs as $n => $match) {
1251
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1252
-			}
1253
-		}
1246
+    // Cas du turc
1247
+    if ($GLOBALS['spip_lang'] == 'tr') {
1248
+        # remplacer hors des tags et des entites
1249
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1250
+            foreach ($regs as $n => $match) {
1251
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1252
+            }
1253
+        }
1254 1254
 
1255
-		$texte = str_replace('i', '&#304;', $texte);
1255
+        $texte = str_replace('i', '&#304;', $texte);
1256 1256
 
1257
-		if ($regs) {
1258
-			foreach ($regs as $n => $match) {
1259
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1260
-			}
1261
-		}
1262
-	}
1257
+        if ($regs) {
1258
+            foreach ($regs as $n => $match) {
1259
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1260
+            }
1261
+        }
1262
+    }
1263 1263
 
1264
-	// Cas general
1265
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1264
+    // Cas general
1265
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1266 1266
 }
1267 1267
 
1268 1268
 /**
@@ -1280,29 +1280,29 @@  discard block
 block discarded – undo
1280 1280
  * @return string
1281 1281
  **/
1282 1282
 function taille_en_octets($taille) {
1283
-	if (!defined('_KILOBYTE')) {
1284
-		/**
1285
-		 * Définit le nombre d'octets dans un Kilobyte
1286
-		 *
1287
-		 * @var int
1288
-		 **/
1289
-		define('_KILOBYTE', 1024);
1290
-	}
1283
+    if (!defined('_KILOBYTE')) {
1284
+        /**
1285
+         * Définit le nombre d'octets dans un Kilobyte
1286
+         *
1287
+         * @var int
1288
+         **/
1289
+        define('_KILOBYTE', 1024);
1290
+    }
1291 1291
 
1292
-	if ($taille < 1) {
1293
-		return '';
1294
-	}
1295
-	if ($taille < _KILOBYTE) {
1296
-		$taille = _T('taille_octets', array('taille' => $taille));
1297
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1298
-		$taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1299
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1300
-		$taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1301
-	} else {
1302
-		$taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1303
-	}
1292
+    if ($taille < 1) {
1293
+        return '';
1294
+    }
1295
+    if ($taille < _KILOBYTE) {
1296
+        $taille = _T('taille_octets', array('taille' => $taille));
1297
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1298
+        $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1299
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1300
+        $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1301
+    } else {
1302
+        $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1303
+    }
1304 1304
 
1305
-	return $taille;
1305
+    return $taille;
1306 1306
 }
1307 1307
 
1308 1308
 
@@ -1324,15 +1324,15 @@  discard block
 block discarded – undo
1324 1324
  *     Texte prêt pour être utilisé en attribut HTML
1325 1325
  **/
1326 1326
 function attribut_html($texte, $textebrut = true) {
1327
-	$u = $GLOBALS['meta']['pcre_u'];
1328
-	if ($textebrut) {
1329
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1330
-	}
1331
-	$texte = texte_backend($texte);
1332
-	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1327
+    $u = $GLOBALS['meta']['pcre_u'];
1328
+    if ($textebrut) {
1329
+        $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1330
+    }
1331
+    $texte = texte_backend($texte);
1332
+    $texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1333 1333
 
1334
-	return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1335
-		$texte);
1334
+    return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1335
+        $texte);
1336 1336
 }
1337 1337
 
1338 1338
 
@@ -1352,12 +1352,12 @@  discard block
 block discarded – undo
1352 1352
  *     URL ou chaîne vide
1353 1353
  **/
1354 1354
 function vider_url($url, $entites = true) {
1355
-	# un message pour abs_url
1356
-	$GLOBALS['mode_abs_url'] = 'url';
1357
-	$url = trim($url);
1358
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1355
+    # un message pour abs_url
1356
+    $GLOBALS['mode_abs_url'] = 'url';
1357
+    $url = trim($url);
1358
+    $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1359 1359
 
1360
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1360
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1361 1361
 }
1362 1362
 
1363 1363
 
@@ -1372,10 +1372,10 @@  discard block
 block discarded – undo
1372 1372
  * @return string Adresse email maquillée
1373 1373
  **/
1374 1374
 function antispam($texte) {
1375
-	include_spip('inc/acces');
1376
-	$masque = creer_pass_aleatoire(3);
1375
+    include_spip('inc/acces');
1376
+    $masque = creer_pass_aleatoire(3);
1377 1377
 
1378
-	return preg_replace("/@/", " $masque ", $texte);
1378
+    return preg_replace("/@/", " $masque ", $texte);
1379 1379
 }
1380 1380
 
1381 1381
 /**
@@ -1407,12 +1407,12 @@  discard block
 block discarded – undo
1407 1407
  *     True si on a le droit d'accès, false sinon.
1408 1408
  **/
1409 1409
 function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') {
1410
-	include_spip('inc/acces');
1411
-	if ($op) {
1412
-		$dir .= " $op $args";
1413
-	}
1410
+    include_spip('inc/acces');
1411
+    if ($op) {
1412
+        $dir .= " $op $args";
1413
+    }
1414 1414
 
1415
-	return verifier_low_sec($id_auteur, $cle, $dir);
1415
+    return verifier_low_sec($id_auteur, $cle, $dir);
1416 1416
 }
1417 1417
 
1418 1418
 /**
@@ -1437,11 +1437,11 @@  discard block
 block discarded – undo
1437 1437
  *     Retourne $texte, sinon $sinon.
1438 1438
  **/
1439 1439
 function sinon($texte, $sinon = '') {
1440
-	if ($texte or (!is_array($texte) and strlen($texte))) {
1441
-		return $texte;
1442
-	} else {
1443
-		return $sinon;
1444
-	}
1440
+    if ($texte or (!is_array($texte) and strlen($texte))) {
1441
+        return $texte;
1442
+    } else {
1443
+        return $sinon;
1444
+    }
1445 1445
 }
1446 1446
 
1447 1447
 /**
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
  * @return mixed
1466 1466
  **/
1467 1467
 function choixsivide($a, $vide, $pasvide) {
1468
-	return $a ? $pasvide : $vide;
1468
+    return $a ? $pasvide : $vide;
1469 1469
 }
1470 1470
 
1471 1471
 /**
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
  * @return mixed
1490 1490
  **/
1491 1491
 function choixsiegal($a1, $a2, $v, $f) {
1492
-	return ($a1 == $a2) ? $v : $f;
1492
+    return ($a1 == $a2) ? $v : $f;
1493 1493
 }
1494 1494
 
1495 1495
 //
@@ -1508,13 +1508,13 @@  discard block
 block discarded – undo
1508 1508
  * @return string
1509 1509
  **/
1510 1510
 function filtrer_ical($texte) {
1511
-	#include_spip('inc/charsets');
1512
-	$texte = html2unicode($texte);
1513
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1514
-	$texte = preg_replace("/\n/", " ", $texte);
1515
-	$texte = preg_replace("/,/", "\,", $texte);
1511
+    #include_spip('inc/charsets');
1512
+    $texte = html2unicode($texte);
1513
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1514
+    $texte = preg_replace("/\n/", " ", $texte);
1515
+    $texte = preg_replace("/,/", "\,", $texte);
1516 1516
 
1517
-	return $texte;
1517
+    return $texte;
1518 1518
 }
1519 1519
 
1520 1520
 
@@ -1539,53 +1539,53 @@  discard block
 block discarded – undo
1539 1539
  * @return string
1540 1540
  **/
1541 1541
 function post_autobr($texte, $delim = "\n_ ") {
1542
-	if (!function_exists('echappe_html')) {
1543
-		include_spip('inc/texte_mini');
1544
-	}
1545
-	$texte = str_replace("\r\n", "\r", $texte);
1546
-	$texte = str_replace("\r", "\n", $texte);
1547
-
1548
-	if (preg_match(",\n+$,", $texte, $fin)) {
1549
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1550
-	} else {
1551
-		$fin = '';
1552
-	}
1553
-
1554
-	$texte = echappe_html($texte, '', true);
1555
-
1556
-	// echapper les modeles
1557
-	if (strpos($texte, "<") !== false) {
1558
-		include_spip('inc/lien');
1559
-		if (defined('_PREG_MODELE')) {
1560
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1561
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1562
-		}
1563
-	}
1564
-
1565
-	$debut = '';
1566
-	$suite = $texte;
1567
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1568
-		$debut .= substr($suite, 0, $t - 1);
1569
-		$suite = substr($suite, $t);
1570
-		$car = substr($suite, 0, 1);
1571
-		if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1572
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1573
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1574
-		) {
1575
-			$debut .= $delim;
1576
-		} else {
1577
-			$debut .= "\n";
1578
-		}
1579
-		if (preg_match(",^\n+,", $suite, $regs)) {
1580
-			$debut .= $regs[0];
1581
-			$suite = substr($suite, strlen($regs[0]));
1582
-		}
1583
-	}
1584
-	$texte = $debut . $suite;
1585
-
1586
-	$texte = echappe_retour($texte);
1587
-
1588
-	return $texte . $fin;
1542
+    if (!function_exists('echappe_html')) {
1543
+        include_spip('inc/texte_mini');
1544
+    }
1545
+    $texte = str_replace("\r\n", "\r", $texte);
1546
+    $texte = str_replace("\r", "\n", $texte);
1547
+
1548
+    if (preg_match(",\n+$,", $texte, $fin)) {
1549
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1550
+    } else {
1551
+        $fin = '';
1552
+    }
1553
+
1554
+    $texte = echappe_html($texte, '', true);
1555
+
1556
+    // echapper les modeles
1557
+    if (strpos($texte, "<") !== false) {
1558
+        include_spip('inc/lien');
1559
+        if (defined('_PREG_MODELE')) {
1560
+            $preg_modeles = "@" . _PREG_MODELE . "@imsS";
1561
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1562
+        }
1563
+    }
1564
+
1565
+    $debut = '';
1566
+    $suite = $texte;
1567
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1568
+        $debut .= substr($suite, 0, $t - 1);
1569
+        $suite = substr($suite, $t);
1570
+        $car = substr($suite, 0, 1);
1571
+        if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1572
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1573
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1574
+        ) {
1575
+            $debut .= $delim;
1576
+        } else {
1577
+            $debut .= "\n";
1578
+        }
1579
+        if (preg_match(",^\n+,", $suite, $regs)) {
1580
+            $debut .= $regs[0];
1581
+            $suite = substr($suite, strlen($regs[0]));
1582
+        }
1583
+    }
1584
+    $texte = $debut . $suite;
1585
+
1586
+    $texte = echappe_retour($texte);
1587
+
1588
+    return $texte . $fin;
1589 1589
 }
1590 1590
 
1591 1591
 
@@ -1626,46 +1626,46 @@  discard block
 block discarded – undo
1626 1626
  * @return string
1627 1627
  **/
1628 1628
 function extraire_idiome($letexte, $lang = null, $options = array()) {
1629
-	static $traduire = false;
1630
-	if ($letexte
1631
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1632
-	) {
1633
-		if (!$traduire) {
1634
-			$traduire = charger_fonction('traduire', 'inc');
1635
-			include_spip('inc/lang');
1636
-		}
1637
-		if (!$lang) {
1638
-			$lang = $GLOBALS['spip_lang'];
1639
-		}
1640
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1641
-		if (is_bool($options)) {
1642
-			$options = array('echappe_span' => $options);
1643
-		}
1644
-		if (!isset($options['echappe_span'])) {
1645
-			$options = array_merge($options, array('echappe_span' => false));
1646
-		}
1647
-
1648
-		foreach ($regs as $reg) {
1649
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1650
-			$desc = $traduire($cle, $lang, true);
1651
-			$l = $desc->langue;
1652
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1653
-			if (strlen($desc->texte)) {
1654
-				$trad = code_echappement($desc->texte, 'idiome', false);
1655
-				if ($l !== $lang) {
1656
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1657
-				}
1658
-				if (lang_dir($l) !== lang_dir($lang)) {
1659
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1660
-				}
1661
-				if (!$options['echappe_span']) {
1662
-					$trad = echappe_retour($trad, 'idiome');
1663
-				}
1664
-				$letexte = str_replace($reg[0], $trad, $letexte);
1665
-			}
1666
-		}
1667
-	}
1668
-	return $letexte;
1629
+    static $traduire = false;
1630
+    if ($letexte
1631
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1632
+    ) {
1633
+        if (!$traduire) {
1634
+            $traduire = charger_fonction('traduire', 'inc');
1635
+            include_spip('inc/lang');
1636
+        }
1637
+        if (!$lang) {
1638
+            $lang = $GLOBALS['spip_lang'];
1639
+        }
1640
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1641
+        if (is_bool($options)) {
1642
+            $options = array('echappe_span' => $options);
1643
+        }
1644
+        if (!isset($options['echappe_span'])) {
1645
+            $options = array_merge($options, array('echappe_span' => false));
1646
+        }
1647
+
1648
+        foreach ($regs as $reg) {
1649
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1650
+            $desc = $traduire($cle, $lang, true);
1651
+            $l = $desc->langue;
1652
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1653
+            if (strlen($desc->texte)) {
1654
+                $trad = code_echappement($desc->texte, 'idiome', false);
1655
+                if ($l !== $lang) {
1656
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1657
+                }
1658
+                if (lang_dir($l) !== lang_dir($lang)) {
1659
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1660
+                }
1661
+                if (!$options['echappe_span']) {
1662
+                    $trad = echappe_retour($trad, 'idiome');
1663
+                }
1664
+                $letexte = str_replace($reg[0], $trad, $letexte);
1665
+            }
1666
+        }
1667
+    }
1668
+    return $letexte;
1669 1669
 }
1670 1670
 
1671 1671
 /**
@@ -1717,67 +1717,67 @@  discard block
 block discarded – undo
1717 1717
  **/
1718 1718
 function extraire_multi($letexte, $lang = null, $options = array()) {
1719 1719
 
1720
-	if ($letexte
1721
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1722
-	) {
1723
-		if (!$lang) {
1724
-			$lang = $GLOBALS['spip_lang'];
1725
-		}
1726
-
1727
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1728
-		if (is_bool($options)) {
1729
-			$options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1730
-		}
1731
-		if (!isset($options['echappe_span'])) {
1732
-			$options = array_merge($options, array('echappe_span' => false));
1733
-		}
1734
-		if (!isset($options['lang_defaut'])) {
1735
-			$options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1736
-		}
1737
-
1738
-		include_spip('inc/lang');
1739
-		foreach ($regs as $reg) {
1740
-			// chercher la version de la langue courante
1741
-			$trads = extraire_trads($reg[1]);
1742
-			if ($l = approcher_langue($trads, $lang)) {
1743
-				$trad = $trads[$l];
1744
-			} else {
1745
-				if ($options['lang_defaut'] == 'aucune') {
1746
-					$trad = '';
1747
-				} else {
1748
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1749
-					// ou la premiere dispo
1750
-					// mais typographier le texte selon les regles de celle-ci
1751
-					// Attention aux blocs multi sur plusieurs lignes
1752
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1753
-						$l = key($trads);
1754
-					}
1755
-					$trad = $trads[$l];
1756
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1757
-					$trad = $typographie($trad);
1758
-					// Tester si on echappe en span ou en div
1759
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1760
-					include_spip('inc/texte');
1761
-					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1762
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1763
-					if ($mode === 'div') {
1764
-						$trad = rtrim($trad) . "\n\n";
1765
-					}
1766
-					$trad = code_echappement($trad, 'multi', false, $mode);
1767
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1768
-					if (lang_dir($l) !== lang_dir($lang)) {
1769
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1770
-					}
1771
-					if (!$options['echappe_span']) {
1772
-						$trad = echappe_retour($trad, 'multi');
1773
-					}
1774
-				}
1775
-			}
1776
-			$letexte = str_replace($reg[0], $trad, $letexte);
1777
-		}
1778
-	}
1779
-
1780
-	return $letexte;
1720
+    if ($letexte
1721
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1722
+    ) {
1723
+        if (!$lang) {
1724
+            $lang = $GLOBALS['spip_lang'];
1725
+        }
1726
+
1727
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1728
+        if (is_bool($options)) {
1729
+            $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1730
+        }
1731
+        if (!isset($options['echappe_span'])) {
1732
+            $options = array_merge($options, array('echappe_span' => false));
1733
+        }
1734
+        if (!isset($options['lang_defaut'])) {
1735
+            $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1736
+        }
1737
+
1738
+        include_spip('inc/lang');
1739
+        foreach ($regs as $reg) {
1740
+            // chercher la version de la langue courante
1741
+            $trads = extraire_trads($reg[1]);
1742
+            if ($l = approcher_langue($trads, $lang)) {
1743
+                $trad = $trads[$l];
1744
+            } else {
1745
+                if ($options['lang_defaut'] == 'aucune') {
1746
+                    $trad = '';
1747
+                } else {
1748
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1749
+                    // ou la premiere dispo
1750
+                    // mais typographier le texte selon les regles de celle-ci
1751
+                    // Attention aux blocs multi sur plusieurs lignes
1752
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1753
+                        $l = key($trads);
1754
+                    }
1755
+                    $trad = $trads[$l];
1756
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1757
+                    $trad = $typographie($trad);
1758
+                    // Tester si on echappe en span ou en div
1759
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1760
+                    include_spip('inc/texte');
1761
+                    $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1762
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1763
+                    if ($mode === 'div') {
1764
+                        $trad = rtrim($trad) . "\n\n";
1765
+                    }
1766
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1767
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1768
+                    if (lang_dir($l) !== lang_dir($lang)) {
1769
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1770
+                    }
1771
+                    if (!$options['echappe_span']) {
1772
+                        $trad = echappe_retour($trad, 'multi');
1773
+                    }
1774
+                }
1775
+            }
1776
+            $letexte = str_replace($reg[0], $trad, $letexte);
1777
+        }
1778
+    }
1779
+
1780
+    return $letexte;
1781 1781
 }
1782 1782
 
1783 1783
 /**
@@ -1793,20 +1793,20 @@  discard block
 block discarded – undo
1793 1793
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1794 1794
  **/
1795 1795
 function extraire_trads($bloc) {
1796
-	$lang = '';
1796
+    $lang = '';
1797 1797
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1798 1798
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1799
-	while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1800
-		$texte = trim($regs[1]);
1801
-		if ($texte or $lang) {
1802
-			$trads[$lang] = $texte;
1803
-		}
1804
-		$bloc = substr($bloc, strlen($regs[0]));
1805
-		$lang = $regs[2];
1806
-	}
1807
-	$trads[$lang] = $bloc;
1799
+    while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1800
+        $texte = trim($regs[1]);
1801
+        if ($texte or $lang) {
1802
+            $trads[$lang] = $texte;
1803
+        }
1804
+        $bloc = substr($bloc, strlen($regs[0]));
1805
+        $lang = $regs[2];
1806
+    }
1807
+    $trads[$lang] = $bloc;
1808 1808
 
1809
-	return $trads;
1809
+    return $trads;
1810 1810
 }
1811 1811
 
1812 1812
 
@@ -1817,7 +1817,7 @@  discard block
 block discarded – undo
1817 1817
  * @return string L'initiale en majuscule
1818 1818
  */
1819 1819
 function filtre_initiale($nom) {
1820
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1820
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1821 1821
 }
1822 1822
 
1823 1823
 
@@ -1862,33 +1862,33 @@  discard block
 block discarded – undo
1862 1862
  *      - null (interne) : si on empile
1863 1863
  **/
1864 1864
 function unique($donnee, $famille = '', $cpt = false) {
1865
-	static $mem = array();
1866
-	// permettre de vider la pile et de la restaurer
1867
-	// pour le calcul de introduction...
1868
-	if ($famille == '_spip_raz_') {
1869
-		$tmp = $mem;
1870
-		$mem = array();
1871
-
1872
-		return $tmp;
1873
-	} elseif ($famille == '_spip_set_') {
1874
-		$mem = $donnee;
1875
-
1876
-		return;
1877
-	}
1878
-	// eviter une notice
1879
-	if (!isset($mem[$famille])) {
1880
-		$mem[$famille] = array();
1881
-	}
1882
-	if ($cpt) {
1883
-		return count($mem[$famille]);
1884
-	}
1885
-	// eviter une notice
1886
-	if (!isset($mem[$famille][$donnee])) {
1887
-		$mem[$famille][$donnee] = 0;
1888
-	}
1889
-	if (!($mem[$famille][$donnee]++)) {
1890
-		return $donnee;
1891
-	}
1865
+    static $mem = array();
1866
+    // permettre de vider la pile et de la restaurer
1867
+    // pour le calcul de introduction...
1868
+    if ($famille == '_spip_raz_') {
1869
+        $tmp = $mem;
1870
+        $mem = array();
1871
+
1872
+        return $tmp;
1873
+    } elseif ($famille == '_spip_set_') {
1874
+        $mem = $donnee;
1875
+
1876
+        return;
1877
+    }
1878
+    // eviter une notice
1879
+    if (!isset($mem[$famille])) {
1880
+        $mem[$famille] = array();
1881
+    }
1882
+    if ($cpt) {
1883
+        return count($mem[$famille]);
1884
+    }
1885
+    // eviter une notice
1886
+    if (!isset($mem[$famille][$donnee])) {
1887
+        $mem[$famille][$donnee] = 0;
1888
+    }
1889
+    if (!($mem[$famille][$donnee]++)) {
1890
+        return $donnee;
1891
+    }
1892 1892
 }
1893 1893
 
1894 1894
 
@@ -1916,18 +1916,18 @@  discard block
 block discarded – undo
1916 1916
  *     Une des valeurs en fonction du compteur.
1917 1917
  **/
1918 1918
 function alterner($i) {
1919
-	// recuperer les arguments (attention fonctions un peu space)
1920
-	$num = func_num_args();
1921
-	$args = func_get_args();
1919
+    // recuperer les arguments (attention fonctions un peu space)
1920
+    $num = func_num_args();
1921
+    $args = func_get_args();
1922 1922
 
1923
-	if ($num == 2 && is_array($args[1])) {
1924
-		$args = $args[1];
1925
-		array_unshift($args, '');
1926
-		$num = count($args);
1927
-	}
1923
+    if ($num == 2 && is_array($args[1])) {
1924
+        $args = $args[1];
1925
+        array_unshift($args, '');
1926
+        $num = count($args);
1927
+    }
1928 1928
 
1929
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1930
-	return $args[(intval($i) - 1) % ($num - 1) + 1];
1929
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1930
+    return $args[(intval($i) - 1) % ($num - 1) + 1];
1931 1931
 }
1932 1932
 
1933 1933
 
@@ -1952,46 +1952,46 @@  discard block
 block discarded – undo
1952 1952
  *     - Tableau complet (si 2e argument)
1953 1953
  **/
1954 1954
 function extraire_attribut($balise, $attribut, $complet = false) {
1955
-	if (is_array($balise)) {
1956
-		array_walk(
1957
-			$balise,
1958
-			function(&$a, $key, $t){
1959
-				$a = extraire_attribut($a, $t);
1960
-			},
1961
-			$attribut
1962
-		);
1963
-
1964
-		return $balise;
1965
-	}
1966
-	if (preg_match(
1967
-		',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1968
-		. $attribut
1969
-		. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1970
-
1971
-		$balise, $r)) {
1972
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1973
-			$r[4] = substr($r[3], 1, -1);
1974
-			$r[3] = $r[3][0];
1975
-		} elseif ($r[3] !== '') {
1976
-			$r[4] = $r[3];
1977
-			$r[3] = '';
1978
-		} else {
1979
-			$r[4] = trim($r[2]);
1980
-		}
1981
-		$att = $r[4];
1982
-		if (strpos($att, "&#") !== false) {
1983
-			$att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1984
-		}
1985
-		$att = filtrer_entites($att);
1986
-	} else {
1987
-		$att = null;
1988
-	}
1989
-
1990
-	if ($complet) {
1991
-		return array($att, $r);
1992
-	} else {
1993
-		return $att;
1994
-	}
1955
+    if (is_array($balise)) {
1956
+        array_walk(
1957
+            $balise,
1958
+            function(&$a, $key, $t){
1959
+                $a = extraire_attribut($a, $t);
1960
+            },
1961
+            $attribut
1962
+        );
1963
+
1964
+        return $balise;
1965
+    }
1966
+    if (preg_match(
1967
+        ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1968
+        . $attribut
1969
+        . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1970
+
1971
+        $balise, $r)) {
1972
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1973
+            $r[4] = substr($r[3], 1, -1);
1974
+            $r[3] = $r[3][0];
1975
+        } elseif ($r[3] !== '') {
1976
+            $r[4] = $r[3];
1977
+            $r[3] = '';
1978
+        } else {
1979
+            $r[4] = trim($r[2]);
1980
+        }
1981
+        $att = $r[4];
1982
+        if (strpos($att, "&#") !== false) {
1983
+            $att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1984
+        }
1985
+        $att = filtrer_entites($att);
1986
+    } else {
1987
+        $att = null;
1988
+    }
1989
+
1990
+    if ($complet) {
1991
+        return array($att, $r);
1992
+    } else {
1993
+        return $att;
1994
+    }
1995 1995
 }
1996 1996
 
1997 1997
 /**
@@ -2023,37 +2023,37 @@  discard block
 block discarded – undo
2023 2023
  *     Code html modifié
2024 2024
  **/
2025 2025
 function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) {
2026
-	// preparer l'attribut
2027
-	// supprimer les &nbsp; etc mais pas les balises html
2028
-	// qui ont un sens dans un attribut value d'un input
2029
-	if ($proteger) {
2030
-		$val = attribut_html($val, false);
2031
-	}
2032
-
2033
-	// echapper les ' pour eviter tout bug
2034
-	$val = str_replace("'", "&#039;", $val);
2035
-	if ($vider and strlen($val) == 0) {
2036
-		$insert = '';
2037
-	} else {
2038
-		$insert = " $attribut='$val'";
2039
-	}
2040
-
2041
-	list($old, $r) = extraire_attribut($balise, $attribut, true);
2042
-
2043
-	if ($old !== null) {
2044
-		// Remplacer l'ancien attribut du meme nom
2045
-		$balise = $r[1] . $insert . $r[5];
2046
-	} else {
2047
-		// preferer une balise " />" (comme <img />)
2048
-		if (preg_match(',/>,', $balise)) {
2049
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2050
-		} // sinon une balise <a ...> ... </a>
2051
-		else {
2052
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2053
-		}
2054
-	}
2055
-
2056
-	return $balise;
2026
+    // preparer l'attribut
2027
+    // supprimer les &nbsp; etc mais pas les balises html
2028
+    // qui ont un sens dans un attribut value d'un input
2029
+    if ($proteger) {
2030
+        $val = attribut_html($val, false);
2031
+    }
2032
+
2033
+    // echapper les ' pour eviter tout bug
2034
+    $val = str_replace("'", "&#039;", $val);
2035
+    if ($vider and strlen($val) == 0) {
2036
+        $insert = '';
2037
+    } else {
2038
+        $insert = " $attribut='$val'";
2039
+    }
2040
+
2041
+    list($old, $r) = extraire_attribut($balise, $attribut, true);
2042
+
2043
+    if ($old !== null) {
2044
+        // Remplacer l'ancien attribut du meme nom
2045
+        $balise = $r[1] . $insert . $r[5];
2046
+    } else {
2047
+        // preferer une balise " />" (comme <img />)
2048
+        if (preg_match(',/>,', $balise)) {
2049
+            $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2050
+        } // sinon une balise <a ...> ... </a>
2051
+        else {
2052
+            $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2053
+        }
2054
+    }
2055
+
2056
+    return $balise;
2057 2057
 }
2058 2058
 
2059 2059
 /**
@@ -2071,7 +2071,7 @@  discard block
 block discarded – undo
2071 2071
  * @return string Code HTML sans l'attribut
2072 2072
  **/
2073 2073
 function vider_attribut($balise, $attribut) {
2074
-	return inserer_attribut($balise, $attribut, '', false, true);
2074
+    return inserer_attribut($balise, $attribut, '', false, true);
2075 2075
 }
2076 2076
 
2077 2077
 /**
@@ -2083,50 +2083,50 @@  discard block
 block discarded – undo
2083 2083
  * @return string
2084 2084
  */
2085 2085
 function modifier_class($balise, $class, $operation='ajouter') {
2086
-	if (is_string($class)) {
2087
-		$class = explode(' ', trim($class));
2088
-	}
2089
-	$class = array_filter($class);
2090
-
2091
-	// si la ou les classes ont des caracteres invalides on ne fait rien
2092
-	if (preg_match(",[^\w-],", implode('', $class))) {
2093
-		return $balise;
2094
-	}
2095
-
2096
-	if ($class) {
2097
-		$class = array_unique($class);
2098
-		$class_courante = extraire_attribut($balise, 'class');
2099
-
2100
-		$class_new = $class_courante;
2101
-		foreach ($class as $c) {
2102
-			if ($c) {
2103
-				$is_class_presente = false;
2104
-				if (strpos($class_courante, $c) !== false
2105
-					and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) {
2106
-					$is_class_presente = true;
2107
-				}
2108
-				if (in_array($operation, ['ajouter', 'commuter'])
2109
-					and !$is_class_presente) {
2110
-					$class_new = rtrim($class_new) . " " . $c;
2111
-				}
2112
-				elseif (in_array($operation, ['supprimer', 'commuter'])
2113
-					and $is_class_presente) {
2114
-					$class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new));
2115
-				}
2116
-			}
2117
-		}
2118
-
2119
-		if ($class_new !== $class_courante) {
2120
-			if (strlen($class_new)) {
2121
-				$balise = inserer_attribut($balise, 'class', $class_new);
2122
-			}
2123
-			elseif ($class_courante) {
2124
-				$balise = vider_attribut($balise, 'class');
2125
-			}
2126
-		}
2127
-	}
2128
-
2129
-	return $balise;
2086
+    if (is_string($class)) {
2087
+        $class = explode(' ', trim($class));
2088
+    }
2089
+    $class = array_filter($class);
2090
+
2091
+    // si la ou les classes ont des caracteres invalides on ne fait rien
2092
+    if (preg_match(",[^\w-],", implode('', $class))) {
2093
+        return $balise;
2094
+    }
2095
+
2096
+    if ($class) {
2097
+        $class = array_unique($class);
2098
+        $class_courante = extraire_attribut($balise, 'class');
2099
+
2100
+        $class_new = $class_courante;
2101
+        foreach ($class as $c) {
2102
+            if ($c) {
2103
+                $is_class_presente = false;
2104
+                if (strpos($class_courante, $c) !== false
2105
+                    and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) {
2106
+                    $is_class_presente = true;
2107
+                }
2108
+                if (in_array($operation, ['ajouter', 'commuter'])
2109
+                    and !$is_class_presente) {
2110
+                    $class_new = rtrim($class_new) . " " . $c;
2111
+                }
2112
+                elseif (in_array($operation, ['supprimer', 'commuter'])
2113
+                    and $is_class_presente) {
2114
+                    $class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new));
2115
+                }
2116
+            }
2117
+        }
2118
+
2119
+        if ($class_new !== $class_courante) {
2120
+            if (strlen($class_new)) {
2121
+                $balise = inserer_attribut($balise, 'class', $class_new);
2122
+            }
2123
+            elseif ($class_courante) {
2124
+                $balise = vider_attribut($balise, 'class');
2125
+            }
2126
+        }
2127
+    }
2128
+
2129
+    return $balise;
2130 2130
 }
2131 2131
 
2132 2132
 /**
@@ -2136,7 +2136,7 @@  discard block
 block discarded – undo
2136 2136
  * @return string
2137 2137
  */
2138 2138
 function ajouter_class($balise, $class){
2139
-	return modifier_class($balise, $class, 'ajouter');
2139
+    return modifier_class($balise, $class, 'ajouter');
2140 2140
 }
2141 2141
 
2142 2142
 /**
@@ -2146,7 +2146,7 @@  discard block
 block discarded – undo
2146 2146
  * @return string
2147 2147
  */
2148 2148
 function supprimer_class($balise, $class){
2149
-	return modifier_class($balise, $class, 'supprimer');
2149
+    return modifier_class($balise, $class, 'supprimer');
2150 2150
 }
2151 2151
 
2152 2152
 /**
@@ -2157,7 +2157,7 @@  discard block
 block discarded – undo
2157 2157
  * @return string
2158 2158
  */
2159 2159
 function commuter_class($balise, $class){
2160
-	return modifier_class($balise, $class, 'commuter');
2160
+    return modifier_class($balise, $class, 'commuter');
2161 2161
 }
2162 2162
 
2163 2163
 /**
@@ -2168,9 +2168,9 @@  discard block
 block discarded – undo
2168 2168
  * @return string
2169 2169
  */
2170 2170
 function tester_config($id, $mode = '') {
2171
-	include_spip('action/inscrire_auteur');
2171
+    include_spip('action/inscrire_auteur');
2172 2172
 
2173
-	return tester_statut_inscription($mode, $id);
2173
+    return tester_statut_inscription($mode, $id);
2174 2174
 }
2175 2175
 
2176 2176
 //
@@ -2195,7 +2195,7 @@  discard block
 block discarded – undo
2195 2195
  * @return int $a+$b
2196 2196
  **/
2197 2197
 function plus($a, $b) {
2198
-	return $a + $b;
2198
+    return $a + $b;
2199 2199
 }
2200 2200
 function strplus($a, $b) {return strize('plus', $a, $b);}
2201 2201
 /**
@@ -2214,7 +2214,7 @@  discard block
 block discarded – undo
2214 2214
  * @return int $a-$b
2215 2215
  **/
2216 2216
 function moins($a, $b) {
2217
-	return $a - $b;
2217
+    return $a - $b;
2218 2218
 }
2219 2219
 function strmoins($a, $b) {return strize('moins', $a, $b);}
2220 2220
 
@@ -2235,7 +2235,7 @@  discard block
 block discarded – undo
2235 2235
  * @return int $a*$b
2236 2236
  **/
2237 2237
 function mult($a, $b) {
2238
-	return $a * $b;
2238
+    return $a * $b;
2239 2239
 }
2240 2240
 function strmult($a, $b) {return strize('mult', $a, $b);}
2241 2241
 
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
  * @return int $a/$b (ou 0 si $b est nul)
2257 2257
  **/
2258 2258
 function div($a, $b) {
2259
-	return $b ? $a / $b : 0;
2259
+    return $b ? $a / $b : 0;
2260 2260
 }
2261 2261
 function strdiv($a, $b) {return strize('div', $a, $b);}
2262 2262
 
@@ -2278,7 +2278,7 @@  discard block
 block discarded – undo
2278 2278
  * @return int ($nb % $mod) + $add
2279 2279
  **/
2280 2280
 function modulo($nb, $mod, $add = 0) {
2281
-	return ($mod ? $nb % $mod : 0) + $add;
2281
+    return ($mod ? $nb % $mod : 0) + $add;
2282 2282
 }
2283 2283
 
2284 2284
 
@@ -2293,24 +2293,24 @@  discard block
 block discarded – undo
2293 2293
  *      - true sinon
2294 2294
  **/
2295 2295
 function nom_acceptable($nom) {
2296
-	if (!is_string($nom)) {
2297
-		return false;
2298
-	}
2299
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2300
-		define('_TAGS_NOM_AUTEUR', '');
2301
-	}
2302
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2303
-	foreach ($tags_acceptes as $tag) {
2304
-		if (strlen($tag)) {
2305
-			$remp1[] = '<' . trim($tag) . '>';
2306
-			$remp1[] = '</' . trim($tag) . '>';
2307
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2308
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2309
-		}
2310
-	}
2311
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2296
+    if (!is_string($nom)) {
2297
+        return false;
2298
+    }
2299
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2300
+        define('_TAGS_NOM_AUTEUR', '');
2301
+    }
2302
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2303
+    foreach ($tags_acceptes as $tag) {
2304
+        if (strlen($tag)) {
2305
+            $remp1[] = '<' . trim($tag) . '>';
2306
+            $remp1[] = '</' . trim($tag) . '>';
2307
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2308
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2309
+        }
2310
+    }
2311
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2312 2312
 
2313
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2313
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2314 2314
 }
2315 2315
 
2316 2316
 
@@ -2326,14 +2326,14 @@  discard block
 block discarded – undo
2326 2326
  *      - renvoie un tableau si l'entree est un tableau
2327 2327
  **/
2328 2328
 function email_valide($adresses) {
2329
-	if (is_array($adresses)) {
2330
-		$adresses = array_map('email_valide', $adresses);
2331
-		$adresses = array_filter($adresses);
2332
-		return $adresses;
2333
-	}
2329
+    if (is_array($adresses)) {
2330
+        $adresses = array_map('email_valide', $adresses);
2331
+        $adresses = array_filter($adresses);
2332
+        return $adresses;
2333
+    }
2334 2334
 
2335
-	$email_valide = charger_fonction('email_valide', 'inc');
2336
-	return $email_valide($adresses);
2335
+    $email_valide = charger_fonction('email_valide', 'inc');
2336
+    return $email_valide($adresses);
2337 2337
 }
2338 2338
 
2339 2339
 /**
@@ -2347,20 +2347,20 @@  discard block
 block discarded – undo
2347 2347
  * @return string Texte
2348 2348
  **/
2349 2349
 function afficher_enclosures($tags) {
2350
-	$s = array();
2351
-	foreach (extraire_balises($tags, 'a') as $tag) {
2352
-		if (extraire_attribut($tag, 'rel') == 'enclosure'
2353
-			and $t = extraire_attribut($tag, 'href')
2354
-		) {
2355
-			$s[] = preg_replace(',>[^<]+</a>,S',
2356
-				'>'
2357
-				. http_img_pack('attachment-16.png', $t,
2358
-					'title="' . attribut_html($t) . '"')
2359
-				. '</a>', $tag);
2360
-		}
2361
-	}
2350
+    $s = array();
2351
+    foreach (extraire_balises($tags, 'a') as $tag) {
2352
+        if (extraire_attribut($tag, 'rel') == 'enclosure'
2353
+            and $t = extraire_attribut($tag, 'href')
2354
+        ) {
2355
+            $s[] = preg_replace(',>[^<]+</a>,S',
2356
+                '>'
2357
+                . http_img_pack('attachment-16.png', $t,
2358
+                    'title="' . attribut_html($t) . '"')
2359
+                . '</a>', $tag);
2360
+        }
2361
+    }
2362 2362
 
2363
-	return join('&nbsp;', $s);
2363
+    return join('&nbsp;', $s);
2364 2364
 }
2365 2365
 
2366 2366
 /**
@@ -2375,15 +2375,15 @@  discard block
 block discarded – undo
2375 2375
  * @return string Liens trouvés
2376 2376
  **/
2377 2377
 function afficher_tags($tags, $rels = 'tag,directory') {
2378
-	$s = array();
2379
-	foreach (extraire_balises($tags, 'a') as $tag) {
2380
-		$rel = extraire_attribut($tag, 'rel');
2381
-		if (strstr(",$rels,", ",$rel,")) {
2382
-			$s[] = $tag;
2383
-		}
2384
-	}
2378
+    $s = array();
2379
+    foreach (extraire_balises($tags, 'a') as $tag) {
2380
+        $rel = extraire_attribut($tag, 'rel');
2381
+        if (strstr(",$rels,", ",$rel,")) {
2382
+            $s[] = $tag;
2383
+        }
2384
+    }
2385 2385
 
2386
-	return join(', ', $s);
2386
+    return join(', ', $s);
2387 2387
 }
2388 2388
 
2389 2389
 
@@ -2405,21 +2405,21 @@  discard block
 block discarded – undo
2405 2405
  * @return string Tag HTML `<a>` avec microformat.
2406 2406
  **/
2407 2407
 function enclosure2microformat($e) {
2408
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2409
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2410
-	}
2411
-	$type = extraire_attribut($e, 'type');
2412
-	if (!$length = extraire_attribut($e, 'length')) {
2413
-		# <media:content : longeur dans fileSize. On tente.
2414
-		$length = extraire_attribut($e, 'fileSize');
2415
-	}
2416
-	$fichier = basename($url);
2408
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2409
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2410
+    }
2411
+    $type = extraire_attribut($e, 'type');
2412
+    if (!$length = extraire_attribut($e, 'length')) {
2413
+        # <media:content : longeur dans fileSize. On tente.
2414
+        $length = extraire_attribut($e, 'fileSize');
2415
+    }
2416
+    $fichier = basename($url);
2417 2417
 
2418
-	return '<a rel="enclosure"'
2419
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2420
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2421
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2422
-	. '>' . $fichier . '</a>';
2418
+    return '<a rel="enclosure"'
2419
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2420
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2421
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2422
+    . '>' . $fichier . '</a>';
2423 2423
 }
2424 2424
 
2425 2425
 /**
@@ -2437,24 +2437,24 @@  discard block
 block discarded – undo
2437 2437
  * @return string Tags RSS `<enclosure>`.
2438 2438
  **/
2439 2439
 function microformat2enclosure($tags) {
2440
-	$enclosures = array();
2441
-	foreach (extraire_balises($tags, 'a') as $e) {
2442
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2443
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2444
-			$type = extraire_attribut($e, 'type');
2445
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2446
-				$length = intval(extraire_attribut($e, 'length'));
2447
-			} # vieux data
2448
-			$fichier = basename($url);
2449
-			$enclosures[] = '<enclosure'
2450
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2451
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2452
-				. ($length ? ' length="' . $length . '"' : '')
2453
-				. ' />';
2454
-		}
2455
-	}
2440
+    $enclosures = array();
2441
+    foreach (extraire_balises($tags, 'a') as $e) {
2442
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2443
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2444
+            $type = extraire_attribut($e, 'type');
2445
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2446
+                $length = intval(extraire_attribut($e, 'length'));
2447
+            } # vieux data
2448
+            $fichier = basename($url);
2449
+            $enclosures[] = '<enclosure'
2450
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2451
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2452
+                . ($length ? ' length="' . $length . '"' : '')
2453
+                . ' />';
2454
+        }
2455
+    }
2456 2456
 
2457
-	return join("\n", $enclosures);
2457
+    return join("\n", $enclosures);
2458 2458
 }
2459 2459
 
2460 2460
 
@@ -2470,16 +2470,16 @@  discard block
 block discarded – undo
2470 2470
  * @return string Tags RSS Atom `<dc:subject>`.
2471 2471
  **/
2472 2472
 function tags2dcsubject($tags) {
2473
-	$subjects = '';
2474
-	foreach (extraire_balises($tags, 'a') as $e) {
2475
-		if (extraire_attribut($e, 'rel') == 'tag') {
2476
-			$subjects .= '<dc:subject>'
2477
-				. texte_backend(textebrut($e))
2478
-				. '</dc:subject>' . "\n";
2479
-		}
2480
-	}
2473
+    $subjects = '';
2474
+    foreach (extraire_balises($tags, 'a') as $e) {
2475
+        if (extraire_attribut($e, 'rel') == 'tag') {
2476
+            $subjects .= '<dc:subject>'
2477
+                . texte_backend(textebrut($e))
2478
+                . '</dc:subject>' . "\n";
2479
+        }
2480
+    }
2481 2481
 
2482
-	return $subjects;
2482
+    return $subjects;
2483 2483
 }
2484 2484
 
2485 2485
 /**
@@ -2508,23 +2508,23 @@  discard block
 block discarded – undo
2508 2508
  *     - Tableau de résultats, si tableau en entrée.
2509 2509
  **/
2510 2510
 function extraire_balise($texte, $tag = 'a') {
2511
-	if (is_array($texte)) {
2512
-		array_walk(
2513
-			$texte,
2514
-			function(&$a, $key, $t){
2515
-				$a = extraire_balise($a, $t);
2516
-			},
2517
-			$tag
2518
-		);
2511
+    if (is_array($texte)) {
2512
+        array_walk(
2513
+            $texte,
2514
+            function(&$a, $key, $t){
2515
+                $a = extraire_balise($a, $t);
2516
+            },
2517
+            $tag
2518
+        );
2519 2519
 
2520
-		return $texte;
2521
-	}
2520
+        return $texte;
2521
+    }
2522 2522
 
2523
-	if (preg_match(
2524
-		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2525
-		$texte, $regs)) {
2526
-		return $regs[0];
2527
-	}
2523
+    if (preg_match(
2524
+        ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2525
+        $texte, $regs)) {
2526
+        return $regs[0];
2527
+    }
2528 2528
 }
2529 2529
 
2530 2530
 /**
@@ -2552,25 +2552,25 @@  discard block
 block discarded – undo
2552 2552
  *     - Tableau de résultats, si tableau en entrée.
2553 2553
  **/
2554 2554
 function extraire_balises($texte, $tag = 'a') {
2555
-	if (is_array($texte)) {
2556
-		array_walk(
2557
-			$texte,
2558
-			function(&$a, $key, $t){
2559
-				$a = extraire_balises($a, $t);
2560
-			},
2561
-			$tag
2562
-		);
2555
+    if (is_array($texte)) {
2556
+        array_walk(
2557
+            $texte,
2558
+            function(&$a, $key, $t){
2559
+                $a = extraire_balises($a, $t);
2560
+            },
2561
+            $tag
2562
+        );
2563 2563
 
2564
-		return $texte;
2565
-	}
2564
+        return $texte;
2565
+    }
2566 2566
 
2567
-	if (preg_match_all(
2568
-		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2569
-		$texte, $regs, PREG_PATTERN_ORDER)) {
2570
-		return $regs[0];
2571
-	} else {
2572
-		return array();
2573
-	}
2567
+    if (preg_match_all(
2568
+        ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2569
+        $texte, $regs, PREG_PATTERN_ORDER)) {
2570
+        return $regs[0];
2571
+    } else {
2572
+        return array();
2573
+    }
2574 2574
 }
2575 2575
 
2576 2576
 /**
@@ -2599,11 +2599,11 @@  discard block
 block discarded – undo
2599 2599
  *     - `$def` si on n'a pas transmis de tableau
2600 2600
  **/
2601 2601
 function in_any($val, $vals, $def = '') {
2602
-	if (!is_array($vals) and $v = unserialize($vals)) {
2603
-		$vals = $v;
2604
-	}
2602
+    if (!is_array($vals) and $v = unserialize($vals)) {
2603
+        $vals = $v;
2604
+    }
2605 2605
 
2606
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2606
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2607 2607
 }
2608 2608
 
2609 2609
 
@@ -2624,12 +2624,12 @@  discard block
 block discarded – undo
2624 2624
  *     Résultat du calcul
2625 2625
  **/
2626 2626
 function valeur_numerique($expr) {
2627
-	$a = 0;
2628
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2629
-		eval("\$a = $expr;");
2630
-	}
2627
+    $a = 0;
2628
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2629
+        eval("\$a = $expr;");
2630
+    }
2631 2631
 
2632
-	return intval($a);
2632
+    return intval($a);
2633 2633
 }
2634 2634
 
2635 2635
 /**
@@ -2648,7 +2648,7 @@  discard block
 block discarded – undo
2648 2648
  *      Retourne `$a*$b/$c`
2649 2649
  **/
2650 2650
 function regledetrois($a, $b, $c) {
2651
-	return round($a * $b / $c);
2651
+    return round($a * $b / $c);
2652 2652
 }
2653 2653
 
2654 2654
 
@@ -2672,76 +2672,76 @@  discard block
 block discarded – undo
2672 2672
  **/
2673 2673
 function form_hidden($action) {
2674 2674
 
2675
-	$contexte = array();
2676
-	include_spip('inc/urls');
2677
-	if ($p = urls_decoder_url($action, '')
2678
-		and reset($p)
2679
-	) {
2680
-		$fond = array_shift($p);
2681
-		if ($fond != '404') {
2682
-			$contexte = array_shift($p);
2683
-			$contexte['page'] = $fond;
2684
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2685
-		}
2686
-	}
2687
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2688
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2689
-		unset($contexte['type']);
2690
-	}
2691
-	if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2692
-		unset($contexte['type-page']);
2693
-	}
2694
-
2695
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2696
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2697
-	$values = array();
2698
-
2699
-	// d'abord avec celles de l'url
2700
-	if (false !== ($p = strpos($action, '?'))) {
2701
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2702
-			$c = explode('=', $c, 2);
2703
-			$var = array_shift($c);
2704
-			$val = array_shift($c);
2705
-			if ($var) {
2706
-				$val = rawurldecode($val);
2707
-				$var = rawurldecode($var); // decoder les [] eventuels
2708
-				if (preg_match(',\[\]$,S', $var)) {
2709
-					$values[] = array($var, $val);
2710
-				} else {
2711
-					if (!isset($values[$var])) {
2712
-						$values[$var] = array($var, $val);
2713
-					}
2714
-				}
2715
-			}
2716
-		}
2717
-	}
2718
-
2719
-	// ensuite avec celles du contexte, sans doublonner !
2720
-	foreach ($contexte as $var => $val) {
2721
-		if (preg_match(',\[\]$,S', $var)) {
2722
-			$values[] = array($var, $val);
2723
-		} else {
2724
-			if (!isset($values[$var])) {
2725
-				$values[$var] = array($var, $val);
2726
-			}
2727
-		}
2728
-	}
2729
-
2730
-	// puis on rassemble le tout
2731
-	$hidden = array();
2732
-	foreach ($values as $value) {
2733
-		list($var, $val) = $value;
2734
-		$hidden[] = '<input name="'
2735
-			. entites_html($var)
2736
-			. '"'
2737
-			. (is_null($val)
2738
-				? ''
2739
-				: ' value="' . entites_html($val) . '"'
2740
-			)
2741
-			. ' type="hidden"' . "\n/>";
2742
-	}
2743
-
2744
-	return join("", $hidden);
2675
+    $contexte = array();
2676
+    include_spip('inc/urls');
2677
+    if ($p = urls_decoder_url($action, '')
2678
+        and reset($p)
2679
+    ) {
2680
+        $fond = array_shift($p);
2681
+        if ($fond != '404') {
2682
+            $contexte = array_shift($p);
2683
+            $contexte['page'] = $fond;
2684
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2685
+        }
2686
+    }
2687
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2688
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2689
+        unset($contexte['type']);
2690
+    }
2691
+    if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2692
+        unset($contexte['type-page']);
2693
+    }
2694
+
2695
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2696
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2697
+    $values = array();
2698
+
2699
+    // d'abord avec celles de l'url
2700
+    if (false !== ($p = strpos($action, '?'))) {
2701
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2702
+            $c = explode('=', $c, 2);
2703
+            $var = array_shift($c);
2704
+            $val = array_shift($c);
2705
+            if ($var) {
2706
+                $val = rawurldecode($val);
2707
+                $var = rawurldecode($var); // decoder les [] eventuels
2708
+                if (preg_match(',\[\]$,S', $var)) {
2709
+                    $values[] = array($var, $val);
2710
+                } else {
2711
+                    if (!isset($values[$var])) {
2712
+                        $values[$var] = array($var, $val);
2713
+                    }
2714
+                }
2715
+            }
2716
+        }
2717
+    }
2718
+
2719
+    // ensuite avec celles du contexte, sans doublonner !
2720
+    foreach ($contexte as $var => $val) {
2721
+        if (preg_match(',\[\]$,S', $var)) {
2722
+            $values[] = array($var, $val);
2723
+        } else {
2724
+            if (!isset($values[$var])) {
2725
+                $values[$var] = array($var, $val);
2726
+            }
2727
+        }
2728
+    }
2729
+
2730
+    // puis on rassemble le tout
2731
+    $hidden = array();
2732
+    foreach ($values as $value) {
2733
+        list($var, $val) = $value;
2734
+        $hidden[] = '<input name="'
2735
+            . entites_html($var)
2736
+            . '"'
2737
+            . (is_null($val)
2738
+                ? ''
2739
+                : ' value="' . entites_html($val) . '"'
2740
+            )
2741
+            . ' type="hidden"' . "\n/>";
2742
+    }
2743
+
2744
+    return join("", $hidden);
2745 2745
 }
2746 2746
 
2747 2747
 /**
@@ -2759,15 +2759,15 @@  discard block
 block discarded – undo
2759 2759
  *     Liste (première page, dernière page).
2760 2760
  **/
2761 2761
 function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) {
2762
-	if ($max <= 0 or $max >= $nombre) {
2763
-		return array(1, $nombre);
2764
-	}
2762
+    if ($max <= 0 or $max >= $nombre) {
2763
+        return array(1, $nombre);
2764
+    }
2765 2765
 
2766
-	$premiere = max(1, $courante - floor(($max - 1) / 2));
2767
-	$derniere = min($nombre, $premiere + $max - 2);
2768
-	$premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2766
+    $premiere = max(1, $courante - floor(($max - 1) / 2));
2767
+    $derniere = min($nombre, $premiere + $max - 2);
2768
+    $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2769 2769
 
2770
-	return array($premiere, $derniere);
2770
+    return array($premiere, $derniere);
2771 2771
 }
2772 2772
 
2773 2773
 
@@ -2789,7 +2789,7 @@  discard block
 block discarded – undo
2789 2789
  *    - la première valeur du tableau sinon.
2790 2790
  **/
2791 2791
 function filtre_reset($array) {
2792
-	return !is_array($array) ? null : reset($array);
2792
+    return !is_array($array) ? null : reset($array);
2793 2793
 }
2794 2794
 
2795 2795
 /**
@@ -2810,7 +2810,7 @@  discard block
 block discarded – undo
2810 2810
  *    - la dernière valeur du tableau sinon.
2811 2811
  **/
2812 2812
 function filtre_end($array) {
2813
-	return !is_array($array) ? null : end($array);
2813
+    return !is_array($array) ? null : end($array);
2814 2814
 }
2815 2815
 
2816 2816
 /**
@@ -2830,11 +2830,11 @@  discard block
 block discarded – undo
2830 2830
  *
2831 2831
  **/
2832 2832
 function filtre_push($array, $val) {
2833
-	if (!is_array($array) or !array_push($array, $val)) {
2834
-		return '';
2835
-	}
2833
+    if (!is_array($array) or !array_push($array, $val)) {
2834
+        return '';
2835
+    }
2836 2836
 
2837
-	return $array;
2837
+    return $array;
2838 2838
 }
2839 2839
 
2840 2840
 /**
@@ -2853,7 +2853,7 @@  discard block
 block discarded – undo
2853 2853
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2854 2854
  **/
2855 2855
 function filtre_find($array, $val) {
2856
-	return (is_array($array) and in_array($val, $array));
2856
+    return (is_array($array) and in_array($val, $array));
2857 2857
 }
2858 2858
 
2859 2859
 
@@ -2870,15 +2870,15 @@  discard block
 block discarded – undo
2870 2870
  *     Contenu avec urls en absolus
2871 2871
  **/
2872 2872
 function urls_absolues_css($contenu, $source) {
2873
-	$path = suivre_lien(url_absolue($source), './');
2873
+    $path = suivre_lien(url_absolue($source), './');
2874 2874
 
2875
-	return preg_replace_callback(
2876
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2877
-		function($x) use ($path) {
2878
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2879
-		},
2880
-		$contenu
2881
-	);
2875
+    return preg_replace_callback(
2876
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2877
+        function($x) use ($path) {
2878
+            return "url('" . suivre_lien($path, $x[1]) . "')";
2879
+        },
2880
+        $contenu
2881
+    );
2882 2882
 }
2883 2883
 
2884 2884
 
@@ -2907,118 +2907,118 @@  discard block
 block discarded – undo
2907 2907
  *     Chemin du fichier CSS inversé
2908 2908
  **/
2909 2909
 function direction_css($css, $voulue = '') {
2910
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2911
-		return $css;
2912
-	}
2913
-
2914
-	// si on a precise le sens voulu en argument, le prendre en compte
2915
-	if ($voulue = strtolower($voulue)) {
2916
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2917
-			$voulue = lang_dir($voulue);
2918
-		}
2919
-	} else {
2920
-		$voulue = lang_dir();
2921
-	}
2922
-
2923
-	$r = count($r) > 1;
2924
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2925
-	$dir = $r ? 'rtl' : 'ltr';
2926
-	$ndir = $r ? 'ltr' : 'rtl';
2927
-
2928
-	if ($voulue == $dir) {
2929
-		return $css;
2930
-	}
2931
-
2932
-	if (
2933
-		// url absolue
2934
-		preg_match(",^https?:,i", $css)
2935
-		// ou qui contient un ?
2936
-		or (($p = strpos($css, '?')) !== false)
2937
-	) {
2938
-		$distant = true;
2939
-		$cssf = parse_url($css);
2940
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2941
-		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2942
-	} else {
2943
-		$distant = false;
2944
-		$cssf = $css;
2945
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2946
-		//propose (rien a faire dans ce cas)
2947
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2948
-		if (@file_exists($f)) {
2949
-			return $f;
2950
-		}
2951
-	}
2952
-
2953
-	// 2.
2954
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2955
-	$f = $dir_var
2956
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2957
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2958
-
2959
-	// la css peut etre distante (url absolue !)
2960
-	if ($distant) {
2961
-		include_spip('inc/distant');
2962
-		$res = recuperer_url($css);
2963
-		if (!$res or !$contenu = $res['page']) {
2964
-			return $css;
2965
-		}
2966
-	} else {
2967
-		if ((@filemtime($f) > @filemtime($css))
2968
-			and (_VAR_MODE != 'recalcul')
2969
-		) {
2970
-			return $f;
2971
-		}
2972
-		if (!lire_fichier($css, $contenu)) {
2973
-			return $css;
2974
-		}
2975
-	}
2976
-
2977
-
2978
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2979
-	include_spip("lib/csstidy/class.csstidy");
2980
-	$parser = new csstidy();
2981
-	$parser->set_cfg('optimise_shorthands', 0);
2982
-	$parser->set_cfg('reverse_left_and_right', true);
2983
-	$parser->parse($contenu);
2984
-
2985
-	$contenu = $parser->print->plain();
2986
-
2987
-
2988
-	// reperer les @import auxquels il faut propager le direction_css
2989
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2990
-	$src = array();
2991
-	$src_direction_css = array();
2992
-	$src_faux_abs = array();
2993
-	$d = dirname($css);
2994
-	foreach ($regs[1] as $k => $import_css) {
2995
-		$css_direction = direction_css("$d/$import_css", $voulue);
2996
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2997
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2998
-			$css_direction = substr($css_direction, strlen($d) + 1);
2999
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
3000
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3001
-			$css_direction = substr($css_direction, strlen($dir_var));
3002
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
3003
-			$css_direction = "/@@@@@@/" . $css_direction;
3004
-		}
3005
-		$src[] = $regs[0][$k];
3006
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3007
-	}
3008
-	$contenu = str_replace($src, $src_direction_css, $contenu);
3009
-
3010
-	$contenu = urls_absolues_css($contenu, $css);
3011
-
3012
-	// virer les fausses url absolues que l'on a mis dans les import
3013
-	if (count($src_faux_abs)) {
3014
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3015
-	}
3016
-
3017
-	if (!ecrire_fichier($f, $contenu)) {
3018
-		return $css;
3019
-	}
3020
-
3021
-	return $f;
2910
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2911
+        return $css;
2912
+    }
2913
+
2914
+    // si on a precise le sens voulu en argument, le prendre en compte
2915
+    if ($voulue = strtolower($voulue)) {
2916
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2917
+            $voulue = lang_dir($voulue);
2918
+        }
2919
+    } else {
2920
+        $voulue = lang_dir();
2921
+    }
2922
+
2923
+    $r = count($r) > 1;
2924
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2925
+    $dir = $r ? 'rtl' : 'ltr';
2926
+    $ndir = $r ? 'ltr' : 'rtl';
2927
+
2928
+    if ($voulue == $dir) {
2929
+        return $css;
2930
+    }
2931
+
2932
+    if (
2933
+        // url absolue
2934
+        preg_match(",^https?:,i", $css)
2935
+        // ou qui contient un ?
2936
+        or (($p = strpos($css, '?')) !== false)
2937
+    ) {
2938
+        $distant = true;
2939
+        $cssf = parse_url($css);
2940
+        $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2941
+        $cssf = preg_replace(',[?:&=],', "_", $cssf);
2942
+    } else {
2943
+        $distant = false;
2944
+        $cssf = $css;
2945
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2946
+        //propose (rien a faire dans ce cas)
2947
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2948
+        if (@file_exists($f)) {
2949
+            return $f;
2950
+        }
2951
+    }
2952
+
2953
+    // 2.
2954
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2955
+    $f = $dir_var
2956
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2957
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2958
+
2959
+    // la css peut etre distante (url absolue !)
2960
+    if ($distant) {
2961
+        include_spip('inc/distant');
2962
+        $res = recuperer_url($css);
2963
+        if (!$res or !$contenu = $res['page']) {
2964
+            return $css;
2965
+        }
2966
+    } else {
2967
+        if ((@filemtime($f) > @filemtime($css))
2968
+            and (_VAR_MODE != 'recalcul')
2969
+        ) {
2970
+            return $f;
2971
+        }
2972
+        if (!lire_fichier($css, $contenu)) {
2973
+            return $css;
2974
+        }
2975
+    }
2976
+
2977
+
2978
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2979
+    include_spip("lib/csstidy/class.csstidy");
2980
+    $parser = new csstidy();
2981
+    $parser->set_cfg('optimise_shorthands', 0);
2982
+    $parser->set_cfg('reverse_left_and_right', true);
2983
+    $parser->parse($contenu);
2984
+
2985
+    $contenu = $parser->print->plain();
2986
+
2987
+
2988
+    // reperer les @import auxquels il faut propager le direction_css
2989
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2990
+    $src = array();
2991
+    $src_direction_css = array();
2992
+    $src_faux_abs = array();
2993
+    $d = dirname($css);
2994
+    foreach ($regs[1] as $k => $import_css) {
2995
+        $css_direction = direction_css("$d/$import_css", $voulue);
2996
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2997
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2998
+            $css_direction = substr($css_direction, strlen($d) + 1);
2999
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
3000
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3001
+            $css_direction = substr($css_direction, strlen($dir_var));
3002
+            $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
3003
+            $css_direction = "/@@@@@@/" . $css_direction;
3004
+        }
3005
+        $src[] = $regs[0][$k];
3006
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3007
+    }
3008
+    $contenu = str_replace($src, $src_direction_css, $contenu);
3009
+
3010
+    $contenu = urls_absolues_css($contenu, $css);
3011
+
3012
+    // virer les fausses url absolues que l'on a mis dans les import
3013
+    if (count($src_faux_abs)) {
3014
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3015
+    }
3016
+
3017
+    if (!ecrire_fichier($f, $contenu)) {
3018
+        return $css;
3019
+    }
3020
+
3021
+    return $f;
3022 3022
 }
3023 3023
 
3024 3024
 
@@ -3041,43 +3041,43 @@  discard block
 block discarded – undo
3041 3041
  *     - Chemin ou URL du fichier CSS source sinon.
3042 3042
  **/
3043 3043
 function url_absolue_css($css) {
3044
-	if (!preg_match(',\.css$,i', $css, $r)) {
3045
-		return $css;
3046
-	}
3044
+    if (!preg_match(',\.css$,i', $css, $r)) {
3045
+        return $css;
3046
+    }
3047 3047
 
3048
-	$url_absolue_css = url_absolue($css);
3048
+    $url_absolue_css = url_absolue($css);
3049 3049
 
3050
-	$f = basename($css, '.css');
3051
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3052
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3053
-		. '.css';
3050
+    $f = basename($css, '.css');
3051
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3052
+        . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3053
+        . '.css';
3054 3054
 
3055
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3056
-		return $f;
3057
-	}
3055
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3056
+        return $f;
3057
+    }
3058 3058
 
3059
-	if ($url_absolue_css == $css) {
3060
-		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3061
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3062
-		) {
3063
-			include_spip('inc/distant');
3064
-			if (!$contenu = recuperer_page($css)) {
3065
-				return $css;
3066
-			}
3067
-		}
3068
-	} elseif (!lire_fichier($css, $contenu)) {
3069
-		return $css;
3070
-	}
3059
+    if ($url_absolue_css == $css) {
3060
+        if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3061
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3062
+        ) {
3063
+            include_spip('inc/distant');
3064
+            if (!$contenu = recuperer_page($css)) {
3065
+                return $css;
3066
+            }
3067
+        }
3068
+    } elseif (!lire_fichier($css, $contenu)) {
3069
+        return $css;
3070
+    }
3071 3071
 
3072
-	// passer les url relatives a la css d'origine en url absolues
3073
-	$contenu = urls_absolues_css($contenu, $css);
3072
+    // passer les url relatives a la css d'origine en url absolues
3073
+    $contenu = urls_absolues_css($contenu, $css);
3074 3074
 
3075
-	// ecrire la css
3076
-	if (!ecrire_fichier($f, $contenu)) {
3077
-		return $css;
3078
-	}
3075
+    // ecrire la css
3076
+    if (!ecrire_fichier($f, $contenu)) {
3077
+        return $css;
3078
+    }
3079 3079
 
3080
-	return $f;
3080
+    return $f;
3081 3081
 }
3082 3082
 
3083 3083
 
@@ -3111,24 +3111,24 @@  discard block
 block discarded – undo
3111 3111
  *     Valeur trouvée ou valeur par défaut.
3112 3112
  **/
3113 3113
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3114
-	foreach (explode('/', $cle) as $k) {
3114
+    foreach (explode('/', $cle) as $k) {
3115 3115
 
3116
-		$table = is_string($table) ? @unserialize($table) : $table;
3116
+        $table = is_string($table) ? @unserialize($table) : $table;
3117 3117
 
3118
-		if (is_object($table)) {
3119
-			$table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3120
-		} elseif (is_array($table)) {
3121
-			if ($conserver_null) {
3122
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3123
-			} else {
3124
-				$table = isset($table[$k]) ? $table[$k] : $defaut;
3125
-			}
3126
-		} else {
3127
-			$table = $defaut;
3128
-		}
3129
-	}
3118
+        if (is_object($table)) {
3119
+            $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3120
+        } elseif (is_array($table)) {
3121
+            if ($conserver_null) {
3122
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3123
+            } else {
3124
+                $table = isset($table[$k]) ? $table[$k] : $defaut;
3125
+            }
3126
+        } else {
3127
+            $table = $defaut;
3128
+        }
3129
+    }
3130 3130
 
3131
-	return $table;
3131
+    return $table;
3132 3132
 }
3133 3133
 
3134 3134
 /**
@@ -3161,22 +3161,22 @@  discard block
 block discarded – undo
3161 3161
  *     - string : expression trouvée.
3162 3162
  **/
3163 3163
 function filtre_match_dist($texte, $expression, $modif = "UimsS", $capte = 0) {
3164
-	if (intval($modif) and $capte == 0) {
3165
-		$capte = $modif;
3166
-		$modif = "UimsS";
3167
-	}
3168
-	$expression = str_replace("\/", "/", $expression);
3169
-	$expression = str_replace("/", "\/", $expression);
3164
+    if (intval($modif) and $capte == 0) {
3165
+        $capte = $modif;
3166
+        $modif = "UimsS";
3167
+    }
3168
+    $expression = str_replace("\/", "/", $expression);
3169
+    $expression = str_replace("/", "\/", $expression);
3170 3170
 
3171
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3172
-		if (isset($r[$capte])) {
3173
-			return $r[$capte];
3174
-		} else {
3175
-			return true;
3176
-		}
3177
-	}
3171
+    if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3172
+        if (isset($r[$capte])) {
3173
+            return $r[$capte];
3174
+        } else {
3175
+            return true;
3176
+        }
3177
+    }
3178 3178
 
3179
-	return false;
3179
+    return false;
3180 3180
 }
3181 3181
 
3182 3182
 
@@ -3203,10 +3203,10 @@  discard block
 block discarded – undo
3203 3203
  *     Texte
3204 3204
  **/
3205 3205
 function replace($texte, $expression, $replace = '', $modif = "UimsS") {
3206
-	$expression = str_replace("\/", "/", $expression);
3207
-	$expression = str_replace("/", "\/", $expression);
3206
+    $expression = str_replace("\/", "/", $expression);
3207
+    $expression = str_replace("/", "\/", $expression);
3208 3208
 
3209
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3209
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3210 3210
 }
3211 3211
 
3212 3212
 
@@ -3224,21 +3224,21 @@  discard block
 block discarded – undo
3224 3224
  **/
3225 3225
 function traiter_doublons_documents(&$doublons, $letexte) {
3226 3226
 
3227
-	// Verifier dans le texte & les notes (pas beau, helas)
3228
-	$t = $letexte . $GLOBALS['les_notes'];
3227
+    // Verifier dans le texte & les notes (pas beau, helas)
3228
+    $t = $letexte . $GLOBALS['les_notes'];
3229 3229
 
3230
-	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3231
-		and preg_match_all(
3232
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3233
-			$t, $matches, PREG_PATTERN_ORDER)
3234
-	) {
3235
-		if (!isset($doublons['documents'])) {
3236
-			$doublons['documents'] = "";
3237
-		}
3238
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3239
-	}
3230
+    if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3231
+        and preg_match_all(
3232
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3233
+            $t, $matches, PREG_PATTERN_ORDER)
3234
+    ) {
3235
+        if (!isset($doublons['documents'])) {
3236
+            $doublons['documents'] = "";
3237
+        }
3238
+        $doublons['documents'] .= "," . join(',', $matches[1]);
3239
+    }
3240 3240
 
3241
-	return $letexte;
3241
+    return $letexte;
3242 3242
 }
3243 3243
 
3244 3244
 /**
@@ -3252,7 +3252,7 @@  discard block
 block discarded – undo
3252 3252
  * @return string Chaîne vide
3253 3253
  **/
3254 3254
 function vide($texte) {
3255
-	return "";
3255
+    return "";
3256 3256
 }
3257 3257
 
3258 3258
 //
@@ -3281,23 +3281,23 @@  discard block
 block discarded – undo
3281 3281
  *      Code HTML résultant
3282 3282
  **/
3283 3283
 function env_to_params($env, $ignore_params = array()) {
3284
-	$ignore_params = array_merge(
3285
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3286
-		$ignore_params
3287
-	);
3288
-	if (!is_array($env)) {
3289
-		$env = unserialize($env);
3290
-	}
3291
-	$texte = "";
3292
-	if ($env) {
3293
-		foreach ($env as $i => $j) {
3294
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3295
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3296
-			}
3297
-		}
3298
-	}
3299
-
3300
-	return $texte;
3284
+    $ignore_params = array_merge(
3285
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3286
+        $ignore_params
3287
+    );
3288
+    if (!is_array($env)) {
3289
+        $env = unserialize($env);
3290
+    }
3291
+    $texte = "";
3292
+    if ($env) {
3293
+        foreach ($env as $i => $j) {
3294
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3295
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3296
+            }
3297
+        }
3298
+    }
3299
+
3300
+    return $texte;
3301 3301
 }
3302 3302
 
3303 3303
 /**
@@ -3320,23 +3320,23 @@  discard block
 block discarded – undo
3320 3320
  *      Code HTML résultant
3321 3321
  **/
3322 3322
 function env_to_attributs($env, $ignore_params = array()) {
3323
-	$ignore_params = array_merge(
3324
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3325
-		$ignore_params
3326
-	);
3327
-	if (!is_array($env)) {
3328
-		$env = unserialize($env);
3329
-	}
3330
-	$texte = "";
3331
-	if ($env) {
3332
-		foreach ($env as $i => $j) {
3333
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3334
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3335
-			}
3336
-		}
3337
-	}
3323
+    $ignore_params = array_merge(
3324
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3325
+        $ignore_params
3326
+    );
3327
+    if (!is_array($env)) {
3328
+        $env = unserialize($env);
3329
+    }
3330
+    $texte = "";
3331
+    if ($env) {
3332
+        foreach ($env as $i => $j) {
3333
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3334
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3335
+            }
3336
+        }
3337
+    }
3338 3338
 
3339
-	return $texte;
3339
+    return $texte;
3340 3340
 }
3341 3341
 
3342 3342
 
@@ -3353,9 +3353,9 @@  discard block
 block discarded – undo
3353 3353
  * @return string Chaînes concaténés
3354 3354
  **/
3355 3355
 function concat() {
3356
-	$args = func_get_args();
3356
+    $args = func_get_args();
3357 3357
 
3358
-	return join('', $args);
3358
+    return join('', $args);
3359 3359
 }
3360 3360
 
3361 3361
 
@@ -3375,23 +3375,23 @@  discard block
 block discarded – undo
3375 3375
  *     Contenu du ou des fichiers, concaténé
3376 3376
  **/
3377 3377
 function charge_scripts($files, $script = true) {
3378
-	$flux = "";
3379
-	foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3380
-		if (!is_string($file)) {
3381
-			continue;
3382
-		}
3383
-		if ($script) {
3384
-			$file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3385
-		}
3386
-		if ($file) {
3387
-			$path = find_in_path($file);
3388
-			if ($path) {
3389
-				$flux .= spip_file_get_contents($path);
3390
-			}
3391
-		}
3392
-	}
3378
+    $flux = "";
3379
+    foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3380
+        if (!is_string($file)) {
3381
+            continue;
3382
+        }
3383
+        if ($script) {
3384
+            $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3385
+        }
3386
+        if ($file) {
3387
+            $path = find_in_path($file);
3388
+            if ($path) {
3389
+                $flux .= spip_file_get_contents($path);
3390
+            }
3391
+        }
3392
+    }
3393 3393
 
3394
-	return $flux;
3394
+    return $flux;
3395 3395
 }
3396 3396
 
3397 3397
 
@@ -3413,64 +3413,64 @@  discard block
 block discarded – undo
3413 3413
  */
3414 3414
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) {
3415 3415
 
3416
-	$img_file = $img;
3417
-	if ($p = strpos($img_file, '?')) {
3418
-		$img_file = substr($img_file,0, $p);
3419
-	}
3420
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3421
-		$img_file = chemin_image($img);
3422
-	}
3423
-	else {
3424
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3425
-			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3426
-			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3427
-			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3428
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3429
-			  and file_exists($variante_svg_generique)) {
3430
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3431
-					$img_file = $variante_svg_size;
3432
-				}
3433
-				else {
3434
-					$img_file = $variante_svg_generique;
3435
-				}
3436
-			}
3437
-		}
3438
-	}
3439
-	if (stripos($atts, 'width') === false) {
3440
-		// utiliser directement l'info de taille presente dans le nom
3441
-		if ((!isset($options['utiliser_suffixe_size'])
3442
-				or $options['utiliser_suffixe_size'] == true
3443
-			  or strpos($img_file, '-xx.svg') !== false)
3444
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3445
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3446
-		) {
3447
-			$largeur = $hauteur = intval($regs[1]);
3448
-		} else {
3449
-			$taille = taille_image($img_file);
3450
-			list($hauteur, $largeur) = $taille;
3451
-			if (!$hauteur or !$largeur) {
3452
-				return "";
3453
-			}
3454
-		}
3455
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3456
-	}
3457
-
3458
-	if (file_exists($img_file)) {
3459
-		$img_file = timestamp($img_file);
3460
-	}
3461
-	if ($alt === false) {
3462
-		$alt = '';
3463
-	}
3464
-	elseif($alt or $alt==='') {
3465
-		$alt = " alt='".attribut_html($alt)."'";
3466
-	}
3467
-	else {
3468
-		$alt = " alt='".attribut_html($title)."'";
3469
-	}
3470
-	return "<img src='$img_file'$alt"
3471
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3472
-	. " " . ltrim($atts)
3473
-	. " />";
3416
+    $img_file = $img;
3417
+    if ($p = strpos($img_file, '?')) {
3418
+        $img_file = substr($img_file,0, $p);
3419
+    }
3420
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3421
+        $img_file = chemin_image($img);
3422
+    }
3423
+    else {
3424
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3425
+            // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3426
+            // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3427
+            if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3428
+              and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3429
+              and file_exists($variante_svg_generique)) {
3430
+                if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3431
+                    $img_file = $variante_svg_size;
3432
+                }
3433
+                else {
3434
+                    $img_file = $variante_svg_generique;
3435
+                }
3436
+            }
3437
+        }
3438
+    }
3439
+    if (stripos($atts, 'width') === false) {
3440
+        // utiliser directement l'info de taille presente dans le nom
3441
+        if ((!isset($options['utiliser_suffixe_size'])
3442
+                or $options['utiliser_suffixe_size'] == true
3443
+              or strpos($img_file, '-xx.svg') !== false)
3444
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3445
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3446
+        ) {
3447
+            $largeur = $hauteur = intval($regs[1]);
3448
+        } else {
3449
+            $taille = taille_image($img_file);
3450
+            list($hauteur, $largeur) = $taille;
3451
+            if (!$hauteur or !$largeur) {
3452
+                return "";
3453
+            }
3454
+        }
3455
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3456
+    }
3457
+
3458
+    if (file_exists($img_file)) {
3459
+        $img_file = timestamp($img_file);
3460
+    }
3461
+    if ($alt === false) {
3462
+        $alt = '';
3463
+    }
3464
+    elseif($alt or $alt==='') {
3465
+        $alt = " alt='".attribut_html($alt)."'";
3466
+    }
3467
+    else {
3468
+        $alt = " alt='".attribut_html($title)."'";
3469
+    }
3470
+    return "<img src='$img_file'$alt"
3471
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3472
+    . " " . ltrim($atts)
3473
+    . " />";
3474 3474
 }
3475 3475
 
3476 3476
 /**
@@ -3482,68 +3482,68 @@  discard block
 block discarded – undo
3482 3482
  * @return string
3483 3483
  */
3484 3484
 function http_style_background($img, $att = '', $size=null) {
3485
-	if ($size and is_numeric($size)){
3486
-		$size = trim($size) . "px";
3487
-	}
3488
-	return " style='background" .
3489
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3490
-		. ($size ? "background-size:{$size};" : '')
3491
-		. "'";
3485
+    if ($size and is_numeric($size)){
3486
+        $size = trim($size) . "px";
3487
+    }
3488
+    return " style='background" .
3489
+        ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3490
+        . ($size ? "background-size:{$size};" : '')
3491
+        . "'";
3492 3492
 }
3493 3493
 
3494 3494
 
3495 3495
 function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) {
3496
-	$args = [$alt_or_size, $class_or_size, $size];
3497
-	while (is_null(end($args)) and count($args)) {
3498
-		array_pop($args);
3499
-	}
3500
-	if (!count($args)) {
3501
-		return [null, null, null];
3502
-	}
3503
-	if (count($args) < 3) {
3504
-		$maybe_size = array_pop($args);
3505
-		// @2x
3506
-		// @1.5x
3507
-		// 512
3508
-		// 512x*
3509
-		// 512x300
3510
-		if (!strlen($maybe_size)
3511
-			or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))) {
3512
-			$args[] = $maybe_size;
3513
-			$maybe_size = null;
3514
-		}
3515
-		while (count($args)<2) {
3516
-			$args[] = null; // default alt or class
3517
-		}
3518
-		$args[] = $maybe_size;
3519
-	}
3520
-	return $args;
3496
+    $args = [$alt_or_size, $class_or_size, $size];
3497
+    while (is_null(end($args)) and count($args)) {
3498
+        array_pop($args);
3499
+    }
3500
+    if (!count($args)) {
3501
+        return [null, null, null];
3502
+    }
3503
+    if (count($args) < 3) {
3504
+        $maybe_size = array_pop($args);
3505
+        // @2x
3506
+        // @1.5x
3507
+        // 512
3508
+        // 512x*
3509
+        // 512x300
3510
+        if (!strlen($maybe_size)
3511
+            or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))) {
3512
+            $args[] = $maybe_size;
3513
+            $maybe_size = null;
3514
+        }
3515
+        while (count($args)<2) {
3516
+            $args[] = null; // default alt or class
3517
+        }
3518
+        $args[] = $maybe_size;
3519
+    }
3520
+    return $args;
3521 3521
 }
3522 3522
 
3523 3523
 function helper_filtre_balise_img_svg_size($img, $size) {
3524
-	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3525
-	if (strpos($size, '@') === 0 and substr($size,-1) === 'x') {
3526
-		$coef = floatval(substr($size, 1, -1));
3527
-		list($h, $w) = taille_image($img);
3528
-		$height = intval(round($h / $coef));
3529
-		$width = intval(round($w / $coef));
3530
-	}
3531
-	// sinon c'est une valeur seule si image caree ou largeurxhauteur
3532
-	else {
3533
-		$size = explode('x', $size, 2);
3534
-		$size = array_map('trim', $size);
3535
-		$height = $width = intval(array_shift($size));
3536
-
3537
-		if (count($size) and reset($size)) {
3538
-			$height = array_shift($size);
3539
-			if ($height === '*') {
3540
-				list($h, $w) = taille_image($img);
3541
-				$height = intval(round($h * $width / $w));
3542
-			}
3543
-		}
3544
-	}
3545
-
3546
-	return [$width, $height];
3524
+    // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3525
+    if (strpos($size, '@') === 0 and substr($size,-1) === 'x') {
3526
+        $coef = floatval(substr($size, 1, -1));
3527
+        list($h, $w) = taille_image($img);
3528
+        $height = intval(round($h / $coef));
3529
+        $width = intval(round($w / $coef));
3530
+    }
3531
+    // sinon c'est une valeur seule si image caree ou largeurxhauteur
3532
+    else {
3533
+        $size = explode('x', $size, 2);
3534
+        $size = array_map('trim', $size);
3535
+        $height = $width = intval(array_shift($size));
3536
+
3537
+        if (count($size) and reset($size)) {
3538
+            $height = array_shift($size);
3539
+            if ($height === '*') {
3540
+                list($h, $w) = taille_image($img);
3541
+                $height = intval(round($h * $width / $w));
3542
+            }
3543
+        }
3544
+    }
3545
+
3546
+    return [$width, $height];
3547 3547
 }
3548 3548
 
3549 3549
 /**
@@ -3579,38 +3579,38 @@  discard block
 block discarded – undo
3579 3579
  */
3580 3580
 function filtre_balise_img_dist($img, $alt = '', $class = null, $size=null) {
3581 3581
 
3582
-	list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3582
+    list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3583 3583
 
3584
-	$img = trim($img);
3585
-	if (strpos($img, '<img') === 0) {
3586
-		if (!is_null($alt)) {
3587
-			$img = inserer_attribut($img, 'alt', $alt);
3588
-		}
3589
-		if (!is_null($class)) {
3590
-			if (strlen($class)) {
3591
-				$img = inserer_attribut($img, 'class', $class);
3592
-			}
3593
-			else {
3594
-				$img = vider_attribut($img, 'class');
3595
-			}
3596
-		}
3597
-	}
3598
-	else {
3599
-		$img = http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3600
-				array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3601
-		if (is_null($alt)) {
3602
-			$img = vider_attribut($img, 'alt');
3603
-		}
3604
-	}
3584
+    $img = trim($img);
3585
+    if (strpos($img, '<img') === 0) {
3586
+        if (!is_null($alt)) {
3587
+            $img = inserer_attribut($img, 'alt', $alt);
3588
+        }
3589
+        if (!is_null($class)) {
3590
+            if (strlen($class)) {
3591
+                $img = inserer_attribut($img, 'class', $class);
3592
+            }
3593
+            else {
3594
+                $img = vider_attribut($img, 'class');
3595
+            }
3596
+        }
3597
+    }
3598
+    else {
3599
+        $img = http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3600
+                array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3601
+        if (is_null($alt)) {
3602
+            $img = vider_attribut($img, 'alt');
3603
+        }
3604
+    }
3605 3605
 
3606
-	if ($img and !is_null($size) and strlen($size = trim($size))) {
3607
-		list($width, $height) = helper_filtre_balise_img_svg_size($img, $size);
3606
+    if ($img and !is_null($size) and strlen($size = trim($size))) {
3607
+        list($width, $height) = helper_filtre_balise_img_svg_size($img, $size);
3608 3608
 
3609
-		$img = inserer_attribut($img, 'width', $width);
3610
-		$img = inserer_attribut($img, 'height', $height);
3611
-	}
3609
+        $img = inserer_attribut($img, 'width', $width);
3610
+        $img = inserer_attribut($img, 'height', $height);
3611
+    }
3612 3612
 
3613
-	return $img;
3613
+    return $img;
3614 3614
 }
3615 3615
 
3616 3616
 
@@ -3644,67 +3644,67 @@  discard block
 block discarded – undo
3644 3644
  */
3645 3645
 function filtre_balise_svg_dist($img, $alt = '', $class = null, $size=null) {
3646 3646
 
3647
-	$img = trim($img);
3648
-	$img_file = $img;
3649
-	if (strpos($img, '<svg') === false){
3650
-		if ($p = strpos($img_file, '?')){
3651
-			$img_file = substr($img_file, 0, $p);
3652
-		}
3647
+    $img = trim($img);
3648
+    $img_file = $img;
3649
+    if (strpos($img, '<svg') === false){
3650
+        if ($p = strpos($img_file, '?')){
3651
+            $img_file = substr($img_file, 0, $p);
3652
+        }
3653 3653
 
3654
-		if (!$img_file or !$svg = file_get_contents($img_file)){
3655
-			return '';
3656
-		}
3657
-	}
3654
+        if (!$img_file or !$svg = file_get_contents($img_file)){
3655
+            return '';
3656
+        }
3657
+    }
3658 3658
 
3659
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3660
-		return '';
3661
-	}
3659
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3660
+        return '';
3661
+    }
3662 3662
 
3663
-	list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3663
+    list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3664 3664
 
3665
-	$balise_svg = $match[0];
3666
-	$balise_svg_source = $balise_svg;
3665
+    $balise_svg = $match[0];
3666
+    $balise_svg_source = $balise_svg;
3667 3667
 
3668
-	// entete XML à supprimer
3669
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3668
+    // entete XML à supprimer
3669
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3670 3670
 
3671
-	// IE est toujours mon ami
3672
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3671
+    // IE est toujours mon ami
3672
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3673 3673
 
3674
-	// regler la classe
3675
-	if (!is_null($class)) {
3676
-		if (strlen($class)) {
3677
-			$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3678
-		}
3679
-		else {
3680
-			$balise_svg = vider_attribut($balise_svg, 'class');
3681
-		}
3682
-	}
3674
+    // regler la classe
3675
+    if (!is_null($class)) {
3676
+        if (strlen($class)) {
3677
+            $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3678
+        }
3679
+        else {
3680
+            $balise_svg = vider_attribut($balise_svg, 'class');
3681
+        }
3682
+    }
3683 3683
 
3684
-	// regler le alt
3685
-	if ($alt){
3686
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3687
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3688
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3689
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3690
-		$balise_svg .= $title;
3691
-	}
3692
-	else {
3693
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3694
-	}
3684
+    // regler le alt
3685
+    if ($alt){
3686
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3687
+        $id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3688
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3689
+        $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3690
+        $balise_svg .= $title;
3691
+    }
3692
+    else {
3693
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3694
+    }
3695 3695
 
3696
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3696
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3697 3697
 
3698
-	if (!is_null($size) and strlen($size = trim($size))) {
3699
-		list($width, $height) = helper_filtre_balise_img_svg_size($svg, $size);
3698
+    if (!is_null($size) and strlen($size = trim($size))) {
3699
+        list($width, $height) = helper_filtre_balise_img_svg_size($svg, $size);
3700 3700
 
3701
-		if (!function_exists('svg_redimensionner')) {
3702
-			include_spip('inc/svg');
3703
-		}
3704
-		$svg = svg_redimensionner($svg, $width, $height);
3705
-	}
3701
+        if (!function_exists('svg_redimensionner')) {
3702
+            include_spip('inc/svg');
3703
+        }
3704
+        $svg = svg_redimensionner($svg, $width, $height);
3705
+    }
3706 3706
 
3707
-	return $svg;
3707
+    return $svg;
3708 3708
 }
3709 3709
 
3710 3710
 
@@ -3727,17 +3727,17 @@  discard block
 block discarded – undo
3727 3727
  *     Code HTML résultant
3728 3728
  **/
3729 3729
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3730
-	$texte = '';
3731
-	if (is_array($tableau)) {
3732
-		foreach ($tableau as $k => $v) {
3733
-			$res = recuperer_fond('modeles/' . $modele,
3734
-				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3735
-			);
3736
-			$texte .= $res;
3737
-		}
3738
-	}
3730
+    $texte = '';
3731
+    if (is_array($tableau)) {
3732
+        foreach ($tableau as $k => $v) {
3733
+            $res = recuperer_fond('modeles/' . $modele,
3734
+                array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3735
+            );
3736
+            $texte .= $res;
3737
+        }
3738
+    }
3739 3739
 
3740
-	return $texte;
3740
+    return $texte;
3741 3741
 }
3742 3742
 
3743 3743
 
@@ -3762,37 +3762,37 @@  discard block
 block discarded – undo
3762 3762
  *         - tout : retourne toutes les informations du plugin actif
3763 3763
  **/
3764 3764
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3765
-	include_spip('inc/plugin');
3766
-	$plugin = strtoupper($plugin);
3767
-	$plugins_actifs = liste_plugin_actifs();
3768
-
3769
-	if (!$plugin) {
3770
-		return serialize(array_keys($plugins_actifs));
3771
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3772
-		return '';
3773
-	} elseif (($type_info == 'est_actif') and !$reload) {
3774
-		return $plugins_actifs[$plugin] ? 1 : 0;
3775
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3776
-		return $plugins_actifs[$plugin][$type_info];
3777
-	} else {
3778
-		$get_infos = charger_fonction('get_infos', 'plugins');
3779
-		// On prend en compte les extensions
3780
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3781
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3782
-		} else {
3783
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3784
-		}
3785
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3786
-			return '';
3787
-		}
3788
-		if ($type_info == 'tout') {
3789
-			return $infos;
3790
-		} elseif ($type_info == 'est_actif') {
3791
-			return $infos ? 1 : 0;
3792
-		} else {
3793
-			return strval($infos[$type_info]);
3794
-		}
3795
-	}
3765
+    include_spip('inc/plugin');
3766
+    $plugin = strtoupper($plugin);
3767
+    $plugins_actifs = liste_plugin_actifs();
3768
+
3769
+    if (!$plugin) {
3770
+        return serialize(array_keys($plugins_actifs));
3771
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3772
+        return '';
3773
+    } elseif (($type_info == 'est_actif') and !$reload) {
3774
+        return $plugins_actifs[$plugin] ? 1 : 0;
3775
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3776
+        return $plugins_actifs[$plugin][$type_info];
3777
+    } else {
3778
+        $get_infos = charger_fonction('get_infos', 'plugins');
3779
+        // On prend en compte les extensions
3780
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3781
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3782
+        } else {
3783
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3784
+        }
3785
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3786
+            return '';
3787
+        }
3788
+        if ($type_info == 'tout') {
3789
+            return $infos;
3790
+        } elseif ($type_info == 'est_actif') {
3791
+            return $infos ? 1 : 0;
3792
+        } else {
3793
+            return strval($infos[$type_info]);
3794
+        }
3795
+    }
3796 3796
 }
3797 3797
 
3798 3798
 
@@ -3819,9 +3819,9 @@  discard block
 block discarded – undo
3819 3819
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3820 3820
  */
3821 3821
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3822
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3822
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3823 3823
 
3824
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3824
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3825 3825
 }
3826 3826
 
3827 3827
 
@@ -3851,13 +3851,13 @@  discard block
 block discarded – undo
3851 3851
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3852 3852
  */
3853 3853
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3854
-	static $puce_statut = null;
3855
-	if (!$puce_statut) {
3856
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3857
-	}
3854
+    static $puce_statut = null;
3855
+    if (!$puce_statut) {
3856
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3857
+    }
3858 3858
 
3859
-	return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3860
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3859
+    return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3860
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3861 3861
 }
3862 3862
 
3863 3863
 
@@ -3884,95 +3884,95 @@  discard block
 block discarded – undo
3884 3884
  *   hash du contexte
3885 3885
  */
3886 3886
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3887
-	if (is_string($c)
3888
-		and @unserialize($c) !== false
3889
-	) {
3890
-		$c = unserialize($c);
3891
-	}
3892
-
3893
-	// supprimer les parametres debut_x
3894
-	// pour que la pagination ajax ne soit pas plantee
3895
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3896
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3897
-	if (is_array($c)) {
3898
-		foreach ($c as $k => $v) {
3899
-			if (strpos($k, 'debut_') === 0) {
3900
-				unset($c[$k]);
3901
-			}
3902
-		}
3903
-	}
3904
-
3905
-	if (!function_exists('calculer_cle_action')) {
3906
-		include_spip("inc/securiser_action");
3907
-	}
3908
-
3909
-	$c = serialize($c);
3910
-	$cle = calculer_cle_action($form . $c);
3911
-	$c = "$cle:$c";
3912
-
3913
-	// on ne stocke pas les contextes dans des fichiers en cache
3914
-	// par defaut, sauf si cette configuration a été forcée
3915
-	// OU que la longueur de l’argument géneré est plus long
3916
-	// que ce qui est toléré.
3917
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3918
-	if (!$cache_contextes_ajax) {
3919
-		$env = $c;
3920
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3921
-			$env = gzdeflate($env);
3922
-		}
3923
-		$env = _xor($env);
3924
-		$env = base64_encode($env);
3925
-		$len = strlen($env);
3926
-		// Si l’url est trop longue pour le navigateur
3927
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3928
-		if ($len > $max_len) {
3929
-			$cache_contextes_ajax = true;
3930
-			spip_log("Contextes AJAX forces en fichiers !"
3931
-				. " Cela arrive lorsque la valeur du contexte" 
3932
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3933
-				, _LOG_AVERTISSEMENT);
3934
-		}
3935
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3936
-		elseif (
3937
-			$max_len = @ini_get('suhosin.get.max_value_length')
3938
-			and $max_len < $len
3939
-		) {
3940
-			$cache_contextes_ajax = true;
3941
-			spip_log("Contextes AJAX forces en fichiers !"
3942
-				. " Cela arrive lorsque la valeur du contexte"
3943
-				. " depasse la longueur maximale autorisee par Suhosin"
3944
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3945
-				. " Vous devriez modifier les parametres de Suhosin"
3946
-				. " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3947
-		} 
3948
-
3949
-	}
3950
-
3951
-	if ($cache_contextes_ajax) {
3952
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3953
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3954
-		$md5 = md5($c);
3955
-		ecrire_fichier("$dir/c$md5", $c);
3956
-		$env = $md5;
3957
-	}
3958
-
3959
-	if ($emboite === null) {
3960
-		return $env;
3961
-	}
3962
-	if (!trim($emboite)) {
3963
-		return "";
3964
-	}
3965
-	// toujours encoder l'url source dans le bloc ajax
3966
-	$r = self();
3967
-	$r = ' data-origin="' . $r . '"';
3968
-	$class = 'ajaxbloc';
3969
-	if ($ajaxid and is_string($ajaxid)) {
3970
-		// ajaxid est normalement conforme a un nom de classe css
3971
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3972
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3973
-	}
3974
-
3975
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3887
+    if (is_string($c)
3888
+        and @unserialize($c) !== false
3889
+    ) {
3890
+        $c = unserialize($c);
3891
+    }
3892
+
3893
+    // supprimer les parametres debut_x
3894
+    // pour que la pagination ajax ne soit pas plantee
3895
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3896
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3897
+    if (is_array($c)) {
3898
+        foreach ($c as $k => $v) {
3899
+            if (strpos($k, 'debut_') === 0) {
3900
+                unset($c[$k]);
3901
+            }
3902
+        }
3903
+    }
3904
+
3905
+    if (!function_exists('calculer_cle_action')) {
3906
+        include_spip("inc/securiser_action");
3907
+    }
3908
+
3909
+    $c = serialize($c);
3910
+    $cle = calculer_cle_action($form . $c);
3911
+    $c = "$cle:$c";
3912
+
3913
+    // on ne stocke pas les contextes dans des fichiers en cache
3914
+    // par defaut, sauf si cette configuration a été forcée
3915
+    // OU que la longueur de l’argument géneré est plus long
3916
+    // que ce qui est toléré.
3917
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3918
+    if (!$cache_contextes_ajax) {
3919
+        $env = $c;
3920
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3921
+            $env = gzdeflate($env);
3922
+        }
3923
+        $env = _xor($env);
3924
+        $env = base64_encode($env);
3925
+        $len = strlen($env);
3926
+        // Si l’url est trop longue pour le navigateur
3927
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3928
+        if ($len > $max_len) {
3929
+            $cache_contextes_ajax = true;
3930
+            spip_log("Contextes AJAX forces en fichiers !"
3931
+                . " Cela arrive lorsque la valeur du contexte" 
3932
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3933
+                , _LOG_AVERTISSEMENT);
3934
+        }
3935
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3936
+        elseif (
3937
+            $max_len = @ini_get('suhosin.get.max_value_length')
3938
+            and $max_len < $len
3939
+        ) {
3940
+            $cache_contextes_ajax = true;
3941
+            spip_log("Contextes AJAX forces en fichiers !"
3942
+                . " Cela arrive lorsque la valeur du contexte"
3943
+                . " depasse la longueur maximale autorisee par Suhosin"
3944
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3945
+                . " Vous devriez modifier les parametres de Suhosin"
3946
+                . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3947
+        } 
3948
+
3949
+    }
3950
+
3951
+    if ($cache_contextes_ajax) {
3952
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3953
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3954
+        $md5 = md5($c);
3955
+        ecrire_fichier("$dir/c$md5", $c);
3956
+        $env = $md5;
3957
+    }
3958
+
3959
+    if ($emboite === null) {
3960
+        return $env;
3961
+    }
3962
+    if (!trim($emboite)) {
3963
+        return "";
3964
+    }
3965
+    // toujours encoder l'url source dans le bloc ajax
3966
+    $r = self();
3967
+    $r = ' data-origin="' . $r . '"';
3968
+    $class = 'ajaxbloc';
3969
+    if ($ajaxid and is_string($ajaxid)) {
3970
+        // ajaxid est normalement conforme a un nom de classe css
3971
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3972
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3973
+    }
3974
+
3975
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3976 3976
 }
3977 3977
 
3978 3978
 /**
@@ -3992,36 +3992,36 @@  discard block
 block discarded – undo
3992 3992
  *   - false : erreur de décodage
3993 3993
  */
3994 3994
 function decoder_contexte_ajax($c, $form = '') {
3995
-	if (!function_exists('calculer_cle_action')) {
3996
-		include_spip("inc/securiser_action");
3997
-	}
3998
-	if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3999
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4000
-		and lire_fichier("$dir/c$c", $contexte)
4001
-	) {
4002
-		$c = $contexte;
4003
-	} else {
4004
-		$c = @base64_decode($c);
4005
-		$c = _xor($c);
4006
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4007
-			$c = @gzinflate($c);
4008
-		}
4009
-	}
4010
-
4011
-	// extraire la signature en debut de contexte
4012
-	// et la verifier avant de deserializer
4013
-	// format : signature:donneesserializees
4014
-	if ($p = strpos($c,":")){
4015
-		$cle = substr($c,0,$p);
4016
-		$c = substr($c,$p+1);
4017
-
4018
-		if ($cle == calculer_cle_action($form . $c)) {
4019
-			$env = @unserialize($c);
4020
-			return $env;
4021
-		}
4022
-	}
4023
-
4024
-	return false;
3995
+    if (!function_exists('calculer_cle_action')) {
3996
+        include_spip("inc/securiser_action");
3997
+    }
3998
+    if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3999
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4000
+        and lire_fichier("$dir/c$c", $contexte)
4001
+    ) {
4002
+        $c = $contexte;
4003
+    } else {
4004
+        $c = @base64_decode($c);
4005
+        $c = _xor($c);
4006
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4007
+            $c = @gzinflate($c);
4008
+        }
4009
+    }
4010
+
4011
+    // extraire la signature en debut de contexte
4012
+    // et la verifier avant de deserializer
4013
+    // format : signature:donneesserializees
4014
+    if ($p = strpos($c,":")){
4015
+        $cle = substr($c,0,$p);
4016
+        $c = substr($c,$p+1);
4017
+
4018
+        if ($cle == calculer_cle_action($form . $c)) {
4019
+            $env = @unserialize($c);
4020
+            return $env;
4021
+        }
4022
+    }
4023
+
4024
+    return false;
4025 4025
 }
4026 4026
 
4027 4027
 
@@ -4039,20 +4039,20 @@  discard block
 block discarded – undo
4039 4039
  *    Message décrypté ou encrypté
4040 4040
  **/
4041 4041
 function _xor($message, $key = null) {
4042
-	if (is_null($key)) {
4043
-		if (!function_exists('calculer_cle_action')) {
4044
-			include_spip("inc/securiser_action");
4045
-		}
4046
-		$key = pack("H*", calculer_cle_action('_xor'));
4047
-	}
4042
+    if (is_null($key)) {
4043
+        if (!function_exists('calculer_cle_action')) {
4044
+            include_spip("inc/securiser_action");
4045
+        }
4046
+        $key = pack("H*", calculer_cle_action('_xor'));
4047
+    }
4048 4048
 
4049
-	$keylen = strlen($key);
4050
-	$messagelen = strlen($message);
4051
-	for ($i = 0; $i < $messagelen; $i++) {
4052
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4053
-	}
4049
+    $keylen = strlen($key);
4050
+    $messagelen = strlen($message);
4051
+    for ($i = 0; $i < $messagelen; $i++) {
4052
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4053
+    }
4054 4054
 
4055
-	return $message;
4055
+    return $message;
4056 4056
 }
4057 4057
 
4058 4058
 /**
@@ -4115,37 +4115,37 @@  discard block
 block discarded – undo
4115 4115
  *   Code HTML
4116 4116
  */
4117 4117
 function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') {
4118
-	if ($on) {
4119
-		$bal = 'strong';
4120
-		$class = "";
4121
-		$att = "";
4122
-		// si $on passe la balise et optionnelement une ou ++classe
4123
-		// a.active span.selected.active etc....
4124
-		if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
4125
-			$on = explode(".", $on);
4126
-			// on verifie que c'est exactement une des 3 balises a, span ou strong
4127
-			if (in_array(reset($on), array('a', 'span', 'strong'))){
4128
-				$bal = array_shift($on);
4129
-				$class = implode(" ", $on);
4130
-				if ($bal=="a"){
4131
-					$att = 'href="#" ';
4132
-				}
4133
-			}
4134
-		}
4135
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4136
-	} else {
4137
-		$bal = 'a';
4138
-		$att = "href='$url'"
4139
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4140
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4141
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4142
-			. $evt;
4143
-	}
4144
-	if ($libelle === null) {
4145
-		$libelle = $url;
4146
-	}
4147
-
4148
-	return "<$bal $att>$libelle</$bal>";
4118
+    if ($on) {
4119
+        $bal = 'strong';
4120
+        $class = "";
4121
+        $att = "";
4122
+        // si $on passe la balise et optionnelement une ou ++classe
4123
+        // a.active span.selected.active etc....
4124
+        if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
4125
+            $on = explode(".", $on);
4126
+            // on verifie que c'est exactement une des 3 balises a, span ou strong
4127
+            if (in_array(reset($on), array('a', 'span', 'strong'))){
4128
+                $bal = array_shift($on);
4129
+                $class = implode(" ", $on);
4130
+                if ($bal=="a"){
4131
+                    $att = 'href="#" ';
4132
+                }
4133
+            }
4134
+        }
4135
+        $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4136
+    } else {
4137
+        $bal = 'a';
4138
+        $att = "href='$url'"
4139
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
4140
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
4141
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4142
+            . $evt;
4143
+    }
4144
+    if ($libelle === null) {
4145
+        $libelle = $url;
4146
+    }
4147
+
4148
+    return "<$bal $att>$libelle</$bal>";
4149 4149
 }
4150 4150
 
4151 4151
 
@@ -4162,37 +4162,37 @@  discard block
 block discarded – undo
4162 4162
  * @return string : la chaine de langue finale en utilisant la fonction _T()
4163 4163
  */
4164 4164
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) {
4165
-	static $local_singulier_ou_pluriel = array();
4165
+    static $local_singulier_ou_pluriel = array();
4166 4166
 
4167
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4168
-	if (!is_numeric($nb) or $nb == 0) {
4169
-		return "";
4170
-	}
4171
-	if (!is_array($vars)) {
4172
-		return "";
4173
-	}
4167
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4168
+    if (!is_numeric($nb) or $nb == 0) {
4169
+        return "";
4170
+    }
4171
+    if (!is_array($vars)) {
4172
+        return "";
4173
+    }
4174 4174
 
4175
-	$langue = $GLOBALS['spip_lang'];
4176
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
4177
-		$local_singulier_ou_pluriel[$langue] = false;
4178
-		if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
4179
-		  or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) {
4180
-			$local_singulier_ou_pluriel[$langue] = $f;
4181
-		}
4182
-	}
4175
+    $langue = $GLOBALS['spip_lang'];
4176
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
4177
+        $local_singulier_ou_pluriel[$langue] = false;
4178
+        if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
4179
+          or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) {
4180
+            $local_singulier_ou_pluriel[$langue] = $f;
4181
+        }
4182
+    }
4183 4183
 
4184
-	// si on a une surcharge on l'utilise
4185
-	if ($local_singulier_ou_pluriel[$langue]) {
4186
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4187
-	}
4184
+    // si on a une surcharge on l'utilise
4185
+    if ($local_singulier_ou_pluriel[$langue]) {
4186
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4187
+    }
4188 4188
 
4189
-	// sinon traitement par defaut
4190
-	$vars[$var] = $nb;
4191
-	if ($nb >= 2) {
4192
-		return _T($chaine_plusieurs, $vars);
4193
-	} else {
4194
-		return _T($chaine_un, $vars);
4195
-	}
4189
+    // sinon traitement par defaut
4190
+    $vars[$var] = $nb;
4191
+    if ($nb >= 2) {
4192
+        return _T($chaine_plusieurs, $vars);
4193
+    } else {
4194
+        return _T($chaine_un, $vars);
4195
+    }
4196 4196
 }
4197 4197
 
4198 4198
 
@@ -4217,56 +4217,56 @@  discard block
 block discarded – undo
4217 4217
  * @return string
4218 4218
  */
4219 4219
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4220
-	if (in_array($fonction, array("del", "supprimer.gif"))) {
4221
-		$class .= ' danger';
4222
-	} elseif ($fonction == "rien.gif") {
4223
-		$fonction = "";
4224
-	} elseif ($fonction == "delsafe") {
4225
-		$fonction = "del";
4226
-	}
4227
-
4228
-	$fond_origine = $fond;
4229
-	// remappage des icone : article-24.png+new => article-new-24.png
4230
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4231
-		list($fond, $fonction) = $icone_renommer($fond, $fonction);
4232
-	}
4233
-
4234
-	// ajouter le type d'objet dans la class de l'icone
4235
-	$class .= " " . substr(basename($fond), 0, -4);
4236
-
4237
-	$alt = attribut_html($texte);
4238
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4239
-
4240
-	$ajax = "";
4241
-	if (strpos($class, "ajax") !== false) {
4242
-		$ajax = "ajax";
4243
-		if (strpos($class, "preload") !== false) {
4244
-			$ajax .= " preload";
4245
-		}
4246
-		if (strpos($class, "nocache") !== false) {
4247
-			$ajax .= " nocache";
4248
-		}
4249
-		$ajax = " class='$ajax'";
4250
-	}
4251
-
4252
-	$size = 24;
4253
-	if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4254
-	  or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4255
-		$size = $match[1];
4256
-	}
4257
-
4258
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4259
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4260
-
4261
-	if ($type == 'lien') {
4262
-		return "<span class='icone s$size $class'>"
4263
-		. "<a href='$lien'$title$ajax$javascript>"
4264
-		. $icone
4265
-		. "<b>$texte</b>"
4266
-		. "</a></span>\n";
4267
-	} else {
4268
-		return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4269
-	}
4220
+    if (in_array($fonction, array("del", "supprimer.gif"))) {
4221
+        $class .= ' danger';
4222
+    } elseif ($fonction == "rien.gif") {
4223
+        $fonction = "";
4224
+    } elseif ($fonction == "delsafe") {
4225
+        $fonction = "del";
4226
+    }
4227
+
4228
+    $fond_origine = $fond;
4229
+    // remappage des icone : article-24.png+new => article-new-24.png
4230
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4231
+        list($fond, $fonction) = $icone_renommer($fond, $fonction);
4232
+    }
4233
+
4234
+    // ajouter le type d'objet dans la class de l'icone
4235
+    $class .= " " . substr(basename($fond), 0, -4);
4236
+
4237
+    $alt = attribut_html($texte);
4238
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4239
+
4240
+    $ajax = "";
4241
+    if (strpos($class, "ajax") !== false) {
4242
+        $ajax = "ajax";
4243
+        if (strpos($class, "preload") !== false) {
4244
+            $ajax .= " preload";
4245
+        }
4246
+        if (strpos($class, "nocache") !== false) {
4247
+            $ajax .= " nocache";
4248
+        }
4249
+        $ajax = " class='$ajax'";
4250
+    }
4251
+
4252
+    $size = 24;
4253
+    if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4254
+      or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4255
+        $size = $match[1];
4256
+    }
4257
+
4258
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4259
+    $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4260
+
4261
+    if ($type == 'lien') {
4262
+        return "<span class='icone s$size $class'>"
4263
+        . "<a href='$lien'$title$ajax$javascript>"
4264
+        . $icone
4265
+        . "<b>$texte</b>"
4266
+        . "</a></span>\n";
4267
+    } else {
4268
+        return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4269
+    }
4270 4270
 }
4271 4271
 
4272 4272
 /**
@@ -4290,7 +4290,7 @@  discard block
 block discarded – undo
4290 4290
  *     Code HTML du lien
4291 4291
  **/
4292 4292
 function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4293
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4293
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4294 4294
 }
4295 4295
 
4296 4296
 /**
@@ -4325,7 +4325,7 @@  discard block
 block discarded – undo
4325 4325
  *     Code HTML du lien
4326 4326
  **/
4327 4327
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4328
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4328
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4329 4329
 }
4330 4330
 
4331 4331
 /**
@@ -4370,7 +4370,7 @@  discard block
 block discarded – undo
4370 4370
  *     Code HTML du lien
4371 4371
  **/
4372 4372
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4373
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4373
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4374 4374
 }
4375 4375
 
4376 4376
 /**
@@ -4401,7 +4401,7 @@  discard block
 block discarded – undo
4401 4401
  *     Code HTML du lien
4402 4402
  **/
4403 4403
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") {
4404
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4404
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4405 4405
 }
4406 4406
 
4407 4407
 /**
@@ -4431,7 +4431,7 @@  discard block
 block discarded – undo
4431 4431
  *     Code HTML du lien
4432 4432
  */
4433 4433
 function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") {
4434
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4434
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4435 4435
 }
4436 4436
 
4437 4437
 
@@ -4479,26 +4479,26 @@  discard block
 block discarded – undo
4479 4479
  * @return string Code CSS
4480 4480
  */
4481 4481
 function bando_images_background() {
4482
-	include_spip('inc/bandeau');
4483
-	// recuperer tous les boutons et leurs images
4484
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4482
+    include_spip('inc/bandeau');
4483
+    // recuperer tous les boutons et leurs images
4484
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4485 4485
 
4486
-	$res = "";
4487
-	foreach ($boutons as $page => $detail) {
4488
-		if ($detail->icone and strlen(trim($detail->icone))) {
4489
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4490
-		}
4491
-		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4492
-		if (is_array($detail->sousmenu)) {
4493
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4494
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4495
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4496
-				}
4497
-			}
4498
-		}
4499
-	}
4486
+    $res = "";
4487
+    foreach ($boutons as $page => $detail) {
4488
+        if ($detail->icone and strlen(trim($detail->icone))) {
4489
+            $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4490
+        }
4491
+        $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4492
+        if (is_array($detail->sousmenu)) {
4493
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4494
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4495
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4496
+                }
4497
+            }
4498
+        }
4499
+    }
4500 4500
 
4501
-	return $res;
4501
+    return $res;
4502 4502
 }
4503 4503
 
4504 4504
 /**
@@ -4517,19 +4517,19 @@  discard block
 block discarded – undo
4517 4517
  * @return string
4518 4518
  */
4519 4519
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4520
-	if ($confirm) {
4521
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4522
-		if ($callback) {
4523
-			$callback = "$confirm?($callback):false";
4524
-		} else {
4525
-			$callback = $confirm;
4526
-		}
4527
-	}
4528
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4529
-	$title = $title ? " title='$title'" : "";
4520
+    if ($confirm) {
4521
+        $confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4522
+        if ($callback) {
4523
+            $callback = "$confirm?($callback):false";
4524
+        } else {
4525
+            $callback = $confirm;
4526
+        }
4527
+    }
4528
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4529
+    $title = $title ? " title='$title'" : "";
4530 4530
 
4531
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4532
-	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4531
+    return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4532
+    . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4533 4533
 }
4534 4534
 
4535 4535
 /**
@@ -4550,78 +4550,78 @@  discard block
 block discarded – undo
4550 4550
  * @return string
4551 4551
  */
4552 4552
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") {
4553
-	static $trouver_table = null;
4554
-	static $objets;
4555
-
4556
-	// On verifie qu'on a tout ce qu'il faut
4557
-	$id_objet = intval($id_objet);
4558
-	if (!($id_objet and $type_objet and $info)) {
4559
-		return '';
4560
-	}
4561
-
4562
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4563
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4564
-		return '';
4565
-	}
4566
-
4567
-	// Si on demande l'url, on retourne direct la fonction
4568
-	if ($info == 'url') {
4569
-		return generer_url_entite($id_objet, $type_objet);
4570
-	}
4571
-
4572
-	// Sinon on va tout chercher dans la table et on garde en memoire
4573
-	$demande_titre = ($info == 'titre');
4574
-
4575
-	// 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
4576
-	if (!isset($objets[$type_objet][$id_objet])
4577
-		or
4578
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4579
-	) {
4580
-		if (!$trouver_table) {
4581
-			$trouver_table = charger_fonction('trouver_table', 'base');
4582
-		}
4583
-		$desc = $trouver_table(table_objet_sql($type_objet));
4584
-		if (!$desc) {
4585
-			return $objets[$type_objet] = false;
4586
-		}
4587
-
4588
-		// Si on demande le titre, on le gere en interne
4589
-		$champ_titre = "";
4590
-		if ($demande_titre) {
4591
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4592
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4593
-		}
4594
-		include_spip('base/abstract_sql');
4595
-		include_spip('base/connect_sql');
4596
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4597
-			'*' . $champ_titre,
4598
-			$desc['table_sql'],
4599
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4600
-		);
4601
-	}
4602
-
4603
-	// Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4604
-	if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4605
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4606
-	} // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4607
-	else {
4608
-		if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4609
-			$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4610
-		} // Sinon on prend directement le champ SQL tel quel
4611
-		else {
4612
-			$info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4613
-		}
4614
-	}
4615
-
4616
-	// On va ensuite appliquer les traitements automatiques si besoin
4617
-	if (!$etoile) {
4618
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4619
-		// mais ce fonctionnement est a ameliorer !
4620
-		$info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4621
-			array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4622
-	}
4623
-
4624
-	return $info_generee;
4553
+    static $trouver_table = null;
4554
+    static $objets;
4555
+
4556
+    // On verifie qu'on a tout ce qu'il faut
4557
+    $id_objet = intval($id_objet);
4558
+    if (!($id_objet and $type_objet and $info)) {
4559
+        return '';
4560
+    }
4561
+
4562
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4563
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4564
+        return '';
4565
+    }
4566
+
4567
+    // Si on demande l'url, on retourne direct la fonction
4568
+    if ($info == 'url') {
4569
+        return generer_url_entite($id_objet, $type_objet);
4570
+    }
4571
+
4572
+    // Sinon on va tout chercher dans la table et on garde en memoire
4573
+    $demande_titre = ($info == 'titre');
4574
+
4575
+    // 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
4576
+    if (!isset($objets[$type_objet][$id_objet])
4577
+        or
4578
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4579
+    ) {
4580
+        if (!$trouver_table) {
4581
+            $trouver_table = charger_fonction('trouver_table', 'base');
4582
+        }
4583
+        $desc = $trouver_table(table_objet_sql($type_objet));
4584
+        if (!$desc) {
4585
+            return $objets[$type_objet] = false;
4586
+        }
4587
+
4588
+        // Si on demande le titre, on le gere en interne
4589
+        $champ_titre = "";
4590
+        if ($demande_titre) {
4591
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4592
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4593
+        }
4594
+        include_spip('base/abstract_sql');
4595
+        include_spip('base/connect_sql');
4596
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4597
+            '*' . $champ_titre,
4598
+            $desc['table_sql'],
4599
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4600
+        );
4601
+    }
4602
+
4603
+    // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4604
+    if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4605
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4606
+    } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4607
+    else {
4608
+        if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4609
+            $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4610
+        } // Sinon on prend directement le champ SQL tel quel
4611
+        else {
4612
+            $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4613
+        }
4614
+    }
4615
+
4616
+    // On va ensuite appliquer les traitements automatiques si besoin
4617
+    if (!$etoile) {
4618
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4619
+        // mais ce fonctionnement est a ameliorer !
4620
+        $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4621
+            array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4622
+    }
4623
+
4624
+    return $info_generee;
4625 4625
 }
4626 4626
 
4627 4627
 /**
@@ -4635,44 +4635,44 @@  discard block
 block discarded – undo
4635 4635
  * @return string
4636 4636
  */
4637 4637
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') {
4638
-	if (!$champ) {
4639
-		return $texte;
4640
-	}
4638
+    if (!$champ) {
4639
+        return $texte;
4640
+    }
4641 4641
 	
4642
-	// On charge toujours les filtres de texte car la majorité des traitements les utilisent
4643
-	// et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4644
-	include_spip('inc/texte');
4642
+    // On charge toujours les filtres de texte car la majorité des traitements les utilisent
4643
+    // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4644
+    include_spip('inc/texte');
4645 4645
 	
4646
-	$champ = strtoupper($champ);
4647
-	$traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4648
-	if (!$traitements or !is_array($traitements)) {
4649
-		return $texte;
4650
-	}
4646
+    $champ = strtoupper($champ);
4647
+    $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4648
+    if (!$traitements or !is_array($traitements)) {
4649
+        return $texte;
4650
+    }
4651 4651
 
4652
-	$traitement = '';
4653
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4654
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4655
-		$table_objet = table_objet($table_objet);
4656
-		if (isset($traitements[$table_objet])) {
4657
-			$traitement = $traitements[$table_objet];
4658
-		}
4659
-	}
4660
-	if (!$traitement and isset($traitements[0])) {
4661
-		$traitement = $traitements[0];
4662
-	}
4663
-	// (sinon prendre le premier de la liste par defaut ?)
4652
+    $traitement = '';
4653
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4654
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4655
+        $table_objet = table_objet($table_objet);
4656
+        if (isset($traitements[$table_objet])) {
4657
+            $traitement = $traitements[$table_objet];
4658
+        }
4659
+    }
4660
+    if (!$traitement and isset($traitements[0])) {
4661
+        $traitement = $traitements[0];
4662
+    }
4663
+    // (sinon prendre le premier de la liste par defaut ?)
4664 4664
 
4665
-	if (!$traitement) {
4666
-		return $texte;
4667
-	}
4665
+    if (!$traitement) {
4666
+        return $texte;
4667
+    }
4668 4668
 
4669
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4669
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4670 4670
 
4671
-	// Fournir $connect et $Pile[0] au traitement si besoin
4672
-	$Pile = array(0 => $env);
4673
-	eval("\$texte = $traitement;");
4671
+    // Fournir $connect et $Pile[0] au traitement si besoin
4672
+    $Pile = array(0 => $env);
4673
+    eval("\$texte = $traitement;");
4674 4674
 
4675
-	return $texte;
4675
+    return $texte;
4676 4676
 }
4677 4677
 
4678 4678
 
@@ -4686,21 +4686,21 @@  discard block
 block discarded – undo
4686 4686
  * @return string
4687 4687
  */
4688 4688
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4689
-	include_spip('inc/liens');
4690
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4691
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4692
-	// le raccourcis n'est plus valide
4693
-	$titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4694
-	// on essaye avec generer_info_entite ?
4695
-	if (!strlen($titre) and !$connect) {
4696
-		$titre = generer_info_entite($id_objet, $objet, 'titre');
4697
-	}
4698
-	if (!strlen($titre)) {
4699
-		$titre = _T('info_sans_titre');
4700
-	}
4701
-	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4689
+    include_spip('inc/liens');
4690
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4691
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4692
+    // le raccourcis n'est plus valide
4693
+    $titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4694
+    // on essaye avec generer_info_entite ?
4695
+    if (!strlen($titre) and !$connect) {
4696
+        $titre = generer_info_entite($id_objet, $objet, 'titre');
4697
+    }
4698
+    if (!strlen($titre)) {
4699
+        $titre = _T('info_sans_titre');
4700
+    }
4701
+    $url = generer_url_entite($id_objet, $objet, '', '', $connect);
4702 4702
 
4703
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4703
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4704 4704
 }
4705 4705
 
4706 4706
 
@@ -4717,15 +4717,15 @@  discard block
 block discarded – undo
4717 4717
  * @return string
4718 4718
  */
4719 4719
 function wrap($texte, $wrap) {
4720
-	$balises = extraire_balises($wrap);
4721
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4722
-		$texte = $wrap . $texte;
4723
-		$regs = array_reverse($regs[1]);
4724
-		$wrap = "</" . implode("></", $regs) . ">";
4725
-		$texte = $texte . $wrap;
4726
-	}
4720
+    $balises = extraire_balises($wrap);
4721
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4722
+        $texte = $wrap . $texte;
4723
+        $regs = array_reverse($regs[1]);
4724
+        $wrap = "</" . implode("></", $regs) . ">";
4725
+        $texte = $texte . $wrap;
4726
+    }
4727 4727
 
4728
-	return $texte;
4728
+    return $texte;
4729 4729
 }
4730 4730
 
4731 4731
 
@@ -4745,43 +4745,43 @@  discard block
 block discarded – undo
4745 4745
  * @return array|mixed|string
4746 4746
  */
4747 4747
 function filtre_print_dist($u, $join = "<br />", $indent = 0) {
4748
-	if (is_string($u)) {
4749
-		$u = typo($u);
4748
+    if (is_string($u)) {
4749
+        $u = typo($u);
4750 4750
 
4751
-		return $u;
4752
-	}
4751
+        return $u;
4752
+    }
4753 4753
 
4754
-	// caster $u en array si besoin
4755
-	if (is_object($u)) {
4756
-		$u = (array)$u;
4757
-	}
4754
+    // caster $u en array si besoin
4755
+    if (is_object($u)) {
4756
+        $u = (array)$u;
4757
+    }
4758 4758
 
4759
-	if (is_array($u)) {
4760
-		$out = "";
4761
-		// toutes les cles sont numeriques ?
4762
-		// et aucun enfant n'est un tableau
4763
-		// liste simple separee par des virgules
4764
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4765
-		$array_values = array_map('is_array', $u);
4766
-		$object_values = array_map('is_object', $u);
4767
-		if (array_sum($numeric_keys) == count($numeric_keys)
4768
-			and !array_sum($array_values)
4769
-			and !array_sum($object_values)
4770
-		) {
4771
-			return join(", ", array_map('filtre_print_dist', $u));
4772
-		}
4759
+    if (is_array($u)) {
4760
+        $out = "";
4761
+        // toutes les cles sont numeriques ?
4762
+        // et aucun enfant n'est un tableau
4763
+        // liste simple separee par des virgules
4764
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4765
+        $array_values = array_map('is_array', $u);
4766
+        $object_values = array_map('is_object', $u);
4767
+        if (array_sum($numeric_keys) == count($numeric_keys)
4768
+            and !array_sum($array_values)
4769
+            and !array_sum($object_values)
4770
+        ) {
4771
+            return join(", ", array_map('filtre_print_dist', $u));
4772
+        }
4773 4773
 
4774
-		// sinon on passe a la ligne et on indente
4775
-		$i_str = str_pad("", $indent, " ");
4776
-		foreach ($u as $k => $v) {
4777
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4778
-		}
4774
+        // sinon on passe a la ligne et on indente
4775
+        $i_str = str_pad("", $indent, " ");
4776
+        foreach ($u as $k => $v) {
4777
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4778
+        }
4779 4779
 
4780
-		return $out;
4781
-	}
4780
+        return $out;
4781
+    }
4782 4782
 
4783
-	// on sait pas quoi faire...
4784
-	return $u;
4783
+    // on sait pas quoi faire...
4784
+    return $u;
4785 4785
 }
4786 4786
 
4787 4787
 
@@ -4794,10 +4794,10 @@  discard block
 block discarded – undo
4794 4794
  * @return string|array
4795 4795
  */
4796 4796
 function objet_info($objet, $info) {
4797
-	$table = table_objet_sql($objet);
4798
-	$infos = lister_tables_objets_sql($table);
4797
+    $table = table_objet_sql($objet);
4798
+    $infos = lister_tables_objets_sql($table);
4799 4799
 
4800
-	return (isset($infos[$info]) ? $infos[$info] : '');
4800
+    return (isset($infos[$info]) ? $infos[$info] : '');
4801 4801
 }
4802 4802
 
4803 4803
 /**
@@ -4812,11 +4812,11 @@  discard block
 block discarded – undo
4812 4812
  *     Texte traduit du comptage, tel que '3 articles'
4813 4813
  */
4814 4814
 function objet_afficher_nb($nb, $objet) {
4815
-	if (!$nb) {
4816
-		return _T(objet_info($objet, 'info_aucun_objet'));
4817
-	} else {
4818
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4819
-	}
4815
+    if (!$nb) {
4816
+        return _T(objet_info($objet, 'info_aucun_objet'));
4817
+    } else {
4818
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4819
+    }
4820 4820
 }
4821 4821
 
4822 4822
 /**
@@ -4828,11 +4828,11 @@  discard block
 block discarded – undo
4828 4828
  * @return string
4829 4829
  */
4830 4830
 function objet_icone($objet, $taille = 24, $class='') {
4831
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4832
-	$icone = chemin_image($icone);
4833
-	$balise_img = charger_filtre('balise_img');
4831
+    $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4832
+    $icone = chemin_image($icone);
4833
+    $balise_img = charger_filtre('balise_img');
4834 4834
 
4835
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4835
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4836 4836
 }
4837 4837
 
4838 4838
 /**
@@ -4853,12 +4853,12 @@  discard block
 block discarded – undo
4853 4853
  * @return string
4854 4854
  */
4855 4855
 function objet_T($objet, $chaine, $args = array(), $options = array()){
4856
-	$chaine = explode(':',$chaine);
4857
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4858
-		return $t;
4859
-	}
4860
-	$chaine = implode(':',$chaine);
4861
-	return _T($chaine, $args, $options);
4856
+    $chaine = explode(':',$chaine);
4857
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4858
+        return $t;
4859
+    }
4860
+    $chaine = implode(':',$chaine);
4861
+    return _T($chaine, $args, $options);
4862 4862
 }
4863 4863
 
4864 4864
 /**
@@ -4872,17 +4872,17 @@  discard block
 block discarded – undo
4872 4872
  * @return string      Code HTML
4873 4873
  */
4874 4874
 function insert_head_css_conditionnel($flux) {
4875
-	if (strpos($flux, '<!-- insert_head_css -->') === false
4876
-		and $p = strpos($flux, '<!-- insert_head -->')
4877
-	) {
4878
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4879
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4880
-			$p = $p1;
4881
-		}
4882
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4883
-	}
4875
+    if (strpos($flux, '<!-- insert_head_css -->') === false
4876
+        and $p = strpos($flux, '<!-- insert_head -->')
4877
+    ) {
4878
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4879
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4880
+            $p = $p1;
4881
+        }
4882
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4883
+    }
4884 4884
 
4885
-	return $flux;
4885
+    return $flux;
4886 4886
 }
4887 4887
 
4888 4888
 /**
@@ -4903,69 +4903,69 @@  discard block
 block discarded – undo
4903 4903
  * @return string
4904 4904
  */
4905 4905
 function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') {
4906
-	if (isset($contexte['format'])) {
4907
-		$extension = $contexte['format'];
4908
-		unset($contexte['format']);
4909
-	} else {
4910
-		$extension = "html";
4911
-		if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4912
-			$extension = $m[1];
4913
-		}
4914
-	}
4915
-	// recuperer le contenu produit par le squelette
4916
-	$options['raw'] = true;
4917
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4918
-
4919
-	// calculer le nom de la css
4920
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4921
-	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4922
-	$contexte_implicite = calculer_contexte_implicite();
4923
-
4924
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4925
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4926
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4927
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4928
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4929
-	}
4930
-	else {
4931
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4932
-		ksort($contexte);
4933
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4934
-	}
4935
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4936
-
4937
-	// mettre a jour le fichier si il n'existe pas
4938
-	// ou trop ancien
4939
-	// le dernier fichier produit est toujours suffixe par .last
4940
-	// et recopie sur le fichier cible uniquement si il change
4941
-	if (!file_exists($filename)
4942
-		or !file_exists($filename . ".last")
4943
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4944
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4945
-	) {
4946
-		$contenu = $cache['texte'];
4947
-		// passer les urls en absolu si c'est une css
4948
-		if ($extension == "css") {
4949
-			$contenu = urls_absolues_css($contenu,
4950
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4951
-		}
4952
-
4953
-		$comment = '';
4954
-		// ne pas insérer de commentaire si c'est du json
4955
-		if ($extension != "json") {
4956
-			$comment = "/* #PRODUIRE{fond=$fond";
4957
-			foreach ($contexte as $k => $v) {
4958
-				$comment .= ",$k=$v";
4959
-			}
4960
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4961
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4962
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4963
-		}
4964
-		// et ecrire le fichier si il change
4965
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4966
-	}
4967
-
4968
-	return timestamp($filename);
4906
+    if (isset($contexte['format'])) {
4907
+        $extension = $contexte['format'];
4908
+        unset($contexte['format']);
4909
+    } else {
4910
+        $extension = "html";
4911
+        if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4912
+            $extension = $m[1];
4913
+        }
4914
+    }
4915
+    // recuperer le contenu produit par le squelette
4916
+    $options['raw'] = true;
4917
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4918
+
4919
+    // calculer le nom de la css
4920
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4921
+    $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4922
+    $contexte_implicite = calculer_contexte_implicite();
4923
+
4924
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4925
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4926
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4927
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4928
+        $hash = md5($contexte_implicite['host'] . '::'. $cache);
4929
+    }
4930
+    else {
4931
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4932
+        ksort($contexte);
4933
+        $hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4934
+    }
4935
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4936
+
4937
+    // mettre a jour le fichier si il n'existe pas
4938
+    // ou trop ancien
4939
+    // le dernier fichier produit est toujours suffixe par .last
4940
+    // et recopie sur le fichier cible uniquement si il change
4941
+    if (!file_exists($filename)
4942
+        or !file_exists($filename . ".last")
4943
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4944
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4945
+    ) {
4946
+        $contenu = $cache['texte'];
4947
+        // passer les urls en absolu si c'est une css
4948
+        if ($extension == "css") {
4949
+            $contenu = urls_absolues_css($contenu,
4950
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4951
+        }
4952
+
4953
+        $comment = '';
4954
+        // ne pas insérer de commentaire si c'est du json
4955
+        if ($extension != "json") {
4956
+            $comment = "/* #PRODUIRE{fond=$fond";
4957
+            foreach ($contexte as $k => $v) {
4958
+                $comment .= ",$k=$v";
4959
+            }
4960
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4961
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4962
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
4963
+        }
4964
+        // et ecrire le fichier si il change
4965
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4966
+    }
4967
+
4968
+    return timestamp($filename);
4969 4969
 }
4970 4970
 
4971 4971
 /**
@@ -4978,14 +4978,14 @@  discard block
 block discarded – undo
4978 4978
  *    $fichier auquel on a ajouté le timestamp
4979 4979
  */
4980 4980
 function timestamp($fichier) {
4981
-	if (!$fichier
4982
-		or !file_exists($fichier)
4983
-		or !$m = filemtime($fichier)
4984
-	) {
4985
-		return $fichier;
4986
-	}
4981
+    if (!$fichier
4982
+        or !file_exists($fichier)
4983
+        or !$m = filemtime($fichier)
4984
+    ) {
4985
+        return $fichier;
4986
+    }
4987 4987
 
4988
-	return "$fichier?$m";
4988
+    return "$fichier?$m";
4989 4989
 }
4990 4990
 
4991 4991
 /**
@@ -4995,11 +4995,11 @@  discard block
 block discarded – undo
4995 4995
  * @return string
4996 4996
  */
4997 4997
 function supprimer_timestamp($url) {
4998
-	if (strpos($url, "?") === false) {
4999
-		return $url;
5000
-	}
4998
+    if (strpos($url, "?") === false) {
4999
+        return $url;
5000
+    }
5001 5001
 
5002
-	return preg_replace(",\?[[:digit:]]+$,", "", $url);
5002
+    return preg_replace(",\?[[:digit:]]+$,", "", $url);
5003 5003
 }
5004 5004
 
5005 5005
 /**
@@ -5014,9 +5014,9 @@  discard block
 block discarded – undo
5014 5014
  * @return string
5015 5015
  */
5016 5016
 function filtre_nettoyer_titre_email_dist($titre) {
5017
-	include_spip('inc/envoyer_mail');
5017
+    include_spip('inc/envoyer_mail');
5018 5018
 
5019
-	return nettoyer_titre_email($titre);
5019
+    return nettoyer_titre_email($titre);
5020 5020
 }
5021 5021
 
5022 5022
 /**
@@ -5038,19 +5038,19 @@  discard block
 block discarded – undo
5038 5038
  * @return string
5039 5039
  */
5040 5040
 function filtre_chercher_rubrique_dist(
5041
-	$titre,
5042
-	$id_objet,
5043
-	$id_parent,
5044
-	$objet,
5045
-	$id_secteur,
5046
-	$restreint,
5047
-	$actionable = false,
5048
-	$retour_sans_cadre = false
5041
+    $titre,
5042
+    $id_objet,
5043
+    $id_parent,
5044
+    $objet,
5045
+    $id_secteur,
5046
+    $restreint,
5047
+    $actionable = false,
5048
+    $retour_sans_cadre = false
5049 5049
 ) {
5050
-	include_spip('inc/filtres_ecrire');
5050
+    include_spip('inc/filtres_ecrire');
5051 5051
 
5052
-	return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
5053
-		$retour_sans_cadre);
5052
+    return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
5053
+        $retour_sans_cadre);
5054 5054
 }
5055 5055
 
5056 5056
 /**
@@ -5079,56 +5079,56 @@  discard block
 block discarded – undo
5079 5079
  *     Chaîne vide si l'accès est autorisé
5080 5080
  */
5081 5081
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
5082
-	if ($ok) {
5083
-		return '';
5084
-	}
5085
-
5086
-	// Vider tous les tampons
5087
-	$level = @ob_get_level();
5088
-	while ($level--) {
5089
-		@ob_end_clean();
5090
-	}
5091
-
5092
-	include_spip('inc/headers');
5093
-
5094
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5095
-	if ($url) {
5096
-		redirige_par_entete($url, '', $statut);
5097
-	}
5098
-
5099
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
5100
-	if (!is_numeric($statut) and is_null($message)) {
5101
-		$message = $statut;
5102
-		$statut = 0;
5103
-	}
5104
-	if (!$message) {
5105
-		$message = '';
5106
-	}
5107
-	$statut = intval($statut);
5108
-
5109
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5110
-	if (test_espace_prive()) {
5111
-		if (!$statut or !in_array($statut, array(404, 403))) {
5112
-			$statut = 403;
5113
-		}
5114
-		http_status(403);
5115
-		$echec = charger_fonction('403', 'exec');
5116
-		$echec($message);
5117
-	} else {
5118
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5119
-		if (!$statut) {
5120
-			$statut = 404;
5121
-		}
5122
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
5123
-		http_status($statut);
5124
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5125
-		if ($statut >= 400) {
5126
-			echo recuperer_fond("$statut", array('erreur' => $message));
5127
-		}
5128
-	}
5129
-
5130
-
5131
-	exit;
5082
+    if ($ok) {
5083
+        return '';
5084
+    }
5085
+
5086
+    // Vider tous les tampons
5087
+    $level = @ob_get_level();
5088
+    while ($level--) {
5089
+        @ob_end_clean();
5090
+    }
5091
+
5092
+    include_spip('inc/headers');
5093
+
5094
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5095
+    if ($url) {
5096
+        redirige_par_entete($url, '', $statut);
5097
+    }
5098
+
5099
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
5100
+    if (!is_numeric($statut) and is_null($message)) {
5101
+        $message = $statut;
5102
+        $statut = 0;
5103
+    }
5104
+    if (!$message) {
5105
+        $message = '';
5106
+    }
5107
+    $statut = intval($statut);
5108
+
5109
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5110
+    if (test_espace_prive()) {
5111
+        if (!$statut or !in_array($statut, array(404, 403))) {
5112
+            $statut = 403;
5113
+        }
5114
+        http_status(403);
5115
+        $echec = charger_fonction('403', 'exec');
5116
+        $echec($message);
5117
+    } else {
5118
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5119
+        if (!$statut) {
5120
+            $statut = 404;
5121
+        }
5122
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
5123
+        http_status($statut);
5124
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5125
+        if ($statut >= 400) {
5126
+            echo recuperer_fond("$statut", array('erreur' => $message));
5127
+        }
5128
+    }
5129
+
5130
+
5131
+    exit;
5132 5132
 }
5133 5133
 
5134 5134
 /**
@@ -5139,11 +5139,11 @@  discard block
 block discarded – undo
5139 5139
  * @return string
5140 5140
  */
5141 5141
 function filtre_compacte_dist($source, $format = null) {
5142
-	if (function_exists('compacte')) {
5143
-		return compacte($source, $format);
5144
-	}
5142
+    if (function_exists('compacte')) {
5143
+        return compacte($source, $format);
5144
+    }
5145 5145
 
5146
-	return $source;
5146
+    return $source;
5147 5147
 }
5148 5148
 
5149 5149
 
@@ -5155,31 +5155,31 @@  discard block
 block discarded – undo
5155 5155
  * @return string
5156 5156
  */
5157 5157
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
5158
-	$l = strlen($passe);
5159
-
5160
-	if ($l<=8 or !$afficher_partiellement){
5161
-		if (!$l) {
5162
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5163
-		}
5164
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
5165
-	}
5166
-
5167
-	if (is_null($portion_pourcent)) {
5168
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5169
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5170
-		}
5171
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5172
-	}
5173
-	if ($portion_pourcent >= 100) {
5174
-		return $passe;
5175
-	}
5176
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
5177
-	$e = max($e, 0);
5178
-	$mid = str_pad('',$l-2*$e,'*');
5179
-	if ($e>0 and strlen($mid)>8){
5180
-		$mid = '***...***';
5181
-	}
5182
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
5158
+    $l = strlen($passe);
5159
+
5160
+    if ($l<=8 or !$afficher_partiellement){
5161
+        if (!$l) {
5162
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5163
+        }
5164
+        return str_pad('',$afficher_partiellement ? $l : 16,'*');
5165
+    }
5166
+
5167
+    if (is_null($portion_pourcent)) {
5168
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5169
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5170
+        }
5171
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5172
+    }
5173
+    if ($portion_pourcent >= 100) {
5174
+        return $passe;
5175
+    }
5176
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
5177
+    $e = max($e, 0);
5178
+    $mid = str_pad('',$l-2*$e,'*');
5179
+    if ($e>0 and strlen($mid)>8){
5180
+        $mid = '***...***';
5181
+    }
5182
+    return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
5183 5183
 }
5184 5184
 
5185 5185
 
@@ -5200,62 +5200,62 @@  discard block
 block discarded – undo
5200 5200
  */
5201 5201
 function identifiant_slug($texte, $type = '', $options = array()) {
5202 5202
 
5203
-	$original = $texte;
5204
-	$separateur = (isset($options['separateur'])?$options['separateur']:'_');
5205
-	$longueur_maxi = (isset($options['longueur_maxi'])?$options['longueur_maxi']:60);
5206
-	$longueur_mini = (isset($options['longueur_mini'])?$options['longueur_mini']:0);
5207
-
5208
-	if (!function_exists('translitteration')) {
5209
-		include_spip('inc/charsets');
5210
-	}
5211
-
5212
-	// pas de balise html
5213
-	if (strpos($texte, '<') !== false) {
5214
-		$texte = strip_tags($texte);
5215
-	}
5216
-	if (strpos($texte, '&') !== false) {
5217
-		$texte = unicode2charset($texte);
5218
-	}
5219
-	// On enlève les espaces indésirables
5220
-	$texte = trim($texte);
5221
-
5222
-	// On enlève les accents et cie
5223
-	$texte = translitteration($texte);
5224
-
5225
-	// On remplace tout ce qui n'est pas un mot par un séparateur
5226
-	$texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5227
-
5228
-	// nettoyer les doubles occurences du separateur si besoin
5229
-	while (strpos($texte, "$separateur$separateur") !== false) {
5230
-		$texte = str_replace("$separateur$separateur", $separateur, $texte);
5231
-	}
5232
-
5233
-	// pas de separateur au debut ni a la fin
5234
-	$texte = trim($texte, $separateur);
5235
-
5236
-	// en minuscules
5237
-	$texte = strtolower($texte);
5238
-
5239
-	switch ($type) {
5240
-		case 'class':
5241
-		case 'id':
5242
-		case 'anchor':
5243
-			if (preg_match(',^\d,', $texte)) {
5244
-				$texte = substr($type, 0, 1).$texte;
5245
-			}
5246
-	}
5247
-
5248
-	if (strlen($texte)>$longueur_maxi) {
5249
-		$texte = substr($texte, 0, $longueur_maxi);
5250
-	}
5251
-
5252
-	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5253
-		if (preg_match(',^\d,', $texte)) {
5254
-			$texte = ($type ? substr($type,0,1) : "s") . $texte;
5255
-		}
5256
-		$texte .= $separateur . md5($original);
5257
-		$texte = substr($texte, 0, $longueur_mini);
5258
-	}
5259
-
5260
-	return $texte;
5203
+    $original = $texte;
5204
+    $separateur = (isset($options['separateur'])?$options['separateur']:'_');
5205
+    $longueur_maxi = (isset($options['longueur_maxi'])?$options['longueur_maxi']:60);
5206
+    $longueur_mini = (isset($options['longueur_mini'])?$options['longueur_mini']:0);
5207
+
5208
+    if (!function_exists('translitteration')) {
5209
+        include_spip('inc/charsets');
5210
+    }
5211
+
5212
+    // pas de balise html
5213
+    if (strpos($texte, '<') !== false) {
5214
+        $texte = strip_tags($texte);
5215
+    }
5216
+    if (strpos($texte, '&') !== false) {
5217
+        $texte = unicode2charset($texte);
5218
+    }
5219
+    // On enlève les espaces indésirables
5220
+    $texte = trim($texte);
5221
+
5222
+    // On enlève les accents et cie
5223
+    $texte = translitteration($texte);
5224
+
5225
+    // On remplace tout ce qui n'est pas un mot par un séparateur
5226
+    $texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5227
+
5228
+    // nettoyer les doubles occurences du separateur si besoin
5229
+    while (strpos($texte, "$separateur$separateur") !== false) {
5230
+        $texte = str_replace("$separateur$separateur", $separateur, $texte);
5231
+    }
5232
+
5233
+    // pas de separateur au debut ni a la fin
5234
+    $texte = trim($texte, $separateur);
5235
+
5236
+    // en minuscules
5237
+    $texte = strtolower($texte);
5238
+
5239
+    switch ($type) {
5240
+        case 'class':
5241
+        case 'id':
5242
+        case 'anchor':
5243
+            if (preg_match(',^\d,', $texte)) {
5244
+                $texte = substr($type, 0, 1).$texte;
5245
+            }
5246
+    }
5247
+
5248
+    if (strlen($texte)>$longueur_maxi) {
5249
+        $texte = substr($texte, 0, $longueur_maxi);
5250
+    }
5251
+
5252
+    if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5253
+        if (preg_match(',^\d,', $texte)) {
5254
+            $texte = ($type ? substr($type,0,1) : "s") . $texte;
5255
+        }
5256
+        $texte .= $separateur . md5($original);
5257
+        $texte = substr($texte, 0, $longueur_mini);
5258
+    }
5259
+
5260
+    return $texte;
5261 5261
 }
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)) {
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	// affichage "GIT [master: abcdef]"
222 222
 	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
223 223
 	if ($desc['branch']) {
224
-		$commit = $desc['branch'] . ': ' . $commit;
224
+		$commit = $desc['branch'].': '.$commit;
225 225
 	}
226 226
 	return "{$desc['vcs']} [$commit]";
227 227
 }
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 
242 242
 	// version installee par GIT
243
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
243
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
244 244
 		$currentHead = trim(substr($c, 4));
245
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
245
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
246 246
 			return [
247 247
 				'vcs' => 'GIT',
248 248
 				'branch' => basename($currentHead),
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 		$dir = '.';
270 270
 	}
271 271
 	// version installee par SVN
272
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
273
-		$db = new SQLite3($dir . '/.svn/wc.db');
272
+	if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) {
273
+		$db = new SQLite3($dir.'/.svn/wc.db');
274 274
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
275 275
 		if ($result) {
276 276
 			$row = $result->fetchArray();
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 
310 310
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
311 311
 // et laisser passer les fonctions personnelles baptisees image_...
312
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
313
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
314
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
315
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
316
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
312
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
313
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
314
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
315
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
316
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
317 317
 
318 318
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
319 319
 $GLOBALS['spip_matrice']['couleur_hex_to_hsl'] = 'inc/filtres_images_mini.php';
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
  */
473 473
 function filtre_debug($val, $key = null) {
474 474
 	$debug = (
475
-		is_null($key) ? '' : (var_export($key, true) . " = ")
476
-		) . var_export($val, true);
475
+		is_null($key) ? '' : (var_export($key, true)." = ")
476
+		).var_export($val, true);
477 477
 
478 478
 	include_spip('inc/autoriser');
479 479
 	if (autoriser('webmestre')) {
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
573 573
 							$srcover = $match[1];
574 574
 							array_shift($args);
575
-							array_unshift($args, "<img src='" . $match[1] . "' />");
575
+							array_unshift($args, "<img src='".$match[1]."' />");
576 576
 							$srcover_filter = call_user_func_array($filtre, $args);
577 577
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
578 578
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -643,14 +643,14 @@  discard block
 block discarded – undo
643 643
 				$hauteur_img[$src] = $srcHeight = $srcsize[1];
644 644
 			}
645 645
 		}
646
-		elseif(strpos($src, "<svg") !== false) {
646
+		elseif (strpos($src, "<svg") !== false) {
647 647
 			include_spip('inc/svg');
648
-			if ($attrs = svg_lire_attributs($src)){
648
+			if ($attrs = svg_lire_attributs($src)) {
649 649
 				list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
650
-				if (!$srcWidth){
650
+				if (!$srcWidth) {
651 651
 					$largeur_img[$src] = $srcWidth = $width;
652 652
 				}
653
-				if (!$srcHeight){
653
+				if (!$srcHeight) {
654 654
 					$hauteur_img[$src] = $srcHeight = $height;
655 655
 				}
656 656
 			}
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 	// " -> &quot; et tout ce genre de choses
935 935
 	$u = $GLOBALS['meta']['pcre_u'];
936 936
 	$texte = str_replace("&nbsp;", " ", $texte);
937
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
937
+	$texte = preg_replace('/\s{2,}/S'.$u, " ", $texte);
938 938
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
939 939
 	$texte = entites_html($texte, false, false);
940 940
 	// mais bien echapper les double quotes !
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
  **/
995 995
 function supprimer_numero($texte) {
996 996
 	return preg_replace(
997
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
997
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
998 998
 		"", $texte);
999 999
 }
1000 1000
 
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
  **/
1020 1020
 function recuperer_numero($texte) {
1021 1021
 	if (preg_match(
1022
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
1022
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
1023 1023
 		$texte, $regs)) {
1024 1024
 		return strval($regs[1]);
1025 1025
 	} else {
@@ -1104,8 +1104,8 @@  discard block
 block discarded – undo
1104 1104
  **/
1105 1105
 function textebrut($texte) {
1106 1106
 	$u = $GLOBALS['meta']['pcre_u'];
1107
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1108
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1107
+	$texte = preg_replace('/\s+/S'.$u, " ", $texte);
1108
+	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
1109 1109
 	$texte = preg_replace("/^\n+/", "", $texte);
1110 1110
 	$texte = preg_replace("/\n+$/", "", $texte);
1111 1111
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1134 1134
 		$texte, $liens, PREG_PATTERN_ORDER)) {
1135 1135
 		foreach ($liens[0] as $a) {
1136
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1136
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1137 1137
 			$ablank = inserer_attribut($a, 'rel', $rel);
1138 1138
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1139 1139
 			$texte = str_replace($a, $ablank, $texte);
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 		foreach ($regs[0] as $a) {
1159 1159
 			$rel = extraire_attribut($a, "rel");
1160 1160
 			if (strpos($rel, "nofollow") === false) {
1161
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1161
+				$rel = "nofollow".($rel ? " $rel" : "");
1162 1162
 				$anofollow = inserer_attribut($a, "rel", $rel);
1163 1163
 				$texte = str_replace($a, $anofollow, $texte);
1164 1164
 			}
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 	$u = $GLOBALS['meta']['pcre_u'];
1188 1188
 	$texte = preg_replace("@</p>@iS", "\n", $texte);
1189 1189
 	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1190
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1190
+	$texte = preg_replace("@^\s*<br />@S".$u, "", $texte);
1191 1191
 
1192 1192
 	return $texte;
1193 1193
 }
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 		return $texte;
1218 1218
 	}
1219 1219
 	include_spip('inc/texte');
1220
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1220
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1221 1221
 		'div' : 'span';
1222 1222
 
1223 1223
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 function attribut_html($texte, $textebrut = true) {
1327 1327
 	$u = $GLOBALS['meta']['pcre_u'];
1328 1328
 	if ($textebrut) {
1329
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1329
+		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte));
1330 1330
 	}
1331 1331
 	$texte = texte_backend($texte);
1332 1332
 	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 	# un message pour abs_url
1356 1356
 	$GLOBALS['mode_abs_url'] = 'url';
1357 1357
 	$url = trim($url);
1358
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1358
+	$r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS';
1359 1359
 
1360 1360
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1361 1361
 }
@@ -1557,14 +1557,14 @@  discard block
 block discarded – undo
1557 1557
 	if (strpos($texte, "<") !== false) {
1558 1558
 		include_spip('inc/lien');
1559 1559
 		if (defined('_PREG_MODELE')) {
1560
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1560
+			$preg_modeles = "@"._PREG_MODELE."@imsS";
1561 1561
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1562 1562
 		}
1563 1563
 	}
1564 1564
 
1565 1565
 	$debut = '';
1566 1566
 	$suite = $texte;
1567
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1567
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1568 1568
 		$debut .= substr($suite, 0, $t - 1);
1569 1569
 		$suite = substr($suite, $t);
1570 1570
 		$car = substr($suite, 0, 1);
@@ -1581,11 +1581,11 @@  discard block
 block discarded – undo
1581 1581
 			$suite = substr($suite, strlen($regs[0]));
1582 1582
 		}
1583 1583
 	}
1584
-	$texte = $debut . $suite;
1584
+	$texte = $debut.$suite;
1585 1585
 
1586 1586
 	$texte = echappe_retour($texte);
1587 1587
 
1588
-	return $texte . $fin;
1588
+	return $texte.$fin;
1589 1589
 }
1590 1590
 
1591 1591
 
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
 		}
1647 1647
 
1648 1648
 		foreach ($regs as $reg) {
1649
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1649
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1650 1650
 			$desc = $traduire($cle, $lang, true);
1651 1651
 			$l = $desc->langue;
1652 1652
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1759,9 +1759,9 @@  discard block
 block discarded – undo
1759 1759
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1760 1760
 					include_spip('inc/texte');
1761 1761
 					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1762
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1762
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1763 1763
 					if ($mode === 'div') {
1764
-						$trad = rtrim($trad) . "\n\n";
1764
+						$trad = rtrim($trad)."\n\n";
1765 1765
 					}
1766 1766
 					$trad = code_echappement($trad, 'multi', false, $mode);
1767 1767
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
 	if (is_array($balise)) {
1956 1956
 		array_walk(
1957 1957
 			$balise,
1958
-			function(&$a, $key, $t){
1958
+			function(&$a, $key, $t) {
1959 1959
 				$a = extraire_attribut($a, $t);
1960 1960
 			},
1961 1961
 			$attribut
@@ -2042,14 +2042,14 @@  discard block
 block discarded – undo
2042 2042
 
2043 2043
 	if ($old !== null) {
2044 2044
 		// Remplacer l'ancien attribut du meme nom
2045
-		$balise = $r[1] . $insert . $r[5];
2045
+		$balise = $r[1].$insert.$r[5];
2046 2046
 	} else {
2047 2047
 		// preferer une balise " />" (comme <img />)
2048 2048
 		if (preg_match(',/>,', $balise)) {
2049
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2049
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
2050 2050
 		} // sinon une balise <a ...> ... </a>
2051 2051
 		else {
2052
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2052
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
2053 2053
 		}
2054 2054
 	}
2055 2055
 
@@ -2082,7 +2082,7 @@  discard block
 block discarded – undo
2082 2082
  * @param string $operation
2083 2083
  * @return string
2084 2084
  */
2085
-function modifier_class($balise, $class, $operation='ajouter') {
2085
+function modifier_class($balise, $class, $operation = 'ajouter') {
2086 2086
 	if (is_string($class)) {
2087 2087
 		$class = explode(' ', trim($class));
2088 2088
 	}
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
 				}
2108 2108
 				if (in_array($operation, ['ajouter', 'commuter'])
2109 2109
 					and !$is_class_presente) {
2110
-					$class_new = rtrim($class_new) . " " . $c;
2110
+					$class_new = rtrim($class_new)." ".$c;
2111 2111
 				}
2112 2112
 				elseif (in_array($operation, ['supprimer', 'commuter'])
2113 2113
 					and $is_class_presente) {
@@ -2135,7 +2135,7 @@  discard block
 block discarded – undo
2135 2135
  * @param string|array $class
2136 2136
  * @return string
2137 2137
  */
2138
-function ajouter_class($balise, $class){
2138
+function ajouter_class($balise, $class) {
2139 2139
 	return modifier_class($balise, $class, 'ajouter');
2140 2140
 }
2141 2141
 
@@ -2145,7 +2145,7 @@  discard block
 block discarded – undo
2145 2145
  * @param string|array $class
2146 2146
  * @return string
2147 2147
  */
2148
-function supprimer_class($balise, $class){
2148
+function supprimer_class($balise, $class) {
2149 2149
 	return modifier_class($balise, $class, 'supprimer');
2150 2150
 }
2151 2151
 
@@ -2156,7 +2156,7 @@  discard block
 block discarded – undo
2156 2156
  * @param string|array $class
2157 2157
  * @return string
2158 2158
  */
2159
-function commuter_class($balise, $class){
2159
+function commuter_class($balise, $class) {
2160 2160
 	return modifier_class($balise, $class, 'commuter');
2161 2161
 }
2162 2162
 
@@ -2176,8 +2176,8 @@  discard block
 block discarded – undo
2176 2176
 //
2177 2177
 // Quelques fonctions de calcul arithmetique
2178 2178
 //
2179
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
2180
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
2179
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
2180
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
2181 2181
 
2182 2182
 /**
2183 2183
  * Additionne 2 nombres
@@ -2197,7 +2197,7 @@  discard block
 block discarded – undo
2197 2197
 function plus($a, $b) {
2198 2198
 	return $a + $b;
2199 2199
 }
2200
-function strplus($a, $b) {return strize('plus', $a, $b);}
2200
+function strplus($a, $b) {return strize('plus', $a, $b); }
2201 2201
 /**
2202 2202
  * Soustrait 2 nombres
2203 2203
  *
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 function moins($a, $b) {
2217 2217
 	return $a - $b;
2218 2218
 }
2219
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2219
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2220 2220
 
2221 2221
 /**
2222 2222
  * Multiplie 2 nombres
@@ -2237,7 +2237,7 @@  discard block
 block discarded – undo
2237 2237
 function mult($a, $b) {
2238 2238
 	return $a * $b;
2239 2239
 }
2240
-function strmult($a, $b) {return strize('mult', $a, $b);}
2240
+function strmult($a, $b) {return strize('mult', $a, $b); }
2241 2241
 
2242 2242
 /**
2243 2243
  * Divise 2 nombres
@@ -2258,7 +2258,7 @@  discard block
 block discarded – undo
2258 2258
 function div($a, $b) {
2259 2259
 	return $b ? $a / $b : 0;
2260 2260
 }
2261
-function strdiv($a, $b) {return strize('div', $a, $b);}
2261
+function strdiv($a, $b) {return strize('div', $a, $b); }
2262 2262
 
2263 2263
 /**
2264 2264
  * Retourne le modulo 2 nombres
@@ -2299,13 +2299,13 @@  discard block
 block discarded – undo
2299 2299
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2300 2300
 		define('_TAGS_NOM_AUTEUR', '');
2301 2301
 	}
2302
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2302
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2303 2303
 	foreach ($tags_acceptes as $tag) {
2304 2304
 		if (strlen($tag)) {
2305
-			$remp1[] = '<' . trim($tag) . '>';
2306
-			$remp1[] = '</' . trim($tag) . '>';
2307
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2308
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2305
+			$remp1[] = '<'.trim($tag).'>';
2306
+			$remp1[] = '</'.trim($tag).'>';
2307
+			$remp2[] = '\x60'.trim($tag).'\x61';
2308
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2309 2309
 		}
2310 2310
 	}
2311 2311
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2355,7 +2355,7 @@  discard block
 block discarded – undo
2355 2355
 			$s[] = preg_replace(',>[^<]+</a>,S',
2356 2356
 				'>'
2357 2357
 				. http_img_pack('attachment-16.png', $t,
2358
-					'title="' . attribut_html($t) . '"')
2358
+					'title="'.attribut_html($t).'"')
2359 2359
 				. '</a>', $tag);
2360 2360
 		}
2361 2361
 	}
@@ -2416,10 +2416,10 @@  discard block
 block discarded – undo
2416 2416
 	$fichier = basename($url);
2417 2417
 
2418 2418
 	return '<a rel="enclosure"'
2419
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2420
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2421
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2422
-	. '>' . $fichier . '</a>';
2419
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2420
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2421
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2422
+	. '>'.$fichier.'</a>';
2423 2423
 }
2424 2424
 
2425 2425
 /**
@@ -2447,9 +2447,9 @@  discard block
 block discarded – undo
2447 2447
 			} # vieux data
2448 2448
 			$fichier = basename($url);
2449 2449
 			$enclosures[] = '<enclosure'
2450
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2451
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2452
-				. ($length ? ' length="' . $length . '"' : '')
2450
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2451
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2452
+				. ($length ? ' length="'.$length.'"' : '')
2453 2453
 				. ' />';
2454 2454
 		}
2455 2455
 	}
@@ -2475,7 +2475,7 @@  discard block
 block discarded – undo
2475 2475
 		if (extraire_attribut($e, 'rel') == 'tag') {
2476 2476
 			$subjects .= '<dc:subject>'
2477 2477
 				. texte_backend(textebrut($e))
2478
-				. '</dc:subject>' . "\n";
2478
+				. '</dc:subject>'."\n";
2479 2479
 		}
2480 2480
 	}
2481 2481
 
@@ -2511,7 +2511,7 @@  discard block
 block discarded – undo
2511 2511
 	if (is_array($texte)) {
2512 2512
 		array_walk(
2513 2513
 			$texte,
2514
-			function(&$a, $key, $t){
2514
+			function(&$a, $key, $t) {
2515 2515
 				$a = extraire_balise($a, $t);
2516 2516
 			},
2517 2517
 			$tag
@@ -2555,7 +2555,7 @@  discard block
 block discarded – undo
2555 2555
 	if (is_array($texte)) {
2556 2556
 		array_walk(
2557 2557
 			$texte,
2558
-			function(&$a, $key, $t){
2558
+			function(&$a, $key, $t) {
2559 2559
 				$a = extraire_balises($a, $t);
2560 2560
 			},
2561 2561
 			$tag
@@ -2681,7 +2681,7 @@  discard block
 block discarded – undo
2681 2681
 		if ($fond != '404') {
2682 2682
 			$contexte = array_shift($p);
2683 2683
 			$contexte['page'] = $fond;
2684
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2684
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2685 2685
 		}
2686 2686
 	}
2687 2687
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2736,9 +2736,9 @@  discard block
 block discarded – undo
2736 2736
 			. '"'
2737 2737
 			. (is_null($val)
2738 2738
 				? ''
2739
-				: ' value="' . entites_html($val) . '"'
2739
+				: ' value="'.entites_html($val).'"'
2740 2740
 			)
2741
-			. ' type="hidden"' . "\n/>";
2741
+			. ' type="hidden"'."\n/>";
2742 2742
 	}
2743 2743
 
2744 2744
 	return join("", $hidden);
@@ -2875,7 +2875,7 @@  discard block
 block discarded – undo
2875 2875
 	return preg_replace_callback(
2876 2876
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2877 2877
 		function($x) use ($path) {
2878
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2878
+			return "url('".suivre_lien($path, $x[1])."')";
2879 2879
 		},
2880 2880
 		$contenu
2881 2881
 	);
@@ -2937,14 +2937,14 @@  discard block
 block discarded – undo
2937 2937
 	) {
2938 2938
 		$distant = true;
2939 2939
 		$cssf = parse_url($css);
2940
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2940
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2941 2941
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2942 2942
 	} else {
2943 2943
 		$distant = false;
2944 2944
 		$cssf = $css;
2945 2945
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2946 2946
 		//propose (rien a faire dans ce cas)
2947
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2947
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2948 2948
 		if (@file_exists($f)) {
2949 2949
 			return $f;
2950 2950
 		}
@@ -2954,7 +2954,7 @@  discard block
 block discarded – undo
2954 2954
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2955 2955
 	$f = $dir_var
2956 2956
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2957
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2957
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2958 2958
 
2959 2959
 	// la css peut etre distante (url absolue !)
2960 2960
 	if ($distant) {
@@ -2999,8 +2999,8 @@  discard block
 block discarded – undo
2999 2999
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
3000 3000
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3001 3001
 			$css_direction = substr($css_direction, strlen($dir_var));
3002
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
3003
-			$css_direction = "/@@@@@@/" . $css_direction;
3002
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
3003
+			$css_direction = "/@@@@@@/".$css_direction;
3004 3004
 		}
3005 3005
 		$src[] = $regs[0][$k];
3006 3006
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -3049,7 +3049,7 @@  discard block
 block discarded – undo
3049 3049
 
3050 3050
 	$f = basename($css, '.css');
3051 3051
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3052
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3052
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3053 3053
 		. '.css';
3054 3054
 
3055 3055
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3058,7 +3058,7 @@  discard block
 block discarded – undo
3058 3058
 
3059 3059
 	if ($url_absolue_css == $css) {
3060 3060
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3061
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3061
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3062 3062
 		) {
3063 3063
 			include_spip('inc/distant');
3064 3064
 			if (!$contenu = recuperer_page($css)) {
@@ -3168,7 +3168,7 @@  discard block
 block discarded – undo
3168 3168
 	$expression = str_replace("\/", "/", $expression);
3169 3169
 	$expression = str_replace("/", "\/", $expression);
3170 3170
 
3171
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3171
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3172 3172
 		if (isset($r[$capte])) {
3173 3173
 			return $r[$capte];
3174 3174
 		} else {
@@ -3206,7 +3206,7 @@  discard block
 block discarded – undo
3206 3206
 	$expression = str_replace("\/", "/", $expression);
3207 3207
 	$expression = str_replace("/", "\/", $expression);
3208 3208
 
3209
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3209
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3210 3210
 }
3211 3211
 
3212 3212
 
@@ -3225,7 +3225,7 @@  discard block
 block discarded – undo
3225 3225
 function traiter_doublons_documents(&$doublons, $letexte) {
3226 3226
 
3227 3227
 	// Verifier dans le texte & les notes (pas beau, helas)
3228
-	$t = $letexte . $GLOBALS['les_notes'];
3228
+	$t = $letexte.$GLOBALS['les_notes'];
3229 3229
 
3230 3230
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3231 3231
 		and preg_match_all(
@@ -3235,7 +3235,7 @@  discard block
 block discarded – undo
3235 3235
 		if (!isset($doublons['documents'])) {
3236 3236
 			$doublons['documents'] = "";
3237 3237
 		}
3238
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3238
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3239 3239
 	}
3240 3240
 
3241 3241
 	return $letexte;
@@ -3292,7 +3292,7 @@  discard block
 block discarded – undo
3292 3292
 	if ($env) {
3293 3293
 		foreach ($env as $i => $j) {
3294 3294
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3295
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3295
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3296 3296
 			}
3297 3297
 		}
3298 3298
 	}
@@ -3331,7 +3331,7 @@  discard block
 block discarded – undo
3331 3331
 	if ($env) {
3332 3332
 		foreach ($env as $i => $j) {
3333 3333
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3334
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3334
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3335 3335
 			}
3336 3336
 		}
3337 3337
 	}
@@ -3415,19 +3415,19 @@  discard block
 block discarded – undo
3415 3415
 
3416 3416
 	$img_file = $img;
3417 3417
 	if ($p = strpos($img_file, '?')) {
3418
-		$img_file = substr($img_file,0, $p);
3418
+		$img_file = substr($img_file, 0, $p);
3419 3419
 	}
3420 3420
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3421 3421
 		$img_file = chemin_image($img);
3422 3422
 	}
3423 3423
 	else {
3424
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3424
+		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3425 3425
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3426 3426
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3427 3427
 			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3428
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3428
+			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg"
3429 3429
 			  and file_exists($variante_svg_generique)) {
3430
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3430
+				if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) {
3431 3431
 					$img_file = $variante_svg_size;
3432 3432
 				}
3433 3433
 				else {
@@ -3452,7 +3452,7 @@  discard block
 block discarded – undo
3452 3452
 				return "";
3453 3453
 			}
3454 3454
 		}
3455
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3455
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3456 3456
 	}
3457 3457
 
3458 3458
 	if (file_exists($img_file)) {
@@ -3461,15 +3461,15 @@  discard block
 block discarded – undo
3461 3461
 	if ($alt === false) {
3462 3462
 		$alt = '';
3463 3463
 	}
3464
-	elseif($alt or $alt==='') {
3464
+	elseif ($alt or $alt === '') {
3465 3465
 		$alt = " alt='".attribut_html($alt)."'";
3466 3466
 	}
3467 3467
 	else {
3468 3468
 		$alt = " alt='".attribut_html($title)."'";
3469 3469
 	}
3470 3470
 	return "<img src='$img_file'$alt"
3471
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3472
-	. " " . ltrim($atts)
3471
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3472
+	. " ".ltrim($atts)
3473 3473
 	. " />";
3474 3474
 }
3475 3475
 
@@ -3481,12 +3481,12 @@  discard block
 block discarded – undo
3481 3481
  * @param string $size
3482 3482
  * @return string
3483 3483
  */
3484
-function http_style_background($img, $att = '', $size=null) {
3485
-	if ($size and is_numeric($size)){
3486
-		$size = trim($size) . "px";
3484
+function http_style_background($img, $att = '', $size = null) {
3485
+	if ($size and is_numeric($size)) {
3486
+		$size = trim($size)."px";
3487 3487
 	}
3488
-	return " style='background" .
3489
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3488
+	return " style='background".
3489
+		($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";"
3490 3490
 		. ($size ? "background-size:{$size};" : '')
3491 3491
 		. "'";
3492 3492
 }
@@ -3512,7 +3512,7 @@  discard block
 block discarded – undo
3512 3512
 			$args[] = $maybe_size;
3513 3513
 			$maybe_size = null;
3514 3514
 		}
3515
-		while (count($args)<2) {
3515
+		while (count($args) < 2) {
3516 3516
 			$args[] = null; // default alt or class
3517 3517
 		}
3518 3518
 		$args[] = $maybe_size;
@@ -3522,7 +3522,7 @@  discard block
 block discarded – undo
3522 3522
 
3523 3523
 function helper_filtre_balise_img_svg_size($img, $size) {
3524 3524
 	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3525
-	if (strpos($size, '@') === 0 and substr($size,-1) === 'x') {
3525
+	if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3526 3526
 		$coef = floatval(substr($size, 1, -1));
3527 3527
 		list($h, $w) = taille_image($img);
3528 3528
 		$height = intval(round($h / $coef));
@@ -3577,7 +3577,7 @@  discard block
 block discarded – undo
3577 3577
  * @return string
3578 3578
  *     Code HTML de la balise IMG
3579 3579
  */
3580
-function filtre_balise_img_dist($img, $alt = '', $class = null, $size=null) {
3580
+function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) {
3581 3581
 
3582 3582
 	list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3583 3583
 
@@ -3596,7 +3596,7 @@  discard block
 block discarded – undo
3596 3596
 		}
3597 3597
 	}
3598 3598
 	else {
3599
-		$img = http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3599
+		$img = http_img_pack($img, $alt, $class ? " class='".attribut_html($class)."'" : '', '',
3600 3600
 				array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3601 3601
 		if (is_null($alt)) {
3602 3602
 			$img = vider_attribut($img, 'alt');
@@ -3642,16 +3642,16 @@  discard block
 block discarded – undo
3642 3642
  * @return string
3643 3643
  *     Code HTML de la balise SVG
3644 3644
  */
3645
-function filtre_balise_svg_dist($img, $alt = '', $class = null, $size=null) {
3645
+function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) {
3646 3646
 
3647 3647
 	$img = trim($img);
3648 3648
 	$img_file = $img;
3649
-	if (strpos($img, '<svg') === false){
3650
-		if ($p = strpos($img_file, '?')){
3649
+	if (strpos($img, '<svg') === false) {
3650
+		if ($p = strpos($img_file, '?')) {
3651 3651
 			$img_file = substr($img_file, 0, $p);
3652 3652
 		}
3653 3653
 
3654
-		if (!$img_file or !$svg = file_get_contents($img_file)){
3654
+		if (!$img_file or !$svg = file_get_contents($img_file)) {
3655 3655
 			return '';
3656 3656
 		}
3657 3657
 	}
@@ -3666,7 +3666,7 @@  discard block
 block discarded – undo
3666 3666
 	$balise_svg_source = $balise_svg;
3667 3667
 
3668 3668
 	// entete XML à supprimer
3669
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3669
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3670 3670
 
3671 3671
 	// IE est toujours mon ami
3672 3672
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
@@ -3682,11 +3682,11 @@  discard block
 block discarded – undo
3682 3682
 	}
3683 3683
 
3684 3684
 	// regler le alt
3685
-	if ($alt){
3685
+	if ($alt) {
3686 3686
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3687
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3687
+		$id = "img-svg-title-".substr(md5("$img_file:$svg:$alt"), 0, 4);
3688 3688
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3689
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3689
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3690 3690
 		$balise_svg .= $title;
3691 3691
 	}
3692 3692
 	else {
@@ -3730,7 +3730,7 @@  discard block
 block discarded – undo
3730 3730
 	$texte = '';
3731 3731
 	if (is_array($tableau)) {
3732 3732
 		foreach ($tableau as $k => $v) {
3733
-			$res = recuperer_fond('modeles/' . $modele,
3733
+			$res = recuperer_fond('modeles/'.$modele,
3734 3734
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3735 3735
 			);
3736 3736
 			$texte .= $res;
@@ -3907,7 +3907,7 @@  discard block
 block discarded – undo
3907 3907
 	}
3908 3908
 
3909 3909
 	$c = serialize($c);
3910
-	$cle = calculer_cle_action($form . $c);
3910
+	$cle = calculer_cle_action($form.$c);
3911 3911
 	$c = "$cle:$c";
3912 3912
 
3913 3913
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3964,15 +3964,15 @@  discard block
 block discarded – undo
3964 3964
 	}
3965 3965
 	// toujours encoder l'url source dans le bloc ajax
3966 3966
 	$r = self();
3967
-	$r = ' data-origin="' . $r . '"';
3967
+	$r = ' data-origin="'.$r.'"';
3968 3968
 	$class = 'ajaxbloc';
3969 3969
 	if ($ajaxid and is_string($ajaxid)) {
3970 3970
 		// ajaxid est normalement conforme a un nom de classe css
3971 3971
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3972
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3972
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3973 3973
 	}
3974 3974
 
3975
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3975
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3976 3976
 }
3977 3977
 
3978 3978
 /**
@@ -4011,11 +4011,11 @@  discard block
 block discarded – undo
4011 4011
 	// extraire la signature en debut de contexte
4012 4012
 	// et la verifier avant de deserializer
4013 4013
 	// format : signature:donneesserializees
4014
-	if ($p = strpos($c,":")){
4015
-		$cle = substr($c,0,$p);
4016
-		$c = substr($c,$p+1);
4014
+	if ($p = strpos($c, ":")) {
4015
+		$cle = substr($c, 0, $p);
4016
+		$c = substr($c, $p + 1);
4017 4017
 
4018
-		if ($cle == calculer_cle_action($form . $c)) {
4018
+		if ($cle == calculer_cle_action($form.$c)) {
4019 4019
 			$env = @unserialize($c);
4020 4020
 			return $env;
4021 4021
 		}
@@ -4121,24 +4121,24 @@  discard block
 block discarded – undo
4121 4121
 		$att = "";
4122 4122
 		// si $on passe la balise et optionnelement une ou ++classe
4123 4123
 		// a.active span.selected.active etc....
4124
-		if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
4124
+		if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4125 4125
 			$on = explode(".", $on);
4126 4126
 			// on verifie que c'est exactement une des 3 balises a, span ou strong
4127
-			if (in_array(reset($on), array('a', 'span', 'strong'))){
4127
+			if (in_array(reset($on), array('a', 'span', 'strong'))) {
4128 4128
 				$bal = array_shift($on);
4129 4129
 				$class = implode(" ", $on);
4130
-				if ($bal=="a"){
4130
+				if ($bal == "a") {
4131 4131
 					$att = 'href="#" ';
4132 4132
 				}
4133 4133
 			}
4134 4134
 		}
4135
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4135
+		$att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"';
4136 4136
 	} else {
4137 4137
 		$bal = 'a';
4138 4138
 		$att = "href='$url'"
4139
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4140
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4141
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4139
+			. ($title ? " title='".attribut_html($title)."'" : '')
4140
+			. ($class ? " class='".attribut_html($class)."'" : '')
4141
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
4142 4142
 			. $evt;
4143 4143
 	}
4144 4144
 	if ($libelle === null) {
@@ -4232,7 +4232,7 @@  discard block
 block discarded – undo
4232 4232
 	}
4233 4233
 
4234 4234
 	// ajouter le type d'objet dans la class de l'icone
4235
-	$class .= " " . substr(basename($fond), 0, -4);
4235
+	$class .= " ".substr(basename($fond), 0, -4);
4236 4236
 
4237 4237
 	$alt = attribut_html($texte);
4238 4238
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -4256,7 +4256,7 @@  discard block
 block discarded – undo
4256 4256
 	}
4257 4257
 
4258 4258
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4259
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4259
+	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "")."\">$icone</span>";
4260 4260
 
4261 4261
 	if ($type == 'lien') {
4262 4262
 		return "<span class='icone s$size $class'>"
@@ -4486,13 +4486,13 @@  discard block
 block discarded – undo
4486 4486
 	$res = "";
4487 4487
 	foreach ($boutons as $page => $detail) {
4488 4488
 		if ($detail->icone and strlen(trim($detail->icone))) {
4489
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4489
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4490 4490
 		}
4491 4491
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4492 4492
 		if (is_array($detail->sousmenu)) {
4493 4493
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4494 4494
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4495
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4495
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4496 4496
 				}
4497 4497
 			}
4498 4498
 		}
@@ -4518,17 +4518,17 @@  discard block
 block discarded – undo
4518 4518
  */
4519 4519
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4520 4520
 	if ($confirm) {
4521
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4521
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4522 4522
 		if ($callback) {
4523 4523
 			$callback = "$confirm?($callback):false";
4524 4524
 		} else {
4525 4525
 			$callback = $confirm;
4526 4526
 		}
4527 4527
 	}
4528
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4528
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4529 4529
 	$title = $title ? " title='$title'" : "";
4530 4530
 
4531
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4531
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4532 4532
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4533 4533
 }
4534 4534
 
@@ -4589,14 +4589,14 @@  discard block
 block discarded – undo
4589 4589
 		$champ_titre = "";
4590 4590
 		if ($demande_titre) {
4591 4591
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4592
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4592
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4593 4593
 		}
4594 4594
 		include_spip('base/abstract_sql');
4595 4595
 		include_spip('base/connect_sql');
4596 4596
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4597
-			'*' . $champ_titre,
4597
+			'*'.$champ_titre,
4598 4598
 			$desc['table_sql'],
4599
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4599
+			id_table_objet($type_objet).' = '.intval($id_objet)
4600 4600
 		);
4601 4601
 	}
4602 4602
 
@@ -4666,7 +4666,7 @@  discard block
 block discarded – undo
4666 4666
 		return $texte;
4667 4667
 	}
4668 4668
 
4669
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4669
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4670 4670
 
4671 4671
 	// Fournir $connect et $Pile[0] au traitement si besoin
4672 4672
 	$Pile = array(0 => $env);
@@ -4700,7 +4700,7 @@  discard block
 block discarded – undo
4700 4700
 	}
4701 4701
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4702 4702
 
4703
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4703
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4704 4704
 }
4705 4705
 
4706 4706
 
@@ -4719,10 +4719,10 @@  discard block
 block discarded – undo
4719 4719
 function wrap($texte, $wrap) {
4720 4720
 	$balises = extraire_balises($wrap);
4721 4721
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4722
-		$texte = $wrap . $texte;
4722
+		$texte = $wrap.$texte;
4723 4723
 		$regs = array_reverse($regs[1]);
4724
-		$wrap = "</" . implode("></", $regs) . ">";
4725
-		$texte = $texte . $wrap;
4724
+		$wrap = "</".implode("></", $regs).">";
4725
+		$texte = $texte.$wrap;
4726 4726
 	}
4727 4727
 
4728 4728
 	return $texte;
@@ -4753,7 +4753,7 @@  discard block
 block discarded – undo
4753 4753
 
4754 4754
 	// caster $u en array si besoin
4755 4755
 	if (is_object($u)) {
4756
-		$u = (array)$u;
4756
+		$u = (array) $u;
4757 4757
 	}
4758 4758
 
4759 4759
 	if (is_array($u)) {
@@ -4774,7 +4774,7 @@  discard block
 block discarded – undo
4774 4774
 		// sinon on passe a la ligne et on indente
4775 4775
 		$i_str = str_pad("", $indent, " ");
4776 4776
 		foreach ($u as $k => $v) {
4777
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4777
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4778 4778
 		}
4779 4779
 
4780 4780
 		return $out;
@@ -4827,8 +4827,8 @@  discard block
 block discarded – undo
4827 4827
  * @param string $class
4828 4828
  * @return string
4829 4829
  */
4830
-function objet_icone($objet, $taille = 24, $class='') {
4831
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4830
+function objet_icone($objet, $taille = 24, $class = '') {
4831
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4832 4832
 	$icone = chemin_image($icone);
4833 4833
 	$balise_img = charger_filtre('balise_img');
4834 4834
 
@@ -4852,12 +4852,12 @@  discard block
 block discarded – undo
4852 4852
  * @param array $options
4853 4853
  * @return string
4854 4854
  */
4855
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4856
-	$chaine = explode(':',$chaine);
4857
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4855
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4856
+	$chaine = explode(':', $chaine);
4857
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4858 4858
 		return $t;
4859 4859
 	}
4860
-	$chaine = implode(':',$chaine);
4860
+	$chaine = implode(':', $chaine);
4861 4861
 	return _T($chaine, $args, $options);
4862 4862
 }
4863 4863
 
@@ -4917,7 +4917,7 @@  discard block
 block discarded – undo
4917 4917
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4918 4918
 
4919 4919
 	// calculer le nom de la css
4920
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4920
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4921 4921
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4922 4922
 	$contexte_implicite = calculer_contexte_implicite();
4923 4923
 
@@ -4925,22 +4925,22 @@  discard block
 block discarded – undo
4925 4925
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4926 4926
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4927 4927
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4928
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4928
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
4929 4929
 	}
4930 4930
 	else {
4931 4931
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4932 4932
 		ksort($contexte);
4933
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4933
+		$hash = md5($fond.json_encode($contexte_implicite).json_encode($contexte).$connect);
4934 4934
 	}
4935
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4935
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4936 4936
 
4937 4937
 	// mettre a jour le fichier si il n'existe pas
4938 4938
 	// ou trop ancien
4939 4939
 	// le dernier fichier produit est toujours suffixe par .last
4940 4940
 	// et recopie sur le fichier cible uniquement si il change
4941 4941
 	if (!file_exists($filename)
4942
-		or !file_exists($filename . ".last")
4943
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4942
+		or !file_exists($filename.".last")
4943
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4944 4944
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4945 4945
 	) {
4946 4946
 		$contenu = $cache['texte'];
@@ -4959,10 +4959,10 @@  discard block
 block discarded – undo
4959 4959
 			}
4960 4960
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4961 4961
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4962
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4962
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4963 4963
 		}
4964 4964
 		// et ecrire le fichier si il change
4965
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4965
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
4966 4966
 	}
4967 4967
 
4968 4968
 	return timestamp($filename);
@@ -5157,11 +5157,11 @@  discard block
 block discarded – undo
5157 5157
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
5158 5158
 	$l = strlen($passe);
5159 5159
 
5160
-	if ($l<=8 or !$afficher_partiellement){
5160
+	if ($l <= 8 or !$afficher_partiellement) {
5161 5161
 		if (!$l) {
5162 5162
 			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5163 5163
 		}
5164
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
5164
+		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5165 5165
 	}
5166 5166
 
5167 5167
 	if (is_null($portion_pourcent)) {
@@ -5175,11 +5175,11 @@  discard block
 block discarded – undo
5175 5175
 	}
5176 5176
 	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
5177 5177
 	$e = max($e, 0);
5178
-	$mid = str_pad('',$l-2*$e,'*');
5179
-	if ($e>0 and strlen($mid)>8){
5178
+	$mid = str_pad('', $l - 2 * $e, '*');
5179
+	if ($e > 0 and strlen($mid) > 8) {
5180 5180
 		$mid = '***...***';
5181 5181
 	}
5182
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
5182
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5183 5183
 }
5184 5184
 
5185 5185
 
@@ -5201,9 +5201,9 @@  discard block
 block discarded – undo
5201 5201
 function identifiant_slug($texte, $type = '', $options = array()) {
5202 5202
 
5203 5203
 	$original = $texte;
5204
-	$separateur = (isset($options['separateur'])?$options['separateur']:'_');
5205
-	$longueur_maxi = (isset($options['longueur_maxi'])?$options['longueur_maxi']:60);
5206
-	$longueur_mini = (isset($options['longueur_mini'])?$options['longueur_mini']:0);
5204
+	$separateur = (isset($options['separateur']) ? $options['separateur'] : '_');
5205
+	$longueur_maxi = (isset($options['longueur_maxi']) ? $options['longueur_maxi'] : 60);
5206
+	$longueur_mini = (isset($options['longueur_mini']) ? $options['longueur_mini'] : 0);
5207 5207
 
5208 5208
 	if (!function_exists('translitteration')) {
5209 5209
 		include_spip('inc/charsets');
@@ -5245,15 +5245,15 @@  discard block
 block discarded – undo
5245 5245
 			}
5246 5246
 	}
5247 5247
 
5248
-	if (strlen($texte)>$longueur_maxi) {
5248
+	if (strlen($texte) > $longueur_maxi) {
5249 5249
 		$texte = substr($texte, 0, $longueur_maxi);
5250 5250
 	}
5251 5251
 
5252 5252
 	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5253 5253
 		if (preg_match(',^\d,', $texte)) {
5254
-			$texte = ($type ? substr($type,0,1) : "s") . $texte;
5254
+			$texte = ($type ? substr($type, 0, 1) : "s").$texte;
5255 5255
 		}
5256
-		$texte .= $separateur . md5($original);
5256
+		$texte .= $separateur.md5($original);
5257 5257
 		$texte = substr($texte, 0, $longueur_mini);
5258 5258
 	}
5259 5259
 
Please login to merge, or discard this patch.