Completed
Push — master ( 29c643...be10ed )
by cam
04:15
created
ecrire/inc/filtres.php 3 patches
Indentation   +2058 added lines, -2058 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,64 +1669,64 @@  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
-					$trad = code_echappement($trad, 'multi', false, $mode);
1716
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1717
-					if (lang_dir($l) !== lang_dir($lang)) {
1718
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1719
-					}
1720
-					if (!$options['echappe_span']) {
1721
-						$trad = echappe_retour($trad, 'multi');
1722
-					}
1723
-				}
1724
-			}
1725
-			$letexte = str_replace($reg[0], $trad, $letexte);
1726
-		}
1727
-	}
1728
-
1729
-	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
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1716
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1717
+                    if (lang_dir($l) !== lang_dir($lang)) {
1718
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1719
+                    }
1720
+                    if (!$options['echappe_span']) {
1721
+                        $trad = echappe_retour($trad, 'multi');
1722
+                    }
1723
+                }
1724
+            }
1725
+            $letexte = str_replace($reg[0], $trad, $letexte);
1726
+        }
1727
+    }
1728
+
1729
+    return $letexte;
1730 1730
 }
1731 1731
 
1732 1732
 /**
@@ -1742,20 +1742,20 @@  discard block
 block discarded – undo
1742 1742
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1743 1743
  **/
1744 1744
 function extraire_trads($bloc) {
1745
-	$lang = '';
1745
+    $lang = '';
1746 1746
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1747 1747
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1748
-	while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1749
-		$texte = trim($regs[1]);
1750
-		if ($texte or $lang) {
1751
-			$trads[$lang] = $texte;
1752
-		}
1753
-		$bloc = substr($bloc, strlen($regs[0]));
1754
-		$lang = $regs[2];
1755
-	}
1756
-	$trads[$lang] = $bloc;
1748
+    while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1749
+        $texte = trim($regs[1]);
1750
+        if ($texte or $lang) {
1751
+            $trads[$lang] = $texte;
1752
+        }
1753
+        $bloc = substr($bloc, strlen($regs[0]));
1754
+        $lang = $regs[2];
1755
+    }
1756
+    $trads[$lang] = $bloc;
1757 1757
 
1758
-	return $trads;
1758
+    return $trads;
1759 1759
 }
1760 1760
 
1761 1761
 
@@ -1766,7 +1766,7 @@  discard block
 block discarded – undo
1766 1766
  * @return string L'initiale en majuscule
1767 1767
  */
1768 1768
 function filtre_initiale($nom) {
1769
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1769
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1770 1770
 }
1771 1771
 
1772 1772
 
@@ -1811,33 +1811,33 @@  discard block
 block discarded – undo
1811 1811
  *      - null (interne) : si on empile
1812 1812
  **/
1813 1813
 function unique($donnee, $famille = '', $cpt = false) {
1814
-	static $mem = array();
1815
-	// permettre de vider la pile et de la restaurer
1816
-	// pour le calcul de introduction...
1817
-	if ($famille == '_spip_raz_') {
1818
-		$tmp = $mem;
1819
-		$mem = array();
1820
-
1821
-		return $tmp;
1822
-	} elseif ($famille == '_spip_set_') {
1823
-		$mem = $donnee;
1824
-
1825
-		return;
1826
-	}
1827
-	// eviter une notice
1828
-	if (!isset($mem[$famille])) {
1829
-		$mem[$famille] = array();
1830
-	}
1831
-	if ($cpt) {
1832
-		return count($mem[$famille]);
1833
-	}
1834
-	// eviter une notice
1835
-	if (!isset($mem[$famille][$donnee])) {
1836
-		$mem[$famille][$donnee] = 0;
1837
-	}
1838
-	if (!($mem[$famille][$donnee]++)) {
1839
-		return $donnee;
1840
-	}
1814
+    static $mem = array();
1815
+    // permettre de vider la pile et de la restaurer
1816
+    // pour le calcul de introduction...
1817
+    if ($famille == '_spip_raz_') {
1818
+        $tmp = $mem;
1819
+        $mem = array();
1820
+
1821
+        return $tmp;
1822
+    } elseif ($famille == '_spip_set_') {
1823
+        $mem = $donnee;
1824
+
1825
+        return;
1826
+    }
1827
+    // eviter une notice
1828
+    if (!isset($mem[$famille])) {
1829
+        $mem[$famille] = array();
1830
+    }
1831
+    if ($cpt) {
1832
+        return count($mem[$famille]);
1833
+    }
1834
+    // eviter une notice
1835
+    if (!isset($mem[$famille][$donnee])) {
1836
+        $mem[$famille][$donnee] = 0;
1837
+    }
1838
+    if (!($mem[$famille][$donnee]++)) {
1839
+        return $donnee;
1840
+    }
1841 1841
 }
1842 1842
 
1843 1843
 
@@ -1865,18 +1865,18 @@  discard block
 block discarded – undo
1865 1865
  *     Une des valeurs en fonction du compteur.
1866 1866
  **/
1867 1867
 function alterner($i) {
1868
-	// recuperer les arguments (attention fonctions un peu space)
1869
-	$num = func_num_args();
1870
-	$args = func_get_args();
1868
+    // recuperer les arguments (attention fonctions un peu space)
1869
+    $num = func_num_args();
1870
+    $args = func_get_args();
1871 1871
 
1872
-	if ($num == 2 && is_array($args[1])) {
1873
-		$args = $args[1];
1874
-		array_unshift($args, '');
1875
-		$num = count($args);
1876
-	}
1872
+    if ($num == 2 && is_array($args[1])) {
1873
+        $args = $args[1];
1874
+        array_unshift($args, '');
1875
+        $num = count($args);
1876
+    }
1877 1877
 
1878
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1879
-	return $args[(intval($i) - 1) % ($num - 1) + 1];
1878
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1879
+    return $args[(intval($i) - 1) % ($num - 1) + 1];
1880 1880
 }
1881 1881
 
1882 1882
 
@@ -1901,46 +1901,46 @@  discard block
 block discarded – undo
1901 1901
  *     - Tableau complet (si 2e argument)
1902 1902
  **/
1903 1903
 function extraire_attribut($balise, $attribut, $complet = false) {
1904
-	if (is_array($balise)) {
1905
-		array_walk(
1906
-			$balise,
1907
-			function(&$a, $key, $t){
1908
-				$a = extraire_attribut($a, $t);
1909
-			},
1910
-			$attribut
1911
-		);
1912
-
1913
-		return $balise;
1914
-	}
1915
-	if (preg_match(
1916
-		',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1917
-		. $attribut
1918
-		. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1919
-
1920
-		$balise, $r)) {
1921
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1922
-			$r[4] = substr($r[3], 1, -1);
1923
-			$r[3] = $r[3][0];
1924
-		} elseif ($r[3] !== '') {
1925
-			$r[4] = $r[3];
1926
-			$r[3] = '';
1927
-		} else {
1928
-			$r[4] = trim($r[2]);
1929
-		}
1930
-		$att = $r[4];
1931
-		if (strpos($att, "&#") !== false) {
1932
-			$att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1933
-		}
1934
-		$att = filtrer_entites($att);
1935
-	} else {
1936
-		$att = null;
1937
-	}
1938
-
1939
-	if ($complet) {
1940
-		return array($att, $r);
1941
-	} else {
1942
-		return $att;
1943
-	}
1904
+    if (is_array($balise)) {
1905
+        array_walk(
1906
+            $balise,
1907
+            function(&$a, $key, $t){
1908
+                $a = extraire_attribut($a, $t);
1909
+            },
1910
+            $attribut
1911
+        );
1912
+
1913
+        return $balise;
1914
+    }
1915
+    if (preg_match(
1916
+        ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1917
+        . $attribut
1918
+        . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1919
+
1920
+        $balise, $r)) {
1921
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1922
+            $r[4] = substr($r[3], 1, -1);
1923
+            $r[3] = $r[3][0];
1924
+        } elseif ($r[3] !== '') {
1925
+            $r[4] = $r[3];
1926
+            $r[3] = '';
1927
+        } else {
1928
+            $r[4] = trim($r[2]);
1929
+        }
1930
+        $att = $r[4];
1931
+        if (strpos($att, "&#") !== false) {
1932
+            $att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1933
+        }
1934
+        $att = filtrer_entites($att);
1935
+    } else {
1936
+        $att = null;
1937
+    }
1938
+
1939
+    if ($complet) {
1940
+        return array($att, $r);
1941
+    } else {
1942
+        return $att;
1943
+    }
1944 1944
 }
1945 1945
 
1946 1946
 /**
@@ -1972,37 +1972,37 @@  discard block
 block discarded – undo
1972 1972
  *     Code html modifié
1973 1973
  **/
1974 1974
 function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) {
1975
-	// preparer l'attribut
1976
-	// supprimer les &nbsp; etc mais pas les balises html
1977
-	// qui ont un sens dans un attribut value d'un input
1978
-	if ($proteger) {
1979
-		$val = attribut_html($val, false);
1980
-	}
1981
-
1982
-	// echapper les ' pour eviter tout bug
1983
-	$val = str_replace("'", "&#039;", $val);
1984
-	if ($vider and strlen($val) == 0) {
1985
-		$insert = '';
1986
-	} else {
1987
-		$insert = " $attribut='$val'";
1988
-	}
1989
-
1990
-	list($old, $r) = extraire_attribut($balise, $attribut, true);
1991
-
1992
-	if ($old !== null) {
1993
-		// Remplacer l'ancien attribut du meme nom
1994
-		$balise = $r[1] . $insert . $r[5];
1995
-	} else {
1996
-		// preferer une balise " />" (comme <img />)
1997
-		if (preg_match(',/>,', $balise)) {
1998
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1999
-		} // sinon une balise <a ...> ... </a>
2000
-		else {
2001
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2002
-		}
2003
-	}
2004
-
2005
-	return $balise;
1975
+    // preparer l'attribut
1976
+    // supprimer les &nbsp; etc mais pas les balises html
1977
+    // qui ont un sens dans un attribut value d'un input
1978
+    if ($proteger) {
1979
+        $val = attribut_html($val, false);
1980
+    }
1981
+
1982
+    // echapper les ' pour eviter tout bug
1983
+    $val = str_replace("'", "&#039;", $val);
1984
+    if ($vider and strlen($val) == 0) {
1985
+        $insert = '';
1986
+    } else {
1987
+        $insert = " $attribut='$val'";
1988
+    }
1989
+
1990
+    list($old, $r) = extraire_attribut($balise, $attribut, true);
1991
+
1992
+    if ($old !== null) {
1993
+        // Remplacer l'ancien attribut du meme nom
1994
+        $balise = $r[1] . $insert . $r[5];
1995
+    } else {
1996
+        // preferer une balise " />" (comme <img />)
1997
+        if (preg_match(',/>,', $balise)) {
1998
+            $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1999
+        } // sinon une balise <a ...> ... </a>
2000
+        else {
2001
+            $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2002
+        }
2003
+    }
2004
+
2005
+    return $balise;
2006 2006
 }
2007 2007
 
2008 2008
 /**
@@ -2020,7 +2020,7 @@  discard block
 block discarded – undo
2020 2020
  * @return string Code HTML sans l'attribut
2021 2021
  **/
2022 2022
 function vider_attribut($balise, $attribut) {
2023
-	return inserer_attribut($balise, $attribut, '', false, true);
2023
+    return inserer_attribut($balise, $attribut, '', false, true);
2024 2024
 }
2025 2025
 
2026 2026
 /**
@@ -2032,50 +2032,50 @@  discard block
 block discarded – undo
2032 2032
  * @return string
2033 2033
  */
2034 2034
 function modifier_class($balise, $class, $operation='ajouter') {
2035
-	if (is_string($class)) {
2036
-		$class = explode(' ', trim($class));
2037
-	}
2038
-	$class = array_filter($class);
2039
-
2040
-	// si la ou les classes ont des caracteres invalides on ne fait rien
2041
-	if (preg_match(",[^\w-],", implode('', $class))) {
2042
-		return $balise;
2043
-	}
2044
-
2045
-	if ($class) {
2046
-		$class = array_unique($class);
2047
-		$class_courante = extraire_attribut($balise, 'class');
2048
-
2049
-		$class_new = $class_courante;
2050
-		foreach ($class as $c) {
2051
-			if ($c) {
2052
-				$is_class_presente = false;
2053
-				if (strpos($class_courante, $c) !== false
2054
-					and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) {
2055
-					$is_class_presente = true;
2056
-				}
2057
-				if (in_array($operation, ['ajouter', 'commuter'])
2058
-					and !$is_class_presente) {
2059
-					$class_new = rtrim($class_new) . " " . $c;
2060
-				}
2061
-				elseif (in_array($operation, ['supprimer', 'commuter'])
2062
-					and $is_class_presente) {
2063
-					$class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new));
2064
-				}
2065
-			}
2066
-		}
2067
-
2068
-		if ($class_new !== $class_courante) {
2069
-			if (strlen($class_new)) {
2070
-				$balise = inserer_attribut($balise, 'class', $class_new);
2071
-			}
2072
-			elseif ($class_courante) {
2073
-				$balise = vider_attribut($balise, 'class');
2074
-			}
2075
-		}
2076
-	}
2077
-
2078
-	return $balise;
2035
+    if (is_string($class)) {
2036
+        $class = explode(' ', trim($class));
2037
+    }
2038
+    $class = array_filter($class);
2039
+
2040
+    // si la ou les classes ont des caracteres invalides on ne fait rien
2041
+    if (preg_match(",[^\w-],", implode('', $class))) {
2042
+        return $balise;
2043
+    }
2044
+
2045
+    if ($class) {
2046
+        $class = array_unique($class);
2047
+        $class_courante = extraire_attribut($balise, 'class');
2048
+
2049
+        $class_new = $class_courante;
2050
+        foreach ($class as $c) {
2051
+            if ($c) {
2052
+                $is_class_presente = false;
2053
+                if (strpos($class_courante, $c) !== false
2054
+                    and preg_match("/(^|\s)".preg_quote($c)."($|\s)/", $class_courante)) {
2055
+                    $is_class_presente = true;
2056
+                }
2057
+                if (in_array($operation, ['ajouter', 'commuter'])
2058
+                    and !$is_class_presente) {
2059
+                    $class_new = rtrim($class_new) . " " . $c;
2060
+                }
2061
+                elseif (in_array($operation, ['supprimer', 'commuter'])
2062
+                    and $is_class_presente) {
2063
+                    $class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new));
2064
+                }
2065
+            }
2066
+        }
2067
+
2068
+        if ($class_new !== $class_courante) {
2069
+            if (strlen($class_new)) {
2070
+                $balise = inserer_attribut($balise, 'class', $class_new);
2071
+            }
2072
+            elseif ($class_courante) {
2073
+                $balise = vider_attribut($balise, 'class');
2074
+            }
2075
+        }
2076
+    }
2077
+
2078
+    return $balise;
2079 2079
 }
2080 2080
 
2081 2081
 /**
@@ -2085,7 +2085,7 @@  discard block
 block discarded – undo
2085 2085
  * @return string
2086 2086
  */
2087 2087
 function ajouter_class($balise, $class){
2088
-	return modifier_class($balise, $class, 'ajouter');
2088
+    return modifier_class($balise, $class, 'ajouter');
2089 2089
 }
2090 2090
 
2091 2091
 /**
@@ -2095,7 +2095,7 @@  discard block
 block discarded – undo
2095 2095
  * @return string
2096 2096
  */
2097 2097
 function supprimer_class($balise, $class){
2098
-	return modifier_class($balise, $class, 'supprimer');
2098
+    return modifier_class($balise, $class, 'supprimer');
2099 2099
 }
2100 2100
 
2101 2101
 /**
@@ -2106,7 +2106,7 @@  discard block
 block discarded – undo
2106 2106
  * @return string
2107 2107
  */
2108 2108
 function commuter_class($balise, $class){
2109
-	return modifier_class($balise, $class, 'commuter');
2109
+    return modifier_class($balise, $class, 'commuter');
2110 2110
 }
2111 2111
 
2112 2112
 /**
@@ -2117,9 +2117,9 @@  discard block
 block discarded – undo
2117 2117
  * @return string
2118 2118
  */
2119 2119
 function tester_config($id, $mode = '') {
2120
-	include_spip('action/inscrire_auteur');
2120
+    include_spip('action/inscrire_auteur');
2121 2121
 
2122
-	return tester_statut_inscription($mode, $id);
2122
+    return tester_statut_inscription($mode, $id);
2123 2123
 }
2124 2124
 
2125 2125
 //
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
  * @return int $a+$b
2145 2145
  **/
2146 2146
 function plus($a, $b) {
2147
-	return $a + $b;
2147
+    return $a + $b;
2148 2148
 }
2149 2149
 function strplus($a, $b) {return strize('plus', $a, $b);}
2150 2150
 /**
@@ -2163,7 +2163,7 @@  discard block
 block discarded – undo
2163 2163
  * @return int $a-$b
2164 2164
  **/
2165 2165
 function moins($a, $b) {
2166
-	return $a - $b;
2166
+    return $a - $b;
2167 2167
 }
2168 2168
 function strmoins($a, $b) {return strize('moins', $a, $b);}
2169 2169
 
@@ -2184,7 +2184,7 @@  discard block
 block discarded – undo
2184 2184
  * @return int $a*$b
2185 2185
  **/
2186 2186
 function mult($a, $b) {
2187
-	return $a * $b;
2187
+    return $a * $b;
2188 2188
 }
2189 2189
 function strmult($a, $b) {return strize('mult', $a, $b);}
2190 2190
 
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
  * @return int $a/$b (ou 0 si $b est nul)
2206 2206
  **/
2207 2207
 function div($a, $b) {
2208
-	return $b ? $a / $b : 0;
2208
+    return $b ? $a / $b : 0;
2209 2209
 }
2210 2210
 function strdiv($a, $b) {return strize('div', $a, $b);}
2211 2211
 
@@ -2227,7 +2227,7 @@  discard block
 block discarded – undo
2227 2227
  * @return int ($nb % $mod) + $add
2228 2228
  **/
2229 2229
 function modulo($nb, $mod, $add = 0) {
2230
-	return ($mod ? $nb % $mod : 0) + $add;
2230
+    return ($mod ? $nb % $mod : 0) + $add;
2231 2231
 }
2232 2232
 
2233 2233
 
@@ -2242,24 +2242,24 @@  discard block
 block discarded – undo
2242 2242
  *      - true sinon
2243 2243
  **/
2244 2244
 function nom_acceptable($nom) {
2245
-	if (!is_string($nom)) {
2246
-		return false;
2247
-	}
2248
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2249
-		define('_TAGS_NOM_AUTEUR', '');
2250
-	}
2251
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2252
-	foreach ($tags_acceptes as $tag) {
2253
-		if (strlen($tag)) {
2254
-			$remp1[] = '<' . trim($tag) . '>';
2255
-			$remp1[] = '</' . trim($tag) . '>';
2256
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2257
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2258
-		}
2259
-	}
2260
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2245
+    if (!is_string($nom)) {
2246
+        return false;
2247
+    }
2248
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2249
+        define('_TAGS_NOM_AUTEUR', '');
2250
+    }
2251
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2252
+    foreach ($tags_acceptes as $tag) {
2253
+        if (strlen($tag)) {
2254
+            $remp1[] = '<' . trim($tag) . '>';
2255
+            $remp1[] = '</' . trim($tag) . '>';
2256
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2257
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2258
+        }
2259
+    }
2260
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2261 2261
 
2262
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2262
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2263 2263
 }
2264 2264
 
2265 2265
 
@@ -2275,14 +2275,14 @@  discard block
 block discarded – undo
2275 2275
  *      - renvoie un tableau si l'entree est un tableau
2276 2276
  **/
2277 2277
 function email_valide($adresses) {
2278
-	if (is_array($adresses)) {
2279
-		$adresses = array_map('email_valide', $adresses);
2280
-		$adresses = array_filter($adresses);
2281
-		return $adresses;
2282
-	}
2278
+    if (is_array($adresses)) {
2279
+        $adresses = array_map('email_valide', $adresses);
2280
+        $adresses = array_filter($adresses);
2281
+        return $adresses;
2282
+    }
2283 2283
 
2284
-	$email_valide = charger_fonction('email_valide', 'inc');
2285
-	return $email_valide($adresses);
2284
+    $email_valide = charger_fonction('email_valide', 'inc');
2285
+    return $email_valide($adresses);
2286 2286
 }
2287 2287
 
2288 2288
 /**
@@ -2296,20 +2296,20 @@  discard block
 block discarded – undo
2296 2296
  * @return string Texte
2297 2297
  **/
2298 2298
 function afficher_enclosures($tags) {
2299
-	$s = array();
2300
-	foreach (extraire_balises($tags, 'a') as $tag) {
2301
-		if (extraire_attribut($tag, 'rel') == 'enclosure'
2302
-			and $t = extraire_attribut($tag, 'href')
2303
-		) {
2304
-			$s[] = preg_replace(',>[^<]+</a>,S',
2305
-				'>'
2306
-				. http_img_pack('attachment-16.png', $t,
2307
-					'title="' . attribut_html($t) . '"')
2308
-				. '</a>', $tag);
2309
-		}
2310
-	}
2299
+    $s = array();
2300
+    foreach (extraire_balises($tags, 'a') as $tag) {
2301
+        if (extraire_attribut($tag, 'rel') == 'enclosure'
2302
+            and $t = extraire_attribut($tag, 'href')
2303
+        ) {
2304
+            $s[] = preg_replace(',>[^<]+</a>,S',
2305
+                '>'
2306
+                . http_img_pack('attachment-16.png', $t,
2307
+                    'title="' . attribut_html($t) . '"')
2308
+                . '</a>', $tag);
2309
+        }
2310
+    }
2311 2311
 
2312
-	return join('&nbsp;', $s);
2312
+    return join('&nbsp;', $s);
2313 2313
 }
2314 2314
 
2315 2315
 /**
@@ -2324,15 +2324,15 @@  discard block
 block discarded – undo
2324 2324
  * @return string Liens trouvés
2325 2325
  **/
2326 2326
 function afficher_tags($tags, $rels = 'tag,directory') {
2327
-	$s = array();
2328
-	foreach (extraire_balises($tags, 'a') as $tag) {
2329
-		$rel = extraire_attribut($tag, 'rel');
2330
-		if (strstr(",$rels,", ",$rel,")) {
2331
-			$s[] = $tag;
2332
-		}
2333
-	}
2327
+    $s = array();
2328
+    foreach (extraire_balises($tags, 'a') as $tag) {
2329
+        $rel = extraire_attribut($tag, 'rel');
2330
+        if (strstr(",$rels,", ",$rel,")) {
2331
+            $s[] = $tag;
2332
+        }
2333
+    }
2334 2334
 
2335
-	return join(', ', $s);
2335
+    return join(', ', $s);
2336 2336
 }
2337 2337
 
2338 2338
 
@@ -2354,21 +2354,21 @@  discard block
 block discarded – undo
2354 2354
  * @return string Tag HTML `<a>` avec microformat.
2355 2355
  **/
2356 2356
 function enclosure2microformat($e) {
2357
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2358
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2359
-	}
2360
-	$type = extraire_attribut($e, 'type');
2361
-	if (!$length = extraire_attribut($e, 'length')) {
2362
-		# <media:content : longeur dans fileSize. On tente.
2363
-		$length = extraire_attribut($e, 'fileSize');
2364
-	}
2365
-	$fichier = basename($url);
2357
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2358
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2359
+    }
2360
+    $type = extraire_attribut($e, 'type');
2361
+    if (!$length = extraire_attribut($e, 'length')) {
2362
+        # <media:content : longeur dans fileSize. On tente.
2363
+        $length = extraire_attribut($e, 'fileSize');
2364
+    }
2365
+    $fichier = basename($url);
2366 2366
 
2367
-	return '<a rel="enclosure"'
2368
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2369
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2370
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2371
-	. '>' . $fichier . '</a>';
2367
+    return '<a rel="enclosure"'
2368
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2369
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2370
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2371
+    . '>' . $fichier . '</a>';
2372 2372
 }
2373 2373
 
2374 2374
 /**
@@ -2386,24 +2386,24 @@  discard block
 block discarded – undo
2386 2386
  * @return string Tags RSS `<enclosure>`.
2387 2387
  **/
2388 2388
 function microformat2enclosure($tags) {
2389
-	$enclosures = array();
2390
-	foreach (extraire_balises($tags, 'a') as $e) {
2391
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2392
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2393
-			$type = extraire_attribut($e, 'type');
2394
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2395
-				$length = intval(extraire_attribut($e, 'length'));
2396
-			} # vieux data
2397
-			$fichier = basename($url);
2398
-			$enclosures[] = '<enclosure'
2399
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2400
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2401
-				. ($length ? ' length="' . $length . '"' : '')
2402
-				. ' />';
2403
-		}
2404
-	}
2389
+    $enclosures = array();
2390
+    foreach (extraire_balises($tags, 'a') as $e) {
2391
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2392
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2393
+            $type = extraire_attribut($e, 'type');
2394
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2395
+                $length = intval(extraire_attribut($e, 'length'));
2396
+            } # vieux data
2397
+            $fichier = basename($url);
2398
+            $enclosures[] = '<enclosure'
2399
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2400
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2401
+                . ($length ? ' length="' . $length . '"' : '')
2402
+                . ' />';
2403
+        }
2404
+    }
2405 2405
 
2406
-	return join("\n", $enclosures);
2406
+    return join("\n", $enclosures);
2407 2407
 }
2408 2408
 
2409 2409
 
@@ -2419,16 +2419,16 @@  discard block
 block discarded – undo
2419 2419
  * @return string Tags RSS Atom `<dc:subject>`.
2420 2420
  **/
2421 2421
 function tags2dcsubject($tags) {
2422
-	$subjects = '';
2423
-	foreach (extraire_balises($tags, 'a') as $e) {
2424
-		if (extraire_attribut($e, rel) == 'tag') {
2425
-			$subjects .= '<dc:subject>'
2426
-				. texte_backend(textebrut($e))
2427
-				. '</dc:subject>' . "\n";
2428
-		}
2429
-	}
2422
+    $subjects = '';
2423
+    foreach (extraire_balises($tags, 'a') as $e) {
2424
+        if (extraire_attribut($e, rel) == 'tag') {
2425
+            $subjects .= '<dc:subject>'
2426
+                . texte_backend(textebrut($e))
2427
+                . '</dc:subject>' . "\n";
2428
+        }
2429
+    }
2430 2430
 
2431
-	return $subjects;
2431
+    return $subjects;
2432 2432
 }
2433 2433
 
2434 2434
 /**
@@ -2457,23 +2457,23 @@  discard block
 block discarded – undo
2457 2457
  *     - Tableau de résultats, si tableau en entrée.
2458 2458
  **/
2459 2459
 function extraire_balise($texte, $tag = 'a') {
2460
-	if (is_array($texte)) {
2461
-		array_walk(
2462
-			$texte,
2463
-			function(&$a, $key, $t){
2464
-				$a = extraire_balise($a, $t);
2465
-			},
2466
-			$tag
2467
-		);
2460
+    if (is_array($texte)) {
2461
+        array_walk(
2462
+            $texte,
2463
+            function(&$a, $key, $t){
2464
+                $a = extraire_balise($a, $t);
2465
+            },
2466
+            $tag
2467
+        );
2468 2468
 
2469
-		return $texte;
2470
-	}
2469
+        return $texte;
2470
+    }
2471 2471
 
2472
-	if (preg_match(
2473
-		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2474
-		$texte, $regs)) {
2475
-		return $regs[0];
2476
-	}
2472
+    if (preg_match(
2473
+        ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2474
+        $texte, $regs)) {
2475
+        return $regs[0];
2476
+    }
2477 2477
 }
2478 2478
 
2479 2479
 /**
@@ -2501,25 +2501,25 @@  discard block
 block discarded – undo
2501 2501
  *     - Tableau de résultats, si tableau en entrée.
2502 2502
  **/
2503 2503
 function extraire_balises($texte, $tag = 'a') {
2504
-	if (is_array($texte)) {
2505
-		array_walk(
2506
-			$texte,
2507
-			function(&$a, $key, $t){
2508
-				$a = extraire_balises($a, $t);
2509
-			},
2510
-			$tag
2511
-		);
2504
+    if (is_array($texte)) {
2505
+        array_walk(
2506
+            $texte,
2507
+            function(&$a, $key, $t){
2508
+                $a = extraire_balises($a, $t);
2509
+            },
2510
+            $tag
2511
+        );
2512 2512
 
2513
-		return $texte;
2514
-	}
2513
+        return $texte;
2514
+    }
2515 2515
 
2516
-	if (preg_match_all(
2517
-		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2518
-		$texte, $regs, PREG_PATTERN_ORDER)) {
2519
-		return $regs[0];
2520
-	} else {
2521
-		return array();
2522
-	}
2516
+    if (preg_match_all(
2517
+        ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2518
+        $texte, $regs, PREG_PATTERN_ORDER)) {
2519
+        return $regs[0];
2520
+    } else {
2521
+        return array();
2522
+    }
2523 2523
 }
2524 2524
 
2525 2525
 /**
@@ -2548,11 +2548,11 @@  discard block
 block discarded – undo
2548 2548
  *     - `$def` si on n'a pas transmis de tableau
2549 2549
  **/
2550 2550
 function in_any($val, $vals, $def = '') {
2551
-	if (!is_array($vals) and $v = unserialize($vals)) {
2552
-		$vals = $v;
2553
-	}
2551
+    if (!is_array($vals) and $v = unserialize($vals)) {
2552
+        $vals = $v;
2553
+    }
2554 2554
 
2555
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2555
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2556 2556
 }
2557 2557
 
2558 2558
 
@@ -2573,12 +2573,12 @@  discard block
 block discarded – undo
2573 2573
  *     Résultat du calcul
2574 2574
  **/
2575 2575
 function valeur_numerique($expr) {
2576
-	$a = 0;
2577
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2578
-		eval("\$a = $expr;");
2579
-	}
2576
+    $a = 0;
2577
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2578
+        eval("\$a = $expr;");
2579
+    }
2580 2580
 
2581
-	return intval($a);
2581
+    return intval($a);
2582 2582
 }
2583 2583
 
2584 2584
 /**
@@ -2597,7 +2597,7 @@  discard block
 block discarded – undo
2597 2597
  *      Retourne `$a*$b/$c`
2598 2598
  **/
2599 2599
 function regledetrois($a, $b, $c) {
2600
-	return round($a * $b / $c);
2600
+    return round($a * $b / $c);
2601 2601
 }
2602 2602
 
2603 2603
 
@@ -2621,76 +2621,76 @@  discard block
 block discarded – undo
2621 2621
  **/
2622 2622
 function form_hidden($action) {
2623 2623
 
2624
-	$contexte = array();
2625
-	include_spip('inc/urls');
2626
-	if ($p = urls_decoder_url($action, '')
2627
-		and reset($p)
2628
-	) {
2629
-		$fond = array_shift($p);
2630
-		if ($fond != '404') {
2631
-			$contexte = array_shift($p);
2632
-			$contexte['page'] = $fond;
2633
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2634
-		}
2635
-	}
2636
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2637
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2638
-		unset($contexte['type']);
2639
-	}
2640
-	if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2641
-		unset($contexte['type-page']);
2642
-	}
2643
-
2644
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2645
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2646
-	$values = array();
2647
-
2648
-	// d'abord avec celles de l'url
2649
-	if (false !== ($p = strpos($action, '?'))) {
2650
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2651
-			$c = explode('=', $c, 2);
2652
-			$var = array_shift($c);
2653
-			$val = array_shift($c);
2654
-			if ($var) {
2655
-				$val = rawurldecode($val);
2656
-				$var = rawurldecode($var); // decoder les [] eventuels
2657
-				if (preg_match(',\[\]$,S', $var)) {
2658
-					$values[] = array($var, $val);
2659
-				} else {
2660
-					if (!isset($values[$var])) {
2661
-						$values[$var] = array($var, $val);
2662
-					}
2663
-				}
2664
-			}
2665
-		}
2666
-	}
2667
-
2668
-	// ensuite avec celles du contexte, sans doublonner !
2669
-	foreach ($contexte as $var => $val) {
2670
-		if (preg_match(',\[\]$,S', $var)) {
2671
-			$values[] = array($var, $val);
2672
-		} else {
2673
-			if (!isset($values[$var])) {
2674
-				$values[$var] = array($var, $val);
2675
-			}
2676
-		}
2677
-	}
2678
-
2679
-	// puis on rassemble le tout
2680
-	$hidden = array();
2681
-	foreach ($values as $value) {
2682
-		list($var, $val) = $value;
2683
-		$hidden[] = '<input name="'
2684
-			. entites_html($var)
2685
-			. '"'
2686
-			. (is_null($val)
2687
-				? ''
2688
-				: ' value="' . entites_html($val) . '"'
2689
-			)
2690
-			. ' type="hidden"' . "\n/>";
2691
-	}
2692
-
2693
-	return join("", $hidden);
2624
+    $contexte = array();
2625
+    include_spip('inc/urls');
2626
+    if ($p = urls_decoder_url($action, '')
2627
+        and reset($p)
2628
+    ) {
2629
+        $fond = array_shift($p);
2630
+        if ($fond != '404') {
2631
+            $contexte = array_shift($p);
2632
+            $contexte['page'] = $fond;
2633
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2634
+        }
2635
+    }
2636
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2637
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2638
+        unset($contexte['type']);
2639
+    }
2640
+    if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2641
+        unset($contexte['type-page']);
2642
+    }
2643
+
2644
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2645
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2646
+    $values = array();
2647
+
2648
+    // d'abord avec celles de l'url
2649
+    if (false !== ($p = strpos($action, '?'))) {
2650
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2651
+            $c = explode('=', $c, 2);
2652
+            $var = array_shift($c);
2653
+            $val = array_shift($c);
2654
+            if ($var) {
2655
+                $val = rawurldecode($val);
2656
+                $var = rawurldecode($var); // decoder les [] eventuels
2657
+                if (preg_match(',\[\]$,S', $var)) {
2658
+                    $values[] = array($var, $val);
2659
+                } else {
2660
+                    if (!isset($values[$var])) {
2661
+                        $values[$var] = array($var, $val);
2662
+                    }
2663
+                }
2664
+            }
2665
+        }
2666
+    }
2667
+
2668
+    // ensuite avec celles du contexte, sans doublonner !
2669
+    foreach ($contexte as $var => $val) {
2670
+        if (preg_match(',\[\]$,S', $var)) {
2671
+            $values[] = array($var, $val);
2672
+        } else {
2673
+            if (!isset($values[$var])) {
2674
+                $values[$var] = array($var, $val);
2675
+            }
2676
+        }
2677
+    }
2678
+
2679
+    // puis on rassemble le tout
2680
+    $hidden = array();
2681
+    foreach ($values as $value) {
2682
+        list($var, $val) = $value;
2683
+        $hidden[] = '<input name="'
2684
+            . entites_html($var)
2685
+            . '"'
2686
+            . (is_null($val)
2687
+                ? ''
2688
+                : ' value="' . entites_html($val) . '"'
2689
+            )
2690
+            . ' type="hidden"' . "\n/>";
2691
+    }
2692
+
2693
+    return join("", $hidden);
2694 2694
 }
2695 2695
 
2696 2696
 /**
@@ -2708,15 +2708,15 @@  discard block
 block discarded – undo
2708 2708
  *     Liste (première page, dernière page).
2709 2709
  **/
2710 2710
 function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) {
2711
-	if ($max <= 0 or $max >= $nombre) {
2712
-		return array(1, $nombre);
2713
-	}
2711
+    if ($max <= 0 or $max >= $nombre) {
2712
+        return array(1, $nombre);
2713
+    }
2714 2714
 
2715
-	$premiere = max(1, $courante - floor(($max - 1) / 2));
2716
-	$derniere = min($nombre, $premiere + $max - 2);
2717
-	$premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2715
+    $premiere = max(1, $courante - floor(($max - 1) / 2));
2716
+    $derniere = min($nombre, $premiere + $max - 2);
2717
+    $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2718 2718
 
2719
-	return array($premiere, $derniere);
2719
+    return array($premiere, $derniere);
2720 2720
 }
2721 2721
 
2722 2722
 
@@ -2738,7 +2738,7 @@  discard block
 block discarded – undo
2738 2738
  *    - la première valeur du tableau sinon.
2739 2739
  **/
2740 2740
 function filtre_reset($array) {
2741
-	return !is_array($array) ? null : reset($array);
2741
+    return !is_array($array) ? null : reset($array);
2742 2742
 }
2743 2743
 
2744 2744
 /**
@@ -2759,7 +2759,7 @@  discard block
 block discarded – undo
2759 2759
  *    - la dernière valeur du tableau sinon.
2760 2760
  **/
2761 2761
 function filtre_end($array) {
2762
-	return !is_array($array) ? null : end($array);
2762
+    return !is_array($array) ? null : end($array);
2763 2763
 }
2764 2764
 
2765 2765
 /**
@@ -2779,11 +2779,11 @@  discard block
 block discarded – undo
2779 2779
  *
2780 2780
  **/
2781 2781
 function filtre_push($array, $val) {
2782
-	if (!is_array($array) or !array_push($array, $val)) {
2783
-		return '';
2784
-	}
2782
+    if (!is_array($array) or !array_push($array, $val)) {
2783
+        return '';
2784
+    }
2785 2785
 
2786
-	return $array;
2786
+    return $array;
2787 2787
 }
2788 2788
 
2789 2789
 /**
@@ -2802,7 +2802,7 @@  discard block
 block discarded – undo
2802 2802
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2803 2803
  **/
2804 2804
 function filtre_find($array, $val) {
2805
-	return (is_array($array) and in_array($val, $array));
2805
+    return (is_array($array) and in_array($val, $array));
2806 2806
 }
2807 2807
 
2808 2808
 
@@ -2819,15 +2819,15 @@  discard block
 block discarded – undo
2819 2819
  *     Contenu avec urls en absolus
2820 2820
  **/
2821 2821
 function urls_absolues_css($contenu, $source) {
2822
-	$path = suivre_lien(url_absolue($source), './');
2822
+    $path = suivre_lien(url_absolue($source), './');
2823 2823
 
2824
-	return preg_replace_callback(
2825
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2826
-		function($x) use ($path) {
2827
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2828
-		},
2829
-		$contenu
2830
-	);
2824
+    return preg_replace_callback(
2825
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2826
+        function($x) use ($path) {
2827
+            return "url('" . suivre_lien($path, $x[1]) . "')";
2828
+        },
2829
+        $contenu
2830
+    );
2831 2831
 }
2832 2832
 
2833 2833
 
@@ -2856,118 +2856,118 @@  discard block
 block discarded – undo
2856 2856
  *     Chemin du fichier CSS inversé
2857 2857
  **/
2858 2858
 function direction_css($css, $voulue = '') {
2859
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2860
-		return $css;
2861
-	}
2862
-
2863
-	// si on a precise le sens voulu en argument, le prendre en compte
2864
-	if ($voulue = strtolower($voulue)) {
2865
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2866
-			$voulue = lang_dir($voulue);
2867
-		}
2868
-	} else {
2869
-		$voulue = lang_dir();
2870
-	}
2871
-
2872
-	$r = count($r) > 1;
2873
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2874
-	$dir = $r ? 'rtl' : 'ltr';
2875
-	$ndir = $r ? 'ltr' : 'rtl';
2876
-
2877
-	if ($voulue == $dir) {
2878
-		return $css;
2879
-	}
2880
-
2881
-	if (
2882
-		// url absolue
2883
-		preg_match(",^https?:,i", $css)
2884
-		// ou qui contient un ?
2885
-		or (($p = strpos($css, '?')) !== false)
2886
-	) {
2887
-		$distant = true;
2888
-		$cssf = parse_url($css);
2889
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2890
-		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2891
-	} else {
2892
-		$distant = false;
2893
-		$cssf = $css;
2894
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2895
-		//propose (rien a faire dans ce cas)
2896
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2897
-		if (@file_exists($f)) {
2898
-			return $f;
2899
-		}
2900
-	}
2901
-
2902
-	// 2.
2903
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2904
-	$f = $dir_var
2905
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2906
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2907
-
2908
-	// la css peut etre distante (url absolue !)
2909
-	if ($distant) {
2910
-		include_spip('inc/distant');
2911
-		$res = recuperer_url($css);
2912
-		if (!$res or !$contenu = $res['page']) {
2913
-			return $css;
2914
-		}
2915
-	} else {
2916
-		if ((@filemtime($f) > @filemtime($css))
2917
-			and (_VAR_MODE != 'recalcul')
2918
-		) {
2919
-			return $f;
2920
-		}
2921
-		if (!lire_fichier($css, $contenu)) {
2922
-			return $css;
2923
-		}
2924
-	}
2925
-
2926
-
2927
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2928
-	include_spip("lib/csstidy/class.csstidy");
2929
-	$parser = new csstidy();
2930
-	$parser->set_cfg('optimise_shorthands', 0);
2931
-	$parser->set_cfg('reverse_left_and_right', true);
2932
-	$parser->parse($contenu);
2933
-
2934
-	$contenu = $parser->print->plain();
2935
-
2936
-
2937
-	// reperer les @import auxquels il faut propager le direction_css
2938
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2939
-	$src = array();
2940
-	$src_direction_css = array();
2941
-	$src_faux_abs = array();
2942
-	$d = dirname($css);
2943
-	foreach ($regs[1] as $k => $import_css) {
2944
-		$css_direction = direction_css("$d/$import_css", $voulue);
2945
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2946
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2947
-			$css_direction = substr($css_direction, strlen($d) + 1);
2948
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2949
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2950
-			$css_direction = substr($css_direction, strlen($dir_var));
2951
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2952
-			$css_direction = "/@@@@@@/" . $css_direction;
2953
-		}
2954
-		$src[] = $regs[0][$k];
2955
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2956
-	}
2957
-	$contenu = str_replace($src, $src_direction_css, $contenu);
2958
-
2959
-	$contenu = urls_absolues_css($contenu, $css);
2960
-
2961
-	// virer les fausses url absolues que l'on a mis dans les import
2962
-	if (count($src_faux_abs)) {
2963
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2964
-	}
2965
-
2966
-	if (!ecrire_fichier($f, $contenu)) {
2967
-		return $css;
2968
-	}
2969
-
2970
-	return $f;
2859
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2860
+        return $css;
2861
+    }
2862
+
2863
+    // si on a precise le sens voulu en argument, le prendre en compte
2864
+    if ($voulue = strtolower($voulue)) {
2865
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2866
+            $voulue = lang_dir($voulue);
2867
+        }
2868
+    } else {
2869
+        $voulue = lang_dir();
2870
+    }
2871
+
2872
+    $r = count($r) > 1;
2873
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2874
+    $dir = $r ? 'rtl' : 'ltr';
2875
+    $ndir = $r ? 'ltr' : 'rtl';
2876
+
2877
+    if ($voulue == $dir) {
2878
+        return $css;
2879
+    }
2880
+
2881
+    if (
2882
+        // url absolue
2883
+        preg_match(",^https?:,i", $css)
2884
+        // ou qui contient un ?
2885
+        or (($p = strpos($css, '?')) !== false)
2886
+    ) {
2887
+        $distant = true;
2888
+        $cssf = parse_url($css);
2889
+        $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2890
+        $cssf = preg_replace(',[?:&=],', "_", $cssf);
2891
+    } else {
2892
+        $distant = false;
2893
+        $cssf = $css;
2894
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2895
+        //propose (rien a faire dans ce cas)
2896
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2897
+        if (@file_exists($f)) {
2898
+            return $f;
2899
+        }
2900
+    }
2901
+
2902
+    // 2.
2903
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2904
+    $f = $dir_var
2905
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2906
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2907
+
2908
+    // la css peut etre distante (url absolue !)
2909
+    if ($distant) {
2910
+        include_spip('inc/distant');
2911
+        $res = recuperer_url($css);
2912
+        if (!$res or !$contenu = $res['page']) {
2913
+            return $css;
2914
+        }
2915
+    } else {
2916
+        if ((@filemtime($f) > @filemtime($css))
2917
+            and (_VAR_MODE != 'recalcul')
2918
+        ) {
2919
+            return $f;
2920
+        }
2921
+        if (!lire_fichier($css, $contenu)) {
2922
+            return $css;
2923
+        }
2924
+    }
2925
+
2926
+
2927
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2928
+    include_spip("lib/csstidy/class.csstidy");
2929
+    $parser = new csstidy();
2930
+    $parser->set_cfg('optimise_shorthands', 0);
2931
+    $parser->set_cfg('reverse_left_and_right', true);
2932
+    $parser->parse($contenu);
2933
+
2934
+    $contenu = $parser->print->plain();
2935
+
2936
+
2937
+    // reperer les @import auxquels il faut propager le direction_css
2938
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2939
+    $src = array();
2940
+    $src_direction_css = array();
2941
+    $src_faux_abs = array();
2942
+    $d = dirname($css);
2943
+    foreach ($regs[1] as $k => $import_css) {
2944
+        $css_direction = direction_css("$d/$import_css", $voulue);
2945
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2946
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2947
+            $css_direction = substr($css_direction, strlen($d) + 1);
2948
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2949
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2950
+            $css_direction = substr($css_direction, strlen($dir_var));
2951
+            $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2952
+            $css_direction = "/@@@@@@/" . $css_direction;
2953
+        }
2954
+        $src[] = $regs[0][$k];
2955
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2956
+    }
2957
+    $contenu = str_replace($src, $src_direction_css, $contenu);
2958
+
2959
+    $contenu = urls_absolues_css($contenu, $css);
2960
+
2961
+    // virer les fausses url absolues que l'on a mis dans les import
2962
+    if (count($src_faux_abs)) {
2963
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2964
+    }
2965
+
2966
+    if (!ecrire_fichier($f, $contenu)) {
2967
+        return $css;
2968
+    }
2969
+
2970
+    return $f;
2971 2971
 }
2972 2972
 
2973 2973
 
@@ -2990,43 +2990,43 @@  discard block
 block discarded – undo
2990 2990
  *     - Chemin ou URL du fichier CSS source sinon.
2991 2991
  **/
2992 2992
 function url_absolue_css($css) {
2993
-	if (!preg_match(',\.css$,i', $css, $r)) {
2994
-		return $css;
2995
-	}
2993
+    if (!preg_match(',\.css$,i', $css, $r)) {
2994
+        return $css;
2995
+    }
2996 2996
 
2997
-	$url_absolue_css = url_absolue($css);
2997
+    $url_absolue_css = url_absolue($css);
2998 2998
 
2999
-	$f = basename($css, '.css');
3000
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3001
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3002
-		. '.css';
2999
+    $f = basename($css, '.css');
3000
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3001
+        . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3002
+        . '.css';
3003 3003
 
3004
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3005
-		return $f;
3006
-	}
3004
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3005
+        return $f;
3006
+    }
3007 3007
 
3008
-	if ($url_absolue_css == $css) {
3009
-		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3010
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3011
-		) {
3012
-			include_spip('inc/distant');
3013
-			if (!$contenu = recuperer_page($css)) {
3014
-				return $css;
3015
-			}
3016
-		}
3017
-	} elseif (!lire_fichier($css, $contenu)) {
3018
-		return $css;
3019
-	}
3008
+    if ($url_absolue_css == $css) {
3009
+        if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3010
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3011
+        ) {
3012
+            include_spip('inc/distant');
3013
+            if (!$contenu = recuperer_page($css)) {
3014
+                return $css;
3015
+            }
3016
+        }
3017
+    } elseif (!lire_fichier($css, $contenu)) {
3018
+        return $css;
3019
+    }
3020 3020
 
3021
-	// passer les url relatives a la css d'origine en url absolues
3022
-	$contenu = urls_absolues_css($contenu, $css);
3021
+    // passer les url relatives a la css d'origine en url absolues
3022
+    $contenu = urls_absolues_css($contenu, $css);
3023 3023
 
3024
-	// ecrire la css
3025
-	if (!ecrire_fichier($f, $contenu)) {
3026
-		return $css;
3027
-	}
3024
+    // ecrire la css
3025
+    if (!ecrire_fichier($f, $contenu)) {
3026
+        return $css;
3027
+    }
3028 3028
 
3029
-	return $f;
3029
+    return $f;
3030 3030
 }
3031 3031
 
3032 3032
 
@@ -3060,24 +3060,24 @@  discard block
 block discarded – undo
3060 3060
  *     Valeur trouvée ou valeur par défaut.
3061 3061
  **/
3062 3062
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3063
-	foreach (explode('/', $cle) as $k) {
3063
+    foreach (explode('/', $cle) as $k) {
3064 3064
 
3065
-		$table = is_string($table) ? @unserialize($table) : $table;
3065
+        $table = is_string($table) ? @unserialize($table) : $table;
3066 3066
 
3067
-		if (is_object($table)) {
3068
-			$table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3069
-		} elseif (is_array($table)) {
3070
-			if ($conserver_null) {
3071
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3072
-			} else {
3073
-				$table = isset($table[$k]) ? $table[$k] : $defaut;
3074
-			}
3075
-		} else {
3076
-			$table = $defaut;
3077
-		}
3078
-	}
3067
+        if (is_object($table)) {
3068
+            $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3069
+        } elseif (is_array($table)) {
3070
+            if ($conserver_null) {
3071
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3072
+            } else {
3073
+                $table = isset($table[$k]) ? $table[$k] : $defaut;
3074
+            }
3075
+        } else {
3076
+            $table = $defaut;
3077
+        }
3078
+    }
3079 3079
 
3080
-	return $table;
3080
+    return $table;
3081 3081
 }
3082 3082
 
3083 3083
 /**
@@ -3110,22 +3110,22 @@  discard block
 block discarded – undo
3110 3110
  *     - string : expression trouvée.
3111 3111
  **/
3112 3112
 function filtre_match_dist($texte, $expression, $modif = "UimsS", $capte = 0) {
3113
-	if (intval($modif) and $capte == 0) {
3114
-		$capte = $modif;
3115
-		$modif = "UimsS";
3116
-	}
3117
-	$expression = str_replace("\/", "/", $expression);
3118
-	$expression = str_replace("/", "\/", $expression);
3113
+    if (intval($modif) and $capte == 0) {
3114
+        $capte = $modif;
3115
+        $modif = "UimsS";
3116
+    }
3117
+    $expression = str_replace("\/", "/", $expression);
3118
+    $expression = str_replace("/", "\/", $expression);
3119 3119
 
3120
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3121
-		if (isset($r[$capte])) {
3122
-			return $r[$capte];
3123
-		} else {
3124
-			return true;
3125
-		}
3126
-	}
3120
+    if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3121
+        if (isset($r[$capte])) {
3122
+            return $r[$capte];
3123
+        } else {
3124
+            return true;
3125
+        }
3126
+    }
3127 3127
 
3128
-	return false;
3128
+    return false;
3129 3129
 }
3130 3130
 
3131 3131
 
@@ -3152,10 +3152,10 @@  discard block
 block discarded – undo
3152 3152
  *     Texte
3153 3153
  **/
3154 3154
 function replace($texte, $expression, $replace = '', $modif = "UimsS") {
3155
-	$expression = str_replace("\/", "/", $expression);
3156
-	$expression = str_replace("/", "\/", $expression);
3155
+    $expression = str_replace("\/", "/", $expression);
3156
+    $expression = str_replace("/", "\/", $expression);
3157 3157
 
3158
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3158
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3159 3159
 }
3160 3160
 
3161 3161
 
@@ -3173,21 +3173,21 @@  discard block
 block discarded – undo
3173 3173
  **/
3174 3174
 function traiter_doublons_documents(&$doublons, $letexte) {
3175 3175
 
3176
-	// Verifier dans le texte & les notes (pas beau, helas)
3177
-	$t = $letexte . $GLOBALS['les_notes'];
3176
+    // Verifier dans le texte & les notes (pas beau, helas)
3177
+    $t = $letexte . $GLOBALS['les_notes'];
3178 3178
 
3179
-	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3180
-		and preg_match_all(
3181
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3182
-			$t, $matches, PREG_PATTERN_ORDER)
3183
-	) {
3184
-		if (!isset($doublons['documents'])) {
3185
-			$doublons['documents'] = "";
3186
-		}
3187
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3188
-	}
3179
+    if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3180
+        and preg_match_all(
3181
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3182
+            $t, $matches, PREG_PATTERN_ORDER)
3183
+    ) {
3184
+        if (!isset($doublons['documents'])) {
3185
+            $doublons['documents'] = "";
3186
+        }
3187
+        $doublons['documents'] .= "," . join(',', $matches[1]);
3188
+    }
3189 3189
 
3190
-	return $letexte;
3190
+    return $letexte;
3191 3191
 }
3192 3192
 
3193 3193
 /**
@@ -3201,7 +3201,7 @@  discard block
 block discarded – undo
3201 3201
  * @return string Chaîne vide
3202 3202
  **/
3203 3203
 function vide($texte) {
3204
-	return "";
3204
+    return "";
3205 3205
 }
3206 3206
 
3207 3207
 //
@@ -3230,23 +3230,23 @@  discard block
 block discarded – undo
3230 3230
  *      Code HTML résultant
3231 3231
  **/
3232 3232
 function env_to_params($env, $ignore_params = array()) {
3233
-	$ignore_params = array_merge(
3234
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3235
-		$ignore_params
3236
-	);
3237
-	if (!is_array($env)) {
3238
-		$env = unserialize($env);
3239
-	}
3240
-	$texte = "";
3241
-	if ($env) {
3242
-		foreach ($env as $i => $j) {
3243
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3244
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3245
-			}
3246
-		}
3247
-	}
3248
-
3249
-	return $texte;
3233
+    $ignore_params = array_merge(
3234
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3235
+        $ignore_params
3236
+    );
3237
+    if (!is_array($env)) {
3238
+        $env = unserialize($env);
3239
+    }
3240
+    $texte = "";
3241
+    if ($env) {
3242
+        foreach ($env as $i => $j) {
3243
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3244
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3245
+            }
3246
+        }
3247
+    }
3248
+
3249
+    return $texte;
3250 3250
 }
3251 3251
 
3252 3252
 /**
@@ -3269,23 +3269,23 @@  discard block
 block discarded – undo
3269 3269
  *      Code HTML résultant
3270 3270
  **/
3271 3271
 function env_to_attributs($env, $ignore_params = array()) {
3272
-	$ignore_params = array_merge(
3273
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3274
-		$ignore_params
3275
-	);
3276
-	if (!is_array($env)) {
3277
-		$env = unserialize($env);
3278
-	}
3279
-	$texte = "";
3280
-	if ($env) {
3281
-		foreach ($env as $i => $j) {
3282
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3283
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3284
-			}
3285
-		}
3286
-	}
3272
+    $ignore_params = array_merge(
3273
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3274
+        $ignore_params
3275
+    );
3276
+    if (!is_array($env)) {
3277
+        $env = unserialize($env);
3278
+    }
3279
+    $texte = "";
3280
+    if ($env) {
3281
+        foreach ($env as $i => $j) {
3282
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3283
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3284
+            }
3285
+        }
3286
+    }
3287 3287
 
3288
-	return $texte;
3288
+    return $texte;
3289 3289
 }
3290 3290
 
3291 3291
 
@@ -3302,9 +3302,9 @@  discard block
 block discarded – undo
3302 3302
  * @return string Chaînes concaténés
3303 3303
  **/
3304 3304
 function concat() {
3305
-	$args = func_get_args();
3305
+    $args = func_get_args();
3306 3306
 
3307
-	return join('', $args);
3307
+    return join('', $args);
3308 3308
 }
3309 3309
 
3310 3310
 
@@ -3324,23 +3324,23 @@  discard block
 block discarded – undo
3324 3324
  *     Contenu du ou des fichiers, concaténé
3325 3325
  **/
3326 3326
 function charge_scripts($files, $script = true) {
3327
-	$flux = "";
3328
-	foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3329
-		if (!is_string($file)) {
3330
-			continue;
3331
-		}
3332
-		if ($script) {
3333
-			$file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3334
-		}
3335
-		if ($file) {
3336
-			$path = find_in_path($file);
3337
-			if ($path) {
3338
-				$flux .= spip_file_get_contents($path);
3339
-			}
3340
-		}
3341
-	}
3327
+    $flux = "";
3328
+    foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3329
+        if (!is_string($file)) {
3330
+            continue;
3331
+        }
3332
+        if ($script) {
3333
+            $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3334
+        }
3335
+        if ($file) {
3336
+            $path = find_in_path($file);
3337
+            if ($path) {
3338
+                $flux .= spip_file_get_contents($path);
3339
+            }
3340
+        }
3341
+    }
3342 3342
 
3343
-	return $flux;
3343
+    return $flux;
3344 3344
 }
3345 3345
 
3346 3346
 
@@ -3362,64 +3362,64 @@  discard block
 block discarded – undo
3362 3362
  */
3363 3363
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) {
3364 3364
 
3365
-	$img_file = $img;
3366
-	if ($p = strpos($img_file, '?')) {
3367
-		$img_file = substr($img_file,0, $p);
3368
-	}
3369
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3370
-		$img_file = chemin_image($img);
3371
-	}
3372
-	else {
3373
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3374
-			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3375
-			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3376
-			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3377
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3378
-			  and file_exists($variante_svg_generique)) {
3379
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3380
-					$img_file = $variante_svg_size;
3381
-				}
3382
-				else {
3383
-					$img_file = $variante_svg_generique;
3384
-				}
3385
-			}
3386
-		}
3387
-	}
3388
-	if (stripos($atts, 'width') === false) {
3389
-		// utiliser directement l'info de taille presente dans le nom
3390
-		if ((!isset($options['utiliser_suffixe_size'])
3391
-				or $options['utiliser_suffixe_size'] == true
3392
-			  or strpos($img_file, '-xx.svg') !== false)
3393
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3394
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3395
-		) {
3396
-			$largeur = $hauteur = intval($regs[1]);
3397
-		} else {
3398
-			$taille = taille_image($img_file);
3399
-			list($hauteur, $largeur) = $taille;
3400
-			if (!$hauteur or !$largeur) {
3401
-				return "";
3402
-			}
3403
-		}
3404
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3405
-	}
3406
-
3407
-	if (file_exists($img_file)) {
3408
-		$img_file = timestamp($img_file);
3409
-	}
3410
-	if ($alt === false) {
3411
-		$alt = '';
3412
-	}
3413
-	elseif($alt or $alt==='') {
3414
-		$alt = " alt='".attribut_html($alt)."'";
3415
-	}
3416
-	else {
3417
-		$alt = " alt='".attribut_html($title)."'";
3418
-	}
3419
-	return "<img src='$img_file'$alt"
3420
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3421
-	. " " . ltrim($atts)
3422
-	. " />";
3365
+    $img_file = $img;
3366
+    if ($p = strpos($img_file, '?')) {
3367
+        $img_file = substr($img_file,0, $p);
3368
+    }
3369
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3370
+        $img_file = chemin_image($img);
3371
+    }
3372
+    else {
3373
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3374
+            // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3375
+            // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3376
+            if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3377
+              and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3378
+              and file_exists($variante_svg_generique)) {
3379
+                if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3380
+                    $img_file = $variante_svg_size;
3381
+                }
3382
+                else {
3383
+                    $img_file = $variante_svg_generique;
3384
+                }
3385
+            }
3386
+        }
3387
+    }
3388
+    if (stripos($atts, 'width') === false) {
3389
+        // utiliser directement l'info de taille presente dans le nom
3390
+        if ((!isset($options['utiliser_suffixe_size'])
3391
+                or $options['utiliser_suffixe_size'] == true
3392
+              or strpos($img_file, '-xx.svg') !== false)
3393
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3394
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3395
+        ) {
3396
+            $largeur = $hauteur = intval($regs[1]);
3397
+        } else {
3398
+            $taille = taille_image($img_file);
3399
+            list($hauteur, $largeur) = $taille;
3400
+            if (!$hauteur or !$largeur) {
3401
+                return "";
3402
+            }
3403
+        }
3404
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3405
+    }
3406
+
3407
+    if (file_exists($img_file)) {
3408
+        $img_file = timestamp($img_file);
3409
+    }
3410
+    if ($alt === false) {
3411
+        $alt = '';
3412
+    }
3413
+    elseif($alt or $alt==='') {
3414
+        $alt = " alt='".attribut_html($alt)."'";
3415
+    }
3416
+    else {
3417
+        $alt = " alt='".attribut_html($title)."'";
3418
+    }
3419
+    return "<img src='$img_file'$alt"
3420
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3421
+    . " " . ltrim($atts)
3422
+    . " />";
3423 3423
 }
3424 3424
 
3425 3425
 /**
@@ -3431,13 +3431,13 @@  discard block
 block discarded – undo
3431 3431
  * @return string
3432 3432
  */
3433 3433
 function http_style_background($img, $att = '', $size=null) {
3434
-	if ($size and is_numeric($size)){
3435
-		$size = trim($size) . "px";
3436
-	}
3437
-	return " style='background" .
3438
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3439
-		. ($size ? "background-size:{$size};" : '')
3440
-		. "'";
3434
+    if ($size and is_numeric($size)){
3435
+        $size = trim($size) . "px";
3436
+    }
3437
+    return " style='background" .
3438
+        ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3439
+        . ($size ? "background-size:{$size};" : '')
3440
+        . "'";
3441 3441
 }
3442 3442
 
3443 3443
 /**
@@ -3453,17 +3453,17 @@  discard block
 block discarded – undo
3453 3453
  *     Code HTML de la balise IMG
3454 3454
  */
3455 3455
 function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3456
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3457
-	// ecriture courte : on donne le width en 2e arg
3458
-	if (empty($width) and is_numeric($alt)) {
3459
-		$width = $alt;
3460
-		$alt = '';
3461
-	}
3462
-	if ($width) {
3463
-		$atts .= " width='{$width}'";
3464
-	}
3465
-	return http_img_pack($img, $alt, $atts, '',
3466
-		array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3456
+    $atts = $class ? " class='" . attribut_html($class) . "'" : '';
3457
+    // ecriture courte : on donne le width en 2e arg
3458
+    if (empty($width) and is_numeric($alt)) {
3459
+        $width = $alt;
3460
+        $alt = '';
3461
+    }
3462
+    if ($width) {
3463
+        $atts .= " width='{$width}'";
3464
+    }
3465
+    return http_img_pack($img, $alt, $atts, '',
3466
+        array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3467 3467
 }
3468 3468
 
3469 3469
 
@@ -3479,42 +3479,42 @@  discard block
 block discarded – undo
3479 3479
  * @return string
3480 3480
  */
3481 3481
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3482
-	$img_file = $img;
3483
-	if ($p = strpos($img_file, '?')) {
3484
-		$img_file = substr($img_file,0, $p);
3485
-	}
3482
+    $img_file = $img;
3483
+    if ($p = strpos($img_file, '?')) {
3484
+        $img_file = substr($img_file,0, $p);
3485
+    }
3486 3486
 
3487
-	if (!$img_file or !$svg = file_get_contents($img_file)) {
3488
-		return '';
3489
-	}
3487
+    if (!$img_file or !$svg = file_get_contents($img_file)) {
3488
+        return '';
3489
+    }
3490 3490
 
3491
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3492
-		return '';
3493
-	}
3494
-	$balise_svg = $match[0];
3495
-	$balise_svg_source = $balise_svg;
3491
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3492
+        return '';
3493
+    }
3494
+    $balise_svg = $match[0];
3495
+    $balise_svg_source = $balise_svg;
3496 3496
 
3497
-	// entete XML à supprimer
3498
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3497
+    // entete XML à supprimer
3498
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3499 3499
 
3500
-	// IE est toujours mon ami
3501
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3502
-	if ($class) {
3503
-		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3504
-	}
3505
-	if ($alt){
3506
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3507
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3508
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3509
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3510
-		$balise_svg .= $title;
3511
-	}
3512
-	else {
3513
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3514
-	}
3515
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3500
+    // IE est toujours mon ami
3501
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3502
+    if ($class) {
3503
+        $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3504
+    }
3505
+    if ($alt){
3506
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3507
+        $id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3508
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3509
+        $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3510
+        $balise_svg .= $title;
3511
+    }
3512
+    else {
3513
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3514
+    }
3515
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3516 3516
 
3517
-	return $svg;
3517
+    return $svg;
3518 3518
 }
3519 3519
 
3520 3520
 
@@ -3537,17 +3537,17 @@  discard block
 block discarded – undo
3537 3537
  *     Code HTML résultant
3538 3538
  **/
3539 3539
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3540
-	$texte = '';
3541
-	if (is_array($tableau)) {
3542
-		foreach ($tableau as $k => $v) {
3543
-			$res = recuperer_fond('modeles/' . $modele,
3544
-				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3545
-			);
3546
-			$texte .= $res;
3547
-		}
3548
-	}
3540
+    $texte = '';
3541
+    if (is_array($tableau)) {
3542
+        foreach ($tableau as $k => $v) {
3543
+            $res = recuperer_fond('modeles/' . $modele,
3544
+                array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3545
+            );
3546
+            $texte .= $res;
3547
+        }
3548
+    }
3549 3549
 
3550
-	return $texte;
3550
+    return $texte;
3551 3551
 }
3552 3552
 
3553 3553
 
@@ -3572,37 +3572,37 @@  discard block
 block discarded – undo
3572 3572
  *         - tout : retourne toutes les informations du plugin actif
3573 3573
  **/
3574 3574
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3575
-	include_spip('inc/plugin');
3576
-	$plugin = strtoupper($plugin);
3577
-	$plugins_actifs = liste_plugin_actifs();
3578
-
3579
-	if (!$plugin) {
3580
-		return serialize(array_keys($plugins_actifs));
3581
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3582
-		return '';
3583
-	} elseif (($type_info == 'est_actif') and !$reload) {
3584
-		return $plugins_actifs[$plugin] ? 1 : 0;
3585
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3586
-		return $plugins_actifs[$plugin][$type_info];
3587
-	} else {
3588
-		$get_infos = charger_fonction('get_infos', 'plugins');
3589
-		// On prend en compte les extensions
3590
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3591
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3592
-		} else {
3593
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3594
-		}
3595
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3596
-			return '';
3597
-		}
3598
-		if ($type_info == 'tout') {
3599
-			return $infos;
3600
-		} elseif ($type_info == 'est_actif') {
3601
-			return $infos ? 1 : 0;
3602
-		} else {
3603
-			return strval($infos[$type_info]);
3604
-		}
3605
-	}
3575
+    include_spip('inc/plugin');
3576
+    $plugin = strtoupper($plugin);
3577
+    $plugins_actifs = liste_plugin_actifs();
3578
+
3579
+    if (!$plugin) {
3580
+        return serialize(array_keys($plugins_actifs));
3581
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3582
+        return '';
3583
+    } elseif (($type_info == 'est_actif') and !$reload) {
3584
+        return $plugins_actifs[$plugin] ? 1 : 0;
3585
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3586
+        return $plugins_actifs[$plugin][$type_info];
3587
+    } else {
3588
+        $get_infos = charger_fonction('get_infos', 'plugins');
3589
+        // On prend en compte les extensions
3590
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3591
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3592
+        } else {
3593
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3594
+        }
3595
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3596
+            return '';
3597
+        }
3598
+        if ($type_info == 'tout') {
3599
+            return $infos;
3600
+        } elseif ($type_info == 'est_actif') {
3601
+            return $infos ? 1 : 0;
3602
+        } else {
3603
+            return strval($infos[$type_info]);
3604
+        }
3605
+    }
3606 3606
 }
3607 3607
 
3608 3608
 
@@ -3629,9 +3629,9 @@  discard block
 block discarded – undo
3629 3629
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3630 3630
  */
3631 3631
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3632
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3632
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3633 3633
 
3634
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3634
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3635 3635
 }
3636 3636
 
3637 3637
 
@@ -3661,13 +3661,13 @@  discard block
 block discarded – undo
3661 3661
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3662 3662
  */
3663 3663
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3664
-	static $puce_statut = null;
3665
-	if (!$puce_statut) {
3666
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3667
-	}
3664
+    static $puce_statut = null;
3665
+    if (!$puce_statut) {
3666
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3667
+    }
3668 3668
 
3669
-	return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3670
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3669
+    return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3670
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3671 3671
 }
3672 3672
 
3673 3673
 
@@ -3694,100 +3694,100 @@  discard block
 block discarded – undo
3694 3694
  *   hash du contexte
3695 3695
  */
3696 3696
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3697
-	if (is_string($c)
3698
-		and @unserialize($c) !== false
3699
-	) {
3700
-		$c = unserialize($c);
3701
-	}
3702
-
3703
-	// supprimer les parametres debut_x
3704
-	// pour que la pagination ajax ne soit pas plantee
3705
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3706
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3707
-	if (is_array($c)) {
3708
-		foreach ($c as $k => $v) {
3709
-			if (strpos($k, 'debut_') === 0) {
3710
-				unset($c[$k]);
3711
-			}
3712
-		}
3713
-	}
3714
-
3715
-	if (!function_exists('calculer_cle_action')) {
3716
-		include_spip("inc/securiser_action");
3717
-	}
3718
-
3719
-	$c = serialize($c);
3720
-	$cle = calculer_cle_action($form . $c);
3721
-	$c = "$cle:$c";
3722
-
3723
-	// on ne stocke pas les contextes dans des fichiers en cache
3724
-	// par defaut, sauf si cette configuration a été forcée
3725
-	// OU que la longueur de l’argument géneré est plus long
3726
-	// que ce qui est toléré.
3727
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3728
-	if (!$cache_contextes_ajax) {
3729
-		$env = $c;
3730
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3731
-			$env = gzdeflate($env);
3732
-			// https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3733
-			if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3734
-				$cache_contextes_ajax = true;
3735
-				spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3736
-			}
3737
-		}
3738
-		$env = _xor($env);
3739
-		$env = base64_encode($env);
3740
-		$len = strlen($env);
3741
-		// Si l’url est trop longue pour le navigateur
3742
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3743
-		if ($len > $max_len) {
3744
-			$cache_contextes_ajax = true;
3745
-			spip_log("Contextes AJAX forces en fichiers !"
3746
-				. " Cela arrive lorsque la valeur du contexte" 
3747
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3748
-				, _LOG_AVERTISSEMENT);
3749
-		}
3750
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3751
-		elseif (
3752
-			$max_len = @ini_get('suhosin.get.max_value_length')
3753
-			and $max_len < $len
3754
-		) {
3755
-			$cache_contextes_ajax = true;
3756
-			spip_log("Contextes AJAX forces en fichiers !"
3757
-				. " Cela arrive lorsque la valeur du contexte"
3758
-				. " depasse la longueur maximale autorisee par Suhosin"
3759
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3760
-				. " Vous devriez modifier les parametres de Suhosin"
3761
-				. " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3762
-		} 
3763
-
3764
-	}
3765
-
3766
-	if ($cache_contextes_ajax) {
3767
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3768
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3769
-		$md5 = md5($c);
3770
-		ecrire_fichier("$dir/c$md5", $c);
3771
-		$env = $md5;
3772
-	}
3773
-
3774
-	if ($emboite === null) {
3775
-		return $env;
3776
-	}
3777
-	if (!trim($emboite)) {
3778
-		return "";
3779
-	}
3780
-	// toujours encoder l'url source dans le bloc ajax
3781
-	$r = self();
3782
-	$r = ' data-origin="' . $r . '"';
3783
-	$class = 'ajaxbloc';
3784
-	if ($ajaxid and is_string($ajaxid)) {
3785
-		// ajaxid est normalement conforme a un nom de classe css
3786
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3787
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3788
-	}
3789
-
3790
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3697
+    if (is_string($c)
3698
+        and @unserialize($c) !== false
3699
+    ) {
3700
+        $c = unserialize($c);
3701
+    }
3702
+
3703
+    // supprimer les parametres debut_x
3704
+    // pour que la pagination ajax ne soit pas plantee
3705
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3706
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3707
+    if (is_array($c)) {
3708
+        foreach ($c as $k => $v) {
3709
+            if (strpos($k, 'debut_') === 0) {
3710
+                unset($c[$k]);
3711
+            }
3712
+        }
3713
+    }
3714
+
3715
+    if (!function_exists('calculer_cle_action')) {
3716
+        include_spip("inc/securiser_action");
3717
+    }
3718
+
3719
+    $c = serialize($c);
3720
+    $cle = calculer_cle_action($form . $c);
3721
+    $c = "$cle:$c";
3722
+
3723
+    // on ne stocke pas les contextes dans des fichiers en cache
3724
+    // par defaut, sauf si cette configuration a été forcée
3725
+    // OU que la longueur de l’argument géneré est plus long
3726
+    // que ce qui est toléré.
3727
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3728
+    if (!$cache_contextes_ajax) {
3729
+        $env = $c;
3730
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3731
+            $env = gzdeflate($env);
3732
+            // https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3733
+            if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3734
+                $cache_contextes_ajax = true;
3735
+                spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3736
+            }
3737
+        }
3738
+        $env = _xor($env);
3739
+        $env = base64_encode($env);
3740
+        $len = strlen($env);
3741
+        // Si l’url est trop longue pour le navigateur
3742
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3743
+        if ($len > $max_len) {
3744
+            $cache_contextes_ajax = true;
3745
+            spip_log("Contextes AJAX forces en fichiers !"
3746
+                . " Cela arrive lorsque la valeur du contexte" 
3747
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3748
+                , _LOG_AVERTISSEMENT);
3749
+        }
3750
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3751
+        elseif (
3752
+            $max_len = @ini_get('suhosin.get.max_value_length')
3753
+            and $max_len < $len
3754
+        ) {
3755
+            $cache_contextes_ajax = true;
3756
+            spip_log("Contextes AJAX forces en fichiers !"
3757
+                . " Cela arrive lorsque la valeur du contexte"
3758
+                . " depasse la longueur maximale autorisee par Suhosin"
3759
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3760
+                . " Vous devriez modifier les parametres de Suhosin"
3761
+                . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3762
+        } 
3763
+
3764
+    }
3765
+
3766
+    if ($cache_contextes_ajax) {
3767
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3768
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3769
+        $md5 = md5($c);
3770
+        ecrire_fichier("$dir/c$md5", $c);
3771
+        $env = $md5;
3772
+    }
3773
+
3774
+    if ($emboite === null) {
3775
+        return $env;
3776
+    }
3777
+    if (!trim($emboite)) {
3778
+        return "";
3779
+    }
3780
+    // toujours encoder l'url source dans le bloc ajax
3781
+    $r = self();
3782
+    $r = ' data-origin="' . $r . '"';
3783
+    $class = 'ajaxbloc';
3784
+    if ($ajaxid and is_string($ajaxid)) {
3785
+        // ajaxid est normalement conforme a un nom de classe css
3786
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3787
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3788
+    }
3789
+
3790
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3791 3791
 }
3792 3792
 
3793 3793
 /**
@@ -3807,36 +3807,36 @@  discard block
 block discarded – undo
3807 3807
  *   - false : erreur de décodage
3808 3808
  */
3809 3809
 function decoder_contexte_ajax($c, $form = '') {
3810
-	if (!function_exists('calculer_cle_action')) {
3811
-		include_spip("inc/securiser_action");
3812
-	}
3813
-	if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3814
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3815
-		and lire_fichier("$dir/c$c", $contexte)
3816
-	) {
3817
-		$c = $contexte;
3818
-	} else {
3819
-		$c = @base64_decode($c);
3820
-		$c = _xor($c);
3821
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3822
-			$c = @gzinflate($c);
3823
-		}
3824
-	}
3825
-
3826
-	// extraire la signature en debut de contexte
3827
-	// et la verifier avant de deserializer
3828
-	// format : signature:donneesserializees
3829
-	if ($p = strpos($c,":")){
3830
-		$cle = substr($c,0,$p);
3831
-		$c = substr($c,$p+1);
3832
-
3833
-		if ($cle == calculer_cle_action($form . $c)) {
3834
-			$env = @unserialize($c);
3835
-			return $env;
3836
-		}
3837
-	}
3838
-
3839
-	return false;
3810
+    if (!function_exists('calculer_cle_action')) {
3811
+        include_spip("inc/securiser_action");
3812
+    }
3813
+    if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3814
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3815
+        and lire_fichier("$dir/c$c", $contexte)
3816
+    ) {
3817
+        $c = $contexte;
3818
+    } else {
3819
+        $c = @base64_decode($c);
3820
+        $c = _xor($c);
3821
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3822
+            $c = @gzinflate($c);
3823
+        }
3824
+    }
3825
+
3826
+    // extraire la signature en debut de contexte
3827
+    // et la verifier avant de deserializer
3828
+    // format : signature:donneesserializees
3829
+    if ($p = strpos($c,":")){
3830
+        $cle = substr($c,0,$p);
3831
+        $c = substr($c,$p+1);
3832
+
3833
+        if ($cle == calculer_cle_action($form . $c)) {
3834
+            $env = @unserialize($c);
3835
+            return $env;
3836
+        }
3837
+    }
3838
+
3839
+    return false;
3840 3840
 }
3841 3841
 
3842 3842
 
@@ -3854,20 +3854,20 @@  discard block
 block discarded – undo
3854 3854
  *    Message décrypté ou encrypté
3855 3855
  **/
3856 3856
 function _xor($message, $key = null) {
3857
-	if (is_null($key)) {
3858
-		if (!function_exists('calculer_cle_action')) {
3859
-			include_spip("inc/securiser_action");
3860
-		}
3861
-		$key = pack("H*", calculer_cle_action('_xor'));
3862
-	}
3857
+    if (is_null($key)) {
3858
+        if (!function_exists('calculer_cle_action')) {
3859
+            include_spip("inc/securiser_action");
3860
+        }
3861
+        $key = pack("H*", calculer_cle_action('_xor'));
3862
+    }
3863 3863
 
3864
-	$keylen = strlen($key);
3865
-	$messagelen = strlen($message);
3866
-	for ($i = 0; $i < $messagelen; $i++) {
3867
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3868
-	}
3864
+    $keylen = strlen($key);
3865
+    $messagelen = strlen($message);
3866
+    for ($i = 0; $i < $messagelen; $i++) {
3867
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3868
+    }
3869 3869
 
3870
-	return $message;
3870
+    return $message;
3871 3871
 }
3872 3872
 
3873 3873
 /**
@@ -3925,22 +3925,22 @@  discard block
 block discarded – undo
3925 3925
  *   Code HTML
3926 3926
  */
3927 3927
 function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') {
3928
-	if ($on) {
3929
-		$bal = "strong";
3930
-		$att = "class='on'";
3931
-	} else {
3932
-		$bal = 'a';
3933
-		$att = "href='$url'"
3934
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3935
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3936
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3937
-			. $evt;
3938
-	}
3939
-	if ($libelle === null) {
3940
-		$libelle = $url;
3941
-	}
3928
+    if ($on) {
3929
+        $bal = "strong";
3930
+        $att = "class='on'";
3931
+    } else {
3932
+        $bal = 'a';
3933
+        $att = "href='$url'"
3934
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
3935
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
3936
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3937
+            . $evt;
3938
+    }
3939
+    if ($libelle === null) {
3940
+        $libelle = $url;
3941
+    }
3942 3942
 
3943
-	return "<$bal $att>$libelle</$bal>";
3943
+    return "<$bal $att>$libelle</$bal>";
3944 3944
 }
3945 3945
 
3946 3946
 
@@ -3957,37 +3957,37 @@  discard block
 block discarded – undo
3957 3957
  * @return string : la chaine de langue finale en utilisant la fonction _T()
3958 3958
  */
3959 3959
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) {
3960
-	static $local_singulier_ou_pluriel = array();
3960
+    static $local_singulier_ou_pluriel = array();
3961 3961
 
3962
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
3963
-	if (!is_numeric($nb) or $nb == 0) {
3964
-		return "";
3965
-	}
3966
-	if (!is_array($vars)) {
3967
-		return "";
3968
-	}
3962
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
3963
+    if (!is_numeric($nb) or $nb == 0) {
3964
+        return "";
3965
+    }
3966
+    if (!is_array($vars)) {
3967
+        return "";
3968
+    }
3969 3969
 
3970
-	$langue = $GLOBALS['spip_lang'];
3971
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
3972
-		$local_singulier_ou_pluriel[$langue] = false;
3973
-		if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
3974
-		  or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) {
3975
-			$local_singulier_ou_pluriel[$langue] = $f;
3976
-		}
3977
-	}
3970
+    $langue = $GLOBALS['spip_lang'];
3971
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
3972
+        $local_singulier_ou_pluriel[$langue] = false;
3973
+        if ($f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
3974
+          or $f = charger_fonction("singulier_ou_pluriel", 'inc', true)) {
3975
+            $local_singulier_ou_pluriel[$langue] = $f;
3976
+        }
3977
+    }
3978 3978
 
3979
-	// si on a une surcharge on l'utilise
3980
-	if ($local_singulier_ou_pluriel[$langue]) {
3981
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
3982
-	}
3979
+    // si on a une surcharge on l'utilise
3980
+    if ($local_singulier_ou_pluriel[$langue]) {
3981
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
3982
+    }
3983 3983
 
3984
-	// sinon traitement par defaut
3985
-	$vars[$var] = $nb;
3986
-	if ($nb >= 2) {
3987
-		return _T($chaine_plusieurs, $vars);
3988
-	} else {
3989
-		return _T($chaine_un, $vars);
3990
-	}
3984
+    // sinon traitement par defaut
3985
+    $vars[$var] = $nb;
3986
+    if ($nb >= 2) {
3987
+        return _T($chaine_plusieurs, $vars);
3988
+    } else {
3989
+        return _T($chaine_un, $vars);
3990
+    }
3991 3991
 }
3992 3992
 
3993 3993
 
@@ -4012,56 +4012,56 @@  discard block
 block discarded – undo
4012 4012
  * @return string
4013 4013
  */
4014 4014
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4015
-	if (in_array($fonction, array("del", "supprimer.gif"))) {
4016
-		$class .= ' danger';
4017
-	} elseif ($fonction == "rien.gif") {
4018
-		$fonction = "";
4019
-	} elseif ($fonction == "delsafe") {
4020
-		$fonction = "del";
4021
-	}
4022
-
4023
-	$fond_origine = $fond;
4024
-	// remappage des icone : article-24.png+new => article-new-24.png
4025
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4026
-		list($fond, $fonction) = $icone_renommer($fond, $fonction);
4027
-	}
4028
-
4029
-	// ajouter le type d'objet dans la class de l'icone
4030
-	$class .= " " . substr(basename($fond), 0, -4);
4031
-
4032
-	$alt = attribut_html($texte);
4033
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4034
-
4035
-	$ajax = "";
4036
-	if (strpos($class, "ajax") !== false) {
4037
-		$ajax = "ajax";
4038
-		if (strpos($class, "preload") !== false) {
4039
-			$ajax .= " preload";
4040
-		}
4041
-		if (strpos($class, "nocache") !== false) {
4042
-			$ajax .= " nocache";
4043
-		}
4044
-		$ajax = " class='$ajax'";
4045
-	}
4046
-
4047
-	$size = 24;
4048
-	if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4049
-	  or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4050
-		$size = $match[1];
4051
-	}
4052
-
4053
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4054
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4055
-
4056
-	if ($type == 'lien') {
4057
-		return "<span class='icone s$size $class'>"
4058
-		. "<a href='$lien'$title$ajax$javascript>"
4059
-		. $icone
4060
-		. "<b>$texte</b>"
4061
-		. "</a></span>\n";
4062
-	} else {
4063
-		return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4064
-	}
4015
+    if (in_array($fonction, array("del", "supprimer.gif"))) {
4016
+        $class .= ' danger';
4017
+    } elseif ($fonction == "rien.gif") {
4018
+        $fonction = "";
4019
+    } elseif ($fonction == "delsafe") {
4020
+        $fonction = "del";
4021
+    }
4022
+
4023
+    $fond_origine = $fond;
4024
+    // remappage des icone : article-24.png+new => article-new-24.png
4025
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4026
+        list($fond, $fonction) = $icone_renommer($fond, $fonction);
4027
+    }
4028
+
4029
+    // ajouter le type d'objet dans la class de l'icone
4030
+    $class .= " " . substr(basename($fond), 0, -4);
4031
+
4032
+    $alt = attribut_html($texte);
4033
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4034
+
4035
+    $ajax = "";
4036
+    if (strpos($class, "ajax") !== false) {
4037
+        $ajax = "ajax";
4038
+        if (strpos($class, "preload") !== false) {
4039
+            $ajax .= " preload";
4040
+        }
4041
+        if (strpos($class, "nocache") !== false) {
4042
+            $ajax .= " nocache";
4043
+        }
4044
+        $ajax = " class='$ajax'";
4045
+    }
4046
+
4047
+    $size = 24;
4048
+    if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4049
+      or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4050
+        $size = $match[1];
4051
+    }
4052
+
4053
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4054
+    $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4055
+
4056
+    if ($type == 'lien') {
4057
+        return "<span class='icone s$size $class'>"
4058
+        . "<a href='$lien'$title$ajax$javascript>"
4059
+        . $icone
4060
+        . "<b>$texte</b>"
4061
+        . "</a></span>\n";
4062
+    } else {
4063
+        return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4064
+    }
4065 4065
 }
4066 4066
 
4067 4067
 /**
@@ -4085,7 +4085,7 @@  discard block
 block discarded – undo
4085 4085
  *     Code HTML du lien
4086 4086
  **/
4087 4087
 function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4088
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4088
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4089 4089
 }
4090 4090
 
4091 4091
 /**
@@ -4120,7 +4120,7 @@  discard block
 block discarded – undo
4120 4120
  *     Code HTML du lien
4121 4121
  **/
4122 4122
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4123
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4123
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4124 4124
 }
4125 4125
 
4126 4126
 /**
@@ -4165,7 +4165,7 @@  discard block
 block discarded – undo
4165 4165
  *     Code HTML du lien
4166 4166
  **/
4167 4167
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4168
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4168
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4169 4169
 }
4170 4170
 
4171 4171
 /**
@@ -4196,7 +4196,7 @@  discard block
 block discarded – undo
4196 4196
  *     Code HTML du lien
4197 4197
  **/
4198 4198
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") {
4199
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4199
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4200 4200
 }
4201 4201
 
4202 4202
 /**
@@ -4226,7 +4226,7 @@  discard block
 block discarded – undo
4226 4226
  *     Code HTML du lien
4227 4227
  */
4228 4228
 function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") {
4229
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4229
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4230 4230
 }
4231 4231
 
4232 4232
 
@@ -4274,26 +4274,26 @@  discard block
 block discarded – undo
4274 4274
  * @return string Code CSS
4275 4275
  */
4276 4276
 function bando_images_background() {
4277
-	include_spip('inc/bandeau');
4278
-	// recuperer tous les boutons et leurs images
4279
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4277
+    include_spip('inc/bandeau');
4278
+    // recuperer tous les boutons et leurs images
4279
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4280 4280
 
4281
-	$res = "";
4282
-	foreach ($boutons as $page => $detail) {
4283
-		if ($detail->icone and strlen(trim($detail->icone))) {
4284
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4285
-		}
4286
-		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4287
-		if (is_array($detail->sousmenu)) {
4288
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4289
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4290
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4291
-				}
4292
-			}
4293
-		}
4294
-	}
4281
+    $res = "";
4282
+    foreach ($boutons as $page => $detail) {
4283
+        if ($detail->icone and strlen(trim($detail->icone))) {
4284
+            $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4285
+        }
4286
+        $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4287
+        if (is_array($detail->sousmenu)) {
4288
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4289
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4290
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4291
+                }
4292
+            }
4293
+        }
4294
+    }
4295 4295
 
4296
-	return $res;
4296
+    return $res;
4297 4297
 }
4298 4298
 
4299 4299
 /**
@@ -4312,19 +4312,19 @@  discard block
 block discarded – undo
4312 4312
  * @return string
4313 4313
  */
4314 4314
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4315
-	if ($confirm) {
4316
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4317
-		if ($callback) {
4318
-			$callback = "$confirm?($callback):false";
4319
-		} else {
4320
-			$callback = $confirm;
4321
-		}
4322
-	}
4323
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4324
-	$title = $title ? " title='$title'" : "";
4315
+    if ($confirm) {
4316
+        $confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4317
+        if ($callback) {
4318
+            $callback = "$confirm?($callback):false";
4319
+        } else {
4320
+            $callback = $confirm;
4321
+        }
4322
+    }
4323
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4324
+    $title = $title ? " title='$title'" : "";
4325 4325
 
4326
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4327
-	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4326
+    return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4327
+    . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4328 4328
 }
4329 4329
 
4330 4330
 /**
@@ -4345,78 +4345,78 @@  discard block
 block discarded – undo
4345 4345
  * @return string
4346 4346
  */
4347 4347
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") {
4348
-	static $trouver_table = null;
4349
-	static $objets;
4350
-
4351
-	// On verifie qu'on a tout ce qu'il faut
4352
-	$id_objet = intval($id_objet);
4353
-	if (!($id_objet and $type_objet and $info)) {
4354
-		return '';
4355
-	}
4356
-
4357
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4358
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4359
-		return '';
4360
-	}
4361
-
4362
-	// Si on demande l'url, on retourne direct la fonction
4363
-	if ($info == 'url') {
4364
-		return generer_url_entite($id_objet, $type_objet);
4365
-	}
4366
-
4367
-	// Sinon on va tout chercher dans la table et on garde en memoire
4368
-	$demande_titre = ($info == 'titre');
4369
-
4370
-	// 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
4371
-	if (!isset($objets[$type_objet][$id_objet])
4372
-		or
4373
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4374
-	) {
4375
-		if (!$trouver_table) {
4376
-			$trouver_table = charger_fonction('trouver_table', 'base');
4377
-		}
4378
-		$desc = $trouver_table(table_objet_sql($type_objet));
4379
-		if (!$desc) {
4380
-			return $objets[$type_objet] = false;
4381
-		}
4382
-
4383
-		// Si on demande le titre, on le gere en interne
4384
-		$champ_titre = "";
4385
-		if ($demande_titre) {
4386
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4387
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4388
-		}
4389
-		include_spip('base/abstract_sql');
4390
-		include_spip('base/connect_sql');
4391
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4392
-			'*' . $champ_titre,
4393
-			$desc['table_sql'],
4394
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4395
-		);
4396
-	}
4397
-
4398
-	// Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4399
-	if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4400
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4401
-	} // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4402
-	else {
4403
-		if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4404
-			$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4405
-		} // Sinon on prend directement le champ SQL tel quel
4406
-		else {
4407
-			$info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4408
-		}
4409
-	}
4410
-
4411
-	// On va ensuite appliquer les traitements automatiques si besoin
4412
-	if (!$etoile) {
4413
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4414
-		// mais ce fonctionnement est a ameliorer !
4415
-		$info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4416
-			array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4417
-	}
4418
-
4419
-	return $info_generee;
4348
+    static $trouver_table = null;
4349
+    static $objets;
4350
+
4351
+    // On verifie qu'on a tout ce qu'il faut
4352
+    $id_objet = intval($id_objet);
4353
+    if (!($id_objet and $type_objet and $info)) {
4354
+        return '';
4355
+    }
4356
+
4357
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4358
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4359
+        return '';
4360
+    }
4361
+
4362
+    // Si on demande l'url, on retourne direct la fonction
4363
+    if ($info == 'url') {
4364
+        return generer_url_entite($id_objet, $type_objet);
4365
+    }
4366
+
4367
+    // Sinon on va tout chercher dans la table et on garde en memoire
4368
+    $demande_titre = ($info == 'titre');
4369
+
4370
+    // 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
4371
+    if (!isset($objets[$type_objet][$id_objet])
4372
+        or
4373
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4374
+    ) {
4375
+        if (!$trouver_table) {
4376
+            $trouver_table = charger_fonction('trouver_table', 'base');
4377
+        }
4378
+        $desc = $trouver_table(table_objet_sql($type_objet));
4379
+        if (!$desc) {
4380
+            return $objets[$type_objet] = false;
4381
+        }
4382
+
4383
+        // Si on demande le titre, on le gere en interne
4384
+        $champ_titre = "";
4385
+        if ($demande_titre) {
4386
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4387
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4388
+        }
4389
+        include_spip('base/abstract_sql');
4390
+        include_spip('base/connect_sql');
4391
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4392
+            '*' . $champ_titre,
4393
+            $desc['table_sql'],
4394
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4395
+        );
4396
+    }
4397
+
4398
+    // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4399
+    if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4400
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4401
+    } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4402
+    else {
4403
+        if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4404
+            $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4405
+        } // Sinon on prend directement le champ SQL tel quel
4406
+        else {
4407
+            $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4408
+        }
4409
+    }
4410
+
4411
+    // On va ensuite appliquer les traitements automatiques si besoin
4412
+    if (!$etoile) {
4413
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4414
+        // mais ce fonctionnement est a ameliorer !
4415
+        $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4416
+            array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4417
+    }
4418
+
4419
+    return $info_generee;
4420 4420
 }
4421 4421
 
4422 4422
 /**
@@ -4430,44 +4430,44 @@  discard block
 block discarded – undo
4430 4430
  * @return string
4431 4431
  */
4432 4432
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') {
4433
-	if (!$champ) {
4434
-		return $texte;
4435
-	}
4433
+    if (!$champ) {
4434
+        return $texte;
4435
+    }
4436 4436
 	
4437
-	// On charge toujours les filtres de texte car la majorité des traitements les utilisent
4438
-	// et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4439
-	include_spip('inc/texte');
4437
+    // On charge toujours les filtres de texte car la majorité des traitements les utilisent
4438
+    // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4439
+    include_spip('inc/texte');
4440 4440
 	
4441
-	$champ = strtoupper($champ);
4442
-	$traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4443
-	if (!$traitements or !is_array($traitements)) {
4444
-		return $texte;
4445
-	}
4441
+    $champ = strtoupper($champ);
4442
+    $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4443
+    if (!$traitements or !is_array($traitements)) {
4444
+        return $texte;
4445
+    }
4446 4446
 
4447
-	$traitement = '';
4448
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4449
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4450
-		$table_objet = table_objet($table_objet);
4451
-		if (isset($traitements[$table_objet])) {
4452
-			$traitement = $traitements[$table_objet];
4453
-		}
4454
-	}
4455
-	if (!$traitement and isset($traitements[0])) {
4456
-		$traitement = $traitements[0];
4457
-	}
4458
-	// (sinon prendre le premier de la liste par defaut ?)
4447
+    $traitement = '';
4448
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4449
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4450
+        $table_objet = table_objet($table_objet);
4451
+        if (isset($traitements[$table_objet])) {
4452
+            $traitement = $traitements[$table_objet];
4453
+        }
4454
+    }
4455
+    if (!$traitement and isset($traitements[0])) {
4456
+        $traitement = $traitements[0];
4457
+    }
4458
+    // (sinon prendre le premier de la liste par defaut ?)
4459 4459
 
4460
-	if (!$traitement) {
4461
-		return $texte;
4462
-	}
4460
+    if (!$traitement) {
4461
+        return $texte;
4462
+    }
4463 4463
 
4464
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4464
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4465 4465
 
4466
-	// Fournir $connect et $Pile[0] au traitement si besoin
4467
-	$Pile = array(0 => $env);
4468
-	eval("\$texte = $traitement;");
4466
+    // Fournir $connect et $Pile[0] au traitement si besoin
4467
+    $Pile = array(0 => $env);
4468
+    eval("\$texte = $traitement;");
4469 4469
 
4470
-	return $texte;
4470
+    return $texte;
4471 4471
 }
4472 4472
 
4473 4473
 
@@ -4481,21 +4481,21 @@  discard block
 block discarded – undo
4481 4481
  * @return string
4482 4482
  */
4483 4483
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4484
-	include_spip('inc/liens');
4485
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4486
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4487
-	// le raccourcis n'est plus valide
4488
-	$titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4489
-	// on essaye avec generer_info_entite ?
4490
-	if (!strlen($titre) and !$connect) {
4491
-		$titre = generer_info_entite($id_objet, $objet, 'titre');
4492
-	}
4493
-	if (!strlen($titre)) {
4494
-		$titre = _T('info_sans_titre');
4495
-	}
4496
-	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4484
+    include_spip('inc/liens');
4485
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4486
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4487
+    // le raccourcis n'est plus valide
4488
+    $titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4489
+    // on essaye avec generer_info_entite ?
4490
+    if (!strlen($titre) and !$connect) {
4491
+        $titre = generer_info_entite($id_objet, $objet, 'titre');
4492
+    }
4493
+    if (!strlen($titre)) {
4494
+        $titre = _T('info_sans_titre');
4495
+    }
4496
+    $url = generer_url_entite($id_objet, $objet, '', '', $connect);
4497 4497
 
4498
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4498
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4499 4499
 }
4500 4500
 
4501 4501
 
@@ -4512,15 +4512,15 @@  discard block
 block discarded – undo
4512 4512
  * @return string
4513 4513
  */
4514 4514
 function wrap($texte, $wrap) {
4515
-	$balises = extraire_balises($wrap);
4516
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4517
-		$texte = $wrap . $texte;
4518
-		$regs = array_reverse($regs[1]);
4519
-		$wrap = "</" . implode("></", $regs) . ">";
4520
-		$texte = $texte . $wrap;
4521
-	}
4515
+    $balises = extraire_balises($wrap);
4516
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4517
+        $texte = $wrap . $texte;
4518
+        $regs = array_reverse($regs[1]);
4519
+        $wrap = "</" . implode("></", $regs) . ">";
4520
+        $texte = $texte . $wrap;
4521
+    }
4522 4522
 
4523
-	return $texte;
4523
+    return $texte;
4524 4524
 }
4525 4525
 
4526 4526
 
@@ -4540,43 +4540,43 @@  discard block
 block discarded – undo
4540 4540
  * @return array|mixed|string
4541 4541
  */
4542 4542
 function filtre_print_dist($u, $join = "<br />", $indent = 0) {
4543
-	if (is_string($u)) {
4544
-		$u = typo($u);
4543
+    if (is_string($u)) {
4544
+        $u = typo($u);
4545 4545
 
4546
-		return $u;
4547
-	}
4546
+        return $u;
4547
+    }
4548 4548
 
4549
-	// caster $u en array si besoin
4550
-	if (is_object($u)) {
4551
-		$u = (array)$u;
4552
-	}
4549
+    // caster $u en array si besoin
4550
+    if (is_object($u)) {
4551
+        $u = (array)$u;
4552
+    }
4553 4553
 
4554
-	if (is_array($u)) {
4555
-		$out = "";
4556
-		// toutes les cles sont numeriques ?
4557
-		// et aucun enfant n'est un tableau
4558
-		// liste simple separee par des virgules
4559
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4560
-		$array_values = array_map('is_array', $u);
4561
-		$object_values = array_map('is_object', $u);
4562
-		if (array_sum($numeric_keys) == count($numeric_keys)
4563
-			and !array_sum($array_values)
4564
-			and !array_sum($object_values)
4565
-		) {
4566
-			return join(", ", array_map('filtre_print_dist', $u));
4567
-		}
4554
+    if (is_array($u)) {
4555
+        $out = "";
4556
+        // toutes les cles sont numeriques ?
4557
+        // et aucun enfant n'est un tableau
4558
+        // liste simple separee par des virgules
4559
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4560
+        $array_values = array_map('is_array', $u);
4561
+        $object_values = array_map('is_object', $u);
4562
+        if (array_sum($numeric_keys) == count($numeric_keys)
4563
+            and !array_sum($array_values)
4564
+            and !array_sum($object_values)
4565
+        ) {
4566
+            return join(", ", array_map('filtre_print_dist', $u));
4567
+        }
4568 4568
 
4569
-		// sinon on passe a la ligne et on indente
4570
-		$i_str = str_pad("", $indent, " ");
4571
-		foreach ($u as $k => $v) {
4572
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4573
-		}
4569
+        // sinon on passe a la ligne et on indente
4570
+        $i_str = str_pad("", $indent, " ");
4571
+        foreach ($u as $k => $v) {
4572
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4573
+        }
4574 4574
 
4575
-		return $out;
4576
-	}
4575
+        return $out;
4576
+    }
4577 4577
 
4578
-	// on sait pas quoi faire...
4579
-	return $u;
4578
+    // on sait pas quoi faire...
4579
+    return $u;
4580 4580
 }
4581 4581
 
4582 4582
 
@@ -4589,10 +4589,10 @@  discard block
 block discarded – undo
4589 4589
  * @return string|array
4590 4590
  */
4591 4591
 function objet_info($objet, $info) {
4592
-	$table = table_objet_sql($objet);
4593
-	$infos = lister_tables_objets_sql($table);
4592
+    $table = table_objet_sql($objet);
4593
+    $infos = lister_tables_objets_sql($table);
4594 4594
 
4595
-	return (isset($infos[$info]) ? $infos[$info] : '');
4595
+    return (isset($infos[$info]) ? $infos[$info] : '');
4596 4596
 }
4597 4597
 
4598 4598
 /**
@@ -4607,11 +4607,11 @@  discard block
 block discarded – undo
4607 4607
  *     Texte traduit du comptage, tel que '3 articles'
4608 4608
  */
4609 4609
 function objet_afficher_nb($nb, $objet) {
4610
-	if (!$nb) {
4611
-		return _T(objet_info($objet, 'info_aucun_objet'));
4612
-	} else {
4613
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4614
-	}
4610
+    if (!$nb) {
4611
+        return _T(objet_info($objet, 'info_aucun_objet'));
4612
+    } else {
4613
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4614
+    }
4615 4615
 }
4616 4616
 
4617 4617
 /**
@@ -4623,11 +4623,11 @@  discard block
 block discarded – undo
4623 4623
  * @return string
4624 4624
  */
4625 4625
 function objet_icone($objet, $taille = 24, $class='') {
4626
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4627
-	$icone = chemin_image($icone);
4628
-	$balise_img = charger_filtre('balise_img');
4626
+    $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4627
+    $icone = chemin_image($icone);
4628
+    $balise_img = charger_filtre('balise_img');
4629 4629
 
4630
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4630
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4631 4631
 }
4632 4632
 
4633 4633
 /**
@@ -4648,12 +4648,12 @@  discard block
 block discarded – undo
4648 4648
  * @return string
4649 4649
  */
4650 4650
 function objet_T($objet, $chaine, $args = array(), $options = array()){
4651
-	$chaine = explode(':',$chaine);
4652
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4653
-		return $t;
4654
-	}
4655
-	$chaine = implode(':',$chaine);
4656
-	return _T($chaine, $args, $options);
4651
+    $chaine = explode(':',$chaine);
4652
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4653
+        return $t;
4654
+    }
4655
+    $chaine = implode(':',$chaine);
4656
+    return _T($chaine, $args, $options);
4657 4657
 }
4658 4658
 
4659 4659
 /**
@@ -4667,17 +4667,17 @@  discard block
 block discarded – undo
4667 4667
  * @return string      Code HTML
4668 4668
  */
4669 4669
 function insert_head_css_conditionnel($flux) {
4670
-	if (strpos($flux, '<!-- insert_head_css -->') === false
4671
-		and $p = strpos($flux, '<!-- insert_head -->')
4672
-	) {
4673
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4674
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4675
-			$p = $p1;
4676
-		}
4677
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4678
-	}
4670
+    if (strpos($flux, '<!-- insert_head_css -->') === false
4671
+        and $p = strpos($flux, '<!-- insert_head -->')
4672
+    ) {
4673
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4674
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4675
+            $p = $p1;
4676
+        }
4677
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4678
+    }
4679 4679
 
4680
-	return $flux;
4680
+    return $flux;
4681 4681
 }
4682 4682
 
4683 4683
 /**
@@ -4698,69 +4698,69 @@  discard block
 block discarded – undo
4698 4698
  * @return string
4699 4699
  */
4700 4700
 function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') {
4701
-	if (isset($contexte['format'])) {
4702
-		$extension = $contexte['format'];
4703
-		unset($contexte['format']);
4704
-	} else {
4705
-		$extension = "html";
4706
-		if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4707
-			$extension = $m[1];
4708
-		}
4709
-	}
4710
-	// recuperer le contenu produit par le squelette
4711
-	$options['raw'] = true;
4712
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4713
-
4714
-	// calculer le nom de la css
4715
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4716
-	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4717
-	$contexte_implicite = calculer_contexte_implicite();
4718
-
4719
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4720
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4721
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4722
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4723
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4724
-	}
4725
-	else {
4726
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4727
-		ksort($contexte);
4728
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4729
-	}
4730
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4731
-
4732
-	// mettre a jour le fichier si il n'existe pas
4733
-	// ou trop ancien
4734
-	// le dernier fichier produit est toujours suffixe par .last
4735
-	// et recopie sur le fichier cible uniquement si il change
4736
-	if (!file_exists($filename)
4737
-		or !file_exists($filename . ".last")
4738
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4739
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4740
-	) {
4741
-		$contenu = $cache['texte'];
4742
-		// passer les urls en absolu si c'est une css
4743
-		if ($extension == "css") {
4744
-			$contenu = urls_absolues_css($contenu,
4745
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4746
-		}
4747
-
4748
-		$comment = '';
4749
-		// ne pas insérer de commentaire si c'est du json
4750
-		if ($extension != "json") {
4751
-			$comment = "/* #PRODUIRE{fond=$fond";
4752
-			foreach ($contexte as $k => $v) {
4753
-				$comment .= ",$k=$v";
4754
-			}
4755
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4756
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4757
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4758
-		}
4759
-		// et ecrire le fichier si il change
4760
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4761
-	}
4762
-
4763
-	return timestamp($filename);
4701
+    if (isset($contexte['format'])) {
4702
+        $extension = $contexte['format'];
4703
+        unset($contexte['format']);
4704
+    } else {
4705
+        $extension = "html";
4706
+        if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4707
+            $extension = $m[1];
4708
+        }
4709
+    }
4710
+    // recuperer le contenu produit par le squelette
4711
+    $options['raw'] = true;
4712
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4713
+
4714
+    // calculer le nom de la css
4715
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4716
+    $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4717
+    $contexte_implicite = calculer_contexte_implicite();
4718
+
4719
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4720
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4721
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4722
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4723
+        $hash = md5($contexte_implicite['host'] . '::'. $cache);
4724
+    }
4725
+    else {
4726
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4727
+        ksort($contexte);
4728
+        $hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4729
+    }
4730
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4731
+
4732
+    // mettre a jour le fichier si il n'existe pas
4733
+    // ou trop ancien
4734
+    // le dernier fichier produit est toujours suffixe par .last
4735
+    // et recopie sur le fichier cible uniquement si il change
4736
+    if (!file_exists($filename)
4737
+        or !file_exists($filename . ".last")
4738
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4739
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4740
+    ) {
4741
+        $contenu = $cache['texte'];
4742
+        // passer les urls en absolu si c'est une css
4743
+        if ($extension == "css") {
4744
+            $contenu = urls_absolues_css($contenu,
4745
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4746
+        }
4747
+
4748
+        $comment = '';
4749
+        // ne pas insérer de commentaire si c'est du json
4750
+        if ($extension != "json") {
4751
+            $comment = "/* #PRODUIRE{fond=$fond";
4752
+            foreach ($contexte as $k => $v) {
4753
+                $comment .= ",$k=$v";
4754
+            }
4755
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4756
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4757
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
4758
+        }
4759
+        // et ecrire le fichier si il change
4760
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4761
+    }
4762
+
4763
+    return timestamp($filename);
4764 4764
 }
4765 4765
 
4766 4766
 /**
@@ -4773,14 +4773,14 @@  discard block
 block discarded – undo
4773 4773
  *    $fichier auquel on a ajouté le timestamp
4774 4774
  */
4775 4775
 function timestamp($fichier) {
4776
-	if (!$fichier
4777
-		or !file_exists($fichier)
4778
-		or !$m = filemtime($fichier)
4779
-	) {
4780
-		return $fichier;
4781
-	}
4776
+    if (!$fichier
4777
+        or !file_exists($fichier)
4778
+        or !$m = filemtime($fichier)
4779
+    ) {
4780
+        return $fichier;
4781
+    }
4782 4782
 
4783
-	return "$fichier?$m";
4783
+    return "$fichier?$m";
4784 4784
 }
4785 4785
 
4786 4786
 /**
@@ -4790,11 +4790,11 @@  discard block
 block discarded – undo
4790 4790
  * @return string
4791 4791
  */
4792 4792
 function supprimer_timestamp($url) {
4793
-	if (strpos($url, "?") === false) {
4794
-		return $url;
4795
-	}
4793
+    if (strpos($url, "?") === false) {
4794
+        return $url;
4795
+    }
4796 4796
 
4797
-	return preg_replace(",\?[[:digit:]]+$,", "", $url);
4797
+    return preg_replace(",\?[[:digit:]]+$,", "", $url);
4798 4798
 }
4799 4799
 
4800 4800
 /**
@@ -4809,9 +4809,9 @@  discard block
 block discarded – undo
4809 4809
  * @return string
4810 4810
  */
4811 4811
 function filtre_nettoyer_titre_email_dist($titre) {
4812
-	include_spip('inc/envoyer_mail');
4812
+    include_spip('inc/envoyer_mail');
4813 4813
 
4814
-	return nettoyer_titre_email($titre);
4814
+    return nettoyer_titre_email($titre);
4815 4815
 }
4816 4816
 
4817 4817
 /**
@@ -4833,19 +4833,19 @@  discard block
 block discarded – undo
4833 4833
  * @return string
4834 4834
  */
4835 4835
 function filtre_chercher_rubrique_dist(
4836
-	$titre,
4837
-	$id_objet,
4838
-	$id_parent,
4839
-	$objet,
4840
-	$id_secteur,
4841
-	$restreint,
4842
-	$actionable = false,
4843
-	$retour_sans_cadre = false
4836
+    $titre,
4837
+    $id_objet,
4838
+    $id_parent,
4839
+    $objet,
4840
+    $id_secteur,
4841
+    $restreint,
4842
+    $actionable = false,
4843
+    $retour_sans_cadre = false
4844 4844
 ) {
4845
-	include_spip('inc/filtres_ecrire');
4845
+    include_spip('inc/filtres_ecrire');
4846 4846
 
4847
-	return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4848
-		$retour_sans_cadre);
4847
+    return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4848
+        $retour_sans_cadre);
4849 4849
 }
4850 4850
 
4851 4851
 /**
@@ -4874,56 +4874,56 @@  discard block
 block discarded – undo
4874 4874
  *     Chaîne vide si l'accès est autorisé
4875 4875
  */
4876 4876
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
4877
-	if ($ok) {
4878
-		return '';
4879
-	}
4880
-
4881
-	// Vider tous les tampons
4882
-	$level = @ob_get_level();
4883
-	while ($level--) {
4884
-		@ob_end_clean();
4885
-	}
4886
-
4887
-	include_spip('inc/headers');
4888
-
4889
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4890
-	if ($url) {
4891
-		redirige_par_entete($url, '', $statut);
4892
-	}
4893
-
4894
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
4895
-	if (!is_numeric($statut) and is_null($message)) {
4896
-		$message = $statut;
4897
-		$statut = 0;
4898
-	}
4899
-	if (!$message) {
4900
-		$message = '';
4901
-	}
4902
-	$statut = intval($statut);
4903
-
4904
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4905
-	if (test_espace_prive()) {
4906
-		if (!$statut or !in_array($statut, array(404, 403))) {
4907
-			$statut = 403;
4908
-		}
4909
-		http_status(403);
4910
-		$echec = charger_fonction('403', 'exec');
4911
-		$echec($message);
4912
-	} else {
4913
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4914
-		if (!$statut) {
4915
-			$statut = 404;
4916
-		}
4917
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
4918
-		http_status($statut);
4919
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4920
-		if ($statut >= 400) {
4921
-			echo recuperer_fond("$statut", array('erreur' => $message));
4922
-		}
4923
-	}
4924
-
4925
-
4926
-	exit;
4877
+    if ($ok) {
4878
+        return '';
4879
+    }
4880
+
4881
+    // Vider tous les tampons
4882
+    $level = @ob_get_level();
4883
+    while ($level--) {
4884
+        @ob_end_clean();
4885
+    }
4886
+
4887
+    include_spip('inc/headers');
4888
+
4889
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4890
+    if ($url) {
4891
+        redirige_par_entete($url, '', $statut);
4892
+    }
4893
+
4894
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
4895
+    if (!is_numeric($statut) and is_null($message)) {
4896
+        $message = $statut;
4897
+        $statut = 0;
4898
+    }
4899
+    if (!$message) {
4900
+        $message = '';
4901
+    }
4902
+    $statut = intval($statut);
4903
+
4904
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4905
+    if (test_espace_prive()) {
4906
+        if (!$statut or !in_array($statut, array(404, 403))) {
4907
+            $statut = 403;
4908
+        }
4909
+        http_status(403);
4910
+        $echec = charger_fonction('403', 'exec');
4911
+        $echec($message);
4912
+    } else {
4913
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4914
+        if (!$statut) {
4915
+            $statut = 404;
4916
+        }
4917
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
4918
+        http_status($statut);
4919
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4920
+        if ($statut >= 400) {
4921
+            echo recuperer_fond("$statut", array('erreur' => $message));
4922
+        }
4923
+    }
4924
+
4925
+
4926
+    exit;
4927 4927
 }
4928 4928
 
4929 4929
 /**
@@ -4934,11 +4934,11 @@  discard block
 block discarded – undo
4934 4934
  * @return string
4935 4935
  */
4936 4936
 function filtre_compacte_dist($source, $format = null) {
4937
-	if (function_exists('compacte')) {
4938
-		return compacte($source, $format);
4939
-	}
4937
+    if (function_exists('compacte')) {
4938
+        return compacte($source, $format);
4939
+    }
4940 4940
 
4941
-	return $source;
4941
+    return $source;
4942 4942
 }
4943 4943
 
4944 4944
 
@@ -4950,29 +4950,29 @@  discard block
 block discarded – undo
4950 4950
  * @return string
4951 4951
  */
4952 4952
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4953
-	$l = strlen($passe);
4954
-
4955
-	if ($l<=8 or !$afficher_partiellement){
4956
-		if (!$l) {
4957
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4958
-		}
4959
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4960
-	}
4961
-
4962
-	if (is_null($portion_pourcent)) {
4963
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4964
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4965
-		}
4966
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4967
-	}
4968
-	if ($portion_pourcent >= 100) {
4969
-		return $passe;
4970
-	}
4971
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4972
-	$e = max($e, 0);
4973
-	$mid = str_pad('',$l-2*$e,'*');
4974
-	if ($e>0 and strlen($mid)>8){
4975
-		$mid = '***...***';
4976
-	}
4977
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4953
+    $l = strlen($passe);
4954
+
4955
+    if ($l<=8 or !$afficher_partiellement){
4956
+        if (!$l) {
4957
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4958
+        }
4959
+        return str_pad('',$afficher_partiellement ? $l : 16,'*');
4960
+    }
4961
+
4962
+    if (is_null($portion_pourcent)) {
4963
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4964
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4965
+        }
4966
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4967
+    }
4968
+    if ($portion_pourcent >= 100) {
4969
+        return $passe;
4970
+    }
4971
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
4972
+    $e = max($e, 0);
4973
+    $mid = str_pad('',$l-2*$e,'*');
4974
+    if ($e>0 and strlen($mid)>8){
4975
+        $mid = '***...***';
4976
+    }
4977
+    return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4978 4978
 }
4979 4979
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +147 added lines, -147 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,7 +1711,7 @@  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
 					$trad = code_echappement($trad, 'multi', false, $mode);
1716 1716
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1717 1717
 					if (lang_dir($l) !== lang_dir($lang)) {
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 	if (is_array($balise)) {
1905 1905
 		array_walk(
1906 1906
 			$balise,
1907
-			function(&$a, $key, $t){
1907
+			function(&$a, $key, $t) {
1908 1908
 				$a = extraire_attribut($a, $t);
1909 1909
 			},
1910 1910
 			$attribut
@@ -1991,14 +1991,14 @@  discard block
 block discarded – undo
1991 1991
 
1992 1992
 	if ($old !== null) {
1993 1993
 		// Remplacer l'ancien attribut du meme nom
1994
-		$balise = $r[1] . $insert . $r[5];
1994
+		$balise = $r[1].$insert.$r[5];
1995 1995
 	} else {
1996 1996
 		// preferer une balise " />" (comme <img />)
1997 1997
 		if (preg_match(',/>,', $balise)) {
1998
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1998
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
1999 1999
 		} // sinon une balise <a ...> ... </a>
2000 2000
 		else {
2001
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2001
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
2002 2002
 		}
2003 2003
 	}
2004 2004
 
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
  * @param string $operation
2032 2032
  * @return string
2033 2033
  */
2034
-function modifier_class($balise, $class, $operation='ajouter') {
2034
+function modifier_class($balise, $class, $operation = 'ajouter') {
2035 2035
 	if (is_string($class)) {
2036 2036
 		$class = explode(' ', trim($class));
2037 2037
 	}
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
 				}
2057 2057
 				if (in_array($operation, ['ajouter', 'commuter'])
2058 2058
 					and !$is_class_presente) {
2059
-					$class_new = rtrim($class_new) . " " . $c;
2059
+					$class_new = rtrim($class_new)." ".$c;
2060 2060
 				}
2061 2061
 				elseif (in_array($operation, ['supprimer', 'commuter'])
2062 2062
 					and $is_class_presente) {
@@ -2084,7 +2084,7 @@  discard block
 block discarded – undo
2084 2084
  * @param string|array $class
2085 2085
  * @return string
2086 2086
  */
2087
-function ajouter_class($balise, $class){
2087
+function ajouter_class($balise, $class) {
2088 2088
 	return modifier_class($balise, $class, 'ajouter');
2089 2089
 }
2090 2090
 
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
  * @param string|array $class
2095 2095
  * @return string
2096 2096
  */
2097
-function supprimer_class($balise, $class){
2097
+function supprimer_class($balise, $class) {
2098 2098
 	return modifier_class($balise, $class, 'supprimer');
2099 2099
 }
2100 2100
 
@@ -2105,7 +2105,7 @@  discard block
 block discarded – undo
2105 2105
  * @param string|array $class
2106 2106
  * @return string
2107 2107
  */
2108
-function commuter_class($balise, $class){
2108
+function commuter_class($balise, $class) {
2109 2109
 	return modifier_class($balise, $class, 'commuter');
2110 2110
 }
2111 2111
 
@@ -2125,8 +2125,8 @@  discard block
 block discarded – undo
2125 2125
 //
2126 2126
 // Quelques fonctions de calcul arithmetique
2127 2127
 //
2128
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
2129
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
2128
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
2129
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
2130 2130
 
2131 2131
 /**
2132 2132
  * Additionne 2 nombres
@@ -2146,7 +2146,7 @@  discard block
 block discarded – undo
2146 2146
 function plus($a, $b) {
2147 2147
 	return $a + $b;
2148 2148
 }
2149
-function strplus($a, $b) {return strize('plus', $a, $b);}
2149
+function strplus($a, $b) {return strize('plus', $a, $b); }
2150 2150
 /**
2151 2151
  * Soustrait 2 nombres
2152 2152
  *
@@ -2165,7 +2165,7 @@  discard block
 block discarded – undo
2165 2165
 function moins($a, $b) {
2166 2166
 	return $a - $b;
2167 2167
 }
2168
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2168
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2169 2169
 
2170 2170
 /**
2171 2171
  * Multiplie 2 nombres
@@ -2186,7 +2186,7 @@  discard block
 block discarded – undo
2186 2186
 function mult($a, $b) {
2187 2187
 	return $a * $b;
2188 2188
 }
2189
-function strmult($a, $b) {return strize('mult', $a, $b);}
2189
+function strmult($a, $b) {return strize('mult', $a, $b); }
2190 2190
 
2191 2191
 /**
2192 2192
  * Divise 2 nombres
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
 function div($a, $b) {
2208 2208
 	return $b ? $a / $b : 0;
2209 2209
 }
2210
-function strdiv($a, $b) {return strize('div', $a, $b);}
2210
+function strdiv($a, $b) {return strize('div', $a, $b); }
2211 2211
 
2212 2212
 /**
2213 2213
  * Retourne le modulo 2 nombres
@@ -2248,13 +2248,13 @@  discard block
 block discarded – undo
2248 2248
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2249 2249
 		define('_TAGS_NOM_AUTEUR', '');
2250 2250
 	}
2251
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2251
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2252 2252
 	foreach ($tags_acceptes as $tag) {
2253 2253
 		if (strlen($tag)) {
2254
-			$remp1[] = '<' . trim($tag) . '>';
2255
-			$remp1[] = '</' . trim($tag) . '>';
2256
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2257
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2254
+			$remp1[] = '<'.trim($tag).'>';
2255
+			$remp1[] = '</'.trim($tag).'>';
2256
+			$remp2[] = '\x60'.trim($tag).'\x61';
2257
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2258 2258
 		}
2259 2259
 	}
2260 2260
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2304,7 +2304,7 @@  discard block
 block discarded – undo
2304 2304
 			$s[] = preg_replace(',>[^<]+</a>,S',
2305 2305
 				'>'
2306 2306
 				. http_img_pack('attachment-16.png', $t,
2307
-					'title="' . attribut_html($t) . '"')
2307
+					'title="'.attribut_html($t).'"')
2308 2308
 				. '</a>', $tag);
2309 2309
 		}
2310 2310
 	}
@@ -2365,10 +2365,10 @@  discard block
 block discarded – undo
2365 2365
 	$fichier = basename($url);
2366 2366
 
2367 2367
 	return '<a rel="enclosure"'
2368
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2369
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2370
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2371
-	. '>' . $fichier . '</a>';
2368
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2369
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2370
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2371
+	. '>'.$fichier.'</a>';
2372 2372
 }
2373 2373
 
2374 2374
 /**
@@ -2396,9 +2396,9 @@  discard block
 block discarded – undo
2396 2396
 			} # vieux data
2397 2397
 			$fichier = basename($url);
2398 2398
 			$enclosures[] = '<enclosure'
2399
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2400
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2401
-				. ($length ? ' length="' . $length . '"' : '')
2399
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2400
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2401
+				. ($length ? ' length="'.$length.'"' : '')
2402 2402
 				. ' />';
2403 2403
 		}
2404 2404
 	}
@@ -2424,7 +2424,7 @@  discard block
 block discarded – undo
2424 2424
 		if (extraire_attribut($e, rel) == 'tag') {
2425 2425
 			$subjects .= '<dc:subject>'
2426 2426
 				. texte_backend(textebrut($e))
2427
-				. '</dc:subject>' . "\n";
2427
+				. '</dc:subject>'."\n";
2428 2428
 		}
2429 2429
 	}
2430 2430
 
@@ -2460,7 +2460,7 @@  discard block
 block discarded – undo
2460 2460
 	if (is_array($texte)) {
2461 2461
 		array_walk(
2462 2462
 			$texte,
2463
-			function(&$a, $key, $t){
2463
+			function(&$a, $key, $t) {
2464 2464
 				$a = extraire_balise($a, $t);
2465 2465
 			},
2466 2466
 			$tag
@@ -2504,7 +2504,7 @@  discard block
 block discarded – undo
2504 2504
 	if (is_array($texte)) {
2505 2505
 		array_walk(
2506 2506
 			$texte,
2507
-			function(&$a, $key, $t){
2507
+			function(&$a, $key, $t) {
2508 2508
 				$a = extraire_balises($a, $t);
2509 2509
 			},
2510 2510
 			$tag
@@ -2630,7 +2630,7 @@  discard block
 block discarded – undo
2630 2630
 		if ($fond != '404') {
2631 2631
 			$contexte = array_shift($p);
2632 2632
 			$contexte['page'] = $fond;
2633
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2633
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2634 2634
 		}
2635 2635
 	}
2636 2636
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2685,9 +2685,9 @@  discard block
 block discarded – undo
2685 2685
 			. '"'
2686 2686
 			. (is_null($val)
2687 2687
 				? ''
2688
-				: ' value="' . entites_html($val) . '"'
2688
+				: ' value="'.entites_html($val).'"'
2689 2689
 			)
2690
-			. ' type="hidden"' . "\n/>";
2690
+			. ' type="hidden"'."\n/>";
2691 2691
 	}
2692 2692
 
2693 2693
 	return join("", $hidden);
@@ -2824,7 +2824,7 @@  discard block
 block discarded – undo
2824 2824
 	return preg_replace_callback(
2825 2825
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2826 2826
 		function($x) use ($path) {
2827
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2827
+			return "url('".suivre_lien($path, $x[1])."')";
2828 2828
 		},
2829 2829
 		$contenu
2830 2830
 	);
@@ -2886,14 +2886,14 @@  discard block
 block discarded – undo
2886 2886
 	) {
2887 2887
 		$distant = true;
2888 2888
 		$cssf = parse_url($css);
2889
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2889
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2890 2890
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2891 2891
 	} else {
2892 2892
 		$distant = false;
2893 2893
 		$cssf = $css;
2894 2894
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2895 2895
 		//propose (rien a faire dans ce cas)
2896
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2896
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2897 2897
 		if (@file_exists($f)) {
2898 2898
 			return $f;
2899 2899
 		}
@@ -2903,7 +2903,7 @@  discard block
 block discarded – undo
2903 2903
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2904 2904
 	$f = $dir_var
2905 2905
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2906
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2906
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2907 2907
 
2908 2908
 	// la css peut etre distante (url absolue !)
2909 2909
 	if ($distant) {
@@ -2948,8 +2948,8 @@  discard block
 block discarded – undo
2948 2948
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2949 2949
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2950 2950
 			$css_direction = substr($css_direction, strlen($dir_var));
2951
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2952
-			$css_direction = "/@@@@@@/" . $css_direction;
2951
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
2952
+			$css_direction = "/@@@@@@/".$css_direction;
2953 2953
 		}
2954 2954
 		$src[] = $regs[0][$k];
2955 2955
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -2998,7 +2998,7 @@  discard block
 block discarded – undo
2998 2998
 
2999 2999
 	$f = basename($css, '.css');
3000 3000
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3001
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3001
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3002 3002
 		. '.css';
3003 3003
 
3004 3004
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3007,7 +3007,7 @@  discard block
 block discarded – undo
3007 3007
 
3008 3008
 	if ($url_absolue_css == $css) {
3009 3009
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3010
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3010
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3011 3011
 		) {
3012 3012
 			include_spip('inc/distant');
3013 3013
 			if (!$contenu = recuperer_page($css)) {
@@ -3117,7 +3117,7 @@  discard block
 block discarded – undo
3117 3117
 	$expression = str_replace("\/", "/", $expression);
3118 3118
 	$expression = str_replace("/", "\/", $expression);
3119 3119
 
3120
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3120
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3121 3121
 		if (isset($r[$capte])) {
3122 3122
 			return $r[$capte];
3123 3123
 		} else {
@@ -3155,7 +3155,7 @@  discard block
 block discarded – undo
3155 3155
 	$expression = str_replace("\/", "/", $expression);
3156 3156
 	$expression = str_replace("/", "\/", $expression);
3157 3157
 
3158
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3158
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3159 3159
 }
3160 3160
 
3161 3161
 
@@ -3174,7 +3174,7 @@  discard block
 block discarded – undo
3174 3174
 function traiter_doublons_documents(&$doublons, $letexte) {
3175 3175
 
3176 3176
 	// Verifier dans le texte & les notes (pas beau, helas)
3177
-	$t = $letexte . $GLOBALS['les_notes'];
3177
+	$t = $letexte.$GLOBALS['les_notes'];
3178 3178
 
3179 3179
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3180 3180
 		and preg_match_all(
@@ -3184,7 +3184,7 @@  discard block
 block discarded – undo
3184 3184
 		if (!isset($doublons['documents'])) {
3185 3185
 			$doublons['documents'] = "";
3186 3186
 		}
3187
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3187
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3188 3188
 	}
3189 3189
 
3190 3190
 	return $letexte;
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
 	if ($env) {
3242 3242
 		foreach ($env as $i => $j) {
3243 3243
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3244
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3244
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3245 3245
 			}
3246 3246
 		}
3247 3247
 	}
@@ -3280,7 +3280,7 @@  discard block
 block discarded – undo
3280 3280
 	if ($env) {
3281 3281
 		foreach ($env as $i => $j) {
3282 3282
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3283
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3283
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3284 3284
 			}
3285 3285
 		}
3286 3286
 	}
@@ -3364,19 +3364,19 @@  discard block
 block discarded – undo
3364 3364
 
3365 3365
 	$img_file = $img;
3366 3366
 	if ($p = strpos($img_file, '?')) {
3367
-		$img_file = substr($img_file,0, $p);
3367
+		$img_file = substr($img_file, 0, $p);
3368 3368
 	}
3369 3369
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3370 3370
 		$img_file = chemin_image($img);
3371 3371
 	}
3372 3372
 	else {
3373
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3373
+		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3374 3374
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3375 3375
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3376 3376
 			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3377
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3377
+			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg"
3378 3378
 			  and file_exists($variante_svg_generique)) {
3379
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3379
+				if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) {
3380 3380
 					$img_file = $variante_svg_size;
3381 3381
 				}
3382 3382
 				else {
@@ -3401,7 +3401,7 @@  discard block
 block discarded – undo
3401 3401
 				return "";
3402 3402
 			}
3403 3403
 		}
3404
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3404
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3405 3405
 	}
3406 3406
 
3407 3407
 	if (file_exists($img_file)) {
@@ -3410,15 +3410,15 @@  discard block
 block discarded – undo
3410 3410
 	if ($alt === false) {
3411 3411
 		$alt = '';
3412 3412
 	}
3413
-	elseif($alt or $alt==='') {
3413
+	elseif ($alt or $alt === '') {
3414 3414
 		$alt = " alt='".attribut_html($alt)."'";
3415 3415
 	}
3416 3416
 	else {
3417 3417
 		$alt = " alt='".attribut_html($title)."'";
3418 3418
 	}
3419 3419
 	return "<img src='$img_file'$alt"
3420
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3421
-	. " " . ltrim($atts)
3420
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3421
+	. " ".ltrim($atts)
3422 3422
 	. " />";
3423 3423
 }
3424 3424
 
@@ -3430,12 +3430,12 @@  discard block
 block discarded – undo
3430 3430
  * @param string $size
3431 3431
  * @return string
3432 3432
  */
3433
-function http_style_background($img, $att = '', $size=null) {
3434
-	if ($size and is_numeric($size)){
3435
-		$size = trim($size) . "px";
3433
+function http_style_background($img, $att = '', $size = null) {
3434
+	if ($size and is_numeric($size)) {
3435
+		$size = trim($size)."px";
3436 3436
 	}
3437
-	return " style='background" .
3438
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3437
+	return " style='background".
3438
+		($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";"
3439 3439
 		. ($size ? "background-size:{$size};" : '')
3440 3440
 		. "'";
3441 3441
 }
@@ -3452,8 +3452,8 @@  discard block
 block discarded – undo
3452 3452
  * @return string
3453 3453
  *     Code HTML de la balise IMG
3454 3454
  */
3455
-function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3456
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3455
+function filtre_balise_img_dist($img, $alt = "", $class = "", $width = null) {
3456
+	$atts = $class ? " class='".attribut_html($class)."'" : '';
3457 3457
 	// ecriture courte : on donne le width en 2e arg
3458 3458
 	if (empty($width) and is_numeric($alt)) {
3459 3459
 		$width = $alt;
@@ -3481,7 +3481,7 @@  discard block
 block discarded – undo
3481 3481
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3482 3482
 	$img_file = $img;
3483 3483
 	if ($p = strpos($img_file, '?')) {
3484
-		$img_file = substr($img_file,0, $p);
3484
+		$img_file = substr($img_file, 0, $p);
3485 3485
 	}
3486 3486
 
3487 3487
 	if (!$img_file or !$svg = file_get_contents($img_file)) {
@@ -3495,18 +3495,18 @@  discard block
 block discarded – undo
3495 3495
 	$balise_svg_source = $balise_svg;
3496 3496
 
3497 3497
 	// entete XML à supprimer
3498
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3498
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3499 3499
 
3500 3500
 	// IE est toujours mon ami
3501 3501
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3502 3502
 	if ($class) {
3503 3503
 		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3504 3504
 	}
3505
-	if ($alt){
3505
+	if ($alt) {
3506 3506
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3507
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3507
+		$id = "img-svg-title-".substr(md5("$img_file:$svg:$alt"), 0, 4);
3508 3508
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3509
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3509
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3510 3510
 		$balise_svg .= $title;
3511 3511
 	}
3512 3512
 	else {
@@ -3540,7 +3540,7 @@  discard block
 block discarded – undo
3540 3540
 	$texte = '';
3541 3541
 	if (is_array($tableau)) {
3542 3542
 		foreach ($tableau as $k => $v) {
3543
-			$res = recuperer_fond('modeles/' . $modele,
3543
+			$res = recuperer_fond('modeles/'.$modele,
3544 3544
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3545 3545
 			);
3546 3546
 			$texte .= $res;
@@ -3717,7 +3717,7 @@  discard block
 block discarded – undo
3717 3717
 	}
3718 3718
 
3719 3719
 	$c = serialize($c);
3720
-	$cle = calculer_cle_action($form . $c);
3720
+	$cle = calculer_cle_action($form.$c);
3721 3721
 	$c = "$cle:$c";
3722 3722
 
3723 3723
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3779,15 +3779,15 @@  discard block
 block discarded – undo
3779 3779
 	}
3780 3780
 	// toujours encoder l'url source dans le bloc ajax
3781 3781
 	$r = self();
3782
-	$r = ' data-origin="' . $r . '"';
3782
+	$r = ' data-origin="'.$r.'"';
3783 3783
 	$class = 'ajaxbloc';
3784 3784
 	if ($ajaxid and is_string($ajaxid)) {
3785 3785
 		// ajaxid est normalement conforme a un nom de classe css
3786 3786
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3787
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3787
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3788 3788
 	}
3789 3789
 
3790
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3790
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3791 3791
 }
3792 3792
 
3793 3793
 /**
@@ -3826,11 +3826,11 @@  discard block
 block discarded – undo
3826 3826
 	// extraire la signature en debut de contexte
3827 3827
 	// et la verifier avant de deserializer
3828 3828
 	// format : signature:donneesserializees
3829
-	if ($p = strpos($c,":")){
3830
-		$cle = substr($c,0,$p);
3831
-		$c = substr($c,$p+1);
3829
+	if ($p = strpos($c, ":")) {
3830
+		$cle = substr($c, 0, $p);
3831
+		$c = substr($c, $p + 1);
3832 3832
 
3833
-		if ($cle == calculer_cle_action($form . $c)) {
3833
+		if ($cle == calculer_cle_action($form.$c)) {
3834 3834
 			$env = @unserialize($c);
3835 3835
 			return $env;
3836 3836
 		}
@@ -3931,9 +3931,9 @@  discard block
 block discarded – undo
3931 3931
 	} else {
3932 3932
 		$bal = 'a';
3933 3933
 		$att = "href='$url'"
3934
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3935
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3936
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3934
+			. ($title ? " title='".attribut_html($title)."'" : '')
3935
+			. ($class ? " class='".attribut_html($class)."'" : '')
3936
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
3937 3937
 			. $evt;
3938 3938
 	}
3939 3939
 	if ($libelle === null) {
@@ -4027,7 +4027,7 @@  discard block
 block discarded – undo
4027 4027
 	}
4028 4028
 
4029 4029
 	// ajouter le type d'objet dans la class de l'icone
4030
-	$class .= " " . substr(basename($fond), 0, -4);
4030
+	$class .= " ".substr(basename($fond), 0, -4);
4031 4031
 
4032 4032
 	$alt = attribut_html($texte);
4033 4033
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -4051,7 +4051,7 @@  discard block
 block discarded – undo
4051 4051
 	}
4052 4052
 
4053 4053
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4054
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4054
+	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "")."\">$icone</span>";
4055 4055
 
4056 4056
 	if ($type == 'lien') {
4057 4057
 		return "<span class='icone s$size $class'>"
@@ -4281,13 +4281,13 @@  discard block
 block discarded – undo
4281 4281
 	$res = "";
4282 4282
 	foreach ($boutons as $page => $detail) {
4283 4283
 		if ($detail->icone and strlen(trim($detail->icone))) {
4284
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4284
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4285 4285
 		}
4286 4286
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4287 4287
 		if (is_array($detail->sousmenu)) {
4288 4288
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4289 4289
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4290
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4290
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4291 4291
 				}
4292 4292
 			}
4293 4293
 		}
@@ -4313,17 +4313,17 @@  discard block
 block discarded – undo
4313 4313
  */
4314 4314
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4315 4315
 	if ($confirm) {
4316
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4316
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4317 4317
 		if ($callback) {
4318 4318
 			$callback = "$confirm?($callback):false";
4319 4319
 		} else {
4320 4320
 			$callback = $confirm;
4321 4321
 		}
4322 4322
 	}
4323
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4323
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4324 4324
 	$title = $title ? " title='$title'" : "";
4325 4325
 
4326
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4326
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4327 4327
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4328 4328
 }
4329 4329
 
@@ -4384,14 +4384,14 @@  discard block
 block discarded – undo
4384 4384
 		$champ_titre = "";
4385 4385
 		if ($demande_titre) {
4386 4386
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4387
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4387
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4388 4388
 		}
4389 4389
 		include_spip('base/abstract_sql');
4390 4390
 		include_spip('base/connect_sql');
4391 4391
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4392
-			'*' . $champ_titre,
4392
+			'*'.$champ_titre,
4393 4393
 			$desc['table_sql'],
4394
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4394
+			id_table_objet($type_objet).' = '.intval($id_objet)
4395 4395
 		);
4396 4396
 	}
4397 4397
 
@@ -4461,7 +4461,7 @@  discard block
 block discarded – undo
4461 4461
 		return $texte;
4462 4462
 	}
4463 4463
 
4464
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4464
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4465 4465
 
4466 4466
 	// Fournir $connect et $Pile[0] au traitement si besoin
4467 4467
 	$Pile = array(0 => $env);
@@ -4495,7 +4495,7 @@  discard block
 block discarded – undo
4495 4495
 	}
4496 4496
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4497 4497
 
4498
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4498
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4499 4499
 }
4500 4500
 
4501 4501
 
@@ -4514,10 +4514,10 @@  discard block
 block discarded – undo
4514 4514
 function wrap($texte, $wrap) {
4515 4515
 	$balises = extraire_balises($wrap);
4516 4516
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4517
-		$texte = $wrap . $texte;
4517
+		$texte = $wrap.$texte;
4518 4518
 		$regs = array_reverse($regs[1]);
4519
-		$wrap = "</" . implode("></", $regs) . ">";
4520
-		$texte = $texte . $wrap;
4519
+		$wrap = "</".implode("></", $regs).">";
4520
+		$texte = $texte.$wrap;
4521 4521
 	}
4522 4522
 
4523 4523
 	return $texte;
@@ -4548,7 +4548,7 @@  discard block
 block discarded – undo
4548 4548
 
4549 4549
 	// caster $u en array si besoin
4550 4550
 	if (is_object($u)) {
4551
-		$u = (array)$u;
4551
+		$u = (array) $u;
4552 4552
 	}
4553 4553
 
4554 4554
 	if (is_array($u)) {
@@ -4569,7 +4569,7 @@  discard block
 block discarded – undo
4569 4569
 		// sinon on passe a la ligne et on indente
4570 4570
 		$i_str = str_pad("", $indent, " ");
4571 4571
 		foreach ($u as $k => $v) {
4572
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4572
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4573 4573
 		}
4574 4574
 
4575 4575
 		return $out;
@@ -4622,8 +4622,8 @@  discard block
 block discarded – undo
4622 4622
  * @param string $class
4623 4623
  * @return string
4624 4624
  */
4625
-function objet_icone($objet, $taille = 24, $class='') {
4626
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4625
+function objet_icone($objet, $taille = 24, $class = '') {
4626
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4627 4627
 	$icone = chemin_image($icone);
4628 4628
 	$balise_img = charger_filtre('balise_img');
4629 4629
 
@@ -4647,12 +4647,12 @@  discard block
 block discarded – undo
4647 4647
  * @param array $options
4648 4648
  * @return string
4649 4649
  */
4650
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4651
-	$chaine = explode(':',$chaine);
4652
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4650
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4651
+	$chaine = explode(':', $chaine);
4652
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4653 4653
 		return $t;
4654 4654
 	}
4655
-	$chaine = implode(':',$chaine);
4655
+	$chaine = implode(':', $chaine);
4656 4656
 	return _T($chaine, $args, $options);
4657 4657
 }
4658 4658
 
@@ -4712,7 +4712,7 @@  discard block
 block discarded – undo
4712 4712
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4713 4713
 
4714 4714
 	// calculer le nom de la css
4715
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4715
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4716 4716
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4717 4717
 	$contexte_implicite = calculer_contexte_implicite();
4718 4718
 
@@ -4720,22 +4720,22 @@  discard block
 block discarded – undo
4720 4720
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4721 4721
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4722 4722
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4723
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4723
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
4724 4724
 	}
4725 4725
 	else {
4726 4726
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4727 4727
 		ksort($contexte);
4728
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4728
+		$hash = md5($fond.json_encode($contexte_implicite).json_encode($contexte).$connect);
4729 4729
 	}
4730
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4730
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4731 4731
 
4732 4732
 	// mettre a jour le fichier si il n'existe pas
4733 4733
 	// ou trop ancien
4734 4734
 	// le dernier fichier produit est toujours suffixe par .last
4735 4735
 	// et recopie sur le fichier cible uniquement si il change
4736 4736
 	if (!file_exists($filename)
4737
-		or !file_exists($filename . ".last")
4738
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4737
+		or !file_exists($filename.".last")
4738
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4739 4739
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4740 4740
 	) {
4741 4741
 		$contenu = $cache['texte'];
@@ -4754,10 +4754,10 @@  discard block
 block discarded – undo
4754 4754
 			}
4755 4755
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4756 4756
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4757
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4757
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4758 4758
 		}
4759 4759
 		// et ecrire le fichier si il change
4760
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4760
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
4761 4761
 	}
4762 4762
 
4763 4763
 	return timestamp($filename);
@@ -4952,11 +4952,11 @@  discard block
 block discarded – undo
4952 4952
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4953 4953
 	$l = strlen($passe);
4954 4954
 
4955
-	if ($l<=8 or !$afficher_partiellement){
4955
+	if ($l <= 8 or !$afficher_partiellement) {
4956 4956
 		if (!$l) {
4957 4957
 			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4958 4958
 		}
4959
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4959
+		return str_pad('', $afficher_partiellement ? $l : 16, '*');
4960 4960
 	}
4961 4961
 
4962 4962
 	if (is_null($portion_pourcent)) {
@@ -4970,9 +4970,9 @@  discard block
 block discarded – undo
4970 4970
 	}
4971 4971
 	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4972 4972
 	$e = max($e, 0);
4973
-	$mid = str_pad('',$l-2*$e,'*');
4974
-	if ($e>0 and strlen($mid)>8){
4973
+	$mid = str_pad('', $l - 2 * $e, '*');
4974
+	if ($e > 0 and strlen($mid) > 8) {
4975 4975
 		$mid = '***...***';
4976 4976
 	}
4977
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4977
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
4978 4978
 }
4979 4979
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2057,8 +2057,7 @@  discard block
 block discarded – undo
2057 2057
 				if (in_array($operation, ['ajouter', 'commuter'])
2058 2058
 					and !$is_class_presente) {
2059 2059
 					$class_new = rtrim($class_new) . " " . $c;
2060
-				}
2061
-				elseif (in_array($operation, ['supprimer', 'commuter'])
2060
+				} elseif (in_array($operation, ['supprimer', 'commuter'])
2062 2061
 					and $is_class_presente) {
2063 2062
 					$class_new = trim(preg_replace("/(^|\s)".preg_quote($c)."($|\s)/", "\\1", $class_new));
2064 2063
 				}
@@ -2068,8 +2067,7 @@  discard block
 block discarded – undo
2068 2067
 		if ($class_new !== $class_courante) {
2069 2068
 			if (strlen($class_new)) {
2070 2069
 				$balise = inserer_attribut($balise, 'class', $class_new);
2071
-			}
2072
-			elseif ($class_courante) {
2070
+			} elseif ($class_courante) {
2073 2071
 				$balise = vider_attribut($balise, 'class');
2074 2072
 			}
2075 2073
 		}
@@ -3368,8 +3366,7 @@  discard block
 block discarded – undo
3368 3366
 	}
3369 3367
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3370 3368
 		$img_file = chemin_image($img);
3371
-	}
3372
-	else {
3369
+	} else {
3373 3370
 		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3374 3371
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3375 3372
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
@@ -3378,8 +3375,7 @@  discard block
 block discarded – undo
3378 3375
 			  and file_exists($variante_svg_generique)) {
3379 3376
 				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3380 3377
 					$img_file = $variante_svg_size;
3381
-				}
3382
-				else {
3378
+				} else {
3383 3379
 					$img_file = $variante_svg_generique;
3384 3380
 				}
3385 3381
 			}
@@ -3409,11 +3405,9 @@  discard block
 block discarded – undo
3409 3405
 	}
3410 3406
 	if ($alt === false) {
3411 3407
 		$alt = '';
3412
-	}
3413
-	elseif($alt or $alt==='') {
3408
+	} elseif($alt or $alt==='') {
3414 3409
 		$alt = " alt='".attribut_html($alt)."'";
3415
-	}
3416
-	else {
3410
+	} else {
3417 3411
 		$alt = " alt='".attribut_html($title)."'";
3418 3412
 	}
3419 3413
 	return "<img src='$img_file'$alt"
@@ -3508,8 +3502,7 @@  discard block
 block discarded – undo
3508 3502
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3509 3503
 		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3510 3504
 		$balise_svg .= $title;
3511
-	}
3512
-	else {
3505
+	} else {
3513 3506
 		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3514 3507
 	}
3515 3508
 	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
@@ -4721,8 +4714,7 @@  discard block
 block discarded – undo
4721 4714
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4722 4715
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4723 4716
 		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4724
-	}
4725
-	else {
4717
+	} else {
4726 4718
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4727 4719
 		ksort($contexte);
4728 4720
 		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
Please login to merge, or discard this patch.