Completed
Push — master ( 76d5f6...2731ba )
by cam
04:35
created
ecrire/inc/filtres.php 2 patches
Indentation   +2077 added lines, -2077 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/charsets');
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
  * @return string Fonction PHP correspondante du filtre
43 43
  */
44 44
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
45
-	include_spip('public/parametrer'); // inclure les fichiers fonctions
46
-	return chercher_filtre($fonc, $default);
45
+    include_spip('public/parametrer'); // inclure les fichiers fonctions
46
+    return chercher_filtre($fonc, $default);
47 47
 }
48 48
 
49 49
 /**
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
  *     Fonction PHP correspondante du filtre demandé
76 76
  */
77 77
 function chercher_filtre($fonc, $default = null) {
78
-	if (!$fonc) {
79
-		return $default;
80
-	}
81
-	// Cas des types mime, sans confondre avec les appels de fonction de classe
82
-	// Foo::Bar
83
-	// qui peuvent etre avec un namespace : space\Foo::Bar
84
-	if (preg_match(',^[\w]+/,', $fonc)) {
85
-		$nom = preg_replace(',\W,', '_', $fonc);
86
-		$f = chercher_filtre($nom);
87
-		// cas du sous-type MIME sans filtre associe, passer au type:
88
-		// si filtre_text_plain pas defini, passe a filtre_text
89
-		if (!$f and $nom !== $fonc) {
90
-			$f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
-		}
92
-
93
-		return $f;
94
-	}
95
-
96
-	include_fichiers_fonctions();
97
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
98
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99
-		// fonction ou name\space\fonction
100
-		if (is_callable($f)) {
101
-			return $f;
102
-		}
103
-		// méthode statique d'une classe Classe::methode ou name\space\Classe::methode
104
-		elseif (false === strpos($f, '::') and is_callable(array($f))) {
105
-			return $f;
106
-		}
107
-	}
108
-
109
-	return $default;
78
+    if (!$fonc) {
79
+        return $default;
80
+    }
81
+    // Cas des types mime, sans confondre avec les appels de fonction de classe
82
+    // Foo::Bar
83
+    // qui peuvent etre avec un namespace : space\Foo::Bar
84
+    if (preg_match(',^[\w]+/,', $fonc)) {
85
+        $nom = preg_replace(',\W,', '_', $fonc);
86
+        $f = chercher_filtre($nom);
87
+        // cas du sous-type MIME sans filtre associe, passer au type:
88
+        // si filtre_text_plain pas defini, passe a filtre_text
89
+        if (!$f and $nom !== $fonc) {
90
+            $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
+        }
92
+
93
+        return $f;
94
+    }
95
+
96
+    include_fichiers_fonctions();
97
+    foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
98
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99
+        // fonction ou name\space\fonction
100
+        if (is_callable($f)) {
101
+            return $f;
102
+        }
103
+        // méthode statique d'une classe Classe::methode ou name\space\Classe::methode
104
+        elseif (false === strpos($f, '::') and is_callable(array($f))) {
105
+            return $f;
106
+        }
107
+    }
108
+
109
+    return $default;
110 110
 }
111 111
 
112 112
 /**
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
  *     Chaîne vide sinon (filtre introuvable).
131 131
  **/
132 132
 function appliquer_filtre($arg, $filtre, $force = null) {
133
-	$f = chercher_filtre($filtre);
134
-	if (!$f) {
135
-		if (!$force) {
136
-			return '';
137
-		} else {
138
-			return $arg;
139
-		}
140
-	}
133
+    $f = chercher_filtre($filtre);
134
+    if (!$f) {
135
+        if (!$force) {
136
+            return '';
137
+        } else {
138
+            return $arg;
139
+        }
140
+    }
141 141
 
142
-	$args = func_get_args();
143
-	array_shift($args); // enlever $arg
144
-	array_shift($args); // enlever $filtre
145
-	array_unshift($args, $arg); // remettre $arg
146
-	return call_user_func_array($f, $args);
142
+    $args = func_get_args();
143
+    array_shift($args); // enlever $arg
144
+    array_shift($args); // enlever $filtre
145
+    array_unshift($args, $arg); // remettre $arg
146
+    return call_user_func_array($f, $args);
147 147
 }
148 148
 
149 149
 /**
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
  *     Version de SPIP
160 160
  **/
161 161
 function spip_version() {
162
-	$version = $GLOBALS['spip_version_affichee'];
163
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
164
-		$version .= " $vcs_version";
165
-	}
162
+    $version = $GLOBALS['spip_version_affichee'];
163
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
164
+        $version .= " $vcs_version";
165
+    }
166 166
 
167
-	return $version;
167
+    return $version;
168 168
 }
169 169
 
170 170
 /**
@@ -177,19 +177,19 @@  discard block
 block discarded – undo
177 177
  *    - string|null si $raw = false
178 178
  */
179 179
 function version_vcs_courante($dir, $raw = false) {
180
-	$desc = decrire_version_git($dir);
181
-	if ($desc === null) {
182
-		$desc = decrire_version_svn($dir);
183
-	}
184
-	if ($desc === null or $raw) {
185
-		return $desc;
186
-	}
187
-	// affichage "GIT [master: abcdef]"
188
-	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189
-	if ($desc['branch']) {
190
-		$commit = $desc['branch'] . ': ' . $commit;
191
-	}
192
-	return "{$desc['vcs']} [$commit]";
180
+    $desc = decrire_version_git($dir);
181
+    if ($desc === null) {
182
+        $desc = decrire_version_svn($dir);
183
+    }
184
+    if ($desc === null or $raw) {
185
+        return $desc;
186
+    }
187
+    // affichage "GIT [master: abcdef]"
188
+    $commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189
+    if ($desc['branch']) {
190
+        $commit = $desc['branch'] . ': ' . $commit;
191
+    }
192
+    return "{$desc['vcs']} [$commit]";
193 193
 }
194 194
 
195 195
 /**
@@ -201,24 +201,24 @@  discard block
 block discarded – undo
201 201
  *      array ['branch' => xx, 'commit' => yy] sinon.
202 202
  **/
203 203
 function decrire_version_git($dir) {
204
-	if (!$dir) {
205
-		$dir = '.';
206
-	}
204
+    if (!$dir) {
205
+        $dir = '.';
206
+    }
207 207
 
208
-	// version installee par GIT
209
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
210
-		$currentHead = trim(substr($c, 4));
211
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
212
-			return [
213
-				'vcs' => 'GIT',
214
-				'branch' => basename($currentHead),
215
-				'commit' => trim($hash),
216
-				'commit_short' => substr(trim($hash), 0, 8),
217
-			];
218
-		}
219
-	}
208
+    // version installee par GIT
209
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
210
+        $currentHead = trim(substr($c, 4));
211
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
212
+            return [
213
+                'vcs' => 'GIT',
214
+                'branch' => basename($currentHead),
215
+                'commit' => trim($hash),
216
+                'commit_short' => substr(trim($hash), 0, 8),
217
+            ];
218
+        }
219
+    }
220 220
 
221
-	return null;
221
+    return null;
222 222
 }
223 223
 
224 224
 
@@ -231,25 +231,25 @@  discard block
 block discarded – undo
231 231
  *      array ['commit' => yy, 'date' => xx, 'author' => xx] sinon.
232 232
  **/
233 233
 function decrire_version_svn($dir) {
234
-	if (!$dir) {
235
-		$dir = '.';
236
-	}
237
-	// version installee par SVN
238
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
-		$db = new SQLite3($dir . '/.svn/wc.db');
240
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241
-		if ($result) {
242
-			$row = $result->fetchArray();
243
-			if ($row['changed_revision'] != "") {
244
-				return [
245
-					'vcs' => 'SVN',
246
-					'branch' => '',
247
-					'commit' => $row['changed_revision'],
248
-				];
249
-			}
250
-		}
251
-	}
252
-	return null;
234
+    if (!$dir) {
235
+        $dir = '.';
236
+    }
237
+    // version installee par SVN
238
+    if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
+        $db = new SQLite3($dir . '/.svn/wc.db');
240
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241
+        if ($result) {
242
+            $row = $result->fetchArray();
243
+            if ($row['changed_revision'] != "") {
244
+                return [
245
+                    'vcs' => 'SVN',
246
+                    'branch' => '',
247
+                    'commit' => $row['changed_revision'],
248
+                ];
249
+            }
250
+        }
251
+    }
252
+    return null;
253 253
 }
254 254
 
255 255
 /**
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
  *
268 268
  **/
269 269
 function version_svn_courante($dir) {
270
-	if ($desc = decrire_version_svn($dir)) {
271
-		return -$desc['commit'];
272
-	}
273
-	return 0;
270
+    if ($desc = decrire_version_svn($dir)) {
271
+        return -$desc['commit'];
272
+    }
273
+    return 0;
274 274
 }
275 275
 
276 276
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -314,18 +314,18 @@  discard block
 block discarded – undo
314 314
  *     Code HTML retourné par le filtre
315 315
  **/
316 316
 function filtrer($filtre) {
317
-	$tous = func_get_args();
318
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
319
-		return image_filtrer($tous);
320
-	} elseif ($f = chercher_filtre($filtre)) {
321
-		array_shift($tous);
322
-		return call_user_func_array($f, $tous);
323
-	} else {
324
-		// le filtre n'existe pas, on provoque une erreur
325
-		$msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
326
-		erreur_squelette($msg);
327
-		return '';
328
-	}
317
+    $tous = func_get_args();
318
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
319
+        return image_filtrer($tous);
320
+    } elseif ($f = chercher_filtre($filtre)) {
321
+        array_shift($tous);
322
+        return call_user_func_array($f, $tous);
323
+    } else {
324
+        // le filtre n'existe pas, on provoque une erreur
325
+        $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
326
+        erreur_squelette($msg);
327
+        return '';
328
+    }
329 329
 }
330 330
 
331 331
 /**
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
343 343
  */
344 344
 function trouver_filtre_matrice($filtre) {
345
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
346
-		find_in_path($f, '', true);
347
-		$GLOBALS['spip_matrice'][$filtre] = true;
348
-	}
349
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
345
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
346
+        find_in_path($f, '', true);
347
+        $GLOBALS['spip_matrice'][$filtre] = true;
348
+    }
349
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
350 350
 }
351 351
 
352 352
 
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
  * @return mixed
375 375
  */
376 376
 function filtre_set(&$Pile, $val, $key, $continue = null) {
377
-	$Pile['vars'][$key] = $val;
378
-	return $continue ? $val : '';
377
+    $Pile['vars'][$key] = $val;
378
+    return $continue ? $val : '';
379 379
 }
380 380
 
381 381
 /**
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
402 402
  */
403 403
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
404
-	$Pile[0][$key] = $val;
405
-	return $continue ? $val : '';
404
+    $Pile[0][$key] = $val;
405
+    return $continue ? $val : '';
406 406
 }
407 407
 
408 408
 /**
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
  * @return string
412 412
  */
413 413
 function filtre_sanitize_env(&$Pile, $keys) {
414
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
415
-	return '';
414
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
415
+    return '';
416 416
 }
417 417
 
418 418
 
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
  * @return mixed Retourne la valeur (sans la modifier).
436 436
  */
437 437
 function filtre_debug($val, $key = null) {
438
-	$debug = (
439
-		is_null($key) ? '' : (var_export($key, true) . " = ")
440
-		) . var_export($val, true);
438
+    $debug = (
439
+        is_null($key) ? '' : (var_export($key, true) . " = ")
440
+        ) . var_export($val, true);
441 441
 
442
-	include_spip('inc/autoriser');
443
-	if (autoriser('webmestre')) {
444
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
445
-	}
442
+    include_spip('inc/autoriser');
443
+    if (autoriser('webmestre')) {
444
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
445
+    }
446 446
 
447
-	spip_log($debug, 'debug');
447
+    spip_log($debug, 'debug');
448 448
 
449
-	return $val;
449
+    return $val;
450 450
 }
451 451
 
452 452
 
@@ -474,82 +474,82 @@  discard block
 block discarded – undo
474 474
  *     Texte qui a reçu les filtres
475 475
  **/
476 476
 function image_filtrer($args) {
477
-	$filtre = array_shift($args); # enlever $filtre
478
-	$texte = array_shift($args);
479
-	if (!strlen($texte)) {
480
-		return;
481
-	}
482
-	find_in_path('filtres_images_mini.php', 'inc/', true);
483
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
484
-	// Cas du nom de fichier local
485
-	$is_file = trim($texte);
486
-	if (strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
487
-		  or strpbrk($is_file, "<>\n\r\t") !== false
488
-		  or strpos($is_file, '/') === 0
489
-	) {
490
-		$is_file = false;
491
-	}
492
-	if ($is_file) {
493
-		$is_local_file = function($path) {
494
-			if (strpos($path, "?") !== false) {
495
-				$path = supprimer_timestamp($path);
496
-				// remove ?24px added by find_in_theme on .svg files
497
-				$path = preg_replace(",\?[[:digit:]]+(px)$,", "", $path);
498
-			}
499
-			return file_exists($path);
500
-		};
501
-		if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
502
-			array_unshift($args, "<img src='$is_file' />");
503
-			$res = call_user_func_array($filtre, $args);
504
-			statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
505
-			return $res;
506
-		}
507
-	}
508
-
509
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
510
-	if (preg_match_all(
511
-		',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
512
-		$texte, $tags, PREG_SET_ORDER)) {
513
-		foreach ($tags as $tag) {
514
-			$class = extraire_attribut($tag[3], 'class');
515
-			if (!$class or
516
-				(strpos($class, 'filtre_inactif') === false
517
-					// compat historique a virer en 3.2
518
-					and strpos($class, 'no_image_filtrer') === false)
519
-			) {
520
-				array_unshift($args, $tag[3]);
521
-				if ($reduit = call_user_func_array($filtre, $args)) {
522
-					// En cas de span spip_documents, modifier le style=...width:
523
-					if ($tag[1]) {
524
-						$w = extraire_attribut($reduit, 'width');
525
-						if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
526
-							$w = $regs[1];
527
-						}
528
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
529
-							$style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
530
-							$replace = inserer_attribut($tag[1], 'style', $style);
531
-							$texte = str_replace($tag[1], $replace, $texte);
532
-						}
533
-					}
534
-					// traiter aussi un eventuel mouseover
535
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
536
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
537
-							$srcover = $match[1];
538
-							array_shift($args);
539
-							array_unshift($args, "<img src='" . $match[1] . "' />");
540
-							$srcover_filter = call_user_func_array($filtre, $args);
541
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
542
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
543
-						}
544
-					}
545
-					$texte = str_replace($tag[3], $reduit, $texte);
546
-				}
547
-				array_shift($args);
548
-			}
549
-		}
550
-	}
551
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
552
-	return $texte;
477
+    $filtre = array_shift($args); # enlever $filtre
478
+    $texte = array_shift($args);
479
+    if (!strlen($texte)) {
480
+        return;
481
+    }
482
+    find_in_path('filtres_images_mini.php', 'inc/', true);
483
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
484
+    // Cas du nom de fichier local
485
+    $is_file = trim($texte);
486
+    if (strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
487
+          or strpbrk($is_file, "<>\n\r\t") !== false
488
+          or strpos($is_file, '/') === 0
489
+    ) {
490
+        $is_file = false;
491
+    }
492
+    if ($is_file) {
493
+        $is_local_file = function($path) {
494
+            if (strpos($path, "?") !== false) {
495
+                $path = supprimer_timestamp($path);
496
+                // remove ?24px added by find_in_theme on .svg files
497
+                $path = preg_replace(",\?[[:digit:]]+(px)$,", "", $path);
498
+            }
499
+            return file_exists($path);
500
+        };
501
+        if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
502
+            array_unshift($args, "<img src='$is_file' />");
503
+            $res = call_user_func_array($filtre, $args);
504
+            statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
505
+            return $res;
506
+        }
507
+    }
508
+
509
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
510
+    if (preg_match_all(
511
+        ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
512
+        $texte, $tags, PREG_SET_ORDER)) {
513
+        foreach ($tags as $tag) {
514
+            $class = extraire_attribut($tag[3], 'class');
515
+            if (!$class or
516
+                (strpos($class, 'filtre_inactif') === false
517
+                    // compat historique a virer en 3.2
518
+                    and strpos($class, 'no_image_filtrer') === false)
519
+            ) {
520
+                array_unshift($args, $tag[3]);
521
+                if ($reduit = call_user_func_array($filtre, $args)) {
522
+                    // En cas de span spip_documents, modifier le style=...width:
523
+                    if ($tag[1]) {
524
+                        $w = extraire_attribut($reduit, 'width');
525
+                        if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
526
+                            $w = $regs[1];
527
+                        }
528
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
529
+                            $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
530
+                            $replace = inserer_attribut($tag[1], 'style', $style);
531
+                            $texte = str_replace($tag[1], $replace, $texte);
532
+                        }
533
+                    }
534
+                    // traiter aussi un eventuel mouseover
535
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
536
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
537
+                            $srcover = $match[1];
538
+                            array_shift($args);
539
+                            array_unshift($args, "<img src='" . $match[1] . "' />");
540
+                            $srcover_filter = call_user_func_array($filtre, $args);
541
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
542
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
543
+                        }
544
+                    }
545
+                    $texte = str_replace($tag[3], $reduit, $texte);
546
+                }
547
+                array_shift($args);
548
+            }
549
+        }
550
+    }
551
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
552
+    return $texte;
553 553
 }
554 554
 
555 555
 /**
@@ -564,65 +564,65 @@  discard block
 block discarded – undo
564 564
  **/
565 565
 function taille_image($img, $force_refresh = false) {
566 566
 
567
-	static $largeur_img = array(), $hauteur_img = array();
568
-	$srcWidth = 0;
569
-	$srcHeight = 0;
570
-
571
-	$src = extraire_attribut($img, 'src');
572
-
573
-	if (!$src) {
574
-		$src = $img;
575
-	} else {
576
-		$srcWidth = extraire_attribut($img, 'width');
577
-		$srcHeight = extraire_attribut($img, 'height');
578
-	}
579
-
580
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
581
-	// la copie locale a toutes les chances d'etre la ou de resservir
582
-	if (tester_url_absolue($src)) {
583
-		include_spip('inc/distant');
584
-		$fichier = copie_locale($src);
585
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
586
-	}
587
-	if (($p = strpos($src, '?')) !== false) {
588
-		$src = substr($src, 0, $p);
589
-	}
590
-
591
-	$srcsize = false;
592
-	if (isset($largeur_img[$src]) and !$force_refresh) {
593
-		$srcWidth = $largeur_img[$src];
594
-	}
595
-	if (isset($hauteur_img[$src]) and !$force_refresh) {
596
-		$srcHeight = $hauteur_img[$src];
597
-	}
598
-	if (!$srcWidth or !$srcHeight) {
599
-
600
-		if (file_exists($src)
601
-			and $srcsize = spip_getimagesize($src)
602
-		) {
603
-			if (!$srcWidth) {
604
-				$largeur_img[$src] = $srcWidth = $srcsize[0];
605
-			}
606
-			if (!$srcHeight) {
607
-				$hauteur_img[$src] = $srcHeight = $srcsize[1];
608
-			}
609
-		}
610
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
611
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
612
-		elseif (@file_exists($f = "$src.src")
613
-			and lire_fichier($f, $valeurs)
614
-			and $valeurs = unserialize($valeurs)
615
-		) {
616
-			if (!$srcWidth) {
617
-				$largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
618
-			}
619
-			if (!$srcHeight) {
620
-				$hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
621
-			}
622
-		}
623
-	}
624
-
625
-	return array($srcHeight, $srcWidth);
567
+    static $largeur_img = array(), $hauteur_img = array();
568
+    $srcWidth = 0;
569
+    $srcHeight = 0;
570
+
571
+    $src = extraire_attribut($img, 'src');
572
+
573
+    if (!$src) {
574
+        $src = $img;
575
+    } else {
576
+        $srcWidth = extraire_attribut($img, 'width');
577
+        $srcHeight = extraire_attribut($img, 'height');
578
+    }
579
+
580
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
581
+    // la copie locale a toutes les chances d'etre la ou de resservir
582
+    if (tester_url_absolue($src)) {
583
+        include_spip('inc/distant');
584
+        $fichier = copie_locale($src);
585
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
586
+    }
587
+    if (($p = strpos($src, '?')) !== false) {
588
+        $src = substr($src, 0, $p);
589
+    }
590
+
591
+    $srcsize = false;
592
+    if (isset($largeur_img[$src]) and !$force_refresh) {
593
+        $srcWidth = $largeur_img[$src];
594
+    }
595
+    if (isset($hauteur_img[$src]) and !$force_refresh) {
596
+        $srcHeight = $hauteur_img[$src];
597
+    }
598
+    if (!$srcWidth or !$srcHeight) {
599
+
600
+        if (file_exists($src)
601
+            and $srcsize = spip_getimagesize($src)
602
+        ) {
603
+            if (!$srcWidth) {
604
+                $largeur_img[$src] = $srcWidth = $srcsize[0];
605
+            }
606
+            if (!$srcHeight) {
607
+                $hauteur_img[$src] = $srcHeight = $srcsize[1];
608
+            }
609
+        }
610
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
611
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
612
+        elseif (@file_exists($f = "$src.src")
613
+            and lire_fichier($f, $valeurs)
614
+            and $valeurs = unserialize($valeurs)
615
+        ) {
616
+            if (!$srcWidth) {
617
+                $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
618
+            }
619
+            if (!$srcHeight) {
620
+                $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
621
+            }
622
+        }
623
+    }
624
+
625
+    return array($srcHeight, $srcWidth);
626 626
 }
627 627
 
628 628
 
@@ -640,12 +640,12 @@  discard block
 block discarded – undo
640 640
  *     Largeur en pixels, NULL ou 0 si aucune image.
641 641
  **/
642 642
 function largeur($img) {
643
-	if (!$img) {
644
-		return;
645
-	}
646
-	list($h, $l) = taille_image($img);
643
+    if (!$img) {
644
+        return;
645
+    }
646
+    list($h, $l) = taille_image($img);
647 647
 
648
-	return $l;
648
+    return $l;
649 649
 }
650 650
 
651 651
 /**
@@ -662,12 +662,12 @@  discard block
 block discarded – undo
662 662
  *     Hauteur en pixels, NULL ou 0 si aucune image.
663 663
  **/
664 664
 function hauteur($img) {
665
-	if (!$img) {
666
-		return;
667
-	}
668
-	list($h, $l) = taille_image($img);
665
+    if (!$img) {
666
+        return;
667
+    }
668
+    list($h, $l) = taille_image($img);
669 669
 
670
-	return $h;
670
+    return $h;
671 671
 }
672 672
 
673 673
 
@@ -687,11 +687,11 @@  discard block
 block discarded – undo
687 687
  * @return string
688 688
  **/
689 689
 function corriger_entites_html($texte) {
690
-	if (strpos($texte, '&amp;') === false) {
691
-		return $texte;
692
-	}
690
+    if (strpos($texte, '&amp;') === false) {
691
+        return $texte;
692
+    }
693 693
 
694
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
694
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
695 695
 }
696 696
 
697 697
 /**
@@ -706,11 +706,11 @@  discard block
 block discarded – undo
706 706
  * @return string
707 707
  **/
708 708
 function corriger_toutes_entites_html($texte) {
709
-	if (strpos($texte, '&amp;') === false) {
710
-		return $texte;
711
-	}
709
+    if (strpos($texte, '&amp;') === false) {
710
+        return $texte;
711
+    }
712 712
 
713
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
713
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
714 714
 }
715 715
 
716 716
 /**
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
  * @return string
721 721
  **/
722 722
 function proteger_amp($texte) {
723
-	return str_replace('&', '&amp;', $texte);
723
+    return str_replace('&', '&amp;', $texte);
724 724
 }
725 725
 
726 726
 
@@ -751,20 +751,20 @@  discard block
 block discarded – undo
751 751
  * @return mixed|string
752 752
  */
753 753
 function entites_html($texte, $tout = false, $quote = true) {
754
-	if (!is_string($texte) or !$texte
755
-		or strpbrk($texte, "&\"'<>") == false
756
-	) {
757
-		return $texte;
758
-	}
759
-	include_spip('inc/texte');
760
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
761
-	$flags |= ENT_HTML401;
762
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
763
-	if ($tout) {
764
-		return corriger_toutes_entites_html($texte);
765
-	} else {
766
-		return corriger_entites_html($texte);
767
-	}
754
+    if (!is_string($texte) or !$texte
755
+        or strpbrk($texte, "&\"'<>") == false
756
+    ) {
757
+        return $texte;
758
+    }
759
+    include_spip('inc/texte');
760
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
761
+    $flags |= ENT_HTML401;
762
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
763
+    if ($tout) {
764
+        return corriger_toutes_entites_html($texte);
765
+    } else {
766
+        return corriger_entites_html($texte);
767
+    }
768 768
 }
769 769
 
770 770
 /**
@@ -783,37 +783,37 @@  discard block
 block discarded – undo
783 783
  *     Texte converti
784 784
  **/
785 785
 function filtrer_entites($texte) {
786
-	if (strpos($texte, '&') === false) {
787
-		return $texte;
788
-	}
789
-	// filtrer
790
-	$texte = html2unicode($texte);
791
-	// remettre le tout dans le charset cible
792
-	$texte = unicode2charset($texte);
793
-	// cas particulier des " et ' qu'il faut filtrer aussi
794
-	// (on le faisait deja avec un &quot;)
795
-	if (strpos($texte, "&#") !== false) {
796
-		$texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
797
-	}
786
+    if (strpos($texte, '&') === false) {
787
+        return $texte;
788
+    }
789
+    // filtrer
790
+    $texte = html2unicode($texte);
791
+    // remettre le tout dans le charset cible
792
+    $texte = unicode2charset($texte);
793
+    // cas particulier des " et ' qu'il faut filtrer aussi
794
+    // (on le faisait deja avec un &quot;)
795
+    if (strpos($texte, "&#") !== false) {
796
+        $texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
797
+    }
798 798
 
799
-	return $texte;
799
+    return $texte;
800 800
 }
801 801
 
802 802
 
803 803
 if (!function_exists('filtre_filtrer_entites_dist')) {
804
-	/**
805
-	 * Version sécurisée de filtrer_entites
806
-	 * 
807
-	 * @uses interdire_scripts()
808
-	 * @uses filtrer_entites()
809
-	 * 
810
-	 * @param string $t
811
-	 * @return string
812
-	 */
813
-	function filtre_filtrer_entites_dist($t) {
814
-		include_spip('inc/texte');
815
-		return interdire_scripts(filtrer_entites($t));
816
-	}
804
+    /**
805
+     * Version sécurisée de filtrer_entites
806
+     * 
807
+     * @uses interdire_scripts()
808
+     * @uses filtrer_entites()
809
+     * 
810
+     * @param string $t
811
+     * @return string
812
+     */
813
+    function filtre_filtrer_entites_dist($t) {
814
+        include_spip('inc/texte');
815
+        return interdire_scripts(filtrer_entites($t));
816
+    }
817 817
 }
818 818
 
819 819
 
@@ -828,18 +828,18 @@  discard block
 block discarded – undo
828 828
  * @return string|array
829 829
  **/
830 830
 function supprimer_caracteres_illegaux($texte) {
831
-	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";
832
-	static $to = null;
831
+    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";
832
+    static $to = null;
833 833
 
834
-	if (is_array($texte)) {
835
-		return array_map('supprimer_caracteres_illegaux', $texte);
836
-	}
834
+    if (is_array($texte)) {
835
+        return array_map('supprimer_caracteres_illegaux', $texte);
836
+    }
837 837
 
838
-	if (!$to) {
839
-		$to = str_repeat('-', strlen($from));
840
-	}
838
+    if (!$to) {
839
+        $to = str_repeat('-', strlen($from));
840
+    }
841 841
 
842
-	return strtr($texte, $from, $to);
842
+    return strtr($texte, $from, $to);
843 843
 }
844 844
 
845 845
 /**
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
  * @return string|array
852 852
  **/
853 853
 function corriger_caracteres($texte) {
854
-	$texte = corriger_caracteres_windows($texte);
855
-	$texte = supprimer_caracteres_illegaux($texte);
854
+    $texte = corriger_caracteres_windows($texte);
855
+    $texte = supprimer_caracteres_illegaux($texte);
856 856
 
857
-	return $texte;
857
+    return $texte;
858 858
 }
859 859
 
860 860
 /**
@@ -872,40 +872,40 @@  discard block
 block discarded – undo
872 872
  */
873 873
 function texte_backend($texte) {
874 874
 
875
-	static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
875
+    static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
876 876
 
877
-	// si on a des liens ou des images, les passer en absolu
878
-	$texte = liens_absolus($texte);
877
+    // si on a des liens ou des images, les passer en absolu
878
+    $texte = liens_absolus($texte);
879 879
 
880
-	// echapper les tags &gt; &lt;
881
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
880
+    // echapper les tags &gt; &lt;
881
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
882 882
 
883
-	// importer les &eacute;
884
-	$texte = filtrer_entites($texte);
883
+    // importer les &eacute;
884
+    $texte = filtrer_entites($texte);
885 885
 
886
-	// " -> &quot; et tout ce genre de choses
887
-	$u = $GLOBALS['meta']['pcre_u'];
888
-	$texte = str_replace("&nbsp;", " ", $texte);
889
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
890
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
891
-	$texte = entites_html($texte, false, false);
892
-	// mais bien echapper les double quotes !
893
-	$texte = str_replace('"', '&#034;', $texte);
886
+    // " -> &quot; et tout ce genre de choses
887
+    $u = $GLOBALS['meta']['pcre_u'];
888
+    $texte = str_replace("&nbsp;", " ", $texte);
889
+    $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
890
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
891
+    $texte = entites_html($texte, false, false);
892
+    // mais bien echapper les double quotes !
893
+    $texte = str_replace('"', '&#034;', $texte);
894 894
 
895
-	// verifier le charset
896
-	$texte = charset2unicode($texte);
895
+    // verifier le charset
896
+    $texte = charset2unicode($texte);
897 897
 
898
-	// Caracteres problematiques en iso-latin 1
899
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
900
-		$texte = str_replace(chr(156), '&#156;', $texte);
901
-		$texte = str_replace(chr(140), '&#140;', $texte);
902
-		$texte = str_replace(chr(159), '&#159;', $texte);
903
-	}
898
+    // Caracteres problematiques en iso-latin 1
899
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
900
+        $texte = str_replace(chr(156), '&#156;', $texte);
901
+        $texte = str_replace(chr(140), '&#140;', $texte);
902
+        $texte = str_replace(chr(159), '&#159;', $texte);
903
+    }
904 904
 
905
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
906
-	// et le caractere apostrophe alourdit les squelettes avec PHP
907
-	// ==> on les remplace par l'entite HTML
908
-	return str_replace($apostrophe, "'", $texte);
905
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
906
+    // et le caractere apostrophe alourdit les squelettes avec PHP
907
+    // ==> on les remplace par l'entite HTML
908
+    return str_replace($apostrophe, "'", $texte);
909 909
 }
910 910
 
911 911
 /**
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
  *     Texte encodé et quote pour XML
923 923
  */
924 924
 function texte_backendq($texte) {
925
-	return addslashes(texte_backend($texte));
925
+    return addslashes(texte_backend($texte));
926 926
 }
927 927
 
928 928
 
@@ -945,9 +945,9 @@  discard block
 block discarded – undo
945 945
  *     Numéro de titre, sinon chaîne vide
946 946
  **/
947 947
 function supprimer_numero($texte) {
948
-	return preg_replace(
949
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
950
-		"", $texte);
948
+    return preg_replace(
949
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
950
+        "", $texte);
951 951
 }
952 952
 
953 953
 /**
@@ -970,13 +970,13 @@  discard block
 block discarded – undo
970 970
  *     Numéro de titre, sinon chaîne vide
971 971
  **/
972 972
 function recuperer_numero($texte) {
973
-	if (preg_match(
974
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
975
-		$texte, $regs)) {
976
-		return strval($regs[1]);
977
-	} else {
978
-		return '';
979
-	}
973
+    if (preg_match(
974
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
975
+        $texte, $regs)) {
976
+        return strval($regs[1]);
977
+    } else {
978
+        return '';
979
+    }
980 980
 }
981 981
 
982 982
 /**
@@ -1003,13 +1003,13 @@  discard block
 block discarded – undo
1003 1003
  *     Texte converti
1004 1004
  **/
1005 1005
 function supprimer_tags($texte, $rempl = "") {
1006
-	$texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
1007
-	// ne pas oublier un < final non ferme car coupe
1008
-	$texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
1009
-	// mais qui peut aussi etre un simple signe plus petit que
1010
-	$texte = str_replace('<', '&lt;', $texte);
1006
+    $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
1007
+    // ne pas oublier un < final non ferme car coupe
1008
+    $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
1009
+    // mais qui peut aussi etre un simple signe plus petit que
1010
+    $texte = str_replace('<', '&lt;', $texte);
1011 1011
 
1012
-	return $texte;
1012
+    return $texte;
1013 1013
 }
1014 1014
 
1015 1015
 /**
@@ -1032,9 +1032,9 @@  discard block
 block discarded – undo
1032 1032
  *     Texte converti
1033 1033
  **/
1034 1034
 function echapper_tags($texte, $rempl = "") {
1035
-	$texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1035
+    $texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1036 1036
 
1037
-	return $texte;
1037
+    return $texte;
1038 1038
 }
1039 1039
 
1040 1040
 /**
@@ -1055,18 +1055,18 @@  discard block
 block discarded – undo
1055 1055
  *     Texte converti
1056 1056
  **/
1057 1057
 function textebrut($texte) {
1058
-	$u = $GLOBALS['meta']['pcre_u'];
1059
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1060
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1061
-	$texte = preg_replace("/^\n+/", "", $texte);
1062
-	$texte = preg_replace("/\n+$/", "", $texte);
1063
-	$texte = preg_replace("/\n +/", "\n", $texte);
1064
-	$texte = supprimer_tags($texte);
1065
-	$texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1066
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1067
-	$texte = str_replace("&#8217;", "'", $texte);
1058
+    $u = $GLOBALS['meta']['pcre_u'];
1059
+    $texte = preg_replace('/\s+/S' . $u, " ", $texte);
1060
+    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1061
+    $texte = preg_replace("/^\n+/", "", $texte);
1062
+    $texte = preg_replace("/\n+$/", "", $texte);
1063
+    $texte = preg_replace("/\n +/", "\n", $texte);
1064
+    $texte = supprimer_tags($texte);
1065
+    $texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1066
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1067
+    $texte = str_replace("&#8217;", "'", $texte);
1068 1068
 
1069
-	return $texte;
1069
+    return $texte;
1070 1070
 }
1071 1071
 
1072 1072
 
@@ -1082,17 +1082,17 @@  discard block
 block discarded – undo
1082 1082
  *     Texte avec liens ouvrants
1083 1083
  **/
1084 1084
 function liens_ouvrants($texte) {
1085
-	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1086
-		$texte, $liens, PREG_PATTERN_ORDER)) {
1087
-		foreach ($liens[0] as $a) {
1088
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1089
-			$ablank = inserer_attribut($a, 'rel', $rel);
1090
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1091
-			$texte = str_replace($a, $ablank, $texte);
1092
-		}
1093
-	}
1085
+    if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1086
+        $texte, $liens, PREG_PATTERN_ORDER)) {
1087
+        foreach ($liens[0] as $a) {
1088
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1089
+            $ablank = inserer_attribut($a, 'rel', $rel);
1090
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1091
+            $texte = str_replace($a, $ablank, $texte);
1092
+        }
1093
+    }
1094 1094
 
1095
-	return $texte;
1095
+    return $texte;
1096 1096
 }
1097 1097
 
1098 1098
 /**
@@ -1102,22 +1102,22 @@  discard block
 block discarded – undo
1102 1102
  * @return string
1103 1103
  */
1104 1104
 function liens_nofollow($texte) {
1105
-	if (stripos($texte, "<a") === false) {
1106
-		return $texte;
1107
-	}
1105
+    if (stripos($texte, "<a") === false) {
1106
+        return $texte;
1107
+    }
1108 1108
 
1109
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1110
-		foreach ($regs[0] as $a) {
1111
-			$rel = extraire_attribut($a, "rel");
1112
-			if (strpos($rel, "nofollow") === false) {
1113
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1114
-				$anofollow = inserer_attribut($a, "rel", $rel);
1115
-				$texte = str_replace($a, $anofollow, $texte);
1116
-			}
1117
-		}
1118
-	}
1109
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1110
+        foreach ($regs[0] as $a) {
1111
+            $rel = extraire_attribut($a, "rel");
1112
+            if (strpos($rel, "nofollow") === false) {
1113
+                $rel = "nofollow" . ($rel ? " $rel" : "");
1114
+                $anofollow = inserer_attribut($a, "rel", $rel);
1115
+                $texte = str_replace($a, $anofollow, $texte);
1116
+            }
1117
+        }
1118
+    }
1119 1119
 
1120
-	return $texte;
1120
+    return $texte;
1121 1121
 }
1122 1122
 
1123 1123
 /**
@@ -1136,12 +1136,12 @@  discard block
 block discarded – undo
1136 1136
  *     Texte sans paraghaphes
1137 1137
  **/
1138 1138
 function PtoBR($texte) {
1139
-	$u = $GLOBALS['meta']['pcre_u'];
1140
-	$texte = preg_replace("@</p>@iS", "\n", $texte);
1141
-	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1142
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1139
+    $u = $GLOBALS['meta']['pcre_u'];
1140
+    $texte = preg_replace("@</p>@iS", "\n", $texte);
1141
+    $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1142
+    $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1143 1143
 
1144
-	return $texte;
1144
+    return $texte;
1145 1145
 }
1146 1146
 
1147 1147
 
@@ -1165,14 +1165,14 @@  discard block
 block discarded – undo
1165 1165
  * @return string Texte encadré du style CSS
1166 1166
  */
1167 1167
 function lignes_longues($texte) {
1168
-	if (!strlen(trim($texte))) {
1169
-		return $texte;
1170
-	}
1171
-	include_spip('inc/texte');
1172
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1173
-		'div' : 'span';
1168
+    if (!strlen(trim($texte))) {
1169
+        return $texte;
1170
+    }
1171
+    include_spip('inc/texte');
1172
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1173
+        'div' : 'span';
1174 1174
 
1175
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1175
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1176 1176
 }
1177 1177
 
1178 1178
 /**
@@ -1191,30 +1191,30 @@  discard block
 block discarded – undo
1191 1191
  * @return string Texte en majuscule
1192 1192
  */
1193 1193
 function majuscules($texte) {
1194
-	if (!strlen($texte)) {
1195
-		return '';
1196
-	}
1194
+    if (!strlen($texte)) {
1195
+        return '';
1196
+    }
1197 1197
 
1198
-	// Cas du turc
1199
-	if ($GLOBALS['spip_lang'] == 'tr') {
1200
-		# remplacer hors des tags et des entites
1201
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1202
-			foreach ($regs as $n => $match) {
1203
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1204
-			}
1205
-		}
1198
+    // Cas du turc
1199
+    if ($GLOBALS['spip_lang'] == 'tr') {
1200
+        # remplacer hors des tags et des entites
1201
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1202
+            foreach ($regs as $n => $match) {
1203
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1204
+            }
1205
+        }
1206 1206
 
1207
-		$texte = str_replace('i', '&#304;', $texte);
1207
+        $texte = str_replace('i', '&#304;', $texte);
1208 1208
 
1209
-		if ($regs) {
1210
-			foreach ($regs as $n => $match) {
1211
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1212
-			}
1213
-		}
1214
-	}
1209
+        if ($regs) {
1210
+            foreach ($regs as $n => $match) {
1211
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1212
+            }
1213
+        }
1214
+    }
1215 1215
 
1216
-	// Cas general
1217
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1216
+    // Cas general
1217
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1218 1218
 }
1219 1219
 
1220 1220
 /**
@@ -1232,29 +1232,29 @@  discard block
 block discarded – undo
1232 1232
  * @return string
1233 1233
  **/
1234 1234
 function taille_en_octets($taille) {
1235
-	if (!defined('_KILOBYTE')) {
1236
-		/**
1237
-		 * Définit le nombre d'octets dans un Kilobyte
1238
-		 *
1239
-		 * @var int
1240
-		 **/
1241
-		define('_KILOBYTE', 1024);
1242
-	}
1235
+    if (!defined('_KILOBYTE')) {
1236
+        /**
1237
+         * Définit le nombre d'octets dans un Kilobyte
1238
+         *
1239
+         * @var int
1240
+         **/
1241
+        define('_KILOBYTE', 1024);
1242
+    }
1243 1243
 
1244
-	if ($taille < 1) {
1245
-		return '';
1246
-	}
1247
-	if ($taille < _KILOBYTE) {
1248
-		$taille = _T('taille_octets', array('taille' => $taille));
1249
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1250
-		$taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1251
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1252
-		$taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1253
-	} else {
1254
-		$taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1255
-	}
1244
+    if ($taille < 1) {
1245
+        return '';
1246
+    }
1247
+    if ($taille < _KILOBYTE) {
1248
+        $taille = _T('taille_octets', array('taille' => $taille));
1249
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1250
+        $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1251
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1252
+        $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1253
+    } else {
1254
+        $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1255
+    }
1256 1256
 
1257
-	return $taille;
1257
+    return $taille;
1258 1258
 }
1259 1259
 
1260 1260
 
@@ -1276,15 +1276,15 @@  discard block
 block discarded – undo
1276 1276
  *     Texte prêt pour être utilisé en attribut HTML
1277 1277
  **/
1278 1278
 function attribut_html($texte, $textebrut = true) {
1279
-	$u = $GLOBALS['meta']['pcre_u'];
1280
-	if ($textebrut) {
1281
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1282
-	}
1283
-	$texte = texte_backend($texte);
1284
-	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1279
+    $u = $GLOBALS['meta']['pcre_u'];
1280
+    if ($textebrut) {
1281
+        $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1282
+    }
1283
+    $texte = texte_backend($texte);
1284
+    $texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1285 1285
 
1286
-	return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1287
-		$texte);
1286
+    return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1287
+        $texte);
1288 1288
 }
1289 1289
 
1290 1290
 
@@ -1304,12 +1304,12 @@  discard block
 block discarded – undo
1304 1304
  *     URL ou chaîne vide
1305 1305
  **/
1306 1306
 function vider_url($url, $entites = true) {
1307
-	# un message pour abs_url
1308
-	$GLOBALS['mode_abs_url'] = 'url';
1309
-	$url = trim($url);
1310
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1307
+    # un message pour abs_url
1308
+    $GLOBALS['mode_abs_url'] = 'url';
1309
+    $url = trim($url);
1310
+    $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1311 1311
 
1312
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1312
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1313 1313
 }
1314 1314
 
1315 1315
 
@@ -1324,10 +1324,10 @@  discard block
 block discarded – undo
1324 1324
  * @return string Adresse email maquillée
1325 1325
  **/
1326 1326
 function antispam($texte) {
1327
-	include_spip('inc/acces');
1328
-	$masque = creer_pass_aleatoire(3);
1327
+    include_spip('inc/acces');
1328
+    $masque = creer_pass_aleatoire(3);
1329 1329
 
1330
-	return preg_replace("/@/", " $masque ", $texte);
1330
+    return preg_replace("/@/", " $masque ", $texte);
1331 1331
 }
1332 1332
 
1333 1333
 /**
@@ -1359,12 +1359,12 @@  discard block
 block discarded – undo
1359 1359
  *     True si on a le droit d'accès, false sinon.
1360 1360
  **/
1361 1361
 function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') {
1362
-	include_spip('inc/acces');
1363
-	if ($op) {
1364
-		$dir .= " $op $args";
1365
-	}
1362
+    include_spip('inc/acces');
1363
+    if ($op) {
1364
+        $dir .= " $op $args";
1365
+    }
1366 1366
 
1367
-	return verifier_low_sec($id_auteur, $cle, $dir);
1367
+    return verifier_low_sec($id_auteur, $cle, $dir);
1368 1368
 }
1369 1369
 
1370 1370
 /**
@@ -1389,11 +1389,11 @@  discard block
 block discarded – undo
1389 1389
  *     Retourne $texte, sinon $sinon.
1390 1390
  **/
1391 1391
 function sinon($texte, $sinon = '') {
1392
-	if ($texte or (!is_array($texte) and strlen($texte))) {
1393
-		return $texte;
1394
-	} else {
1395
-		return $sinon;
1396
-	}
1392
+    if ($texte or (!is_array($texte) and strlen($texte))) {
1393
+        return $texte;
1394
+    } else {
1395
+        return $sinon;
1396
+    }
1397 1397
 }
1398 1398
 
1399 1399
 /**
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
  * @return mixed
1418 1418
  **/
1419 1419
 function choixsivide($a, $vide, $pasvide) {
1420
-	return $a ? $pasvide : $vide;
1420
+    return $a ? $pasvide : $vide;
1421 1421
 }
1422 1422
 
1423 1423
 /**
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
  * @return mixed
1442 1442
  **/
1443 1443
 function choixsiegal($a1, $a2, $v, $f) {
1444
-	return ($a1 == $a2) ? $v : $f;
1444
+    return ($a1 == $a2) ? $v : $f;
1445 1445
 }
1446 1446
 
1447 1447
 //
@@ -1460,13 +1460,13 @@  discard block
 block discarded – undo
1460 1460
  * @return string
1461 1461
  **/
1462 1462
 function filtrer_ical($texte) {
1463
-	#include_spip('inc/charsets');
1464
-	$texte = html2unicode($texte);
1465
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1466
-	$texte = preg_replace("/\n/", " ", $texte);
1467
-	$texte = preg_replace("/,/", "\,", $texte);
1463
+    #include_spip('inc/charsets');
1464
+    $texte = html2unicode($texte);
1465
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1466
+    $texte = preg_replace("/\n/", " ", $texte);
1467
+    $texte = preg_replace("/,/", "\,", $texte);
1468 1468
 
1469
-	return $texte;
1469
+    return $texte;
1470 1470
 }
1471 1471
 
1472 1472
 
@@ -1491,53 +1491,53 @@  discard block
 block discarded – undo
1491 1491
  * @return string
1492 1492
  **/
1493 1493
 function post_autobr($texte, $delim = "\n_ ") {
1494
-	if (!function_exists('echappe_html')) {
1495
-		include_spip('inc/texte_mini');
1496
-	}
1497
-	$texte = str_replace("\r\n", "\r", $texte);
1498
-	$texte = str_replace("\r", "\n", $texte);
1499
-
1500
-	if (preg_match(",\n+$,", $texte, $fin)) {
1501
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1502
-	} else {
1503
-		$fin = '';
1504
-	}
1505
-
1506
-	$texte = echappe_html($texte, '', true);
1507
-
1508
-	// echapper les modeles
1509
-	if (strpos($texte, "<") !== false) {
1510
-		include_spip('inc/lien');
1511
-		if (defined('_PREG_MODELE')) {
1512
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1513
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1514
-		}
1515
-	}
1516
-
1517
-	$debut = '';
1518
-	$suite = $texte;
1519
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1520
-		$debut .= substr($suite, 0, $t - 1);
1521
-		$suite = substr($suite, $t);
1522
-		$car = substr($suite, 0, 1);
1523
-		if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1524
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1525
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1526
-		) {
1527
-			$debut .= $delim;
1528
-		} else {
1529
-			$debut .= "\n";
1530
-		}
1531
-		if (preg_match(",^\n+,", $suite, $regs)) {
1532
-			$debut .= $regs[0];
1533
-			$suite = substr($suite, strlen($regs[0]));
1534
-		}
1535
-	}
1536
-	$texte = $debut . $suite;
1537
-
1538
-	$texte = echappe_retour($texte);
1539
-
1540
-	return $texte . $fin;
1494
+    if (!function_exists('echappe_html')) {
1495
+        include_spip('inc/texte_mini');
1496
+    }
1497
+    $texte = str_replace("\r\n", "\r", $texte);
1498
+    $texte = str_replace("\r", "\n", $texte);
1499
+
1500
+    if (preg_match(",\n+$,", $texte, $fin)) {
1501
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1502
+    } else {
1503
+        $fin = '';
1504
+    }
1505
+
1506
+    $texte = echappe_html($texte, '', true);
1507
+
1508
+    // echapper les modeles
1509
+    if (strpos($texte, "<") !== false) {
1510
+        include_spip('inc/lien');
1511
+        if (defined('_PREG_MODELE')) {
1512
+            $preg_modeles = "@" . _PREG_MODELE . "@imsS";
1513
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1514
+        }
1515
+    }
1516
+
1517
+    $debut = '';
1518
+    $suite = $texte;
1519
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1520
+        $debut .= substr($suite, 0, $t - 1);
1521
+        $suite = substr($suite, $t);
1522
+        $car = substr($suite, 0, 1);
1523
+        if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1524
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1525
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1526
+        ) {
1527
+            $debut .= $delim;
1528
+        } else {
1529
+            $debut .= "\n";
1530
+        }
1531
+        if (preg_match(",^\n+,", $suite, $regs)) {
1532
+            $debut .= $regs[0];
1533
+            $suite = substr($suite, strlen($regs[0]));
1534
+        }
1535
+    }
1536
+    $texte = $debut . $suite;
1537
+
1538
+    $texte = echappe_retour($texte);
1539
+
1540
+    return $texte . $fin;
1541 1541
 }
1542 1542
 
1543 1543
 
@@ -1578,46 +1578,46 @@  discard block
 block discarded – undo
1578 1578
  * @return string
1579 1579
  **/
1580 1580
 function extraire_idiome($letexte, $lang = null, $options = array()) {
1581
-	static $traduire = false;
1582
-	if ($letexte
1583
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1584
-	) {
1585
-		if (!$traduire) {
1586
-			$traduire = charger_fonction('traduire', 'inc');
1587
-			include_spip('inc/lang');
1588
-		}
1589
-		if (!$lang) {
1590
-			$lang = $GLOBALS['spip_lang'];
1591
-		}
1592
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1593
-		if (is_bool($options)) {
1594
-			$options = array('echappe_span' => $options);
1595
-		}
1596
-		if (!isset($options['echappe_span'])) {
1597
-			$options = array_merge($options, array('echappe_span' => false));
1598
-		}
1599
-
1600
-		foreach ($regs as $reg) {
1601
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1602
-			$desc = $traduire($cle, $lang, true);
1603
-			$l = $desc->langue;
1604
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1605
-			if (strlen($desc->texte)) {
1606
-				$trad = code_echappement($desc->texte, 'idiome', false);
1607
-				if ($l !== $lang) {
1608
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1609
-				}
1610
-				if (lang_dir($l) !== lang_dir($lang)) {
1611
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1612
-				}
1613
-				if (!$options['echappe_span']) {
1614
-					$trad = echappe_retour($trad, 'idiome');
1615
-				}
1616
-				$letexte = str_replace($reg[0], $trad, $letexte);
1617
-			}
1618
-		}
1619
-	}
1620
-	return $letexte;
1581
+    static $traduire = false;
1582
+    if ($letexte
1583
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1584
+    ) {
1585
+        if (!$traduire) {
1586
+            $traduire = charger_fonction('traduire', 'inc');
1587
+            include_spip('inc/lang');
1588
+        }
1589
+        if (!$lang) {
1590
+            $lang = $GLOBALS['spip_lang'];
1591
+        }
1592
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1593
+        if (is_bool($options)) {
1594
+            $options = array('echappe_span' => $options);
1595
+        }
1596
+        if (!isset($options['echappe_span'])) {
1597
+            $options = array_merge($options, array('echappe_span' => false));
1598
+        }
1599
+
1600
+        foreach ($regs as $reg) {
1601
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1602
+            $desc = $traduire($cle, $lang, true);
1603
+            $l = $desc->langue;
1604
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1605
+            if (strlen($desc->texte)) {
1606
+                $trad = code_echappement($desc->texte, 'idiome', false);
1607
+                if ($l !== $lang) {
1608
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1609
+                }
1610
+                if (lang_dir($l) !== lang_dir($lang)) {
1611
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1612
+                }
1613
+                if (!$options['echappe_span']) {
1614
+                    $trad = echappe_retour($trad, 'idiome');
1615
+                }
1616
+                $letexte = str_replace($reg[0], $trad, $letexte);
1617
+            }
1618
+        }
1619
+    }
1620
+    return $letexte;
1621 1621
 }
1622 1622
 
1623 1623
 /**
@@ -1669,67 +1669,67 @@  discard block
 block discarded – undo
1669 1669
  **/
1670 1670
 function extraire_multi($letexte, $lang = null, $options = array()) {
1671 1671
 
1672
-	if ($letexte
1673
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1674
-	) {
1675
-		if (!$lang) {
1676
-			$lang = $GLOBALS['spip_lang'];
1677
-		}
1678
-
1679
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1680
-		if (is_bool($options)) {
1681
-			$options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1682
-		}
1683
-		if (!isset($options['echappe_span'])) {
1684
-			$options = array_merge($options, array('echappe_span' => false));
1685
-		}
1686
-		if (!isset($options['lang_defaut'])) {
1687
-			$options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1688
-		}
1689
-
1690
-		include_spip('inc/lang');
1691
-		foreach ($regs as $reg) {
1692
-			// chercher la version de la langue courante
1693
-			$trads = extraire_trads($reg[1]);
1694
-			if ($l = approcher_langue($trads, $lang)) {
1695
-				$trad = $trads[$l];
1696
-			} else {
1697
-				if ($options['lang_defaut'] == 'aucune') {
1698
-					$trad = '';
1699
-				} else {
1700
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1701
-					// ou la premiere dispo
1702
-					// mais typographier le texte selon les regles de celle-ci
1703
-					// Attention aux blocs multi sur plusieurs lignes
1704
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1705
-						$l = key($trads);
1706
-					}
1707
-					$trad = $trads[$l];
1708
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1709
-					$trad = $typographie($trad);
1710
-					// Tester si on echappe en span ou en div
1711
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1712
-					include_spip('inc/texte');
1713
-					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1714
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1715
-					if ($mode === 'div') {
1716
-						$trad = rtrim($trad) . "\n\n";
1717
-					}
1718
-					$trad = code_echappement($trad, 'multi', false, $mode);
1719
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1720
-					if (lang_dir($l) !== lang_dir($lang)) {
1721
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1722
-					}
1723
-					if (!$options['echappe_span']) {
1724
-						$trad = echappe_retour($trad, 'multi');
1725
-					}
1726
-				}
1727
-			}
1728
-			$letexte = str_replace($reg[0], $trad, $letexte);
1729
-		}
1730
-	}
1731
-
1732
-	return $letexte;
1672
+    if ($letexte
1673
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1674
+    ) {
1675
+        if (!$lang) {
1676
+            $lang = $GLOBALS['spip_lang'];
1677
+        }
1678
+
1679
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1680
+        if (is_bool($options)) {
1681
+            $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1682
+        }
1683
+        if (!isset($options['echappe_span'])) {
1684
+            $options = array_merge($options, array('echappe_span' => false));
1685
+        }
1686
+        if (!isset($options['lang_defaut'])) {
1687
+            $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1688
+        }
1689
+
1690
+        include_spip('inc/lang');
1691
+        foreach ($regs as $reg) {
1692
+            // chercher la version de la langue courante
1693
+            $trads = extraire_trads($reg[1]);
1694
+            if ($l = approcher_langue($trads, $lang)) {
1695
+                $trad = $trads[$l];
1696
+            } else {
1697
+                if ($options['lang_defaut'] == 'aucune') {
1698
+                    $trad = '';
1699
+                } else {
1700
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1701
+                    // ou la premiere dispo
1702
+                    // mais typographier le texte selon les regles de celle-ci
1703
+                    // Attention aux blocs multi sur plusieurs lignes
1704
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1705
+                        $l = key($trads);
1706
+                    }
1707
+                    $trad = $trads[$l];
1708
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1709
+                    $trad = $typographie($trad);
1710
+                    // Tester si on echappe en span ou en div
1711
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1712
+                    include_spip('inc/texte');
1713
+                    $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1714
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1715
+                    if ($mode === 'div') {
1716
+                        $trad = rtrim($trad) . "\n\n";
1717
+                    }
1718
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1719
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1720
+                    if (lang_dir($l) !== lang_dir($lang)) {
1721
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1722
+                    }
1723
+                    if (!$options['echappe_span']) {
1724
+                        $trad = echappe_retour($trad, 'multi');
1725
+                    }
1726
+                }
1727
+            }
1728
+            $letexte = str_replace($reg[0], $trad, $letexte);
1729
+        }
1730
+    }
1731
+
1732
+    return $letexte;
1733 1733
 }
1734 1734
 
1735 1735
 /**
@@ -1745,20 +1745,20 @@  discard block
 block discarded – undo
1745 1745
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1746 1746
  **/
1747 1747
 function extraire_trads($bloc) {
1748
-	$lang = '';
1748
+    $lang = '';
1749 1749
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1750 1750
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1751
-	while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1752
-		$texte = trim($regs[1]);
1753
-		if ($texte or $lang) {
1754
-			$trads[$lang] = $texte;
1755
-		}
1756
-		$bloc = substr($bloc, strlen($regs[0]));
1757
-		$lang = $regs[2];
1758
-	}
1759
-	$trads[$lang] = $bloc;
1751
+    while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1752
+        $texte = trim($regs[1]);
1753
+        if ($texte or $lang) {
1754
+            $trads[$lang] = $texte;
1755
+        }
1756
+        $bloc = substr($bloc, strlen($regs[0]));
1757
+        $lang = $regs[2];
1758
+    }
1759
+    $trads[$lang] = $bloc;
1760 1760
 
1761
-	return $trads;
1761
+    return $trads;
1762 1762
 }
1763 1763
 
1764 1764
 
@@ -1769,7 +1769,7 @@  discard block
 block discarded – undo
1769 1769
  * @return string L'initiale en majuscule
1770 1770
  */
1771 1771
 function filtre_initiale($nom) {
1772
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1772
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1773 1773
 }
1774 1774
 
1775 1775
 
@@ -1814,33 +1814,33 @@  discard block
 block discarded – undo
1814 1814
  *      - null (interne) : si on empile
1815 1815
  **/
1816 1816
 function unique($donnee, $famille = '', $cpt = false) {
1817
-	static $mem = array();
1818
-	// permettre de vider la pile et de la restaurer
1819
-	// pour le calcul de introduction...
1820
-	if ($famille == '_spip_raz_') {
1821
-		$tmp = $mem;
1822
-		$mem = array();
1823
-
1824
-		return $tmp;
1825
-	} elseif ($famille == '_spip_set_') {
1826
-		$mem = $donnee;
1827
-
1828
-		return;
1829
-	}
1830
-	// eviter une notice
1831
-	if (!isset($mem[$famille])) {
1832
-		$mem[$famille] = array();
1833
-	}
1834
-	if ($cpt) {
1835
-		return count($mem[$famille]);
1836
-	}
1837
-	// eviter une notice
1838
-	if (!isset($mem[$famille][$donnee])) {
1839
-		$mem[$famille][$donnee] = 0;
1840
-	}
1841
-	if (!($mem[$famille][$donnee]++)) {
1842
-		return $donnee;
1843
-	}
1817
+    static $mem = array();
1818
+    // permettre de vider la pile et de la restaurer
1819
+    // pour le calcul de introduction...
1820
+    if ($famille == '_spip_raz_') {
1821
+        $tmp = $mem;
1822
+        $mem = array();
1823
+
1824
+        return $tmp;
1825
+    } elseif ($famille == '_spip_set_') {
1826
+        $mem = $donnee;
1827
+
1828
+        return;
1829
+    }
1830
+    // eviter une notice
1831
+    if (!isset($mem[$famille])) {
1832
+        $mem[$famille] = array();
1833
+    }
1834
+    if ($cpt) {
1835
+        return count($mem[$famille]);
1836
+    }
1837
+    // eviter une notice
1838
+    if (!isset($mem[$famille][$donnee])) {
1839
+        $mem[$famille][$donnee] = 0;
1840
+    }
1841
+    if (!($mem[$famille][$donnee]++)) {
1842
+        return $donnee;
1843
+    }
1844 1844
 }
1845 1845
 
1846 1846
 
@@ -1868,18 +1868,18 @@  discard block
 block discarded – undo
1868 1868
  *     Une des valeurs en fonction du compteur.
1869 1869
  **/
1870 1870
 function alterner($i) {
1871
-	// recuperer les arguments (attention fonctions un peu space)
1872
-	$num = func_num_args();
1873
-	$args = func_get_args();
1871
+    // recuperer les arguments (attention fonctions un peu space)
1872
+    $num = func_num_args();
1873
+    $args = func_get_args();
1874 1874
 
1875
-	if ($num == 2 && is_array($args[1])) {
1876
-		$args = $args[1];
1877
-		array_unshift($args, '');
1878
-		$num = count($args);
1879
-	}
1875
+    if ($num == 2 && is_array($args[1])) {
1876
+        $args = $args[1];
1877
+        array_unshift($args, '');
1878
+        $num = count($args);
1879
+    }
1880 1880
 
1881
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1882
-	return $args[(intval($i) - 1) % ($num - 1) + 1];
1881
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1882
+    return $args[(intval($i) - 1) % ($num - 1) + 1];
1883 1883
 }
1884 1884
 
1885 1885
 
@@ -1904,46 +1904,46 @@  discard block
 block discarded – undo
1904 1904
  *     - Tableau complet (si 2e argument)
1905 1905
  **/
1906 1906
 function extraire_attribut($balise, $attribut, $complet = false) {
1907
-	if (is_array($balise)) {
1908
-		array_walk(
1909
-			$balise,
1910
-			function(&$a, $key, $t){
1911
-				$a = extraire_attribut($a, $t);
1912
-			},
1913
-			$attribut
1914
-		);
1915
-
1916
-		return $balise;
1917
-	}
1918
-	if (preg_match(
1919
-		',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1920
-		. $attribut
1921
-		. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1922
-
1923
-		$balise, $r)) {
1924
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1925
-			$r[4] = substr($r[3], 1, -1);
1926
-			$r[3] = $r[3][0];
1927
-		} elseif ($r[3] !== '') {
1928
-			$r[4] = $r[3];
1929
-			$r[3] = '';
1930
-		} else {
1931
-			$r[4] = trim($r[2]);
1932
-		}
1933
-		$att = $r[4];
1934
-		if (strpos($att, "&#") !== false) {
1935
-			$att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1936
-		}
1937
-		$att = filtrer_entites($att);
1938
-	} else {
1939
-		$att = null;
1940
-	}
1941
-
1942
-	if ($complet) {
1943
-		return array($att, $r);
1944
-	} else {
1945
-		return $att;
1946
-	}
1907
+    if (is_array($balise)) {
1908
+        array_walk(
1909
+            $balise,
1910
+            function(&$a, $key, $t){
1911
+                $a = extraire_attribut($a, $t);
1912
+            },
1913
+            $attribut
1914
+        );
1915
+
1916
+        return $balise;
1917
+    }
1918
+    if (preg_match(
1919
+        ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1920
+        . $attribut
1921
+        . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1922
+
1923
+        $balise, $r)) {
1924
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1925
+            $r[4] = substr($r[3], 1, -1);
1926
+            $r[3] = $r[3][0];
1927
+        } elseif ($r[3] !== '') {
1928
+            $r[4] = $r[3];
1929
+            $r[3] = '';
1930
+        } else {
1931
+            $r[4] = trim($r[2]);
1932
+        }
1933
+        $att = $r[4];
1934
+        if (strpos($att, "&#") !== false) {
1935
+            $att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1936
+        }
1937
+        $att = filtrer_entites($att);
1938
+    } else {
1939
+        $att = null;
1940
+    }
1941
+
1942
+    if ($complet) {
1943
+        return array($att, $r);
1944
+    } else {
1945
+        return $att;
1946
+    }
1947 1947
 }
1948 1948
 
1949 1949
 /**
@@ -1975,37 +1975,37 @@  discard block
 block discarded – undo
1975 1975
  *     Code html modifié
1976 1976
  **/
1977 1977
 function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) {
1978
-	// preparer l'attribut
1979
-	// supprimer les &nbsp; etc mais pas les balises html
1980
-	// qui ont un sens dans un attribut value d'un input
1981
-	if ($proteger) {
1982
-		$val = attribut_html($val, false);
1983
-	}
1984
-
1985
-	// echapper les ' pour eviter tout bug
1986
-	$val = str_replace("'", "&#039;", $val);
1987
-	if ($vider and strlen($val) == 0) {
1988
-		$insert = '';
1989
-	} else {
1990
-		$insert = " $attribut='$val'";
1991
-	}
1992
-
1993
-	list($old, $r) = extraire_attribut($balise, $attribut, true);
1994
-
1995
-	if ($old !== null) {
1996
-		// Remplacer l'ancien attribut du meme nom
1997
-		$balise = $r[1] . $insert . $r[5];
1998
-	} else {
1999
-		// preferer une balise " />" (comme <img />)
2000
-		if (preg_match(',/>,', $balise)) {
2001
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2002
-		} // sinon une balise <a ...> ... </a>
2003
-		else {
2004
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2005
-		}
2006
-	}
2007
-
2008
-	return $balise;
1978
+    // preparer l'attribut
1979
+    // supprimer les &nbsp; etc mais pas les balises html
1980
+    // qui ont un sens dans un attribut value d'un input
1981
+    if ($proteger) {
1982
+        $val = attribut_html($val, false);
1983
+    }
1984
+
1985
+    // echapper les ' pour eviter tout bug
1986
+    $val = str_replace("'", "&#039;", $val);
1987
+    if ($vider and strlen($val) == 0) {
1988
+        $insert = '';
1989
+    } else {
1990
+        $insert = " $attribut='$val'";
1991
+    }
1992
+
1993
+    list($old, $r) = extraire_attribut($balise, $attribut, true);
1994
+
1995
+    if ($old !== null) {
1996
+        // Remplacer l'ancien attribut du meme nom
1997
+        $balise = $r[1] . $insert . $r[5];
1998
+    } else {
1999
+        // preferer une balise " />" (comme <img />)
2000
+        if (preg_match(',/>,', $balise)) {
2001
+            $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2002
+        } // sinon une balise <a ...> ... </a>
2003
+        else {
2004
+            $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2005
+        }
2006
+    }
2007
+
2008
+    return $balise;
2009 2009
 }
2010 2010
 
2011 2011
 /**
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
  * @return string Code HTML sans l'attribut
2024 2024
  **/
2025 2025
 function vider_attribut($balise, $attribut) {
2026
-	return inserer_attribut($balise, $attribut, '', false, true);
2026
+    return inserer_attribut($balise, $attribut, '', false, true);
2027 2027
 }
2028 2028
 
2029 2029
 /**
@@ -2035,50 +2035,50 @@  discard block
 block discarded – undo
2035 2035
  * @return string
2036 2036
  */
2037 2037
 function modifier_class($balise, $class, $operation='ajouter') {
2038
-	if (is_string($class)) {
2039
-		$class = explode(' ', trim($class));
2040
-	}
2041
-	$class = array_filter($class);
2042
-
2043
-	// si la ou les classes ont des caracteres invalides on ne fait rien
2044
-	if (preg_match(",[^\w-],", implode('', $class))) {
2045
-		return $balise;
2046
-	}
2047
-
2048
-	if ($class) {
2049
-		$class = array_unique($class);
2050
-		$class_courante = extraire_attribut($balise, 'class');
2051
-
2052
-		$class_new = $class_courante;
2053
-		foreach ($class as $c) {
2054
-			if ($c) {
2055
-				$is_class_presente = false;
2056
-				if (strpos($class_courante, $c) !== false
2057
-					and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) {
2058
-					$is_class_presente = true;
2059
-				}
2060
-				if (in_array($operation, ['ajouter', 'commuter'])
2061
-					and !$is_class_presente) {
2062
-					$class_new = rtrim($class_new) . " " . $c;
2063
-				}
2064
-				elseif (in_array($operation, ['supprimer', 'commuter'])
2065
-					and $is_class_presente) {
2066
-					$class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new));
2067
-				}
2068
-			}
2069
-		}
2070
-
2071
-		if ($class_new !== $class_courante) {
2072
-			if (strlen($class_new)) {
2073
-				$balise = inserer_attribut($balise, 'class', $class_new);
2074
-			}
2075
-			elseif ($class_courante) {
2076
-				$balise = vider_attribut($balise, 'class');
2077
-			}
2078
-		}
2079
-	}
2080
-
2081
-	return $balise;
2038
+    if (is_string($class)) {
2039
+        $class = explode(' ', trim($class));
2040
+    }
2041
+    $class = array_filter($class);
2042
+
2043
+    // si la ou les classes ont des caracteres invalides on ne fait rien
2044
+    if (preg_match(",[^\w-],", implode('', $class))) {
2045
+        return $balise;
2046
+    }
2047
+
2048
+    if ($class) {
2049
+        $class = array_unique($class);
2050
+        $class_courante = extraire_attribut($balise, 'class');
2051
+
2052
+        $class_new = $class_courante;
2053
+        foreach ($class as $c) {
2054
+            if ($c) {
2055
+                $is_class_presente = false;
2056
+                if (strpos($class_courante, $c) !== false
2057
+                    and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) {
2058
+                    $is_class_presente = true;
2059
+                }
2060
+                if (in_array($operation, ['ajouter', 'commuter'])
2061
+                    and !$is_class_presente) {
2062
+                    $class_new = rtrim($class_new) . " " . $c;
2063
+                }
2064
+                elseif (in_array($operation, ['supprimer', 'commuter'])
2065
+                    and $is_class_presente) {
2066
+                    $class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new));
2067
+                }
2068
+            }
2069
+        }
2070
+
2071
+        if ($class_new !== $class_courante) {
2072
+            if (strlen($class_new)) {
2073
+                $balise = inserer_attribut($balise, 'class', $class_new);
2074
+            }
2075
+            elseif ($class_courante) {
2076
+                $balise = vider_attribut($balise, 'class');
2077
+            }
2078
+        }
2079
+    }
2080
+
2081
+    return $balise;
2082 2082
 }
2083 2083
 
2084 2084
 /**
@@ -2088,7 +2088,7 @@  discard block
 block discarded – undo
2088 2088
  * @return string
2089 2089
  */
2090 2090
 function ajouter_class($balise, $class){
2091
-	return modifier_class($balise, $class, 'ajouter');
2091
+    return modifier_class($balise, $class, 'ajouter');
2092 2092
 }
2093 2093
 
2094 2094
 /**
@@ -2098,7 +2098,7 @@  discard block
 block discarded – undo
2098 2098
  * @return string
2099 2099
  */
2100 2100
 function supprimer_class($balise, $class){
2101
-	return modifier_class($balise, $class, 'supprimer');
2101
+    return modifier_class($balise, $class, 'supprimer');
2102 2102
 }
2103 2103
 
2104 2104
 /**
@@ -2109,7 +2109,7 @@  discard block
 block discarded – undo
2109 2109
  * @return string
2110 2110
  */
2111 2111
 function commuter_class($balise, $class){
2112
-	return modifier_class($balise, $class, 'commuter');
2112
+    return modifier_class($balise, $class, 'commuter');
2113 2113
 }
2114 2114
 
2115 2115
 /**
@@ -2120,9 +2120,9 @@  discard block
 block discarded – undo
2120 2120
  * @return string
2121 2121
  */
2122 2122
 function tester_config($id, $mode = '') {
2123
-	include_spip('action/inscrire_auteur');
2123
+    include_spip('action/inscrire_auteur');
2124 2124
 
2125
-	return tester_statut_inscription($mode, $id);
2125
+    return tester_statut_inscription($mode, $id);
2126 2126
 }
2127 2127
 
2128 2128
 //
@@ -2147,7 +2147,7 @@  discard block
 block discarded – undo
2147 2147
  * @return int $a+$b
2148 2148
  **/
2149 2149
 function plus($a, $b) {
2150
-	return $a + $b;
2150
+    return $a + $b;
2151 2151
 }
2152 2152
 function strplus($a, $b) {return strize('plus', $a, $b);}
2153 2153
 /**
@@ -2166,7 +2166,7 @@  discard block
 block discarded – undo
2166 2166
  * @return int $a-$b
2167 2167
  **/
2168 2168
 function moins($a, $b) {
2169
-	return $a - $b;
2169
+    return $a - $b;
2170 2170
 }
2171 2171
 function strmoins($a, $b) {return strize('moins', $a, $b);}
2172 2172
 
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
  * @return int $a*$b
2188 2188
  **/
2189 2189
 function mult($a, $b) {
2190
-	return $a * $b;
2190
+    return $a * $b;
2191 2191
 }
2192 2192
 function strmult($a, $b) {return strize('mult', $a, $b);}
2193 2193
 
@@ -2208,7 +2208,7 @@  discard block
 block discarded – undo
2208 2208
  * @return int $a/$b (ou 0 si $b est nul)
2209 2209
  **/
2210 2210
 function div($a, $b) {
2211
-	return $b ? $a / $b : 0;
2211
+    return $b ? $a / $b : 0;
2212 2212
 }
2213 2213
 function strdiv($a, $b) {return strize('div', $a, $b);}
2214 2214
 
@@ -2230,7 +2230,7 @@  discard block
 block discarded – undo
2230 2230
  * @return int ($nb % $mod) + $add
2231 2231
  **/
2232 2232
 function modulo($nb, $mod, $add = 0) {
2233
-	return ($mod ? $nb % $mod : 0) + $add;
2233
+    return ($mod ? $nb % $mod : 0) + $add;
2234 2234
 }
2235 2235
 
2236 2236
 
@@ -2245,24 +2245,24 @@  discard block
 block discarded – undo
2245 2245
  *      - true sinon
2246 2246
  **/
2247 2247
 function nom_acceptable($nom) {
2248
-	if (!is_string($nom)) {
2249
-		return false;
2250
-	}
2251
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2252
-		define('_TAGS_NOM_AUTEUR', '');
2253
-	}
2254
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2255
-	foreach ($tags_acceptes as $tag) {
2256
-		if (strlen($tag)) {
2257
-			$remp1[] = '<' . trim($tag) . '>';
2258
-			$remp1[] = '</' . trim($tag) . '>';
2259
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2260
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2261
-		}
2262
-	}
2263
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2248
+    if (!is_string($nom)) {
2249
+        return false;
2250
+    }
2251
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2252
+        define('_TAGS_NOM_AUTEUR', '');
2253
+    }
2254
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2255
+    foreach ($tags_acceptes as $tag) {
2256
+        if (strlen($tag)) {
2257
+            $remp1[] = '<' . trim($tag) . '>';
2258
+            $remp1[] = '</' . trim($tag) . '>';
2259
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2260
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2261
+        }
2262
+    }
2263
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2264 2264
 
2265
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2265
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2266 2266
 }
2267 2267
 
2268 2268
 
@@ -2278,14 +2278,14 @@  discard block
 block discarded – undo
2278 2278
  *      - renvoie un tableau si l'entree est un tableau
2279 2279
  **/
2280 2280
 function email_valide($adresses) {
2281
-	if (is_array($adresses)) {
2282
-		$adresses = array_map('email_valide', $adresses);
2283
-		$adresses = array_filter($adresses);
2284
-		return $adresses;
2285
-	}
2281
+    if (is_array($adresses)) {
2282
+        $adresses = array_map('email_valide', $adresses);
2283
+        $adresses = array_filter($adresses);
2284
+        return $adresses;
2285
+    }
2286 2286
 
2287
-	$email_valide = charger_fonction('email_valide', 'inc');
2288
-	return $email_valide($adresses);
2287
+    $email_valide = charger_fonction('email_valide', 'inc');
2288
+    return $email_valide($adresses);
2289 2289
 }
2290 2290
 
2291 2291
 /**
@@ -2299,20 +2299,20 @@  discard block
 block discarded – undo
2299 2299
  * @return string Texte
2300 2300
  **/
2301 2301
 function afficher_enclosures($tags) {
2302
-	$s = array();
2303
-	foreach (extraire_balises($tags, 'a') as $tag) {
2304
-		if (extraire_attribut($tag, 'rel') == 'enclosure'
2305
-			and $t = extraire_attribut($tag, 'href')
2306
-		) {
2307
-			$s[] = preg_replace(',>[^<]+</a>,S',
2308
-				'>'
2309
-				. http_img_pack('attachment-16.png', $t,
2310
-					'title="' . attribut_html($t) . '"')
2311
-				. '</a>', $tag);
2312
-		}
2313
-	}
2302
+    $s = array();
2303
+    foreach (extraire_balises($tags, 'a') as $tag) {
2304
+        if (extraire_attribut($tag, 'rel') == 'enclosure'
2305
+            and $t = extraire_attribut($tag, 'href')
2306
+        ) {
2307
+            $s[] = preg_replace(',>[^<]+</a>,S',
2308
+                '>'
2309
+                . http_img_pack('attachment-16.png', $t,
2310
+                    'title="' . attribut_html($t) . '"')
2311
+                . '</a>', $tag);
2312
+        }
2313
+    }
2314 2314
 
2315
-	return join('&nbsp;', $s);
2315
+    return join('&nbsp;', $s);
2316 2316
 }
2317 2317
 
2318 2318
 /**
@@ -2327,15 +2327,15 @@  discard block
 block discarded – undo
2327 2327
  * @return string Liens trouvés
2328 2328
  **/
2329 2329
 function afficher_tags($tags, $rels = 'tag,directory') {
2330
-	$s = array();
2331
-	foreach (extraire_balises($tags, 'a') as $tag) {
2332
-		$rel = extraire_attribut($tag, 'rel');
2333
-		if (strstr(",$rels,", ",$rel,")) {
2334
-			$s[] = $tag;
2335
-		}
2336
-	}
2330
+    $s = array();
2331
+    foreach (extraire_balises($tags, 'a') as $tag) {
2332
+        $rel = extraire_attribut($tag, 'rel');
2333
+        if (strstr(",$rels,", ",$rel,")) {
2334
+            $s[] = $tag;
2335
+        }
2336
+    }
2337 2337
 
2338
-	return join(', ', $s);
2338
+    return join(', ', $s);
2339 2339
 }
2340 2340
 
2341 2341
 
@@ -2357,21 +2357,21 @@  discard block
 block discarded – undo
2357 2357
  * @return string Tag HTML `<a>` avec microformat.
2358 2358
  **/
2359 2359
 function enclosure2microformat($e) {
2360
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2361
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2362
-	}
2363
-	$type = extraire_attribut($e, 'type');
2364
-	if (!$length = extraire_attribut($e, 'length')) {
2365
-		# <media:content : longeur dans fileSize. On tente.
2366
-		$length = extraire_attribut($e, 'fileSize');
2367
-	}
2368
-	$fichier = basename($url);
2360
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2361
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2362
+    }
2363
+    $type = extraire_attribut($e, 'type');
2364
+    if (!$length = extraire_attribut($e, 'length')) {
2365
+        # <media:content : longeur dans fileSize. On tente.
2366
+        $length = extraire_attribut($e, 'fileSize');
2367
+    }
2368
+    $fichier = basename($url);
2369 2369
 
2370
-	return '<a rel="enclosure"'
2371
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2372
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2373
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2374
-	. '>' . $fichier . '</a>';
2370
+    return '<a rel="enclosure"'
2371
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2372
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2373
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2374
+    . '>' . $fichier . '</a>';
2375 2375
 }
2376 2376
 
2377 2377
 /**
@@ -2389,24 +2389,24 @@  discard block
 block discarded – undo
2389 2389
  * @return string Tags RSS `<enclosure>`.
2390 2390
  **/
2391 2391
 function microformat2enclosure($tags) {
2392
-	$enclosures = array();
2393
-	foreach (extraire_balises($tags, 'a') as $e) {
2394
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2395
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2396
-			$type = extraire_attribut($e, 'type');
2397
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2398
-				$length = intval(extraire_attribut($e, 'length'));
2399
-			} # vieux data
2400
-			$fichier = basename($url);
2401
-			$enclosures[] = '<enclosure'
2402
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2403
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2404
-				. ($length ? ' length="' . $length . '"' : '')
2405
-				. ' />';
2406
-		}
2407
-	}
2392
+    $enclosures = array();
2393
+    foreach (extraire_balises($tags, 'a') as $e) {
2394
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2395
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2396
+            $type = extraire_attribut($e, 'type');
2397
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2398
+                $length = intval(extraire_attribut($e, 'length'));
2399
+            } # vieux data
2400
+            $fichier = basename($url);
2401
+            $enclosures[] = '<enclosure'
2402
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2403
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2404
+                . ($length ? ' length="' . $length . '"' : '')
2405
+                . ' />';
2406
+        }
2407
+    }
2408 2408
 
2409
-	return join("\n", $enclosures);
2409
+    return join("\n", $enclosures);
2410 2410
 }
2411 2411
 
2412 2412
 
@@ -2422,16 +2422,16 @@  discard block
 block discarded – undo
2422 2422
  * @return string Tags RSS Atom `<dc:subject>`.
2423 2423
  **/
2424 2424
 function tags2dcsubject($tags) {
2425
-	$subjects = '';
2426
-	foreach (extraire_balises($tags, 'a') as $e) {
2427
-		if (extraire_attribut($e, rel) == 'tag') {
2428
-			$subjects .= '<dc:subject>'
2429
-				. texte_backend(textebrut($e))
2430
-				. '</dc:subject>' . "\n";
2431
-		}
2432
-	}
2425
+    $subjects = '';
2426
+    foreach (extraire_balises($tags, 'a') as $e) {
2427
+        if (extraire_attribut($e, rel) == 'tag') {
2428
+            $subjects .= '<dc:subject>'
2429
+                . texte_backend(textebrut($e))
2430
+                . '</dc:subject>' . "\n";
2431
+        }
2432
+    }
2433 2433
 
2434
-	return $subjects;
2434
+    return $subjects;
2435 2435
 }
2436 2436
 
2437 2437
 /**
@@ -2460,23 +2460,23 @@  discard block
 block discarded – undo
2460 2460
  *     - Tableau de résultats, si tableau en entrée.
2461 2461
  **/
2462 2462
 function extraire_balise($texte, $tag = 'a') {
2463
-	if (is_array($texte)) {
2464
-		array_walk(
2465
-			$texte,
2466
-			function(&$a, $key, $t){
2467
-				$a = extraire_balise($a, $t);
2468
-			},
2469
-			$tag
2470
-		);
2463
+    if (is_array($texte)) {
2464
+        array_walk(
2465
+            $texte,
2466
+            function(&$a, $key, $t){
2467
+                $a = extraire_balise($a, $t);
2468
+            },
2469
+            $tag
2470
+        );
2471 2471
 
2472
-		return $texte;
2473
-	}
2472
+        return $texte;
2473
+    }
2474 2474
 
2475
-	if (preg_match(
2476
-		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2477
-		$texte, $regs)) {
2478
-		return $regs[0];
2479
-	}
2475
+    if (preg_match(
2476
+        ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2477
+        $texte, $regs)) {
2478
+        return $regs[0];
2479
+    }
2480 2480
 }
2481 2481
 
2482 2482
 /**
@@ -2504,25 +2504,25 @@  discard block
 block discarded – undo
2504 2504
  *     - Tableau de résultats, si tableau en entrée.
2505 2505
  **/
2506 2506
 function extraire_balises($texte, $tag = 'a') {
2507
-	if (is_array($texte)) {
2508
-		array_walk(
2509
-			$texte,
2510
-			function(&$a, $key, $t){
2511
-				$a = extraire_balises($a, $t);
2512
-			},
2513
-			$tag
2514
-		);
2507
+    if (is_array($texte)) {
2508
+        array_walk(
2509
+            $texte,
2510
+            function(&$a, $key, $t){
2511
+                $a = extraire_balises($a, $t);
2512
+            },
2513
+            $tag
2514
+        );
2515 2515
 
2516
-		return $texte;
2517
-	}
2516
+        return $texte;
2517
+    }
2518 2518
 
2519
-	if (preg_match_all(
2520
-		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2521
-		$texte, $regs, PREG_PATTERN_ORDER)) {
2522
-		return $regs[0];
2523
-	} else {
2524
-		return array();
2525
-	}
2519
+    if (preg_match_all(
2520
+        ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2521
+        $texte, $regs, PREG_PATTERN_ORDER)) {
2522
+        return $regs[0];
2523
+    } else {
2524
+        return array();
2525
+    }
2526 2526
 }
2527 2527
 
2528 2528
 /**
@@ -2551,11 +2551,11 @@  discard block
 block discarded – undo
2551 2551
  *     - `$def` si on n'a pas transmis de tableau
2552 2552
  **/
2553 2553
 function in_any($val, $vals, $def = '') {
2554
-	if (!is_array($vals) and $v = unserialize($vals)) {
2555
-		$vals = $v;
2556
-	}
2554
+    if (!is_array($vals) and $v = unserialize($vals)) {
2555
+        $vals = $v;
2556
+    }
2557 2557
 
2558
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2558
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2559 2559
 }
2560 2560
 
2561 2561
 
@@ -2576,12 +2576,12 @@  discard block
 block discarded – undo
2576 2576
  *     Résultat du calcul
2577 2577
  **/
2578 2578
 function valeur_numerique($expr) {
2579
-	$a = 0;
2580
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2581
-		eval("\$a = $expr;");
2582
-	}
2579
+    $a = 0;
2580
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2581
+        eval("\$a = $expr;");
2582
+    }
2583 2583
 
2584
-	return intval($a);
2584
+    return intval($a);
2585 2585
 }
2586 2586
 
2587 2587
 /**
@@ -2600,7 +2600,7 @@  discard block
 block discarded – undo
2600 2600
  *      Retourne `$a*$b/$c`
2601 2601
  **/
2602 2602
 function regledetrois($a, $b, $c) {
2603
-	return round($a * $b / $c);
2603
+    return round($a * $b / $c);
2604 2604
 }
2605 2605
 
2606 2606
 
@@ -2624,76 +2624,76 @@  discard block
 block discarded – undo
2624 2624
  **/
2625 2625
 function form_hidden($action) {
2626 2626
 
2627
-	$contexte = array();
2628
-	include_spip('inc/urls');
2629
-	if ($p = urls_decoder_url($action, '')
2630
-		and reset($p)
2631
-	) {
2632
-		$fond = array_shift($p);
2633
-		if ($fond != '404') {
2634
-			$contexte = array_shift($p);
2635
-			$contexte['page'] = $fond;
2636
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2637
-		}
2638
-	}
2639
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2640
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2641
-		unset($contexte['type']);
2642
-	}
2643
-	if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2644
-		unset($contexte['type-page']);
2645
-	}
2646
-
2647
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2648
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2649
-	$values = array();
2650
-
2651
-	// d'abord avec celles de l'url
2652
-	if (false !== ($p = strpos($action, '?'))) {
2653
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2654
-			$c = explode('=', $c, 2);
2655
-			$var = array_shift($c);
2656
-			$val = array_shift($c);
2657
-			if ($var) {
2658
-				$val = rawurldecode($val);
2659
-				$var = rawurldecode($var); // decoder les [] eventuels
2660
-				if (preg_match(',\[\]$,S', $var)) {
2661
-					$values[] = array($var, $val);
2662
-				} else {
2663
-					if (!isset($values[$var])) {
2664
-						$values[$var] = array($var, $val);
2665
-					}
2666
-				}
2667
-			}
2668
-		}
2669
-	}
2670
-
2671
-	// ensuite avec celles du contexte, sans doublonner !
2672
-	foreach ($contexte as $var => $val) {
2673
-		if (preg_match(',\[\]$,S', $var)) {
2674
-			$values[] = array($var, $val);
2675
-		} else {
2676
-			if (!isset($values[$var])) {
2677
-				$values[$var] = array($var, $val);
2678
-			}
2679
-		}
2680
-	}
2681
-
2682
-	// puis on rassemble le tout
2683
-	$hidden = array();
2684
-	foreach ($values as $value) {
2685
-		list($var, $val) = $value;
2686
-		$hidden[] = '<input name="'
2687
-			. entites_html($var)
2688
-			. '"'
2689
-			. (is_null($val)
2690
-				? ''
2691
-				: ' value="' . entites_html($val) . '"'
2692
-			)
2693
-			. ' type="hidden"' . "\n/>";
2694
-	}
2695
-
2696
-	return join("", $hidden);
2627
+    $contexte = array();
2628
+    include_spip('inc/urls');
2629
+    if ($p = urls_decoder_url($action, '')
2630
+        and reset($p)
2631
+    ) {
2632
+        $fond = array_shift($p);
2633
+        if ($fond != '404') {
2634
+            $contexte = array_shift($p);
2635
+            $contexte['page'] = $fond;
2636
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2637
+        }
2638
+    }
2639
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2640
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2641
+        unset($contexte['type']);
2642
+    }
2643
+    if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2644
+        unset($contexte['type-page']);
2645
+    }
2646
+
2647
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2648
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2649
+    $values = array();
2650
+
2651
+    // d'abord avec celles de l'url
2652
+    if (false !== ($p = strpos($action, '?'))) {
2653
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2654
+            $c = explode('=', $c, 2);
2655
+            $var = array_shift($c);
2656
+            $val = array_shift($c);
2657
+            if ($var) {
2658
+                $val = rawurldecode($val);
2659
+                $var = rawurldecode($var); // decoder les [] eventuels
2660
+                if (preg_match(',\[\]$,S', $var)) {
2661
+                    $values[] = array($var, $val);
2662
+                } else {
2663
+                    if (!isset($values[$var])) {
2664
+                        $values[$var] = array($var, $val);
2665
+                    }
2666
+                }
2667
+            }
2668
+        }
2669
+    }
2670
+
2671
+    // ensuite avec celles du contexte, sans doublonner !
2672
+    foreach ($contexte as $var => $val) {
2673
+        if (preg_match(',\[\]$,S', $var)) {
2674
+            $values[] = array($var, $val);
2675
+        } else {
2676
+            if (!isset($values[$var])) {
2677
+                $values[$var] = array($var, $val);
2678
+            }
2679
+        }
2680
+    }
2681
+
2682
+    // puis on rassemble le tout
2683
+    $hidden = array();
2684
+    foreach ($values as $value) {
2685
+        list($var, $val) = $value;
2686
+        $hidden[] = '<input name="'
2687
+            . entites_html($var)
2688
+            . '"'
2689
+            . (is_null($val)
2690
+                ? ''
2691
+                : ' value="' . entites_html($val) . '"'
2692
+            )
2693
+            . ' type="hidden"' . "\n/>";
2694
+    }
2695
+
2696
+    return join("", $hidden);
2697 2697
 }
2698 2698
 
2699 2699
 /**
@@ -2711,15 +2711,15 @@  discard block
 block discarded – undo
2711 2711
  *     Liste (première page, dernière page).
2712 2712
  **/
2713 2713
 function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) {
2714
-	if ($max <= 0 or $max >= $nombre) {
2715
-		return array(1, $nombre);
2716
-	}
2714
+    if ($max <= 0 or $max >= $nombre) {
2715
+        return array(1, $nombre);
2716
+    }
2717 2717
 
2718
-	$premiere = max(1, $courante - floor(($max - 1) / 2));
2719
-	$derniere = min($nombre, $premiere + $max - 2);
2720
-	$premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2718
+    $premiere = max(1, $courante - floor(($max - 1) / 2));
2719
+    $derniere = min($nombre, $premiere + $max - 2);
2720
+    $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2721 2721
 
2722
-	return array($premiere, $derniere);
2722
+    return array($premiere, $derniere);
2723 2723
 }
2724 2724
 
2725 2725
 
@@ -2741,7 +2741,7 @@  discard block
 block discarded – undo
2741 2741
  *    - la première valeur du tableau sinon.
2742 2742
  **/
2743 2743
 function filtre_reset($array) {
2744
-	return !is_array($array) ? null : reset($array);
2744
+    return !is_array($array) ? null : reset($array);
2745 2745
 }
2746 2746
 
2747 2747
 /**
@@ -2762,7 +2762,7 @@  discard block
 block discarded – undo
2762 2762
  *    - la dernière valeur du tableau sinon.
2763 2763
  **/
2764 2764
 function filtre_end($array) {
2765
-	return !is_array($array) ? null : end($array);
2765
+    return !is_array($array) ? null : end($array);
2766 2766
 }
2767 2767
 
2768 2768
 /**
@@ -2782,11 +2782,11 @@  discard block
 block discarded – undo
2782 2782
  *
2783 2783
  **/
2784 2784
 function filtre_push($array, $val) {
2785
-	if (!is_array($array) or !array_push($array, $val)) {
2786
-		return '';
2787
-	}
2785
+    if (!is_array($array) or !array_push($array, $val)) {
2786
+        return '';
2787
+    }
2788 2788
 
2789
-	return $array;
2789
+    return $array;
2790 2790
 }
2791 2791
 
2792 2792
 /**
@@ -2805,7 +2805,7 @@  discard block
 block discarded – undo
2805 2805
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2806 2806
  **/
2807 2807
 function filtre_find($array, $val) {
2808
-	return (is_array($array) and in_array($val, $array));
2808
+    return (is_array($array) and in_array($val, $array));
2809 2809
 }
2810 2810
 
2811 2811
 
@@ -2822,15 +2822,15 @@  discard block
 block discarded – undo
2822 2822
  *     Contenu avec urls en absolus
2823 2823
  **/
2824 2824
 function urls_absolues_css($contenu, $source) {
2825
-	$path = suivre_lien(url_absolue($source), './');
2825
+    $path = suivre_lien(url_absolue($source), './');
2826 2826
 
2827
-	return preg_replace_callback(
2828
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2829
-		function($x) use ($path) {
2830
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2831
-		},
2832
-		$contenu
2833
-	);
2827
+    return preg_replace_callback(
2828
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2829
+        function($x) use ($path) {
2830
+            return "url('" . suivre_lien($path, $x[1]) . "')";
2831
+        },
2832
+        $contenu
2833
+    );
2834 2834
 }
2835 2835
 
2836 2836
 
@@ -2859,118 +2859,118 @@  discard block
 block discarded – undo
2859 2859
  *     Chemin du fichier CSS inversé
2860 2860
  **/
2861 2861
 function direction_css($css, $voulue = '') {
2862
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2863
-		return $css;
2864
-	}
2865
-
2866
-	// si on a precise le sens voulu en argument, le prendre en compte
2867
-	if ($voulue = strtolower($voulue)) {
2868
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2869
-			$voulue = lang_dir($voulue);
2870
-		}
2871
-	} else {
2872
-		$voulue = lang_dir();
2873
-	}
2874
-
2875
-	$r = count($r) > 1;
2876
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2877
-	$dir = $r ? 'rtl' : 'ltr';
2878
-	$ndir = $r ? 'ltr' : 'rtl';
2879
-
2880
-	if ($voulue == $dir) {
2881
-		return $css;
2882
-	}
2883
-
2884
-	if (
2885
-		// url absolue
2886
-		preg_match(",^https?:,i", $css)
2887
-		// ou qui contient un ?
2888
-		or (($p = strpos($css, '?')) !== false)
2889
-	) {
2890
-		$distant = true;
2891
-		$cssf = parse_url($css);
2892
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2893
-		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2894
-	} else {
2895
-		$distant = false;
2896
-		$cssf = $css;
2897
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2898
-		//propose (rien a faire dans ce cas)
2899
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2900
-		if (@file_exists($f)) {
2901
-			return $f;
2902
-		}
2903
-	}
2904
-
2905
-	// 2.
2906
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2907
-	$f = $dir_var
2908
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2909
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2910
-
2911
-	// la css peut etre distante (url absolue !)
2912
-	if ($distant) {
2913
-		include_spip('inc/distant');
2914
-		$res = recuperer_url($css);
2915
-		if (!$res or !$contenu = $res['page']) {
2916
-			return $css;
2917
-		}
2918
-	} else {
2919
-		if ((@filemtime($f) > @filemtime($css))
2920
-			and (_VAR_MODE != 'recalcul')
2921
-		) {
2922
-			return $f;
2923
-		}
2924
-		if (!lire_fichier($css, $contenu)) {
2925
-			return $css;
2926
-		}
2927
-	}
2928
-
2929
-
2930
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2931
-	include_spip("lib/csstidy/class.csstidy");
2932
-	$parser = new csstidy();
2933
-	$parser->set_cfg('optimise_shorthands', 0);
2934
-	$parser->set_cfg('reverse_left_and_right', true);
2935
-	$parser->parse($contenu);
2936
-
2937
-	$contenu = $parser->print->plain();
2938
-
2939
-
2940
-	// reperer les @import auxquels il faut propager le direction_css
2941
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2942
-	$src = array();
2943
-	$src_direction_css = array();
2944
-	$src_faux_abs = array();
2945
-	$d = dirname($css);
2946
-	foreach ($regs[1] as $k => $import_css) {
2947
-		$css_direction = direction_css("$d/$import_css", $voulue);
2948
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2949
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2950
-			$css_direction = substr($css_direction, strlen($d) + 1);
2951
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2952
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2953
-			$css_direction = substr($css_direction, strlen($dir_var));
2954
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2955
-			$css_direction = "/@@@@@@/" . $css_direction;
2956
-		}
2957
-		$src[] = $regs[0][$k];
2958
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2959
-	}
2960
-	$contenu = str_replace($src, $src_direction_css, $contenu);
2961
-
2962
-	$contenu = urls_absolues_css($contenu, $css);
2963
-
2964
-	// virer les fausses url absolues que l'on a mis dans les import
2965
-	if (count($src_faux_abs)) {
2966
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2967
-	}
2968
-
2969
-	if (!ecrire_fichier($f, $contenu)) {
2970
-		return $css;
2971
-	}
2972
-
2973
-	return $f;
2862
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2863
+        return $css;
2864
+    }
2865
+
2866
+    // si on a precise le sens voulu en argument, le prendre en compte
2867
+    if ($voulue = strtolower($voulue)) {
2868
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2869
+            $voulue = lang_dir($voulue);
2870
+        }
2871
+    } else {
2872
+        $voulue = lang_dir();
2873
+    }
2874
+
2875
+    $r = count($r) > 1;
2876
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2877
+    $dir = $r ? 'rtl' : 'ltr';
2878
+    $ndir = $r ? 'ltr' : 'rtl';
2879
+
2880
+    if ($voulue == $dir) {
2881
+        return $css;
2882
+    }
2883
+
2884
+    if (
2885
+        // url absolue
2886
+        preg_match(",^https?:,i", $css)
2887
+        // ou qui contient un ?
2888
+        or (($p = strpos($css, '?')) !== false)
2889
+    ) {
2890
+        $distant = true;
2891
+        $cssf = parse_url($css);
2892
+        $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2893
+        $cssf = preg_replace(',[?:&=],', "_", $cssf);
2894
+    } else {
2895
+        $distant = false;
2896
+        $cssf = $css;
2897
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2898
+        //propose (rien a faire dans ce cas)
2899
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2900
+        if (@file_exists($f)) {
2901
+            return $f;
2902
+        }
2903
+    }
2904
+
2905
+    // 2.
2906
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2907
+    $f = $dir_var
2908
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2909
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2910
+
2911
+    // la css peut etre distante (url absolue !)
2912
+    if ($distant) {
2913
+        include_spip('inc/distant');
2914
+        $res = recuperer_url($css);
2915
+        if (!$res or !$contenu = $res['page']) {
2916
+            return $css;
2917
+        }
2918
+    } else {
2919
+        if ((@filemtime($f) > @filemtime($css))
2920
+            and (_VAR_MODE != 'recalcul')
2921
+        ) {
2922
+            return $f;
2923
+        }
2924
+        if (!lire_fichier($css, $contenu)) {
2925
+            return $css;
2926
+        }
2927
+    }
2928
+
2929
+
2930
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2931
+    include_spip("lib/csstidy/class.csstidy");
2932
+    $parser = new csstidy();
2933
+    $parser->set_cfg('optimise_shorthands', 0);
2934
+    $parser->set_cfg('reverse_left_and_right', true);
2935
+    $parser->parse($contenu);
2936
+
2937
+    $contenu = $parser->print->plain();
2938
+
2939
+
2940
+    // reperer les @import auxquels il faut propager le direction_css
2941
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2942
+    $src = array();
2943
+    $src_direction_css = array();
2944
+    $src_faux_abs = array();
2945
+    $d = dirname($css);
2946
+    foreach ($regs[1] as $k => $import_css) {
2947
+        $css_direction = direction_css("$d/$import_css", $voulue);
2948
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2949
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2950
+            $css_direction = substr($css_direction, strlen($d) + 1);
2951
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2952
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2953
+            $css_direction = substr($css_direction, strlen($dir_var));
2954
+            $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2955
+            $css_direction = "/@@@@@@/" . $css_direction;
2956
+        }
2957
+        $src[] = $regs[0][$k];
2958
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2959
+    }
2960
+    $contenu = str_replace($src, $src_direction_css, $contenu);
2961
+
2962
+    $contenu = urls_absolues_css($contenu, $css);
2963
+
2964
+    // virer les fausses url absolues que l'on a mis dans les import
2965
+    if (count($src_faux_abs)) {
2966
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2967
+    }
2968
+
2969
+    if (!ecrire_fichier($f, $contenu)) {
2970
+        return $css;
2971
+    }
2972
+
2973
+    return $f;
2974 2974
 }
2975 2975
 
2976 2976
 
@@ -2993,43 +2993,43 @@  discard block
 block discarded – undo
2993 2993
  *     - Chemin ou URL du fichier CSS source sinon.
2994 2994
  **/
2995 2995
 function url_absolue_css($css) {
2996
-	if (!preg_match(',\.css$,i', $css, $r)) {
2997
-		return $css;
2998
-	}
2996
+    if (!preg_match(',\.css$,i', $css, $r)) {
2997
+        return $css;
2998
+    }
2999 2999
 
3000
-	$url_absolue_css = url_absolue($css);
3000
+    $url_absolue_css = url_absolue($css);
3001 3001
 
3002
-	$f = basename($css, '.css');
3003
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3004
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3005
-		. '.css';
3002
+    $f = basename($css, '.css');
3003
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3004
+        . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3005
+        . '.css';
3006 3006
 
3007
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3008
-		return $f;
3009
-	}
3007
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3008
+        return $f;
3009
+    }
3010 3010
 
3011
-	if ($url_absolue_css == $css) {
3012
-		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3013
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3014
-		) {
3015
-			include_spip('inc/distant');
3016
-			if (!$contenu = recuperer_page($css)) {
3017
-				return $css;
3018
-			}
3019
-		}
3020
-	} elseif (!lire_fichier($css, $contenu)) {
3021
-		return $css;
3022
-	}
3011
+    if ($url_absolue_css == $css) {
3012
+        if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3013
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3014
+        ) {
3015
+            include_spip('inc/distant');
3016
+            if (!$contenu = recuperer_page($css)) {
3017
+                return $css;
3018
+            }
3019
+        }
3020
+    } elseif (!lire_fichier($css, $contenu)) {
3021
+        return $css;
3022
+    }
3023 3023
 
3024
-	// passer les url relatives a la css d'origine en url absolues
3025
-	$contenu = urls_absolues_css($contenu, $css);
3024
+    // passer les url relatives a la css d'origine en url absolues
3025
+    $contenu = urls_absolues_css($contenu, $css);
3026 3026
 
3027
-	// ecrire la css
3028
-	if (!ecrire_fichier($f, $contenu)) {
3029
-		return $css;
3030
-	}
3027
+    // ecrire la css
3028
+    if (!ecrire_fichier($f, $contenu)) {
3029
+        return $css;
3030
+    }
3031 3031
 
3032
-	return $f;
3032
+    return $f;
3033 3033
 }
3034 3034
 
3035 3035
 
@@ -3063,24 +3063,24 @@  discard block
 block discarded – undo
3063 3063
  *     Valeur trouvée ou valeur par défaut.
3064 3064
  **/
3065 3065
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3066
-	foreach (explode('/', $cle) as $k) {
3066
+    foreach (explode('/', $cle) as $k) {
3067 3067
 
3068
-		$table = is_string($table) ? @unserialize($table) : $table;
3068
+        $table = is_string($table) ? @unserialize($table) : $table;
3069 3069
 
3070
-		if (is_object($table)) {
3071
-			$table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3072
-		} elseif (is_array($table)) {
3073
-			if ($conserver_null) {
3074
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3075
-			} else {
3076
-				$table = isset($table[$k]) ? $table[$k] : $defaut;
3077
-			}
3078
-		} else {
3079
-			$table = $defaut;
3080
-		}
3081
-	}
3070
+        if (is_object($table)) {
3071
+            $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3072
+        } elseif (is_array($table)) {
3073
+            if ($conserver_null) {
3074
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3075
+            } else {
3076
+                $table = isset($table[$k]) ? $table[$k] : $defaut;
3077
+            }
3078
+        } else {
3079
+            $table = $defaut;
3080
+        }
3081
+    }
3082 3082
 
3083
-	return $table;
3083
+    return $table;
3084 3084
 }
3085 3085
 
3086 3086
 /**
@@ -3113,22 +3113,22 @@  discard block
 block discarded – undo
3113 3113
  *     - string : expression trouvée.
3114 3114
  **/
3115 3115
 function filtre_match_dist($texte, $expression, $modif = "UimsS", $capte = 0) {
3116
-	if (intval($modif) and $capte == 0) {
3117
-		$capte = $modif;
3118
-		$modif = "UimsS";
3119
-	}
3120
-	$expression = str_replace("\/", "/", $expression);
3121
-	$expression = str_replace("/", "\/", $expression);
3116
+    if (intval($modif) and $capte == 0) {
3117
+        $capte = $modif;
3118
+        $modif = "UimsS";
3119
+    }
3120
+    $expression = str_replace("\/", "/", $expression);
3121
+    $expression = str_replace("/", "\/", $expression);
3122 3122
 
3123
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3124
-		if (isset($r[$capte])) {
3125
-			return $r[$capte];
3126
-		} else {
3127
-			return true;
3128
-		}
3129
-	}
3123
+    if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3124
+        if (isset($r[$capte])) {
3125
+            return $r[$capte];
3126
+        } else {
3127
+            return true;
3128
+        }
3129
+    }
3130 3130
 
3131
-	return false;
3131
+    return false;
3132 3132
 }
3133 3133
 
3134 3134
 
@@ -3155,10 +3155,10 @@  discard block
 block discarded – undo
3155 3155
  *     Texte
3156 3156
  **/
3157 3157
 function replace($texte, $expression, $replace = '', $modif = "UimsS") {
3158
-	$expression = str_replace("\/", "/", $expression);
3159
-	$expression = str_replace("/", "\/", $expression);
3158
+    $expression = str_replace("\/", "/", $expression);
3159
+    $expression = str_replace("/", "\/", $expression);
3160 3160
 
3161
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3161
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3162 3162
 }
3163 3163
 
3164 3164
 
@@ -3176,21 +3176,21 @@  discard block
 block discarded – undo
3176 3176
  **/
3177 3177
 function traiter_doublons_documents(&$doublons, $letexte) {
3178 3178
 
3179
-	// Verifier dans le texte & les notes (pas beau, helas)
3180
-	$t = $letexte . $GLOBALS['les_notes'];
3179
+    // Verifier dans le texte & les notes (pas beau, helas)
3180
+    $t = $letexte . $GLOBALS['les_notes'];
3181 3181
 
3182
-	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3183
-		and preg_match_all(
3184
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3185
-			$t, $matches, PREG_PATTERN_ORDER)
3186
-	) {
3187
-		if (!isset($doublons['documents'])) {
3188
-			$doublons['documents'] = "";
3189
-		}
3190
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3191
-	}
3182
+    if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3183
+        and preg_match_all(
3184
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3185
+            $t, $matches, PREG_PATTERN_ORDER)
3186
+    ) {
3187
+        if (!isset($doublons['documents'])) {
3188
+            $doublons['documents'] = "";
3189
+        }
3190
+        $doublons['documents'] .= "," . join(',', $matches[1]);
3191
+    }
3192 3192
 
3193
-	return $letexte;
3193
+    return $letexte;
3194 3194
 }
3195 3195
 
3196 3196
 /**
@@ -3204,7 +3204,7 @@  discard block
 block discarded – undo
3204 3204
  * @return string Chaîne vide
3205 3205
  **/
3206 3206
 function vide($texte) {
3207
-	return "";
3207
+    return "";
3208 3208
 }
3209 3209
 
3210 3210
 //
@@ -3233,23 +3233,23 @@  discard block
 block discarded – undo
3233 3233
  *      Code HTML résultant
3234 3234
  **/
3235 3235
 function env_to_params($env, $ignore_params = array()) {
3236
-	$ignore_params = array_merge(
3237
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3238
-		$ignore_params
3239
-	);
3240
-	if (!is_array($env)) {
3241
-		$env = unserialize($env);
3242
-	}
3243
-	$texte = "";
3244
-	if ($env) {
3245
-		foreach ($env as $i => $j) {
3246
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3247
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3248
-			}
3249
-		}
3250
-	}
3251
-
3252
-	return $texte;
3236
+    $ignore_params = array_merge(
3237
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3238
+        $ignore_params
3239
+    );
3240
+    if (!is_array($env)) {
3241
+        $env = unserialize($env);
3242
+    }
3243
+    $texte = "";
3244
+    if ($env) {
3245
+        foreach ($env as $i => $j) {
3246
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3247
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3248
+            }
3249
+        }
3250
+    }
3251
+
3252
+    return $texte;
3253 3253
 }
3254 3254
 
3255 3255
 /**
@@ -3272,23 +3272,23 @@  discard block
 block discarded – undo
3272 3272
  *      Code HTML résultant
3273 3273
  **/
3274 3274
 function env_to_attributs($env, $ignore_params = array()) {
3275
-	$ignore_params = array_merge(
3276
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3277
-		$ignore_params
3278
-	);
3279
-	if (!is_array($env)) {
3280
-		$env = unserialize($env);
3281
-	}
3282
-	$texte = "";
3283
-	if ($env) {
3284
-		foreach ($env as $i => $j) {
3285
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3286
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3287
-			}
3288
-		}
3289
-	}
3275
+    $ignore_params = array_merge(
3276
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3277
+        $ignore_params
3278
+    );
3279
+    if (!is_array($env)) {
3280
+        $env = unserialize($env);
3281
+    }
3282
+    $texte = "";
3283
+    if ($env) {
3284
+        foreach ($env as $i => $j) {
3285
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3286
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3287
+            }
3288
+        }
3289
+    }
3290 3290
 
3291
-	return $texte;
3291
+    return $texte;
3292 3292
 }
3293 3293
 
3294 3294
 
@@ -3305,9 +3305,9 @@  discard block
 block discarded – undo
3305 3305
  * @return string Chaînes concaténés
3306 3306
  **/
3307 3307
 function concat() {
3308
-	$args = func_get_args();
3308
+    $args = func_get_args();
3309 3309
 
3310
-	return join('', $args);
3310
+    return join('', $args);
3311 3311
 }
3312 3312
 
3313 3313
 
@@ -3327,23 +3327,23 @@  discard block
 block discarded – undo
3327 3327
  *     Contenu du ou des fichiers, concaténé
3328 3328
  **/
3329 3329
 function charge_scripts($files, $script = true) {
3330
-	$flux = "";
3331
-	foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3332
-		if (!is_string($file)) {
3333
-			continue;
3334
-		}
3335
-		if ($script) {
3336
-			$file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3337
-		}
3338
-		if ($file) {
3339
-			$path = find_in_path($file);
3340
-			if ($path) {
3341
-				$flux .= spip_file_get_contents($path);
3342
-			}
3343
-		}
3344
-	}
3330
+    $flux = "";
3331
+    foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3332
+        if (!is_string($file)) {
3333
+            continue;
3334
+        }
3335
+        if ($script) {
3336
+            $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3337
+        }
3338
+        if ($file) {
3339
+            $path = find_in_path($file);
3340
+            if ($path) {
3341
+                $flux .= spip_file_get_contents($path);
3342
+            }
3343
+        }
3344
+    }
3345 3345
 
3346
-	return $flux;
3346
+    return $flux;
3347 3347
 }
3348 3348
 
3349 3349
 
@@ -3365,64 +3365,64 @@  discard block
 block discarded – undo
3365 3365
  */
3366 3366
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) {
3367 3367
 
3368
-	$img_file = $img;
3369
-	if ($p = strpos($img_file, '?')) {
3370
-		$img_file = substr($img_file,0, $p);
3371
-	}
3372
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3373
-		$img_file = chemin_image($img);
3374
-	}
3375
-	else {
3376
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3377
-			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3378
-			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3379
-			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3380
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3381
-			  and file_exists($variante_svg_generique)) {
3382
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3383
-					$img_file = $variante_svg_size;
3384
-				}
3385
-				else {
3386
-					$img_file = $variante_svg_generique;
3387
-				}
3388
-			}
3389
-		}
3390
-	}
3391
-	if (stripos($atts, 'width') === false) {
3392
-		// utiliser directement l'info de taille presente dans le nom
3393
-		if ((!isset($options['utiliser_suffixe_size'])
3394
-				or $options['utiliser_suffixe_size'] == true
3395
-			  or strpos($img_file, '-xx.svg') !== false)
3396
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3397
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3398
-		) {
3399
-			$largeur = $hauteur = intval($regs[1]);
3400
-		} else {
3401
-			$taille = taille_image($img_file);
3402
-			list($hauteur, $largeur) = $taille;
3403
-			if (!$hauteur or !$largeur) {
3404
-				return "";
3405
-			}
3406
-		}
3407
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3408
-	}
3409
-
3410
-	if (file_exists($img_file)) {
3411
-		$img_file = timestamp($img_file);
3412
-	}
3413
-	if ($alt === false) {
3414
-		$alt = '';
3415
-	}
3416
-	elseif($alt or $alt==='') {
3417
-		$alt = " alt='".attribut_html($alt)."'";
3418
-	}
3419
-	else {
3420
-		$alt = " alt='".attribut_html($title)."'";
3421
-	}
3422
-	return "<img src='$img_file'$alt"
3423
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3424
-	. " " . ltrim($atts)
3425
-	. " />";
3368
+    $img_file = $img;
3369
+    if ($p = strpos($img_file, '?')) {
3370
+        $img_file = substr($img_file,0, $p);
3371
+    }
3372
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3373
+        $img_file = chemin_image($img);
3374
+    }
3375
+    else {
3376
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3377
+            // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3378
+            // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3379
+            if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3380
+              and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3381
+              and file_exists($variante_svg_generique)) {
3382
+                if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3383
+                    $img_file = $variante_svg_size;
3384
+                }
3385
+                else {
3386
+                    $img_file = $variante_svg_generique;
3387
+                }
3388
+            }
3389
+        }
3390
+    }
3391
+    if (stripos($atts, 'width') === false) {
3392
+        // utiliser directement l'info de taille presente dans le nom
3393
+        if ((!isset($options['utiliser_suffixe_size'])
3394
+                or $options['utiliser_suffixe_size'] == true
3395
+              or strpos($img_file, '-xx.svg') !== false)
3396
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3397
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3398
+        ) {
3399
+            $largeur = $hauteur = intval($regs[1]);
3400
+        } else {
3401
+            $taille = taille_image($img_file);
3402
+            list($hauteur, $largeur) = $taille;
3403
+            if (!$hauteur or !$largeur) {
3404
+                return "";
3405
+            }
3406
+        }
3407
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3408
+    }
3409
+
3410
+    if (file_exists($img_file)) {
3411
+        $img_file = timestamp($img_file);
3412
+    }
3413
+    if ($alt === false) {
3414
+        $alt = '';
3415
+    }
3416
+    elseif($alt or $alt==='') {
3417
+        $alt = " alt='".attribut_html($alt)."'";
3418
+    }
3419
+    else {
3420
+        $alt = " alt='".attribut_html($title)."'";
3421
+    }
3422
+    return "<img src='$img_file'$alt"
3423
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3424
+    . " " . ltrim($atts)
3425
+    . " />";
3426 3426
 }
3427 3427
 
3428 3428
 /**
@@ -3434,13 +3434,13 @@  discard block
 block discarded – undo
3434 3434
  * @return string
3435 3435
  */
3436 3436
 function http_style_background($img, $att = '', $size=null) {
3437
-	if ($size and is_numeric($size)){
3438
-		$size = trim($size) . "px";
3439
-	}
3440
-	return " style='background" .
3441
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3442
-		. ($size ? "background-size:{$size};" : '')
3443
-		. "'";
3437
+    if ($size and is_numeric($size)){
3438
+        $size = trim($size) . "px";
3439
+    }
3440
+    return " style='background" .
3441
+        ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3442
+        . ($size ? "background-size:{$size};" : '')
3443
+        . "'";
3444 3444
 }
3445 3445
 
3446 3446
 /**
@@ -3456,17 +3456,17 @@  discard block
 block discarded – undo
3456 3456
  *     Code HTML de la balise IMG
3457 3457
  */
3458 3458
 function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3459
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3460
-	// ecriture courte : on donne le width en 2e arg
3461
-	if (empty($width) and is_numeric($alt)) {
3462
-		$width = $alt;
3463
-		$alt = '';
3464
-	}
3465
-	if ($width) {
3466
-		$atts .= " width='{$width}'";
3467
-	}
3468
-	return http_img_pack($img, $alt, $atts, '',
3469
-		array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3459
+    $atts = $class ? " class='" . attribut_html($class) . "'" : '';
3460
+    // ecriture courte : on donne le width en 2e arg
3461
+    if (empty($width) and is_numeric($alt)) {
3462
+        $width = $alt;
3463
+        $alt = '';
3464
+    }
3465
+    if ($width) {
3466
+        $atts .= " width='{$width}'";
3467
+    }
3468
+    return http_img_pack($img, $alt, $atts, '',
3469
+        array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3470 3470
 }
3471 3471
 
3472 3472
 
@@ -3482,42 +3482,42 @@  discard block
 block discarded – undo
3482 3482
  * @return string
3483 3483
  */
3484 3484
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3485
-	$img_file = $img;
3486
-	if ($p = strpos($img_file, '?')) {
3487
-		$img_file = substr($img_file,0, $p);
3488
-	}
3485
+    $img_file = $img;
3486
+    if ($p = strpos($img_file, '?')) {
3487
+        $img_file = substr($img_file,0, $p);
3488
+    }
3489 3489
 
3490
-	if (!$img_file or !$svg = file_get_contents($img_file)) {
3491
-		return '';
3492
-	}
3490
+    if (!$img_file or !$svg = file_get_contents($img_file)) {
3491
+        return '';
3492
+    }
3493 3493
 
3494
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3495
-		return '';
3496
-	}
3497
-	$balise_svg = $match[0];
3498
-	$balise_svg_source = $balise_svg;
3494
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3495
+        return '';
3496
+    }
3497
+    $balise_svg = $match[0];
3498
+    $balise_svg_source = $balise_svg;
3499 3499
 
3500
-	// entete XML à supprimer
3501
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3500
+    // entete XML à supprimer
3501
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3502 3502
 
3503
-	// IE est toujours mon ami
3504
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3505
-	if ($class) {
3506
-		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3507
-	}
3508
-	if ($alt){
3509
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3510
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3511
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3512
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3513
-		$balise_svg .= $title;
3514
-	}
3515
-	else {
3516
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3517
-	}
3518
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3503
+    // IE est toujours mon ami
3504
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3505
+    if ($class) {
3506
+        $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3507
+    }
3508
+    if ($alt){
3509
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3510
+        $id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3511
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3512
+        $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3513
+        $balise_svg .= $title;
3514
+    }
3515
+    else {
3516
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3517
+    }
3518
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3519 3519
 
3520
-	return $svg;
3520
+    return $svg;
3521 3521
 }
3522 3522
 
3523 3523
 
@@ -3540,17 +3540,17 @@  discard block
 block discarded – undo
3540 3540
  *     Code HTML résultant
3541 3541
  **/
3542 3542
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3543
-	$texte = '';
3544
-	if (is_array($tableau)) {
3545
-		foreach ($tableau as $k => $v) {
3546
-			$res = recuperer_fond('modeles/' . $modele,
3547
-				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3548
-			);
3549
-			$texte .= $res;
3550
-		}
3551
-	}
3543
+    $texte = '';
3544
+    if (is_array($tableau)) {
3545
+        foreach ($tableau as $k => $v) {
3546
+            $res = recuperer_fond('modeles/' . $modele,
3547
+                array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3548
+            );
3549
+            $texte .= $res;
3550
+        }
3551
+    }
3552 3552
 
3553
-	return $texte;
3553
+    return $texte;
3554 3554
 }
3555 3555
 
3556 3556
 
@@ -3575,37 +3575,37 @@  discard block
 block discarded – undo
3575 3575
  *         - tout : retourne toutes les informations du plugin actif
3576 3576
  **/
3577 3577
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3578
-	include_spip('inc/plugin');
3579
-	$plugin = strtoupper($plugin);
3580
-	$plugins_actifs = liste_plugin_actifs();
3581
-
3582
-	if (!$plugin) {
3583
-		return serialize(array_keys($plugins_actifs));
3584
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3585
-		return '';
3586
-	} elseif (($type_info == 'est_actif') and !$reload) {
3587
-		return $plugins_actifs[$plugin] ? 1 : 0;
3588
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3589
-		return $plugins_actifs[$plugin][$type_info];
3590
-	} else {
3591
-		$get_infos = charger_fonction('get_infos', 'plugins');
3592
-		// On prend en compte les extensions
3593
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3594
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3595
-		} else {
3596
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3597
-		}
3598
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3599
-			return '';
3600
-		}
3601
-		if ($type_info == 'tout') {
3602
-			return $infos;
3603
-		} elseif ($type_info == 'est_actif') {
3604
-			return $infos ? 1 : 0;
3605
-		} else {
3606
-			return strval($infos[$type_info]);
3607
-		}
3608
-	}
3578
+    include_spip('inc/plugin');
3579
+    $plugin = strtoupper($plugin);
3580
+    $plugins_actifs = liste_plugin_actifs();
3581
+
3582
+    if (!$plugin) {
3583
+        return serialize(array_keys($plugins_actifs));
3584
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3585
+        return '';
3586
+    } elseif (($type_info == 'est_actif') and !$reload) {
3587
+        return $plugins_actifs[$plugin] ? 1 : 0;
3588
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3589
+        return $plugins_actifs[$plugin][$type_info];
3590
+    } else {
3591
+        $get_infos = charger_fonction('get_infos', 'plugins');
3592
+        // On prend en compte les extensions
3593
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3594
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3595
+        } else {
3596
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3597
+        }
3598
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3599
+            return '';
3600
+        }
3601
+        if ($type_info == 'tout') {
3602
+            return $infos;
3603
+        } elseif ($type_info == 'est_actif') {
3604
+            return $infos ? 1 : 0;
3605
+        } else {
3606
+            return strval($infos[$type_info]);
3607
+        }
3608
+    }
3609 3609
 }
3610 3610
 
3611 3611
 
@@ -3632,9 +3632,9 @@  discard block
 block discarded – undo
3632 3632
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3633 3633
  */
3634 3634
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3635
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3635
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3636 3636
 
3637
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3637
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3638 3638
 }
3639 3639
 
3640 3640
 
@@ -3664,13 +3664,13 @@  discard block
 block discarded – undo
3664 3664
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3665 3665
  */
3666 3666
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3667
-	static $puce_statut = null;
3668
-	if (!$puce_statut) {
3669
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3670
-	}
3667
+    static $puce_statut = null;
3668
+    if (!$puce_statut) {
3669
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3670
+    }
3671 3671
 
3672
-	return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3673
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3672
+    return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3673
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3674 3674
 }
3675 3675
 
3676 3676
 
@@ -3697,100 +3697,100 @@  discard block
 block discarded – undo
3697 3697
  *   hash du contexte
3698 3698
  */
3699 3699
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3700
-	if (is_string($c)
3701
-		and @unserialize($c) !== false
3702
-	) {
3703
-		$c = unserialize($c);
3704
-	}
3705
-
3706
-	// supprimer les parametres debut_x
3707
-	// pour que la pagination ajax ne soit pas plantee
3708
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3709
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3710
-	if (is_array($c)) {
3711
-		foreach ($c as $k => $v) {
3712
-			if (strpos($k, 'debut_') === 0) {
3713
-				unset($c[$k]);
3714
-			}
3715
-		}
3716
-	}
3717
-
3718
-	if (!function_exists('calculer_cle_action')) {
3719
-		include_spip("inc/securiser_action");
3720
-	}
3721
-
3722
-	$c = serialize($c);
3723
-	$cle = calculer_cle_action($form . $c);
3724
-	$c = "$cle:$c";
3725
-
3726
-	// on ne stocke pas les contextes dans des fichiers en cache
3727
-	// par defaut, sauf si cette configuration a été forcée
3728
-	// OU que la longueur de l’argument géneré est plus long
3729
-	// que ce qui est toléré.
3730
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3731
-	if (!$cache_contextes_ajax) {
3732
-		$env = $c;
3733
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3734
-			$env = gzdeflate($env);
3735
-			// https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3736
-			if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3737
-				$cache_contextes_ajax = true;
3738
-				spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3739
-			}
3740
-		}
3741
-		$env = _xor($env);
3742
-		$env = base64_encode($env);
3743
-		$len = strlen($env);
3744
-		// Si l’url est trop longue pour le navigateur
3745
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3746
-		if ($len > $max_len) {
3747
-			$cache_contextes_ajax = true;
3748
-			spip_log("Contextes AJAX forces en fichiers !"
3749
-				. " Cela arrive lorsque la valeur du contexte" 
3750
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3751
-				, _LOG_AVERTISSEMENT);
3752
-		}
3753
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3754
-		elseif (
3755
-			$max_len = @ini_get('suhosin.get.max_value_length')
3756
-			and $max_len < $len
3757
-		) {
3758
-			$cache_contextes_ajax = true;
3759
-			spip_log("Contextes AJAX forces en fichiers !"
3760
-				. " Cela arrive lorsque la valeur du contexte"
3761
-				. " depasse la longueur maximale autorisee par Suhosin"
3762
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3763
-				. " Vous devriez modifier les parametres de Suhosin"
3764
-				. " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3765
-		} 
3766
-
3767
-	}
3768
-
3769
-	if ($cache_contextes_ajax) {
3770
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3771
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3772
-		$md5 = md5($c);
3773
-		ecrire_fichier("$dir/c$md5", $c);
3774
-		$env = $md5;
3775
-	}
3776
-
3777
-	if ($emboite === null) {
3778
-		return $env;
3779
-	}
3780
-	if (!trim($emboite)) {
3781
-		return "";
3782
-	}
3783
-	// toujours encoder l'url source dans le bloc ajax
3784
-	$r = self();
3785
-	$r = ' data-origin="' . $r . '"';
3786
-	$class = 'ajaxbloc';
3787
-	if ($ajaxid and is_string($ajaxid)) {
3788
-		// ajaxid est normalement conforme a un nom de classe css
3789
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3790
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3791
-	}
3792
-
3793
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3700
+    if (is_string($c)
3701
+        and @unserialize($c) !== false
3702
+    ) {
3703
+        $c = unserialize($c);
3704
+    }
3705
+
3706
+    // supprimer les parametres debut_x
3707
+    // pour que la pagination ajax ne soit pas plantee
3708
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3709
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3710
+    if (is_array($c)) {
3711
+        foreach ($c as $k => $v) {
3712
+            if (strpos($k, 'debut_') === 0) {
3713
+                unset($c[$k]);
3714
+            }
3715
+        }
3716
+    }
3717
+
3718
+    if (!function_exists('calculer_cle_action')) {
3719
+        include_spip("inc/securiser_action");
3720
+    }
3721
+
3722
+    $c = serialize($c);
3723
+    $cle = calculer_cle_action($form . $c);
3724
+    $c = "$cle:$c";
3725
+
3726
+    // on ne stocke pas les contextes dans des fichiers en cache
3727
+    // par defaut, sauf si cette configuration a été forcée
3728
+    // OU que la longueur de l’argument géneré est plus long
3729
+    // que ce qui est toléré.
3730
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3731
+    if (!$cache_contextes_ajax) {
3732
+        $env = $c;
3733
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3734
+            $env = gzdeflate($env);
3735
+            // https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3736
+            if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3737
+                $cache_contextes_ajax = true;
3738
+                spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3739
+            }
3740
+        }
3741
+        $env = _xor($env);
3742
+        $env = base64_encode($env);
3743
+        $len = strlen($env);
3744
+        // Si l’url est trop longue pour le navigateur
3745
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3746
+        if ($len > $max_len) {
3747
+            $cache_contextes_ajax = true;
3748
+            spip_log("Contextes AJAX forces en fichiers !"
3749
+                . " Cela arrive lorsque la valeur du contexte" 
3750
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3751
+                , _LOG_AVERTISSEMENT);
3752
+        }
3753
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3754
+        elseif (
3755
+            $max_len = @ini_get('suhosin.get.max_value_length')
3756
+            and $max_len < $len
3757
+        ) {
3758
+            $cache_contextes_ajax = true;
3759
+            spip_log("Contextes AJAX forces en fichiers !"
3760
+                . " Cela arrive lorsque la valeur du contexte"
3761
+                . " depasse la longueur maximale autorisee par Suhosin"
3762
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3763
+                . " Vous devriez modifier les parametres de Suhosin"
3764
+                . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3765
+        } 
3766
+
3767
+    }
3768
+
3769
+    if ($cache_contextes_ajax) {
3770
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3771
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3772
+        $md5 = md5($c);
3773
+        ecrire_fichier("$dir/c$md5", $c);
3774
+        $env = $md5;
3775
+    }
3776
+
3777
+    if ($emboite === null) {
3778
+        return $env;
3779
+    }
3780
+    if (!trim($emboite)) {
3781
+        return "";
3782
+    }
3783
+    // toujours encoder l'url source dans le bloc ajax
3784
+    $r = self();
3785
+    $r = ' data-origin="' . $r . '"';
3786
+    $class = 'ajaxbloc';
3787
+    if ($ajaxid and is_string($ajaxid)) {
3788
+        // ajaxid est normalement conforme a un nom de classe css
3789
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3790
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3791
+    }
3792
+
3793
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3794 3794
 }
3795 3795
 
3796 3796
 /**
@@ -3810,36 +3810,36 @@  discard block
 block discarded – undo
3810 3810
  *   - false : erreur de décodage
3811 3811
  */
3812 3812
 function decoder_contexte_ajax($c, $form = '') {
3813
-	if (!function_exists('calculer_cle_action')) {
3814
-		include_spip("inc/securiser_action");
3815
-	}
3816
-	if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3817
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3818
-		and lire_fichier("$dir/c$c", $contexte)
3819
-	) {
3820
-		$c = $contexte;
3821
-	} else {
3822
-		$c = @base64_decode($c);
3823
-		$c = _xor($c);
3824
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3825
-			$c = @gzinflate($c);
3826
-		}
3827
-	}
3828
-
3829
-	// extraire la signature en debut de contexte
3830
-	// et la verifier avant de deserializer
3831
-	// format : signature:donneesserializees
3832
-	if ($p = strpos($c,":")){
3833
-		$cle = substr($c,0,$p);
3834
-		$c = substr($c,$p+1);
3835
-
3836
-		if ($cle == calculer_cle_action($form . $c)) {
3837
-			$env = @unserialize($c);
3838
-			return $env;
3839
-		}
3840
-	}
3841
-
3842
-	return false;
3813
+    if (!function_exists('calculer_cle_action')) {
3814
+        include_spip("inc/securiser_action");
3815
+    }
3816
+    if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3817
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3818
+        and lire_fichier("$dir/c$c", $contexte)
3819
+    ) {
3820
+        $c = $contexte;
3821
+    } else {
3822
+        $c = @base64_decode($c);
3823
+        $c = _xor($c);
3824
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3825
+            $c = @gzinflate($c);
3826
+        }
3827
+    }
3828
+
3829
+    // extraire la signature en debut de contexte
3830
+    // et la verifier avant de deserializer
3831
+    // format : signature:donneesserializees
3832
+    if ($p = strpos($c,":")){
3833
+        $cle = substr($c,0,$p);
3834
+        $c = substr($c,$p+1);
3835
+
3836
+        if ($cle == calculer_cle_action($form . $c)) {
3837
+            $env = @unserialize($c);
3838
+            return $env;
3839
+        }
3840
+    }
3841
+
3842
+    return false;
3843 3843
 }
3844 3844
 
3845 3845
 
@@ -3857,20 +3857,20 @@  discard block
 block discarded – undo
3857 3857
  *    Message décrypté ou encrypté
3858 3858
  **/
3859 3859
 function _xor($message, $key = null) {
3860
-	if (is_null($key)) {
3861
-		if (!function_exists('calculer_cle_action')) {
3862
-			include_spip("inc/securiser_action");
3863
-		}
3864
-		$key = pack("H*", calculer_cle_action('_xor'));
3865
-	}
3860
+    if (is_null($key)) {
3861
+        if (!function_exists('calculer_cle_action')) {
3862
+            include_spip("inc/securiser_action");
3863
+        }
3864
+        $key = pack("H*", calculer_cle_action('_xor'));
3865
+    }
3866 3866
 
3867
-	$keylen = strlen($key);
3868
-	$messagelen = strlen($message);
3869
-	for ($i = 0; $i < $messagelen; $i++) {
3870
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3871
-	}
3867
+    $keylen = strlen($key);
3868
+    $messagelen = strlen($message);
3869
+    for ($i = 0; $i < $messagelen; $i++) {
3870
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3871
+    }
3872 3872
 
3873
-	return $message;
3873
+    return $message;
3874 3874
 }
3875 3875
 
3876 3876
 /**
@@ -3933,37 +3933,37 @@  discard block
 block discarded – undo
3933 3933
  *   Code HTML
3934 3934
  */
3935 3935
 function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') {
3936
-	if ($on) {
3937
-		$bal = 'strong';
3938
-		$class = "";
3939
-		$att = "";
3940
-		// si $on passe la balise et optionnelement une ou ++classe
3941
-		// a.active span.selected.active etc....
3942
-		if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
3943
-			$on = explode(".", $on);
3944
-			// on verifie que c'est exactement une des 3 balises a, span ou strong
3945
-			if (in_array(reset($on), array('a', 'span', 'strong'))){
3946
-				$bal = array_shift($on);
3947
-				$class = implode(" ", $on);
3948
-				if ($bal=="a"){
3949
-					$att = 'href="#" ';
3950
-				}
3951
-			}
3952
-		}
3953
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
3954
-	} else {
3955
-		$bal = 'a';
3956
-		$att = "href='$url'"
3957
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3958
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3959
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3960
-			. $evt;
3961
-	}
3962
-	if ($libelle === null) {
3963
-		$libelle = $url;
3964
-	}
3965
-
3966
-	return "<$bal $att>$libelle</$bal>";
3936
+    if ($on) {
3937
+        $bal = 'strong';
3938
+        $class = "";
3939
+        $att = "";
3940
+        // si $on passe la balise et optionnelement une ou ++classe
3941
+        // a.active span.selected.active etc....
3942
+        if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
3943
+            $on = explode(".", $on);
3944
+            // on verifie que c'est exactement une des 3 balises a, span ou strong
3945
+            if (in_array(reset($on), array('a', 'span', 'strong'))){
3946
+                $bal = array_shift($on);
3947
+                $class = implode(" ", $on);
3948
+                if ($bal=="a"){
3949
+                    $att = 'href="#" ';
3950
+                }
3951
+            }
3952
+        }
3953
+        $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
3954
+    } else {
3955
+        $bal = 'a';
3956
+        $att = "href='$url'"
3957
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
3958
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
3959
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3960
+            . $evt;
3961
+    }
3962
+    if ($libelle === null) {
3963
+        $libelle = $url;
3964
+    }
3965
+
3966
+    return "<$bal $att>$libelle</$bal>";
3967 3967
 }
3968 3968
 
3969 3969
 
@@ -3980,37 +3980,37 @@  discard block
 block discarded – undo
3980 3980
  * @return string : la chaine de langue finale en utilisant la fonction _T()
3981 3981
  */
3982 3982
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) {
3983
-	static $local_singulier_ou_pluriel = array();
3983
+    static $local_singulier_ou_pluriel = array();
3984 3984
 
3985
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
3986
-	if (!is_numeric($nb) or $nb == 0) {
3987
-		return "";
3988
-	}
3989
-	if (!is_array($vars)) {
3990
-		return "";
3991
-	}
3985
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
3986
+    if (!is_numeric($nb) or $nb == 0) {
3987
+        return "";
3988
+    }
3989
+    if (!is_array($vars)) {
3990
+        return "";
3991
+    }
3992 3992
 
3993
-	$langue = $GLOBALS['spip_lang'];
3994
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
3995
-		$local_singulier_ou_pluriel[$langue] = false;
3996
-		if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
3997
-		  or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) {
3998
-			$local_singulier_ou_pluriel[$langue] = $f;
3999
-		}
4000
-	}
3993
+    $langue = $GLOBALS['spip_lang'];
3994
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
3995
+        $local_singulier_ou_pluriel[$langue] = false;
3996
+        if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
3997
+          or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) {
3998
+            $local_singulier_ou_pluriel[$langue] = $f;
3999
+        }
4000
+    }
4001 4001
 
4002
-	// si on a une surcharge on l'utilise
4003
-	if ($local_singulier_ou_pluriel[$langue]) {
4004
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4005
-	}
4002
+    // si on a une surcharge on l'utilise
4003
+    if ($local_singulier_ou_pluriel[$langue]) {
4004
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4005
+    }
4006 4006
 
4007
-	// sinon traitement par defaut
4008
-	$vars[$var] = $nb;
4009
-	if ($nb >= 2) {
4010
-		return _T($chaine_plusieurs, $vars);
4011
-	} else {
4012
-		return _T($chaine_un, $vars);
4013
-	}
4007
+    // sinon traitement par defaut
4008
+    $vars[$var] = $nb;
4009
+    if ($nb >= 2) {
4010
+        return _T($chaine_plusieurs, $vars);
4011
+    } else {
4012
+        return _T($chaine_un, $vars);
4013
+    }
4014 4014
 }
4015 4015
 
4016 4016
 
@@ -4035,56 +4035,56 @@  discard block
 block discarded – undo
4035 4035
  * @return string
4036 4036
  */
4037 4037
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4038
-	if (in_array($fonction, array("del", "supprimer.gif"))) {
4039
-		$class .= ' danger';
4040
-	} elseif ($fonction == "rien.gif") {
4041
-		$fonction = "";
4042
-	} elseif ($fonction == "delsafe") {
4043
-		$fonction = "del";
4044
-	}
4045
-
4046
-	$fond_origine = $fond;
4047
-	// remappage des icone : article-24.png+new => article-new-24.png
4048
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4049
-		list($fond, $fonction) = $icone_renommer($fond, $fonction);
4050
-	}
4051
-
4052
-	// ajouter le type d'objet dans la class de l'icone
4053
-	$class .= " " . substr(basename($fond), 0, -4);
4054
-
4055
-	$alt = attribut_html($texte);
4056
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4057
-
4058
-	$ajax = "";
4059
-	if (strpos($class, "ajax") !== false) {
4060
-		$ajax = "ajax";
4061
-		if (strpos($class, "preload") !== false) {
4062
-			$ajax .= " preload";
4063
-		}
4064
-		if (strpos($class, "nocache") !== false) {
4065
-			$ajax .= " nocache";
4066
-		}
4067
-		$ajax = " class='$ajax'";
4068
-	}
4069
-
4070
-	$size = 24;
4071
-	if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4072
-	  or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4073
-		$size = $match[1];
4074
-	}
4075
-
4076
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4077
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4078
-
4079
-	if ($type == 'lien') {
4080
-		return "<span class='icone s$size $class'>"
4081
-		. "<a href='$lien'$title$ajax$javascript>"
4082
-		. $icone
4083
-		. "<b>$texte</b>"
4084
-		. "</a></span>\n";
4085
-	} else {
4086
-		return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4087
-	}
4038
+    if (in_array($fonction, array("del", "supprimer.gif"))) {
4039
+        $class .= ' danger';
4040
+    } elseif ($fonction == "rien.gif") {
4041
+        $fonction = "";
4042
+    } elseif ($fonction == "delsafe") {
4043
+        $fonction = "del";
4044
+    }
4045
+
4046
+    $fond_origine = $fond;
4047
+    // remappage des icone : article-24.png+new => article-new-24.png
4048
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4049
+        list($fond, $fonction) = $icone_renommer($fond, $fonction);
4050
+    }
4051
+
4052
+    // ajouter le type d'objet dans la class de l'icone
4053
+    $class .= " " . substr(basename($fond), 0, -4);
4054
+
4055
+    $alt = attribut_html($texte);
4056
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4057
+
4058
+    $ajax = "";
4059
+    if (strpos($class, "ajax") !== false) {
4060
+        $ajax = "ajax";
4061
+        if (strpos($class, "preload") !== false) {
4062
+            $ajax .= " preload";
4063
+        }
4064
+        if (strpos($class, "nocache") !== false) {
4065
+            $ajax .= " nocache";
4066
+        }
4067
+        $ajax = " class='$ajax'";
4068
+    }
4069
+
4070
+    $size = 24;
4071
+    if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4072
+      or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4073
+        $size = $match[1];
4074
+    }
4075
+
4076
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4077
+    $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4078
+
4079
+    if ($type == 'lien') {
4080
+        return "<span class='icone s$size $class'>"
4081
+        . "<a href='$lien'$title$ajax$javascript>"
4082
+        . $icone
4083
+        . "<b>$texte</b>"
4084
+        . "</a></span>\n";
4085
+    } else {
4086
+        return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4087
+    }
4088 4088
 }
4089 4089
 
4090 4090
 /**
@@ -4108,7 +4108,7 @@  discard block
 block discarded – undo
4108 4108
  *     Code HTML du lien
4109 4109
  **/
4110 4110
 function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4111
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4111
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4112 4112
 }
4113 4113
 
4114 4114
 /**
@@ -4143,7 +4143,7 @@  discard block
 block discarded – undo
4143 4143
  *     Code HTML du lien
4144 4144
  **/
4145 4145
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4146
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4146
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4147 4147
 }
4148 4148
 
4149 4149
 /**
@@ -4188,7 +4188,7 @@  discard block
 block discarded – undo
4188 4188
  *     Code HTML du lien
4189 4189
  **/
4190 4190
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4191
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4191
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4192 4192
 }
4193 4193
 
4194 4194
 /**
@@ -4219,7 +4219,7 @@  discard block
 block discarded – undo
4219 4219
  *     Code HTML du lien
4220 4220
  **/
4221 4221
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") {
4222
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4222
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4223 4223
 }
4224 4224
 
4225 4225
 /**
@@ -4249,7 +4249,7 @@  discard block
 block discarded – undo
4249 4249
  *     Code HTML du lien
4250 4250
  */
4251 4251
 function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") {
4252
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4252
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4253 4253
 }
4254 4254
 
4255 4255
 
@@ -4297,26 +4297,26 @@  discard block
 block discarded – undo
4297 4297
  * @return string Code CSS
4298 4298
  */
4299 4299
 function bando_images_background() {
4300
-	include_spip('inc/bandeau');
4301
-	// recuperer tous les boutons et leurs images
4302
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4300
+    include_spip('inc/bandeau');
4301
+    // recuperer tous les boutons et leurs images
4302
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4303 4303
 
4304
-	$res = "";
4305
-	foreach ($boutons as $page => $detail) {
4306
-		if ($detail->icone and strlen(trim($detail->icone))) {
4307
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4308
-		}
4309
-		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4310
-		if (is_array($detail->sousmenu)) {
4311
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4312
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4313
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4314
-				}
4315
-			}
4316
-		}
4317
-	}
4304
+    $res = "";
4305
+    foreach ($boutons as $page => $detail) {
4306
+        if ($detail->icone and strlen(trim($detail->icone))) {
4307
+            $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4308
+        }
4309
+        $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4310
+        if (is_array($detail->sousmenu)) {
4311
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4312
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4313
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4314
+                }
4315
+            }
4316
+        }
4317
+    }
4318 4318
 
4319
-	return $res;
4319
+    return $res;
4320 4320
 }
4321 4321
 
4322 4322
 /**
@@ -4335,19 +4335,19 @@  discard block
 block discarded – undo
4335 4335
  * @return string
4336 4336
  */
4337 4337
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4338
-	if ($confirm) {
4339
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4340
-		if ($callback) {
4341
-			$callback = "$confirm?($callback):false";
4342
-		} else {
4343
-			$callback = $confirm;
4344
-		}
4345
-	}
4346
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4347
-	$title = $title ? " title='$title'" : "";
4338
+    if ($confirm) {
4339
+        $confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4340
+        if ($callback) {
4341
+            $callback = "$confirm?($callback):false";
4342
+        } else {
4343
+            $callback = $confirm;
4344
+        }
4345
+    }
4346
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4347
+    $title = $title ? " title='$title'" : "";
4348 4348
 
4349
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4350
-	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4349
+    return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4350
+    . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4351 4351
 }
4352 4352
 
4353 4353
 /**
@@ -4368,78 +4368,78 @@  discard block
 block discarded – undo
4368 4368
  * @return string
4369 4369
  */
4370 4370
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") {
4371
-	static $trouver_table = null;
4372
-	static $objets;
4373
-
4374
-	// On verifie qu'on a tout ce qu'il faut
4375
-	$id_objet = intval($id_objet);
4376
-	if (!($id_objet and $type_objet and $info)) {
4377
-		return '';
4378
-	}
4379
-
4380
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4381
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4382
-		return '';
4383
-	}
4384
-
4385
-	// Si on demande l'url, on retourne direct la fonction
4386
-	if ($info == 'url') {
4387
-		return generer_url_entite($id_objet, $type_objet);
4388
-	}
4389
-
4390
-	// Sinon on va tout chercher dans la table et on garde en memoire
4391
-	$demande_titre = ($info == 'titre');
4392
-
4393
-	// 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
4394
-	if (!isset($objets[$type_objet][$id_objet])
4395
-		or
4396
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4397
-	) {
4398
-		if (!$trouver_table) {
4399
-			$trouver_table = charger_fonction('trouver_table', 'base');
4400
-		}
4401
-		$desc = $trouver_table(table_objet_sql($type_objet));
4402
-		if (!$desc) {
4403
-			return $objets[$type_objet] = false;
4404
-		}
4405
-
4406
-		// Si on demande le titre, on le gere en interne
4407
-		$champ_titre = "";
4408
-		if ($demande_titre) {
4409
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4410
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4411
-		}
4412
-		include_spip('base/abstract_sql');
4413
-		include_spip('base/connect_sql');
4414
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4415
-			'*' . $champ_titre,
4416
-			$desc['table_sql'],
4417
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4418
-		);
4419
-	}
4420
-
4421
-	// Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4422
-	if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4423
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4424
-	} // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4425
-	else {
4426
-		if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4427
-			$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4428
-		} // Sinon on prend directement le champ SQL tel quel
4429
-		else {
4430
-			$info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4431
-		}
4432
-	}
4433
-
4434
-	// On va ensuite appliquer les traitements automatiques si besoin
4435
-	if (!$etoile) {
4436
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4437
-		// mais ce fonctionnement est a ameliorer !
4438
-		$info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4439
-			array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4440
-	}
4441
-
4442
-	return $info_generee;
4371
+    static $trouver_table = null;
4372
+    static $objets;
4373
+
4374
+    // On verifie qu'on a tout ce qu'il faut
4375
+    $id_objet = intval($id_objet);
4376
+    if (!($id_objet and $type_objet and $info)) {
4377
+        return '';
4378
+    }
4379
+
4380
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4381
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4382
+        return '';
4383
+    }
4384
+
4385
+    // Si on demande l'url, on retourne direct la fonction
4386
+    if ($info == 'url') {
4387
+        return generer_url_entite($id_objet, $type_objet);
4388
+    }
4389
+
4390
+    // Sinon on va tout chercher dans la table et on garde en memoire
4391
+    $demande_titre = ($info == 'titre');
4392
+
4393
+    // 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
4394
+    if (!isset($objets[$type_objet][$id_objet])
4395
+        or
4396
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4397
+    ) {
4398
+        if (!$trouver_table) {
4399
+            $trouver_table = charger_fonction('trouver_table', 'base');
4400
+        }
4401
+        $desc = $trouver_table(table_objet_sql($type_objet));
4402
+        if (!$desc) {
4403
+            return $objets[$type_objet] = false;
4404
+        }
4405
+
4406
+        // Si on demande le titre, on le gere en interne
4407
+        $champ_titre = "";
4408
+        if ($demande_titre) {
4409
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4410
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4411
+        }
4412
+        include_spip('base/abstract_sql');
4413
+        include_spip('base/connect_sql');
4414
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4415
+            '*' . $champ_titre,
4416
+            $desc['table_sql'],
4417
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4418
+        );
4419
+    }
4420
+
4421
+    // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4422
+    if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4423
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4424
+    } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4425
+    else {
4426
+        if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4427
+            $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4428
+        } // Sinon on prend directement le champ SQL tel quel
4429
+        else {
4430
+            $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4431
+        }
4432
+    }
4433
+
4434
+    // On va ensuite appliquer les traitements automatiques si besoin
4435
+    if (!$etoile) {
4436
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4437
+        // mais ce fonctionnement est a ameliorer !
4438
+        $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4439
+            array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4440
+    }
4441
+
4442
+    return $info_generee;
4443 4443
 }
4444 4444
 
4445 4445
 /**
@@ -4453,44 +4453,44 @@  discard block
 block discarded – undo
4453 4453
  * @return string
4454 4454
  */
4455 4455
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') {
4456
-	if (!$champ) {
4457
-		return $texte;
4458
-	}
4456
+    if (!$champ) {
4457
+        return $texte;
4458
+    }
4459 4459
 	
4460
-	// On charge toujours les filtres de texte car la majorité des traitements les utilisent
4461
-	// et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4462
-	include_spip('inc/texte');
4460
+    // On charge toujours les filtres de texte car la majorité des traitements les utilisent
4461
+    // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4462
+    include_spip('inc/texte');
4463 4463
 	
4464
-	$champ = strtoupper($champ);
4465
-	$traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4466
-	if (!$traitements or !is_array($traitements)) {
4467
-		return $texte;
4468
-	}
4464
+    $champ = strtoupper($champ);
4465
+    $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4466
+    if (!$traitements or !is_array($traitements)) {
4467
+        return $texte;
4468
+    }
4469 4469
 
4470
-	$traitement = '';
4471
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4472
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4473
-		$table_objet = table_objet($table_objet);
4474
-		if (isset($traitements[$table_objet])) {
4475
-			$traitement = $traitements[$table_objet];
4476
-		}
4477
-	}
4478
-	if (!$traitement and isset($traitements[0])) {
4479
-		$traitement = $traitements[0];
4480
-	}
4481
-	// (sinon prendre le premier de la liste par defaut ?)
4470
+    $traitement = '';
4471
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4472
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4473
+        $table_objet = table_objet($table_objet);
4474
+        if (isset($traitements[$table_objet])) {
4475
+            $traitement = $traitements[$table_objet];
4476
+        }
4477
+    }
4478
+    if (!$traitement and isset($traitements[0])) {
4479
+        $traitement = $traitements[0];
4480
+    }
4481
+    // (sinon prendre le premier de la liste par defaut ?)
4482 4482
 
4483
-	if (!$traitement) {
4484
-		return $texte;
4485
-	}
4483
+    if (!$traitement) {
4484
+        return $texte;
4485
+    }
4486 4486
 
4487
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4487
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4488 4488
 
4489
-	// Fournir $connect et $Pile[0] au traitement si besoin
4490
-	$Pile = array(0 => $env);
4491
-	eval("\$texte = $traitement;");
4489
+    // Fournir $connect et $Pile[0] au traitement si besoin
4490
+    $Pile = array(0 => $env);
4491
+    eval("\$texte = $traitement;");
4492 4492
 
4493
-	return $texte;
4493
+    return $texte;
4494 4494
 }
4495 4495
 
4496 4496
 
@@ -4504,21 +4504,21 @@  discard block
 block discarded – undo
4504 4504
  * @return string
4505 4505
  */
4506 4506
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4507
-	include_spip('inc/liens');
4508
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4509
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4510
-	// le raccourcis n'est plus valide
4511
-	$titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4512
-	// on essaye avec generer_info_entite ?
4513
-	if (!strlen($titre) and !$connect) {
4514
-		$titre = generer_info_entite($id_objet, $objet, 'titre');
4515
-	}
4516
-	if (!strlen($titre)) {
4517
-		$titre = _T('info_sans_titre');
4518
-	}
4519
-	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4507
+    include_spip('inc/liens');
4508
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4509
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4510
+    // le raccourcis n'est plus valide
4511
+    $titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4512
+    // on essaye avec generer_info_entite ?
4513
+    if (!strlen($titre) and !$connect) {
4514
+        $titre = generer_info_entite($id_objet, $objet, 'titre');
4515
+    }
4516
+    if (!strlen($titre)) {
4517
+        $titre = _T('info_sans_titre');
4518
+    }
4519
+    $url = generer_url_entite($id_objet, $objet, '', '', $connect);
4520 4520
 
4521
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4521
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4522 4522
 }
4523 4523
 
4524 4524
 
@@ -4535,15 +4535,15 @@  discard block
 block discarded – undo
4535 4535
  * @return string
4536 4536
  */
4537 4537
 function wrap($texte, $wrap) {
4538
-	$balises = extraire_balises($wrap);
4539
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4540
-		$texte = $wrap . $texte;
4541
-		$regs = array_reverse($regs[1]);
4542
-		$wrap = "</" . implode("></", $regs) . ">";
4543
-		$texte = $texte . $wrap;
4544
-	}
4538
+    $balises = extraire_balises($wrap);
4539
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4540
+        $texte = $wrap . $texte;
4541
+        $regs = array_reverse($regs[1]);
4542
+        $wrap = "</" . implode("></", $regs) . ">";
4543
+        $texte = $texte . $wrap;
4544
+    }
4545 4545
 
4546
-	return $texte;
4546
+    return $texte;
4547 4547
 }
4548 4548
 
4549 4549
 
@@ -4563,43 +4563,43 @@  discard block
 block discarded – undo
4563 4563
  * @return array|mixed|string
4564 4564
  */
4565 4565
 function filtre_print_dist($u, $join = "<br />", $indent = 0) {
4566
-	if (is_string($u)) {
4567
-		$u = typo($u);
4566
+    if (is_string($u)) {
4567
+        $u = typo($u);
4568 4568
 
4569
-		return $u;
4570
-	}
4569
+        return $u;
4570
+    }
4571 4571
 
4572
-	// caster $u en array si besoin
4573
-	if (is_object($u)) {
4574
-		$u = (array)$u;
4575
-	}
4572
+    // caster $u en array si besoin
4573
+    if (is_object($u)) {
4574
+        $u = (array)$u;
4575
+    }
4576 4576
 
4577
-	if (is_array($u)) {
4578
-		$out = "";
4579
-		// toutes les cles sont numeriques ?
4580
-		// et aucun enfant n'est un tableau
4581
-		// liste simple separee par des virgules
4582
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4583
-		$array_values = array_map('is_array', $u);
4584
-		$object_values = array_map('is_object', $u);
4585
-		if (array_sum($numeric_keys) == count($numeric_keys)
4586
-			and !array_sum($array_values)
4587
-			and !array_sum($object_values)
4588
-		) {
4589
-			return join(", ", array_map('filtre_print_dist', $u));
4590
-		}
4577
+    if (is_array($u)) {
4578
+        $out = "";
4579
+        // toutes les cles sont numeriques ?
4580
+        // et aucun enfant n'est un tableau
4581
+        // liste simple separee par des virgules
4582
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4583
+        $array_values = array_map('is_array', $u);
4584
+        $object_values = array_map('is_object', $u);
4585
+        if (array_sum($numeric_keys) == count($numeric_keys)
4586
+            and !array_sum($array_values)
4587
+            and !array_sum($object_values)
4588
+        ) {
4589
+            return join(", ", array_map('filtre_print_dist', $u));
4590
+        }
4591 4591
 
4592
-		// sinon on passe a la ligne et on indente
4593
-		$i_str = str_pad("", $indent, " ");
4594
-		foreach ($u as $k => $v) {
4595
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4596
-		}
4592
+        // sinon on passe a la ligne et on indente
4593
+        $i_str = str_pad("", $indent, " ");
4594
+        foreach ($u as $k => $v) {
4595
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4596
+        }
4597 4597
 
4598
-		return $out;
4599
-	}
4598
+        return $out;
4599
+    }
4600 4600
 
4601
-	// on sait pas quoi faire...
4602
-	return $u;
4601
+    // on sait pas quoi faire...
4602
+    return $u;
4603 4603
 }
4604 4604
 
4605 4605
 
@@ -4612,10 +4612,10 @@  discard block
 block discarded – undo
4612 4612
  * @return string|array
4613 4613
  */
4614 4614
 function objet_info($objet, $info) {
4615
-	$table = table_objet_sql($objet);
4616
-	$infos = lister_tables_objets_sql($table);
4615
+    $table = table_objet_sql($objet);
4616
+    $infos = lister_tables_objets_sql($table);
4617 4617
 
4618
-	return (isset($infos[$info]) ? $infos[$info] : '');
4618
+    return (isset($infos[$info]) ? $infos[$info] : '');
4619 4619
 }
4620 4620
 
4621 4621
 /**
@@ -4630,11 +4630,11 @@  discard block
 block discarded – undo
4630 4630
  *     Texte traduit du comptage, tel que '3 articles'
4631 4631
  */
4632 4632
 function objet_afficher_nb($nb, $objet) {
4633
-	if (!$nb) {
4634
-		return _T(objet_info($objet, 'info_aucun_objet'));
4635
-	} else {
4636
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4637
-	}
4633
+    if (!$nb) {
4634
+        return _T(objet_info($objet, 'info_aucun_objet'));
4635
+    } else {
4636
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4637
+    }
4638 4638
 }
4639 4639
 
4640 4640
 /**
@@ -4646,11 +4646,11 @@  discard block
 block discarded – undo
4646 4646
  * @return string
4647 4647
  */
4648 4648
 function objet_icone($objet, $taille = 24, $class='') {
4649
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4650
-	$icone = chemin_image($icone);
4651
-	$balise_img = charger_filtre('balise_img');
4649
+    $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4650
+    $icone = chemin_image($icone);
4651
+    $balise_img = charger_filtre('balise_img');
4652 4652
 
4653
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4653
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4654 4654
 }
4655 4655
 
4656 4656
 /**
@@ -4671,12 +4671,12 @@  discard block
 block discarded – undo
4671 4671
  * @return string
4672 4672
  */
4673 4673
 function objet_T($objet, $chaine, $args = array(), $options = array()){
4674
-	$chaine = explode(':',$chaine);
4675
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4676
-		return $t;
4677
-	}
4678
-	$chaine = implode(':',$chaine);
4679
-	return _T($chaine, $args, $options);
4674
+    $chaine = explode(':',$chaine);
4675
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4676
+        return $t;
4677
+    }
4678
+    $chaine = implode(':',$chaine);
4679
+    return _T($chaine, $args, $options);
4680 4680
 }
4681 4681
 
4682 4682
 /**
@@ -4690,17 +4690,17 @@  discard block
 block discarded – undo
4690 4690
  * @return string      Code HTML
4691 4691
  */
4692 4692
 function insert_head_css_conditionnel($flux) {
4693
-	if (strpos($flux, '<!-- insert_head_css -->') === false
4694
-		and $p = strpos($flux, '<!-- insert_head -->')
4695
-	) {
4696
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4697
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4698
-			$p = $p1;
4699
-		}
4700
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4701
-	}
4693
+    if (strpos($flux, '<!-- insert_head_css -->') === false
4694
+        and $p = strpos($flux, '<!-- insert_head -->')
4695
+    ) {
4696
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4697
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4698
+            $p = $p1;
4699
+        }
4700
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4701
+    }
4702 4702
 
4703
-	return $flux;
4703
+    return $flux;
4704 4704
 }
4705 4705
 
4706 4706
 /**
@@ -4721,69 +4721,69 @@  discard block
 block discarded – undo
4721 4721
  * @return string
4722 4722
  */
4723 4723
 function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') {
4724
-	if (isset($contexte['format'])) {
4725
-		$extension = $contexte['format'];
4726
-		unset($contexte['format']);
4727
-	} else {
4728
-		$extension = "html";
4729
-		if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4730
-			$extension = $m[1];
4731
-		}
4732
-	}
4733
-	// recuperer le contenu produit par le squelette
4734
-	$options['raw'] = true;
4735
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4736
-
4737
-	// calculer le nom de la css
4738
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4739
-	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4740
-	$contexte_implicite = calculer_contexte_implicite();
4741
-
4742
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4743
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4744
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4745
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4746
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4747
-	}
4748
-	else {
4749
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4750
-		ksort($contexte);
4751
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4752
-	}
4753
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4754
-
4755
-	// mettre a jour le fichier si il n'existe pas
4756
-	// ou trop ancien
4757
-	// le dernier fichier produit est toujours suffixe par .last
4758
-	// et recopie sur le fichier cible uniquement si il change
4759
-	if (!file_exists($filename)
4760
-		or !file_exists($filename . ".last")
4761
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4762
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4763
-	) {
4764
-		$contenu = $cache['texte'];
4765
-		// passer les urls en absolu si c'est une css
4766
-		if ($extension == "css") {
4767
-			$contenu = urls_absolues_css($contenu,
4768
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4769
-		}
4770
-
4771
-		$comment = '';
4772
-		// ne pas insérer de commentaire si c'est du json
4773
-		if ($extension != "json") {
4774
-			$comment = "/* #PRODUIRE{fond=$fond";
4775
-			foreach ($contexte as $k => $v) {
4776
-				$comment .= ",$k=$v";
4777
-			}
4778
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4779
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4780
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4781
-		}
4782
-		// et ecrire le fichier si il change
4783
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4784
-	}
4785
-
4786
-	return timestamp($filename);
4724
+    if (isset($contexte['format'])) {
4725
+        $extension = $contexte['format'];
4726
+        unset($contexte['format']);
4727
+    } else {
4728
+        $extension = "html";
4729
+        if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4730
+            $extension = $m[1];
4731
+        }
4732
+    }
4733
+    // recuperer le contenu produit par le squelette
4734
+    $options['raw'] = true;
4735
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4736
+
4737
+    // calculer le nom de la css
4738
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4739
+    $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4740
+    $contexte_implicite = calculer_contexte_implicite();
4741
+
4742
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4743
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4744
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4745
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4746
+        $hash = md5($contexte_implicite['host'] . '::'. $cache);
4747
+    }
4748
+    else {
4749
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4750
+        ksort($contexte);
4751
+        $hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4752
+    }
4753
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4754
+
4755
+    // mettre a jour le fichier si il n'existe pas
4756
+    // ou trop ancien
4757
+    // le dernier fichier produit est toujours suffixe par .last
4758
+    // et recopie sur le fichier cible uniquement si il change
4759
+    if (!file_exists($filename)
4760
+        or !file_exists($filename . ".last")
4761
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4762
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4763
+    ) {
4764
+        $contenu = $cache['texte'];
4765
+        // passer les urls en absolu si c'est une css
4766
+        if ($extension == "css") {
4767
+            $contenu = urls_absolues_css($contenu,
4768
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4769
+        }
4770
+
4771
+        $comment = '';
4772
+        // ne pas insérer de commentaire si c'est du json
4773
+        if ($extension != "json") {
4774
+            $comment = "/* #PRODUIRE{fond=$fond";
4775
+            foreach ($contexte as $k => $v) {
4776
+                $comment .= ",$k=$v";
4777
+            }
4778
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4779
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4780
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
4781
+        }
4782
+        // et ecrire le fichier si il change
4783
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4784
+    }
4785
+
4786
+    return timestamp($filename);
4787 4787
 }
4788 4788
 
4789 4789
 /**
@@ -4796,14 +4796,14 @@  discard block
 block discarded – undo
4796 4796
  *    $fichier auquel on a ajouté le timestamp
4797 4797
  */
4798 4798
 function timestamp($fichier) {
4799
-	if (!$fichier
4800
-		or !file_exists($fichier)
4801
-		or !$m = filemtime($fichier)
4802
-	) {
4803
-		return $fichier;
4804
-	}
4799
+    if (!$fichier
4800
+        or !file_exists($fichier)
4801
+        or !$m = filemtime($fichier)
4802
+    ) {
4803
+        return $fichier;
4804
+    }
4805 4805
 
4806
-	return "$fichier?$m";
4806
+    return "$fichier?$m";
4807 4807
 }
4808 4808
 
4809 4809
 /**
@@ -4813,11 +4813,11 @@  discard block
 block discarded – undo
4813 4813
  * @return string
4814 4814
  */
4815 4815
 function supprimer_timestamp($url) {
4816
-	if (strpos($url, "?") === false) {
4817
-		return $url;
4818
-	}
4816
+    if (strpos($url, "?") === false) {
4817
+        return $url;
4818
+    }
4819 4819
 
4820
-	return preg_replace(",\?[[:digit:]]+$,", "", $url);
4820
+    return preg_replace(",\?[[:digit:]]+$,", "", $url);
4821 4821
 }
4822 4822
 
4823 4823
 /**
@@ -4832,9 +4832,9 @@  discard block
 block discarded – undo
4832 4832
  * @return string
4833 4833
  */
4834 4834
 function filtre_nettoyer_titre_email_dist($titre) {
4835
-	include_spip('inc/envoyer_mail');
4835
+    include_spip('inc/envoyer_mail');
4836 4836
 
4837
-	return nettoyer_titre_email($titre);
4837
+    return nettoyer_titre_email($titre);
4838 4838
 }
4839 4839
 
4840 4840
 /**
@@ -4856,19 +4856,19 @@  discard block
 block discarded – undo
4856 4856
  * @return string
4857 4857
  */
4858 4858
 function filtre_chercher_rubrique_dist(
4859
-	$titre,
4860
-	$id_objet,
4861
-	$id_parent,
4862
-	$objet,
4863
-	$id_secteur,
4864
-	$restreint,
4865
-	$actionable = false,
4866
-	$retour_sans_cadre = false
4859
+    $titre,
4860
+    $id_objet,
4861
+    $id_parent,
4862
+    $objet,
4863
+    $id_secteur,
4864
+    $restreint,
4865
+    $actionable = false,
4866
+    $retour_sans_cadre = false
4867 4867
 ) {
4868
-	include_spip('inc/filtres_ecrire');
4868
+    include_spip('inc/filtres_ecrire');
4869 4869
 
4870
-	return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4871
-		$retour_sans_cadre);
4870
+    return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4871
+        $retour_sans_cadre);
4872 4872
 }
4873 4873
 
4874 4874
 /**
@@ -4897,56 +4897,56 @@  discard block
 block discarded – undo
4897 4897
  *     Chaîne vide si l'accès est autorisé
4898 4898
  */
4899 4899
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
4900
-	if ($ok) {
4901
-		return '';
4902
-	}
4903
-
4904
-	// Vider tous les tampons
4905
-	$level = @ob_get_level();
4906
-	while ($level--) {
4907
-		@ob_end_clean();
4908
-	}
4909
-
4910
-	include_spip('inc/headers');
4911
-
4912
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4913
-	if ($url) {
4914
-		redirige_par_entete($url, '', $statut);
4915
-	}
4916
-
4917
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
4918
-	if (!is_numeric($statut) and is_null($message)) {
4919
-		$message = $statut;
4920
-		$statut = 0;
4921
-	}
4922
-	if (!$message) {
4923
-		$message = '';
4924
-	}
4925
-	$statut = intval($statut);
4926
-
4927
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4928
-	if (test_espace_prive()) {
4929
-		if (!$statut or !in_array($statut, array(404, 403))) {
4930
-			$statut = 403;
4931
-		}
4932
-		http_status(403);
4933
-		$echec = charger_fonction('403', 'exec');
4934
-		$echec($message);
4935
-	} else {
4936
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4937
-		if (!$statut) {
4938
-			$statut = 404;
4939
-		}
4940
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
4941
-		http_status($statut);
4942
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4943
-		if ($statut >= 400) {
4944
-			echo recuperer_fond("$statut", array('erreur' => $message));
4945
-		}
4946
-	}
4947
-
4948
-
4949
-	exit;
4900
+    if ($ok) {
4901
+        return '';
4902
+    }
4903
+
4904
+    // Vider tous les tampons
4905
+    $level = @ob_get_level();
4906
+    while ($level--) {
4907
+        @ob_end_clean();
4908
+    }
4909
+
4910
+    include_spip('inc/headers');
4911
+
4912
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4913
+    if ($url) {
4914
+        redirige_par_entete($url, '', $statut);
4915
+    }
4916
+
4917
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
4918
+    if (!is_numeric($statut) and is_null($message)) {
4919
+        $message = $statut;
4920
+        $statut = 0;
4921
+    }
4922
+    if (!$message) {
4923
+        $message = '';
4924
+    }
4925
+    $statut = intval($statut);
4926
+
4927
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4928
+    if (test_espace_prive()) {
4929
+        if (!$statut or !in_array($statut, array(404, 403))) {
4930
+            $statut = 403;
4931
+        }
4932
+        http_status(403);
4933
+        $echec = charger_fonction('403', 'exec');
4934
+        $echec($message);
4935
+    } else {
4936
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4937
+        if (!$statut) {
4938
+            $statut = 404;
4939
+        }
4940
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
4941
+        http_status($statut);
4942
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4943
+        if ($statut >= 400) {
4944
+            echo recuperer_fond("$statut", array('erreur' => $message));
4945
+        }
4946
+    }
4947
+
4948
+
4949
+    exit;
4950 4950
 }
4951 4951
 
4952 4952
 /**
@@ -4957,11 +4957,11 @@  discard block
 block discarded – undo
4957 4957
  * @return string
4958 4958
  */
4959 4959
 function filtre_compacte_dist($source, $format = null) {
4960
-	if (function_exists('compacte')) {
4961
-		return compacte($source, $format);
4962
-	}
4960
+    if (function_exists('compacte')) {
4961
+        return compacte($source, $format);
4962
+    }
4963 4963
 
4964
-	return $source;
4964
+    return $source;
4965 4965
 }
4966 4966
 
4967 4967
 
@@ -4973,29 +4973,29 @@  discard block
 block discarded – undo
4973 4973
  * @return string
4974 4974
  */
4975 4975
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4976
-	$l = strlen($passe);
4977
-
4978
-	if ($l<=8 or !$afficher_partiellement){
4979
-		if (!$l) {
4980
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4981
-		}
4982
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4983
-	}
4984
-
4985
-	if (is_null($portion_pourcent)) {
4986
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4987
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4988
-		}
4989
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4990
-	}
4991
-	if ($portion_pourcent >= 100) {
4992
-		return $passe;
4993
-	}
4994
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4995
-	$e = max($e, 0);
4996
-	$mid = str_pad('',$l-2*$e,'*');
4997
-	if ($e>0 and strlen($mid)>8){
4998
-		$mid = '***...***';
4999
-	}
5000
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4976
+    $l = strlen($passe);
4977
+
4978
+    if ($l<=8 or !$afficher_partiellement){
4979
+        if (!$l) {
4980
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4981
+        }
4982
+        return str_pad('',$afficher_partiellement ? $l : 16,'*');
4983
+    }
4984
+
4985
+    if (is_null($portion_pourcent)) {
4986
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4987
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4988
+        }
4989
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4990
+    }
4991
+    if ($portion_pourcent >= 100) {
4992
+        return $passe;
4993
+    }
4994
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
4995
+    $e = max($e, 0);
4996
+    $mid = str_pad('',$l-2*$e,'*');
4997
+    if ($e>0 and strlen($mid)>8){
4998
+        $mid = '***...***';
4999
+    }
5000
+    return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
5001 5001
 }
5002 5002
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	}
95 95
 
96 96
 	include_fichiers_fonctions();
97
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
97
+	foreach (array('filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc) as $f) {
98 98
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99 99
 		// fonction ou name\space\fonction
100 100
 		if (is_callable($f)) {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	// affichage "GIT [master: abcdef]"
188 188
 	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189 189
 	if ($desc['branch']) {
190
-		$commit = $desc['branch'] . ': ' . $commit;
190
+		$commit = $desc['branch'].': '.$commit;
191 191
 	}
192 192
 	return "{$desc['vcs']} [$commit]";
193 193
 }
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	}
207 207
 
208 208
 	// version installee par GIT
209
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
209
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
210 210
 		$currentHead = trim(substr($c, 4));
211
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
211
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
212 212
 			return [
213 213
 				'vcs' => 'GIT',
214 214
 				'branch' => basename($currentHead),
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 		$dir = '.';
236 236
 	}
237 237
 	// version installee par SVN
238
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
-		$db = new SQLite3($dir . '/.svn/wc.db');
238
+	if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) {
239
+		$db = new SQLite3($dir.'/.svn/wc.db');
240 240
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241 241
 		if ($result) {
242 242
 			$row = $result->fetchArray();
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 
276 276
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
277 277
 // et laisser passer les fonctions personnelles baptisees image_...
278
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
279
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
280
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
281
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
282
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
278
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
279
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
280
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
281
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
282
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
283 283
 
284 284
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
285 285
 $GLOBALS['spip_matrice']['couleur_foncer'] = 'inc/filtres_images_mini.php';
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
  */
437 437
 function filtre_debug($val, $key = null) {
438 438
 	$debug = (
439
-		is_null($key) ? '' : (var_export($key, true) . " = ")
440
-		) . var_export($val, true);
439
+		is_null($key) ? '' : (var_export($key, true)." = ")
440
+		).var_export($val, true);
441 441
 
442 442
 	include_spip('inc/autoriser');
443 443
 	if (autoriser('webmestre')) {
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
537 537
 							$srcover = $match[1];
538 538
 							array_shift($args);
539
-							array_unshift($args, "<img src='" . $match[1] . "' />");
539
+							array_unshift($args, "<img src='".$match[1]."' />");
540 540
 							$srcover_filter = call_user_func_array($filtre, $args);
541 541
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
542 542
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 	// " -> &quot; et tout ce genre de choses
887 887
 	$u = $GLOBALS['meta']['pcre_u'];
888 888
 	$texte = str_replace("&nbsp;", " ", $texte);
889
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
889
+	$texte = preg_replace('/\s{2,}/S'.$u, " ", $texte);
890 890
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
891 891
 	$texte = entites_html($texte, false, false);
892 892
 	// mais bien echapper les double quotes !
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
  **/
947 947
 function supprimer_numero($texte) {
948 948
 	return preg_replace(
949
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
949
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
950 950
 		"", $texte);
951 951
 }
952 952
 
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
  **/
972 972
 function recuperer_numero($texte) {
973 973
 	if (preg_match(
974
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
974
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
975 975
 		$texte, $regs)) {
976 976
 		return strval($regs[1]);
977 977
 	} else {
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
  **/
1057 1057
 function textebrut($texte) {
1058 1058
 	$u = $GLOBALS['meta']['pcre_u'];
1059
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1060
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1059
+	$texte = preg_replace('/\s+/S'.$u, " ", $texte);
1060
+	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
1061 1061
 	$texte = preg_replace("/^\n+/", "", $texte);
1062 1062
 	$texte = preg_replace("/\n+$/", "", $texte);
1063 1063
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1086 1086
 		$texte, $liens, PREG_PATTERN_ORDER)) {
1087 1087
 		foreach ($liens[0] as $a) {
1088
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1088
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1089 1089
 			$ablank = inserer_attribut($a, 'rel', $rel);
1090 1090
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1091 1091
 			$texte = str_replace($a, $ablank, $texte);
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
 		foreach ($regs[0] as $a) {
1111 1111
 			$rel = extraire_attribut($a, "rel");
1112 1112
 			if (strpos($rel, "nofollow") === false) {
1113
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1113
+				$rel = "nofollow".($rel ? " $rel" : "");
1114 1114
 				$anofollow = inserer_attribut($a, "rel", $rel);
1115 1115
 				$texte = str_replace($a, $anofollow, $texte);
1116 1116
 			}
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 	$u = $GLOBALS['meta']['pcre_u'];
1140 1140
 	$texte = preg_replace("@</p>@iS", "\n", $texte);
1141 1141
 	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1142
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1142
+	$texte = preg_replace("@^\s*<br />@S".$u, "", $texte);
1143 1143
 
1144 1144
 	return $texte;
1145 1145
 }
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 		return $texte;
1170 1170
 	}
1171 1171
 	include_spip('inc/texte');
1172
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1172
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1173 1173
 		'div' : 'span';
1174 1174
 
1175 1175
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 function attribut_html($texte, $textebrut = true) {
1279 1279
 	$u = $GLOBALS['meta']['pcre_u'];
1280 1280
 	if ($textebrut) {
1281
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1281
+		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte));
1282 1282
 	}
1283 1283
 	$texte = texte_backend($texte);
1284 1284
 	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
 	# un message pour abs_url
1308 1308
 	$GLOBALS['mode_abs_url'] = 'url';
1309 1309
 	$url = trim($url);
1310
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1310
+	$r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS';
1311 1311
 
1312 1312
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1313 1313
 }
@@ -1509,14 +1509,14 @@  discard block
 block discarded – undo
1509 1509
 	if (strpos($texte, "<") !== false) {
1510 1510
 		include_spip('inc/lien');
1511 1511
 		if (defined('_PREG_MODELE')) {
1512
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1512
+			$preg_modeles = "@"._PREG_MODELE."@imsS";
1513 1513
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1514 1514
 		}
1515 1515
 	}
1516 1516
 
1517 1517
 	$debut = '';
1518 1518
 	$suite = $texte;
1519
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1519
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1520 1520
 		$debut .= substr($suite, 0, $t - 1);
1521 1521
 		$suite = substr($suite, $t);
1522 1522
 		$car = substr($suite, 0, 1);
@@ -1533,11 +1533,11 @@  discard block
 block discarded – undo
1533 1533
 			$suite = substr($suite, strlen($regs[0]));
1534 1534
 		}
1535 1535
 	}
1536
-	$texte = $debut . $suite;
1536
+	$texte = $debut.$suite;
1537 1537
 
1538 1538
 	$texte = echappe_retour($texte);
1539 1539
 
1540
-	return $texte . $fin;
1540
+	return $texte.$fin;
1541 1541
 }
1542 1542
 
1543 1543
 
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
 		}
1599 1599
 
1600 1600
 		foreach ($regs as $reg) {
1601
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1601
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1602 1602
 			$desc = $traduire($cle, $lang, true);
1603 1603
 			$l = $desc->langue;
1604 1604
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1711,9 +1711,9 @@  discard block
 block discarded – undo
1711 1711
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1712 1712
 					include_spip('inc/texte');
1713 1713
 					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1714
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1714
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1715 1715
 					if ($mode === 'div') {
1716
-						$trad = rtrim($trad) . "\n\n";
1716
+						$trad = rtrim($trad)."\n\n";
1717 1717
 					}
1718 1718
 					$trad = code_echappement($trad, 'multi', false, $mode);
1719 1719
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
@@ -1907,7 +1907,7 @@  discard block
 block discarded – undo
1907 1907
 	if (is_array($balise)) {
1908 1908
 		array_walk(
1909 1909
 			$balise,
1910
-			function(&$a, $key, $t){
1910
+			function(&$a, $key, $t) {
1911 1911
 				$a = extraire_attribut($a, $t);
1912 1912
 			},
1913 1913
 			$attribut
@@ -1994,14 +1994,14 @@  discard block
 block discarded – undo
1994 1994
 
1995 1995
 	if ($old !== null) {
1996 1996
 		// Remplacer l'ancien attribut du meme nom
1997
-		$balise = $r[1] . $insert . $r[5];
1997
+		$balise = $r[1].$insert.$r[5];
1998 1998
 	} else {
1999 1999
 		// preferer une balise " />" (comme <img />)
2000 2000
 		if (preg_match(',/>,', $balise)) {
2001
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2001
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
2002 2002
 		} // sinon une balise <a ...> ... </a>
2003 2003
 		else {
2004
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2004
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
2005 2005
 		}
2006 2006
 	}
2007 2007
 
@@ -2034,7 +2034,7 @@  discard block
 block discarded – undo
2034 2034
  * @param string $operation
2035 2035
  * @return string
2036 2036
  */
2037
-function modifier_class($balise, $class, $operation='ajouter') {
2037
+function modifier_class($balise, $class, $operation = 'ajouter') {
2038 2038
 	if (is_string($class)) {
2039 2039
 		$class = explode(' ', trim($class));
2040 2040
 	}
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
 				}
2060 2060
 				if (in_array($operation, ['ajouter', 'commuter'])
2061 2061
 					and !$is_class_presente) {
2062
-					$class_new = rtrim($class_new) . " " . $c;
2062
+					$class_new = rtrim($class_new)." ".$c;
2063 2063
 				}
2064 2064
 				elseif (in_array($operation, ['supprimer', 'commuter'])
2065 2065
 					and $is_class_presente) {
@@ -2087,7 +2087,7 @@  discard block
 block discarded – undo
2087 2087
  * @param string|array $class
2088 2088
  * @return string
2089 2089
  */
2090
-function ajouter_class($balise, $class){
2090
+function ajouter_class($balise, $class) {
2091 2091
 	return modifier_class($balise, $class, 'ajouter');
2092 2092
 }
2093 2093
 
@@ -2097,7 +2097,7 @@  discard block
 block discarded – undo
2097 2097
  * @param string|array $class
2098 2098
  * @return string
2099 2099
  */
2100
-function supprimer_class($balise, $class){
2100
+function supprimer_class($balise, $class) {
2101 2101
 	return modifier_class($balise, $class, 'supprimer');
2102 2102
 }
2103 2103
 
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
  * @param string|array $class
2109 2109
  * @return string
2110 2110
  */
2111
-function commuter_class($balise, $class){
2111
+function commuter_class($balise, $class) {
2112 2112
 	return modifier_class($balise, $class, 'commuter');
2113 2113
 }
2114 2114
 
@@ -2128,8 +2128,8 @@  discard block
 block discarded – undo
2128 2128
 //
2129 2129
 // Quelques fonctions de calcul arithmetique
2130 2130
 //
2131
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
2132
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
2131
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
2132
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
2133 2133
 
2134 2134
 /**
2135 2135
  * Additionne 2 nombres
@@ -2149,7 +2149,7 @@  discard block
 block discarded – undo
2149 2149
 function plus($a, $b) {
2150 2150
 	return $a + $b;
2151 2151
 }
2152
-function strplus($a, $b) {return strize('plus', $a, $b);}
2152
+function strplus($a, $b) {return strize('plus', $a, $b); }
2153 2153
 /**
2154 2154
  * Soustrait 2 nombres
2155 2155
  *
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
 function moins($a, $b) {
2169 2169
 	return $a - $b;
2170 2170
 }
2171
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2171
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2172 2172
 
2173 2173
 /**
2174 2174
  * Multiplie 2 nombres
@@ -2189,7 +2189,7 @@  discard block
 block discarded – undo
2189 2189
 function mult($a, $b) {
2190 2190
 	return $a * $b;
2191 2191
 }
2192
-function strmult($a, $b) {return strize('mult', $a, $b);}
2192
+function strmult($a, $b) {return strize('mult', $a, $b); }
2193 2193
 
2194 2194
 /**
2195 2195
  * Divise 2 nombres
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
 function div($a, $b) {
2211 2211
 	return $b ? $a / $b : 0;
2212 2212
 }
2213
-function strdiv($a, $b) {return strize('div', $a, $b);}
2213
+function strdiv($a, $b) {return strize('div', $a, $b); }
2214 2214
 
2215 2215
 /**
2216 2216
  * Retourne le modulo 2 nombres
@@ -2251,13 +2251,13 @@  discard block
 block discarded – undo
2251 2251
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2252 2252
 		define('_TAGS_NOM_AUTEUR', '');
2253 2253
 	}
2254
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2254
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2255 2255
 	foreach ($tags_acceptes as $tag) {
2256 2256
 		if (strlen($tag)) {
2257
-			$remp1[] = '<' . trim($tag) . '>';
2258
-			$remp1[] = '</' . trim($tag) . '>';
2259
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2260
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2257
+			$remp1[] = '<'.trim($tag).'>';
2258
+			$remp1[] = '</'.trim($tag).'>';
2259
+			$remp2[] = '\x60'.trim($tag).'\x61';
2260
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2261 2261
 		}
2262 2262
 	}
2263 2263
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
 			$s[] = preg_replace(',>[^<]+</a>,S',
2308 2308
 				'>'
2309 2309
 				. http_img_pack('attachment-16.png', $t,
2310
-					'title="' . attribut_html($t) . '"')
2310
+					'title="'.attribut_html($t).'"')
2311 2311
 				. '</a>', $tag);
2312 2312
 		}
2313 2313
 	}
@@ -2368,10 +2368,10 @@  discard block
 block discarded – undo
2368 2368
 	$fichier = basename($url);
2369 2369
 
2370 2370
 	return '<a rel="enclosure"'
2371
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2372
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2373
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2374
-	. '>' . $fichier . '</a>';
2371
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2372
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2373
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2374
+	. '>'.$fichier.'</a>';
2375 2375
 }
2376 2376
 
2377 2377
 /**
@@ -2399,9 +2399,9 @@  discard block
 block discarded – undo
2399 2399
 			} # vieux data
2400 2400
 			$fichier = basename($url);
2401 2401
 			$enclosures[] = '<enclosure'
2402
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2403
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2404
-				. ($length ? ' length="' . $length . '"' : '')
2402
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2403
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2404
+				. ($length ? ' length="'.$length.'"' : '')
2405 2405
 				. ' />';
2406 2406
 		}
2407 2407
 	}
@@ -2427,7 +2427,7 @@  discard block
 block discarded – undo
2427 2427
 		if (extraire_attribut($e, rel) == 'tag') {
2428 2428
 			$subjects .= '<dc:subject>'
2429 2429
 				. texte_backend(textebrut($e))
2430
-				. '</dc:subject>' . "\n";
2430
+				. '</dc:subject>'."\n";
2431 2431
 		}
2432 2432
 	}
2433 2433
 
@@ -2463,7 +2463,7 @@  discard block
 block discarded – undo
2463 2463
 	if (is_array($texte)) {
2464 2464
 		array_walk(
2465 2465
 			$texte,
2466
-			function(&$a, $key, $t){
2466
+			function(&$a, $key, $t) {
2467 2467
 				$a = extraire_balise($a, $t);
2468 2468
 			},
2469 2469
 			$tag
@@ -2507,7 +2507,7 @@  discard block
 block discarded – undo
2507 2507
 	if (is_array($texte)) {
2508 2508
 		array_walk(
2509 2509
 			$texte,
2510
-			function(&$a, $key, $t){
2510
+			function(&$a, $key, $t) {
2511 2511
 				$a = extraire_balises($a, $t);
2512 2512
 			},
2513 2513
 			$tag
@@ -2633,7 +2633,7 @@  discard block
 block discarded – undo
2633 2633
 		if ($fond != '404') {
2634 2634
 			$contexte = array_shift($p);
2635 2635
 			$contexte['page'] = $fond;
2636
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2636
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2637 2637
 		}
2638 2638
 	}
2639 2639
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2688,9 +2688,9 @@  discard block
 block discarded – undo
2688 2688
 			. '"'
2689 2689
 			. (is_null($val)
2690 2690
 				? ''
2691
-				: ' value="' . entites_html($val) . '"'
2691
+				: ' value="'.entites_html($val).'"'
2692 2692
 			)
2693
-			. ' type="hidden"' . "\n/>";
2693
+			. ' type="hidden"'."\n/>";
2694 2694
 	}
2695 2695
 
2696 2696
 	return join("", $hidden);
@@ -2827,7 +2827,7 @@  discard block
 block discarded – undo
2827 2827
 	return preg_replace_callback(
2828 2828
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2829 2829
 		function($x) use ($path) {
2830
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2830
+			return "url('".suivre_lien($path, $x[1])."')";
2831 2831
 		},
2832 2832
 		$contenu
2833 2833
 	);
@@ -2889,14 +2889,14 @@  discard block
 block discarded – undo
2889 2889
 	) {
2890 2890
 		$distant = true;
2891 2891
 		$cssf = parse_url($css);
2892
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2892
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2893 2893
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2894 2894
 	} else {
2895 2895
 		$distant = false;
2896 2896
 		$cssf = $css;
2897 2897
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2898 2898
 		//propose (rien a faire dans ce cas)
2899
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2899
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2900 2900
 		if (@file_exists($f)) {
2901 2901
 			return $f;
2902 2902
 		}
@@ -2906,7 +2906,7 @@  discard block
 block discarded – undo
2906 2906
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2907 2907
 	$f = $dir_var
2908 2908
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2909
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2909
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2910 2910
 
2911 2911
 	// la css peut etre distante (url absolue !)
2912 2912
 	if ($distant) {
@@ -2951,8 +2951,8 @@  discard block
 block discarded – undo
2951 2951
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2952 2952
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2953 2953
 			$css_direction = substr($css_direction, strlen($dir_var));
2954
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2955
-			$css_direction = "/@@@@@@/" . $css_direction;
2954
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
2955
+			$css_direction = "/@@@@@@/".$css_direction;
2956 2956
 		}
2957 2957
 		$src[] = $regs[0][$k];
2958 2958
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -3001,7 +3001,7 @@  discard block
 block discarded – undo
3001 3001
 
3002 3002
 	$f = basename($css, '.css');
3003 3003
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3004
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3004
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3005 3005
 		. '.css';
3006 3006
 
3007 3007
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3010,7 +3010,7 @@  discard block
 block discarded – undo
3010 3010
 
3011 3011
 	if ($url_absolue_css == $css) {
3012 3012
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3013
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3013
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3014 3014
 		) {
3015 3015
 			include_spip('inc/distant');
3016 3016
 			if (!$contenu = recuperer_page($css)) {
@@ -3120,7 +3120,7 @@  discard block
 block discarded – undo
3120 3120
 	$expression = str_replace("\/", "/", $expression);
3121 3121
 	$expression = str_replace("/", "\/", $expression);
3122 3122
 
3123
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3123
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3124 3124
 		if (isset($r[$capte])) {
3125 3125
 			return $r[$capte];
3126 3126
 		} else {
@@ -3158,7 +3158,7 @@  discard block
 block discarded – undo
3158 3158
 	$expression = str_replace("\/", "/", $expression);
3159 3159
 	$expression = str_replace("/", "\/", $expression);
3160 3160
 
3161
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3161
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3162 3162
 }
3163 3163
 
3164 3164
 
@@ -3177,7 +3177,7 @@  discard block
 block discarded – undo
3177 3177
 function traiter_doublons_documents(&$doublons, $letexte) {
3178 3178
 
3179 3179
 	// Verifier dans le texte & les notes (pas beau, helas)
3180
-	$t = $letexte . $GLOBALS['les_notes'];
3180
+	$t = $letexte.$GLOBALS['les_notes'];
3181 3181
 
3182 3182
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3183 3183
 		and preg_match_all(
@@ -3187,7 +3187,7 @@  discard block
 block discarded – undo
3187 3187
 		if (!isset($doublons['documents'])) {
3188 3188
 			$doublons['documents'] = "";
3189 3189
 		}
3190
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3190
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3191 3191
 	}
3192 3192
 
3193 3193
 	return $letexte;
@@ -3244,7 +3244,7 @@  discard block
 block discarded – undo
3244 3244
 	if ($env) {
3245 3245
 		foreach ($env as $i => $j) {
3246 3246
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3247
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3247
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3248 3248
 			}
3249 3249
 		}
3250 3250
 	}
@@ -3283,7 +3283,7 @@  discard block
 block discarded – undo
3283 3283
 	if ($env) {
3284 3284
 		foreach ($env as $i => $j) {
3285 3285
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3286
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3286
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3287 3287
 			}
3288 3288
 		}
3289 3289
 	}
@@ -3367,19 +3367,19 @@  discard block
 block discarded – undo
3367 3367
 
3368 3368
 	$img_file = $img;
3369 3369
 	if ($p = strpos($img_file, '?')) {
3370
-		$img_file = substr($img_file,0, $p);
3370
+		$img_file = substr($img_file, 0, $p);
3371 3371
 	}
3372 3372
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3373 3373
 		$img_file = chemin_image($img);
3374 3374
 	}
3375 3375
 	else {
3376
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3376
+		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3377 3377
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3378 3378
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3379 3379
 			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3380
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3380
+			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg"
3381 3381
 			  and file_exists($variante_svg_generique)) {
3382
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3382
+				if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) {
3383 3383
 					$img_file = $variante_svg_size;
3384 3384
 				}
3385 3385
 				else {
@@ -3404,7 +3404,7 @@  discard block
 block discarded – undo
3404 3404
 				return "";
3405 3405
 			}
3406 3406
 		}
3407
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3407
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3408 3408
 	}
3409 3409
 
3410 3410
 	if (file_exists($img_file)) {
@@ -3413,15 +3413,15 @@  discard block
 block discarded – undo
3413 3413
 	if ($alt === false) {
3414 3414
 		$alt = '';
3415 3415
 	}
3416
-	elseif($alt or $alt==='') {
3416
+	elseif ($alt or $alt === '') {
3417 3417
 		$alt = " alt='".attribut_html($alt)."'";
3418 3418
 	}
3419 3419
 	else {
3420 3420
 		$alt = " alt='".attribut_html($title)."'";
3421 3421
 	}
3422 3422
 	return "<img src='$img_file'$alt"
3423
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3424
-	. " " . ltrim($atts)
3423
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3424
+	. " ".ltrim($atts)
3425 3425
 	. " />";
3426 3426
 }
3427 3427
 
@@ -3433,12 +3433,12 @@  discard block
 block discarded – undo
3433 3433
  * @param string $size
3434 3434
  * @return string
3435 3435
  */
3436
-function http_style_background($img, $att = '', $size=null) {
3437
-	if ($size and is_numeric($size)){
3438
-		$size = trim($size) . "px";
3436
+function http_style_background($img, $att = '', $size = null) {
3437
+	if ($size and is_numeric($size)) {
3438
+		$size = trim($size)."px";
3439 3439
 	}
3440
-	return " style='background" .
3441
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3440
+	return " style='background".
3441
+		($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";"
3442 3442
 		. ($size ? "background-size:{$size};" : '')
3443 3443
 		. "'";
3444 3444
 }
@@ -3455,8 +3455,8 @@  discard block
 block discarded – undo
3455 3455
  * @return string
3456 3456
  *     Code HTML de la balise IMG
3457 3457
  */
3458
-function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3459
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3458
+function filtre_balise_img_dist($img, $alt = "", $class = "", $width = null) {
3459
+	$atts = $class ? " class='".attribut_html($class)."'" : '';
3460 3460
 	// ecriture courte : on donne le width en 2e arg
3461 3461
 	if (empty($width) and is_numeric($alt)) {
3462 3462
 		$width = $alt;
@@ -3484,7 +3484,7 @@  discard block
 block discarded – undo
3484 3484
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3485 3485
 	$img_file = $img;
3486 3486
 	if ($p = strpos($img_file, '?')) {
3487
-		$img_file = substr($img_file,0, $p);
3487
+		$img_file = substr($img_file, 0, $p);
3488 3488
 	}
3489 3489
 
3490 3490
 	if (!$img_file or !$svg = file_get_contents($img_file)) {
@@ -3498,18 +3498,18 @@  discard block
 block discarded – undo
3498 3498
 	$balise_svg_source = $balise_svg;
3499 3499
 
3500 3500
 	// entete XML à supprimer
3501
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3501
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3502 3502
 
3503 3503
 	// IE est toujours mon ami
3504 3504
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3505 3505
 	if ($class) {
3506 3506
 		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3507 3507
 	}
3508
-	if ($alt){
3508
+	if ($alt) {
3509 3509
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3510
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3510
+		$id = "img-svg-title-".substr(md5("$img_file:$svg:$alt"), 0, 4);
3511 3511
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3512
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3512
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3513 3513
 		$balise_svg .= $title;
3514 3514
 	}
3515 3515
 	else {
@@ -3543,7 +3543,7 @@  discard block
 block discarded – undo
3543 3543
 	$texte = '';
3544 3544
 	if (is_array($tableau)) {
3545 3545
 		foreach ($tableau as $k => $v) {
3546
-			$res = recuperer_fond('modeles/' . $modele,
3546
+			$res = recuperer_fond('modeles/'.$modele,
3547 3547
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3548 3548
 			);
3549 3549
 			$texte .= $res;
@@ -3720,7 +3720,7 @@  discard block
 block discarded – undo
3720 3720
 	}
3721 3721
 
3722 3722
 	$c = serialize($c);
3723
-	$cle = calculer_cle_action($form . $c);
3723
+	$cle = calculer_cle_action($form.$c);
3724 3724
 	$c = "$cle:$c";
3725 3725
 
3726 3726
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3782,15 +3782,15 @@  discard block
 block discarded – undo
3782 3782
 	}
3783 3783
 	// toujours encoder l'url source dans le bloc ajax
3784 3784
 	$r = self();
3785
-	$r = ' data-origin="' . $r . '"';
3785
+	$r = ' data-origin="'.$r.'"';
3786 3786
 	$class = 'ajaxbloc';
3787 3787
 	if ($ajaxid and is_string($ajaxid)) {
3788 3788
 		// ajaxid est normalement conforme a un nom de classe css
3789 3789
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3790
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3790
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3791 3791
 	}
3792 3792
 
3793
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3793
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3794 3794
 }
3795 3795
 
3796 3796
 /**
@@ -3829,11 +3829,11 @@  discard block
 block discarded – undo
3829 3829
 	// extraire la signature en debut de contexte
3830 3830
 	// et la verifier avant de deserializer
3831 3831
 	// format : signature:donneesserializees
3832
-	if ($p = strpos($c,":")){
3833
-		$cle = substr($c,0,$p);
3834
-		$c = substr($c,$p+1);
3832
+	if ($p = strpos($c, ":")) {
3833
+		$cle = substr($c, 0, $p);
3834
+		$c = substr($c, $p + 1);
3835 3835
 
3836
-		if ($cle == calculer_cle_action($form . $c)) {
3836
+		if ($cle == calculer_cle_action($form.$c)) {
3837 3837
 			$env = @unserialize($c);
3838 3838
 			return $env;
3839 3839
 		}
@@ -3939,24 +3939,24 @@  discard block
 block discarded – undo
3939 3939
 		$att = "";
3940 3940
 		// si $on passe la balise et optionnelement une ou ++classe
3941 3941
 		// a.active span.selected.active etc....
3942
-		if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
3942
+		if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
3943 3943
 			$on = explode(".", $on);
3944 3944
 			// on verifie que c'est exactement une des 3 balises a, span ou strong
3945
-			if (in_array(reset($on), array('a', 'span', 'strong'))){
3945
+			if (in_array(reset($on), array('a', 'span', 'strong'))) {
3946 3946
 				$bal = array_shift($on);
3947 3947
 				$class = implode(" ", $on);
3948
-				if ($bal=="a"){
3948
+				if ($bal == "a") {
3949 3949
 					$att = 'href="#" ';
3950 3950
 				}
3951 3951
 			}
3952 3952
 		}
3953
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
3953
+		$att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"';
3954 3954
 	} else {
3955 3955
 		$bal = 'a';
3956 3956
 		$att = "href='$url'"
3957
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3958
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3959
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3957
+			. ($title ? " title='".attribut_html($title)."'" : '')
3958
+			. ($class ? " class='".attribut_html($class)."'" : '')
3959
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
3960 3960
 			. $evt;
3961 3961
 	}
3962 3962
 	if ($libelle === null) {
@@ -4050,7 +4050,7 @@  discard block
 block discarded – undo
4050 4050
 	}
4051 4051
 
4052 4052
 	// ajouter le type d'objet dans la class de l'icone
4053
-	$class .= " " . substr(basename($fond), 0, -4);
4053
+	$class .= " ".substr(basename($fond), 0, -4);
4054 4054
 
4055 4055
 	$alt = attribut_html($texte);
4056 4056
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -4074,7 +4074,7 @@  discard block
 block discarded – undo
4074 4074
 	}
4075 4075
 
4076 4076
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4077
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4077
+	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "")."\">$icone</span>";
4078 4078
 
4079 4079
 	if ($type == 'lien') {
4080 4080
 		return "<span class='icone s$size $class'>"
@@ -4304,13 +4304,13 @@  discard block
 block discarded – undo
4304 4304
 	$res = "";
4305 4305
 	foreach ($boutons as $page => $detail) {
4306 4306
 		if ($detail->icone and strlen(trim($detail->icone))) {
4307
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4307
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4308 4308
 		}
4309 4309
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4310 4310
 		if (is_array($detail->sousmenu)) {
4311 4311
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4312 4312
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4313
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4313
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4314 4314
 				}
4315 4315
 			}
4316 4316
 		}
@@ -4336,17 +4336,17 @@  discard block
 block discarded – undo
4336 4336
  */
4337 4337
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4338 4338
 	if ($confirm) {
4339
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4339
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4340 4340
 		if ($callback) {
4341 4341
 			$callback = "$confirm?($callback):false";
4342 4342
 		} else {
4343 4343
 			$callback = $confirm;
4344 4344
 		}
4345 4345
 	}
4346
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4346
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4347 4347
 	$title = $title ? " title='$title'" : "";
4348 4348
 
4349
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4349
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4350 4350
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4351 4351
 }
4352 4352
 
@@ -4407,14 +4407,14 @@  discard block
 block discarded – undo
4407 4407
 		$champ_titre = "";
4408 4408
 		if ($demande_titre) {
4409 4409
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4410
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4410
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4411 4411
 		}
4412 4412
 		include_spip('base/abstract_sql');
4413 4413
 		include_spip('base/connect_sql');
4414 4414
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4415
-			'*' . $champ_titre,
4415
+			'*'.$champ_titre,
4416 4416
 			$desc['table_sql'],
4417
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4417
+			id_table_objet($type_objet).' = '.intval($id_objet)
4418 4418
 		);
4419 4419
 	}
4420 4420
 
@@ -4484,7 +4484,7 @@  discard block
 block discarded – undo
4484 4484
 		return $texte;
4485 4485
 	}
4486 4486
 
4487
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4487
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4488 4488
 
4489 4489
 	// Fournir $connect et $Pile[0] au traitement si besoin
4490 4490
 	$Pile = array(0 => $env);
@@ -4518,7 +4518,7 @@  discard block
 block discarded – undo
4518 4518
 	}
4519 4519
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4520 4520
 
4521
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4521
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4522 4522
 }
4523 4523
 
4524 4524
 
@@ -4537,10 +4537,10 @@  discard block
 block discarded – undo
4537 4537
 function wrap($texte, $wrap) {
4538 4538
 	$balises = extraire_balises($wrap);
4539 4539
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4540
-		$texte = $wrap . $texte;
4540
+		$texte = $wrap.$texte;
4541 4541
 		$regs = array_reverse($regs[1]);
4542
-		$wrap = "</" . implode("></", $regs) . ">";
4543
-		$texte = $texte . $wrap;
4542
+		$wrap = "</".implode("></", $regs).">";
4543
+		$texte = $texte.$wrap;
4544 4544
 	}
4545 4545
 
4546 4546
 	return $texte;
@@ -4571,7 +4571,7 @@  discard block
 block discarded – undo
4571 4571
 
4572 4572
 	// caster $u en array si besoin
4573 4573
 	if (is_object($u)) {
4574
-		$u = (array)$u;
4574
+		$u = (array) $u;
4575 4575
 	}
4576 4576
 
4577 4577
 	if (is_array($u)) {
@@ -4592,7 +4592,7 @@  discard block
 block discarded – undo
4592 4592
 		// sinon on passe a la ligne et on indente
4593 4593
 		$i_str = str_pad("", $indent, " ");
4594 4594
 		foreach ($u as $k => $v) {
4595
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4595
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4596 4596
 		}
4597 4597
 
4598 4598
 		return $out;
@@ -4645,8 +4645,8 @@  discard block
 block discarded – undo
4645 4645
  * @param string $class
4646 4646
  * @return string
4647 4647
  */
4648
-function objet_icone($objet, $taille = 24, $class='') {
4649
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4648
+function objet_icone($objet, $taille = 24, $class = '') {
4649
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4650 4650
 	$icone = chemin_image($icone);
4651 4651
 	$balise_img = charger_filtre('balise_img');
4652 4652
 
@@ -4670,12 +4670,12 @@  discard block
 block discarded – undo
4670 4670
  * @param array $options
4671 4671
  * @return string
4672 4672
  */
4673
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4674
-	$chaine = explode(':',$chaine);
4675
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4673
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4674
+	$chaine = explode(':', $chaine);
4675
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4676 4676
 		return $t;
4677 4677
 	}
4678
-	$chaine = implode(':',$chaine);
4678
+	$chaine = implode(':', $chaine);
4679 4679
 	return _T($chaine, $args, $options);
4680 4680
 }
4681 4681
 
@@ -4735,7 +4735,7 @@  discard block
 block discarded – undo
4735 4735
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4736 4736
 
4737 4737
 	// calculer le nom de la css
4738
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4738
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4739 4739
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4740 4740
 	$contexte_implicite = calculer_contexte_implicite();
4741 4741
 
@@ -4743,22 +4743,22 @@  discard block
 block discarded – undo
4743 4743
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4744 4744
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4745 4745
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4746
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4746
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
4747 4747
 	}
4748 4748
 	else {
4749 4749
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4750 4750
 		ksort($contexte);
4751
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4751
+		$hash = md5($fond.json_encode($contexte_implicite).json_encode($contexte).$connect);
4752 4752
 	}
4753
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4753
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4754 4754
 
4755 4755
 	// mettre a jour le fichier si il n'existe pas
4756 4756
 	// ou trop ancien
4757 4757
 	// le dernier fichier produit est toujours suffixe par .last
4758 4758
 	// et recopie sur le fichier cible uniquement si il change
4759 4759
 	if (!file_exists($filename)
4760
-		or !file_exists($filename . ".last")
4761
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4760
+		or !file_exists($filename.".last")
4761
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4762 4762
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4763 4763
 	) {
4764 4764
 		$contenu = $cache['texte'];
@@ -4777,10 +4777,10 @@  discard block
 block discarded – undo
4777 4777
 			}
4778 4778
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4779 4779
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4780
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4780
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4781 4781
 		}
4782 4782
 		// et ecrire le fichier si il change
4783
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4783
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
4784 4784
 	}
4785 4785
 
4786 4786
 	return timestamp($filename);
@@ -4975,11 +4975,11 @@  discard block
 block discarded – undo
4975 4975
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4976 4976
 	$l = strlen($passe);
4977 4977
 
4978
-	if ($l<=8 or !$afficher_partiellement){
4978
+	if ($l <= 8 or !$afficher_partiellement) {
4979 4979
 		if (!$l) {
4980 4980
 			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4981 4981
 		}
4982
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4982
+		return str_pad('', $afficher_partiellement ? $l : 16, '*');
4983 4983
 	}
4984 4984
 
4985 4985
 	if (is_null($portion_pourcent)) {
@@ -4993,9 +4993,9 @@  discard block
 block discarded – undo
4993 4993
 	}
4994 4994
 	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4995 4995
 	$e = max($e, 0);
4996
-	$mid = str_pad('',$l-2*$e,'*');
4997
-	if ($e>0 and strlen($mid)>8){
4996
+	$mid = str_pad('', $l - 2 * $e, '*');
4997
+	if ($e > 0 and strlen($mid) > 8) {
4998 4998
 		$mid = '***...***';
4999 4999
 	}
5000
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
5000
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5001 5001
 }
5002 5002
\ No newline at end of file
Please login to merge, or discard this patch.