Completed
Push — master ( d07b85...46a1d0 )
by cam
04:35
created
ecrire/inc/filtres.php 2 patches
Indentation   +2038 added lines, -2038 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,36 +75,36 @@  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
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
96
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
97
-		// fonction ou name\space\fonction
98
-		if (is_callable($f)) {
99
-			return $f;
100
-		}
101
-		// méthode statique d'une classe Classe::methode ou name\space\Classe::methode
102
-		elseif (false === strpos($f, '::') and is_callable(array($f))) {
103
-			return $f;
104
-		}
105
-	}
106
-
107
-	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
+    foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
96
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
97
+        // fonction ou name\space\fonction
98
+        if (is_callable($f)) {
99
+            return $f;
100
+        }
101
+        // méthode statique d'une classe Classe::methode ou name\space\Classe::methode
102
+        elseif (false === strpos($f, '::') and is_callable(array($f))) {
103
+            return $f;
104
+        }
105
+    }
106
+
107
+    return $default;
108 108
 }
109 109
 
110 110
 /**
@@ -128,20 +128,20 @@  discard block
 block discarded – undo
128 128
  *     Chaîne vide sinon (filtre introuvable).
129 129
  **/
130 130
 function appliquer_filtre($arg, $filtre, $force = null) {
131
-	$f = chercher_filtre($filtre);
132
-	if (!$f) {
133
-		if (!$force) {
134
-			return '';
135
-		} else {
136
-			return $arg;
137
-		}
138
-	}
131
+    $f = chercher_filtre($filtre);
132
+    if (!$f) {
133
+        if (!$force) {
134
+            return '';
135
+        } else {
136
+            return $arg;
137
+        }
138
+    }
139 139
 
140
-	$args = func_get_args();
141
-	array_shift($args); // enlever $arg
142
-	array_shift($args); // enlever $filtre
143
-	array_unshift($args, $arg); // remettre $arg
144
-	return call_user_func_array($f, $args);
140
+    $args = func_get_args();
141
+    array_shift($args); // enlever $arg
142
+    array_shift($args); // enlever $filtre
143
+    array_unshift($args, $arg); // remettre $arg
144
+    return call_user_func_array($f, $args);
145 145
 }
146 146
 
147 147
 /**
@@ -157,12 +157,12 @@  discard block
 block discarded – undo
157 157
  *     Version de SPIP
158 158
  **/
159 159
 function spip_version() {
160
-	$version = $GLOBALS['spip_version_affichee'];
161
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
162
-		$version .= " $vcs_version";
163
-	}
160
+    $version = $GLOBALS['spip_version_affichee'];
161
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
162
+        $version .= " $vcs_version";
163
+    }
164 164
 
165
-	return $version;
165
+    return $version;
166 166
 }
167 167
 
168 168
 /**
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
  *    - string|null si $raw = false
176 176
  */
177 177
 function version_vcs_courante($dir, $raw = false) {
178
-	$desc = decrire_version_git($dir);
179
-	if ($desc === null) {
180
-		$desc = decrire_version_svn($dir);
181
-	}
182
-	if ($desc === null or $raw) {
183
-		return $desc;
184
-	}
185
-	// affichage "GIT [master: abcdef]"
186
-	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
187
-	if ($desc['branch']) {
188
-		$commit = $desc['branch'] . ': ' . $commit;
189
-	}
190
-	return "{$desc['vcs']} [$commit]";
178
+    $desc = decrire_version_git($dir);
179
+    if ($desc === null) {
180
+        $desc = decrire_version_svn($dir);
181
+    }
182
+    if ($desc === null or $raw) {
183
+        return $desc;
184
+    }
185
+    // affichage "GIT [master: abcdef]"
186
+    $commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
187
+    if ($desc['branch']) {
188
+        $commit = $desc['branch'] . ': ' . $commit;
189
+    }
190
+    return "{$desc['vcs']} [$commit]";
191 191
 }
192 192
 
193 193
 /**
@@ -199,24 +199,24 @@  discard block
 block discarded – undo
199 199
  *      array ['branch' => xx, 'commit' => yy] sinon.
200 200
  **/
201 201
 function decrire_version_git($dir) {
202
-	if (!$dir) {
203
-		$dir = '.';
204
-	}
202
+    if (!$dir) {
203
+        $dir = '.';
204
+    }
205 205
 
206
-	// version installee par GIT
207
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
208
-		$currentHead = trim(substr($c, 4));
209
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
210
-			return [
211
-				'vcs' => 'GIT',
212
-				'branch' => basename($currentHead),
213
-				'commit' => trim($hash),
214
-				'commit_short' => substr(trim($hash), 0, 8),
215
-			];
216
-		}
217
-	}
206
+    // version installee par GIT
207
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
208
+        $currentHead = trim(substr($c, 4));
209
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
210
+            return [
211
+                'vcs' => 'GIT',
212
+                'branch' => basename($currentHead),
213
+                'commit' => trim($hash),
214
+                'commit_short' => substr(trim($hash), 0, 8),
215
+            ];
216
+        }
217
+    }
218 218
 
219
-	return null;
219
+    return null;
220 220
 }
221 221
 
222 222
 
@@ -229,25 +229,25 @@  discard block
 block discarded – undo
229 229
  *      array ['commit' => yy, 'date' => xx, 'author' => xx] sinon.
230 230
  **/
231 231
 function decrire_version_svn($dir) {
232
-	if (!$dir) {
233
-		$dir = '.';
234
-	}
235
-	// version installee par SVN
236
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
237
-		$db = new SQLite3($dir . '/.svn/wc.db');
238
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
239
-		if ($result) {
240
-			$row = $result->fetchArray();
241
-			if ($row['changed_revision'] != "") {
242
-				return [
243
-					'vcs' => 'SVN',
244
-					'branch' => '',
245
-					'commit' => $row['changed_revision'],
246
-				];
247
-			}
248
-		}
249
-	}
250
-	return null;
232
+    if (!$dir) {
233
+        $dir = '.';
234
+    }
235
+    // version installee par SVN
236
+    if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
237
+        $db = new SQLite3($dir . '/.svn/wc.db');
238
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
239
+        if ($result) {
240
+            $row = $result->fetchArray();
241
+            if ($row['changed_revision'] != "") {
242
+                return [
243
+                    'vcs' => 'SVN',
244
+                    'branch' => '',
245
+                    'commit' => $row['changed_revision'],
246
+                ];
247
+            }
248
+        }
249
+    }
250
+    return null;
251 251
 }
252 252
 
253 253
 /**
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
  *
266 266
  **/
267 267
 function version_svn_courante($dir) {
268
-	if ($desc = decrire_version_svn($dir)) {
269
-		return -$desc['commit'];
270
-	}
271
-	return 0;
268
+    if ($desc = decrire_version_svn($dir)) {
269
+        return -$desc['commit'];
270
+    }
271
+    return 0;
272 272
 }
273 273
 
274 274
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -312,18 +312,18 @@  discard block
 block discarded – undo
312 312
  *     Code HTML retourné par le filtre
313 313
  **/
314 314
 function filtrer($filtre) {
315
-	$tous = func_get_args();
316
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
317
-		return image_filtrer($tous);
318
-	} elseif ($f = chercher_filtre($filtre)) {
319
-		array_shift($tous);
320
-		return call_user_func_array($f, $tous);
321
-	} else {
322
-		// le filtre n'existe pas, on provoque une erreur
323
-		$msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
324
-		erreur_squelette($msg);
325
-		return '';
326
-	}
315
+    $tous = func_get_args();
316
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
317
+        return image_filtrer($tous);
318
+    } elseif ($f = chercher_filtre($filtre)) {
319
+        array_shift($tous);
320
+        return call_user_func_array($f, $tous);
321
+    } else {
322
+        // le filtre n'existe pas, on provoque une erreur
323
+        $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
324
+        erreur_squelette($msg);
325
+        return '';
326
+    }
327 327
 }
328 328
 
329 329
 /**
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
341 341
  */
342 342
 function trouver_filtre_matrice($filtre) {
343
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
344
-		find_in_path($f, '', true);
345
-		$GLOBALS['spip_matrice'][$filtre] = true;
346
-	}
347
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
343
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
344
+        find_in_path($f, '', true);
345
+        $GLOBALS['spip_matrice'][$filtre] = true;
346
+    }
347
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
348 348
 }
349 349
 
350 350
 
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
  * @return mixed
373 373
  */
374 374
 function filtre_set(&$Pile, $val, $key, $continue = null) {
375
-	$Pile['vars'][$key] = $val;
376
-	return $continue ? $val : '';
375
+    $Pile['vars'][$key] = $val;
376
+    return $continue ? $val : '';
377 377
 }
378 378
 
379 379
 /**
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
400 400
  */
401 401
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
402
-	$Pile[0][$key] = $val;
403
-	return $continue ? $val : '';
402
+    $Pile[0][$key] = $val;
403
+    return $continue ? $val : '';
404 404
 }
405 405
 
406 406
 /**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
  * @return string
410 410
  */
411 411
 function filtre_sanitize_env(&$Pile, $keys) {
412
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
413
-	return '';
412
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
413
+    return '';
414 414
 }
415 415
 
416 416
 
@@ -433,18 +433,18 @@  discard block
 block discarded – undo
433 433
  * @return mixed Retourne la valeur (sans la modifier).
434 434
  */
435 435
 function filtre_debug($val, $key = null) {
436
-	$debug = (
437
-		is_null($key) ? '' : (var_export($key, true) . " = ")
438
-		) . var_export($val, true);
436
+    $debug = (
437
+        is_null($key) ? '' : (var_export($key, true) . " = ")
438
+        ) . var_export($val, true);
439 439
 
440
-	include_spip('inc/autoriser');
441
-	if (autoriser('webmestre')) {
442
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
443
-	}
440
+    include_spip('inc/autoriser');
441
+    if (autoriser('webmestre')) {
442
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
443
+    }
444 444
 
445
-	spip_log($debug, 'debug');
445
+    spip_log($debug, 'debug');
446 446
 
447
-	return $val;
447
+    return $val;
448 448
 }
449 449
 
450 450
 
@@ -472,71 +472,71 @@  discard block
 block discarded – undo
472 472
  *     Texte qui a reçu les filtres
473 473
  **/
474 474
 function image_filtrer($args) {
475
-	$filtre = array_shift($args); # enlever $filtre
476
-	$texte = array_shift($args);
477
-	if (!strlen($texte)) {
478
-		return;
479
-	}
480
-	find_in_path('filtres_images_mini.php', 'inc/', true);
481
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
482
-	// Cas du nom de fichier local
483
-	if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
484
-		and !preg_match(',^/|[<>]|\s,S', $texte)
485
-		and (
486
-			file_exists(preg_replace(',[?].*$,', '', $texte))
487
-			or tester_url_absolue($texte)
488
-		)
489
-	) {
490
-		array_unshift($args, "<img src='$texte' />");
491
-		$res = call_user_func_array($filtre, $args);
492
-		statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
493
-		return $res;
494
-	}
495
-
496
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
497
-	if (preg_match_all(
498
-		',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
499
-		$texte, $tags, PREG_SET_ORDER)) {
500
-		foreach ($tags as $tag) {
501
-			$class = extraire_attribut($tag[3], 'class');
502
-			if (!$class or
503
-				(strpos($class, 'filtre_inactif') === false
504
-					// compat historique a virer en 3.2
505
-					and strpos($class, 'no_image_filtrer') === false)
506
-			) {
507
-				array_unshift($args, $tag[3]);
508
-				if ($reduit = call_user_func_array($filtre, $args)) {
509
-					// En cas de span spip_documents, modifier le style=...width:
510
-					if ($tag[1]) {
511
-						$w = extraire_attribut($reduit, 'width');
512
-						if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
513
-							$w = $regs[1];
514
-						}
515
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
516
-							$style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
517
-							$replace = inserer_attribut($tag[1], 'style', $style);
518
-							$texte = str_replace($tag[1], $replace, $texte);
519
-						}
520
-					}
521
-					// traiter aussi un eventuel mouseover
522
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
523
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
524
-							$srcover = $match[1];
525
-							array_shift($args);
526
-							array_unshift($args, "<img src='" . $match[1] . "' />");
527
-							$srcover_filter = call_user_func_array($filtre, $args);
528
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
529
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
530
-						}
531
-					}
532
-					$texte = str_replace($tag[3], $reduit, $texte);
533
-				}
534
-				array_shift($args);
535
-			}
536
-		}
537
-	}
538
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
539
-	return $texte;
475
+    $filtre = array_shift($args); # enlever $filtre
476
+    $texte = array_shift($args);
477
+    if (!strlen($texte)) {
478
+        return;
479
+    }
480
+    find_in_path('filtres_images_mini.php', 'inc/', true);
481
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
482
+    // Cas du nom de fichier local
483
+    if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
484
+        and !preg_match(',^/|[<>]|\s,S', $texte)
485
+        and (
486
+            file_exists(preg_replace(',[?].*$,', '', $texte))
487
+            or tester_url_absolue($texte)
488
+        )
489
+    ) {
490
+        array_unshift($args, "<img src='$texte' />");
491
+        $res = call_user_func_array($filtre, $args);
492
+        statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
493
+        return $res;
494
+    }
495
+
496
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
497
+    if (preg_match_all(
498
+        ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
499
+        $texte, $tags, PREG_SET_ORDER)) {
500
+        foreach ($tags as $tag) {
501
+            $class = extraire_attribut($tag[3], 'class');
502
+            if (!$class or
503
+                (strpos($class, 'filtre_inactif') === false
504
+                    // compat historique a virer en 3.2
505
+                    and strpos($class, 'no_image_filtrer') === false)
506
+            ) {
507
+                array_unshift($args, $tag[3]);
508
+                if ($reduit = call_user_func_array($filtre, $args)) {
509
+                    // En cas de span spip_documents, modifier le style=...width:
510
+                    if ($tag[1]) {
511
+                        $w = extraire_attribut($reduit, 'width');
512
+                        if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
513
+                            $w = $regs[1];
514
+                        }
515
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
516
+                            $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
517
+                            $replace = inserer_attribut($tag[1], 'style', $style);
518
+                            $texte = str_replace($tag[1], $replace, $texte);
519
+                        }
520
+                    }
521
+                    // traiter aussi un eventuel mouseover
522
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
523
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
524
+                            $srcover = $match[1];
525
+                            array_shift($args);
526
+                            array_unshift($args, "<img src='" . $match[1] . "' />");
527
+                            $srcover_filter = call_user_func_array($filtre, $args);
528
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
529
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
530
+                        }
531
+                    }
532
+                    $texte = str_replace($tag[3], $reduit, $texte);
533
+                }
534
+                array_shift($args);
535
+            }
536
+        }
537
+    }
538
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
539
+    return $texte;
540 540
 }
541 541
 
542 542
 /**
@@ -551,65 +551,65 @@  discard block
 block discarded – undo
551 551
  **/
552 552
 function taille_image($img) {
553 553
 
554
-	static $largeur_img = array(), $hauteur_img = array();
555
-	$srcWidth = 0;
556
-	$srcHeight = 0;
557
-
558
-	$src = extraire_attribut($img, 'src');
559
-
560
-	if (!$src) {
561
-		$src = $img;
562
-	} else {
563
-		$srcWidth = extraire_attribut($img, 'width');
564
-		$srcHeight = extraire_attribut($img, 'height');
565
-	}
566
-
567
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
568
-	// la copie locale a toutes les chances d'etre la ou de resservir
569
-	if (tester_url_absolue($src)) {
570
-		include_spip('inc/distant');
571
-		$fichier = copie_locale($src);
572
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
573
-	}
574
-	if (($p = strpos($src, '?')) !== false) {
575
-		$src = substr($src, 0, $p);
576
-	}
577
-
578
-	$srcsize = false;
579
-	if (isset($largeur_img[$src])) {
580
-		$srcWidth = $largeur_img[$src];
581
-	}
582
-	if (isset($hauteur_img[$src])) {
583
-		$srcHeight = $hauteur_img[$src];
584
-	}
585
-	if (!$srcWidth or !$srcHeight) {
586
-
587
-		if (file_exists($src)
588
-			and $srcsize = spip_getimagesize($src)
589
-		) {
590
-			if (!$srcWidth) {
591
-				$largeur_img[$src] = $srcWidth = $srcsize[0];
592
-			}
593
-			if (!$srcHeight) {
594
-				$hauteur_img[$src] = $srcHeight = $srcsize[1];
595
-			}
596
-		}
597
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
598
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
599
-		elseif (@file_exists($f = "$src.src")
600
-			and lire_fichier($f, $valeurs)
601
-			and $valeurs = unserialize($valeurs)
602
-		) {
603
-			if (!$srcWidth) {
604
-				$largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
605
-			}
606
-			if (!$srcHeight) {
607
-				$hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
608
-			}
609
-		}
610
-	}
611
-
612
-	return array($srcHeight, $srcWidth);
554
+    static $largeur_img = array(), $hauteur_img = array();
555
+    $srcWidth = 0;
556
+    $srcHeight = 0;
557
+
558
+    $src = extraire_attribut($img, 'src');
559
+
560
+    if (!$src) {
561
+        $src = $img;
562
+    } else {
563
+        $srcWidth = extraire_attribut($img, 'width');
564
+        $srcHeight = extraire_attribut($img, 'height');
565
+    }
566
+
567
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
568
+    // la copie locale a toutes les chances d'etre la ou de resservir
569
+    if (tester_url_absolue($src)) {
570
+        include_spip('inc/distant');
571
+        $fichier = copie_locale($src);
572
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
573
+    }
574
+    if (($p = strpos($src, '?')) !== false) {
575
+        $src = substr($src, 0, $p);
576
+    }
577
+
578
+    $srcsize = false;
579
+    if (isset($largeur_img[$src])) {
580
+        $srcWidth = $largeur_img[$src];
581
+    }
582
+    if (isset($hauteur_img[$src])) {
583
+        $srcHeight = $hauteur_img[$src];
584
+    }
585
+    if (!$srcWidth or !$srcHeight) {
586
+
587
+        if (file_exists($src)
588
+            and $srcsize = spip_getimagesize($src)
589
+        ) {
590
+            if (!$srcWidth) {
591
+                $largeur_img[$src] = $srcWidth = $srcsize[0];
592
+            }
593
+            if (!$srcHeight) {
594
+                $hauteur_img[$src] = $srcHeight = $srcsize[1];
595
+            }
596
+        }
597
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
598
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
599
+        elseif (@file_exists($f = "$src.src")
600
+            and lire_fichier($f, $valeurs)
601
+            and $valeurs = unserialize($valeurs)
602
+        ) {
603
+            if (!$srcWidth) {
604
+                $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
605
+            }
606
+            if (!$srcHeight) {
607
+                $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
608
+            }
609
+        }
610
+    }
611
+
612
+    return array($srcHeight, $srcWidth);
613 613
 }
614 614
 
615 615
 
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
  *     Largeur en pixels, NULL ou 0 si aucune image.
628 628
  **/
629 629
 function largeur($img) {
630
-	if (!$img) {
631
-		return;
632
-	}
633
-	list($h, $l) = taille_image($img);
630
+    if (!$img) {
631
+        return;
632
+    }
633
+    list($h, $l) = taille_image($img);
634 634
 
635
-	return $l;
635
+    return $l;
636 636
 }
637 637
 
638 638
 /**
@@ -649,12 +649,12 @@  discard block
 block discarded – undo
649 649
  *     Hauteur en pixels, NULL ou 0 si aucune image.
650 650
  **/
651 651
 function hauteur($img) {
652
-	if (!$img) {
653
-		return;
654
-	}
655
-	list($h, $l) = taille_image($img);
652
+    if (!$img) {
653
+        return;
654
+    }
655
+    list($h, $l) = taille_image($img);
656 656
 
657
-	return $h;
657
+    return $h;
658 658
 }
659 659
 
660 660
 
@@ -674,11 +674,11 @@  discard block
 block discarded – undo
674 674
  * @return string
675 675
  **/
676 676
 function corriger_entites_html($texte) {
677
-	if (strpos($texte, '&amp;') === false) {
678
-		return $texte;
679
-	}
677
+    if (strpos($texte, '&amp;') === false) {
678
+        return $texte;
679
+    }
680 680
 
681
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
681
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
682 682
 }
683 683
 
684 684
 /**
@@ -693,11 +693,11 @@  discard block
 block discarded – undo
693 693
  * @return string
694 694
  **/
695 695
 function corriger_toutes_entites_html($texte) {
696
-	if (strpos($texte, '&amp;') === false) {
697
-		return $texte;
698
-	}
696
+    if (strpos($texte, '&amp;') === false) {
697
+        return $texte;
698
+    }
699 699
 
700
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
700
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
701 701
 }
702 702
 
703 703
 /**
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
  * @return string
708 708
  **/
709 709
 function proteger_amp($texte) {
710
-	return str_replace('&', '&amp;', $texte);
710
+    return str_replace('&', '&amp;', $texte);
711 711
 }
712 712
 
713 713
 
@@ -738,20 +738,20 @@  discard block
 block discarded – undo
738 738
  * @return mixed|string
739 739
  */
740 740
 function entites_html($texte, $tout = false, $quote = true) {
741
-	if (!is_string($texte) or !$texte
742
-		or strpbrk($texte, "&\"'<>") == false
743
-	) {
744
-		return $texte;
745
-	}
746
-	include_spip('inc/texte');
747
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
748
-	$flags |= ENT_HTML401;
749
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
750
-	if ($tout) {
751
-		return corriger_toutes_entites_html($texte);
752
-	} else {
753
-		return corriger_entites_html($texte);
754
-	}
741
+    if (!is_string($texte) or !$texte
742
+        or strpbrk($texte, "&\"'<>") == false
743
+    ) {
744
+        return $texte;
745
+    }
746
+    include_spip('inc/texte');
747
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
748
+    $flags |= ENT_HTML401;
749
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
750
+    if ($tout) {
751
+        return corriger_toutes_entites_html($texte);
752
+    } else {
753
+        return corriger_entites_html($texte);
754
+    }
755 755
 }
756 756
 
757 757
 /**
@@ -770,37 +770,37 @@  discard block
 block discarded – undo
770 770
  *     Texte converti
771 771
  **/
772 772
 function filtrer_entites($texte) {
773
-	if (strpos($texte, '&') === false) {
774
-		return $texte;
775
-	}
776
-	// filtrer
777
-	$texte = html2unicode($texte);
778
-	// remettre le tout dans le charset cible
779
-	$texte = unicode2charset($texte);
780
-	// cas particulier des " et ' qu'il faut filtrer aussi
781
-	// (on le faisait deja avec un &quot;)
782
-	if (strpos($texte, "&#") !== false) {
783
-		$texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
784
-	}
773
+    if (strpos($texte, '&') === false) {
774
+        return $texte;
775
+    }
776
+    // filtrer
777
+    $texte = html2unicode($texte);
778
+    // remettre le tout dans le charset cible
779
+    $texte = unicode2charset($texte);
780
+    // cas particulier des " et ' qu'il faut filtrer aussi
781
+    // (on le faisait deja avec un &quot;)
782
+    if (strpos($texte, "&#") !== false) {
783
+        $texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
784
+    }
785 785
 
786
-	return $texte;
786
+    return $texte;
787 787
 }
788 788
 
789 789
 
790 790
 if (!function_exists('filtre_filtrer_entites_dist')) {
791
-	/**
792
-	 * Version sécurisée de filtrer_entites
793
-	 * 
794
-	 * @uses interdire_scripts()
795
-	 * @uses filtrer_entites()
796
-	 * 
797
-	 * @param string $t
798
-	 * @return string
799
-	 */
800
-	function filtre_filtrer_entites_dist($t) {
801
-		include_spip('inc/texte');
802
-		return interdire_scripts(filtrer_entites($t));
803
-	}
791
+    /**
792
+     * Version sécurisée de filtrer_entites
793
+     * 
794
+     * @uses interdire_scripts()
795
+     * @uses filtrer_entites()
796
+     * 
797
+     * @param string $t
798
+     * @return string
799
+     */
800
+    function filtre_filtrer_entites_dist($t) {
801
+        include_spip('inc/texte');
802
+        return interdire_scripts(filtrer_entites($t));
803
+    }
804 804
 }
805 805
 
806 806
 
@@ -815,18 +815,18 @@  discard block
 block discarded – undo
815 815
  * @return string|array
816 816
  **/
817 817
 function supprimer_caracteres_illegaux($texte) {
818
-	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";
819
-	static $to = null;
818
+    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";
819
+    static $to = null;
820 820
 
821
-	if (is_array($texte)) {
822
-		return array_map('supprimer_caracteres_illegaux', $texte);
823
-	}
821
+    if (is_array($texte)) {
822
+        return array_map('supprimer_caracteres_illegaux', $texte);
823
+    }
824 824
 
825
-	if (!$to) {
826
-		$to = str_repeat('-', strlen($from));
827
-	}
825
+    if (!$to) {
826
+        $to = str_repeat('-', strlen($from));
827
+    }
828 828
 
829
-	return strtr($texte, $from, $to);
829
+    return strtr($texte, $from, $to);
830 830
 }
831 831
 
832 832
 /**
@@ -838,10 +838,10 @@  discard block
 block discarded – undo
838 838
  * @return string|array
839 839
  **/
840 840
 function corriger_caracteres($texte) {
841
-	$texte = corriger_caracteres_windows($texte);
842
-	$texte = supprimer_caracteres_illegaux($texte);
841
+    $texte = corriger_caracteres_windows($texte);
842
+    $texte = supprimer_caracteres_illegaux($texte);
843 843
 
844
-	return $texte;
844
+    return $texte;
845 845
 }
846 846
 
847 847
 /**
@@ -859,40 +859,40 @@  discard block
 block discarded – undo
859 859
  */
860 860
 function texte_backend($texte) {
861 861
 
862
-	static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
862
+    static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
863 863
 
864
-	// si on a des liens ou des images, les passer en absolu
865
-	$texte = liens_absolus($texte);
864
+    // si on a des liens ou des images, les passer en absolu
865
+    $texte = liens_absolus($texte);
866 866
 
867
-	// echapper les tags &gt; &lt;
868
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
867
+    // echapper les tags &gt; &lt;
868
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
869 869
 
870
-	// importer les &eacute;
871
-	$texte = filtrer_entites($texte);
870
+    // importer les &eacute;
871
+    $texte = filtrer_entites($texte);
872 872
 
873
-	// " -> &quot; et tout ce genre de choses
874
-	$u = $GLOBALS['meta']['pcre_u'];
875
-	$texte = str_replace("&nbsp;", " ", $texte);
876
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
877
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
878
-	$texte = entites_html($texte, false, false);
879
-	// mais bien echapper les double quotes !
880
-	$texte = str_replace('"', '&#034;', $texte);
873
+    // " -> &quot; et tout ce genre de choses
874
+    $u = $GLOBALS['meta']['pcre_u'];
875
+    $texte = str_replace("&nbsp;", " ", $texte);
876
+    $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
877
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
878
+    $texte = entites_html($texte, false, false);
879
+    // mais bien echapper les double quotes !
880
+    $texte = str_replace('"', '&#034;', $texte);
881 881
 
882
-	// verifier le charset
883
-	$texte = charset2unicode($texte);
882
+    // verifier le charset
883
+    $texte = charset2unicode($texte);
884 884
 
885
-	// Caracteres problematiques en iso-latin 1
886
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
887
-		$texte = str_replace(chr(156), '&#156;', $texte);
888
-		$texte = str_replace(chr(140), '&#140;', $texte);
889
-		$texte = str_replace(chr(159), '&#159;', $texte);
890
-	}
885
+    // Caracteres problematiques en iso-latin 1
886
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
887
+        $texte = str_replace(chr(156), '&#156;', $texte);
888
+        $texte = str_replace(chr(140), '&#140;', $texte);
889
+        $texte = str_replace(chr(159), '&#159;', $texte);
890
+    }
891 891
 
892
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
893
-	// et le caractere apostrophe alourdit les squelettes avec PHP
894
-	// ==> on les remplace par l'entite HTML
895
-	return str_replace($apostrophe, "'", $texte);
892
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
893
+    // et le caractere apostrophe alourdit les squelettes avec PHP
894
+    // ==> on les remplace par l'entite HTML
895
+    return str_replace($apostrophe, "'", $texte);
896 896
 }
897 897
 
898 898
 /**
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
  *     Texte encodé et quote pour XML
910 910
  */
911 911
 function texte_backendq($texte) {
912
-	return addslashes(texte_backend($texte));
912
+    return addslashes(texte_backend($texte));
913 913
 }
914 914
 
915 915
 
@@ -932,9 +932,9 @@  discard block
 block discarded – undo
932 932
  *     Numéro de titre, sinon chaîne vide
933 933
  **/
934 934
 function supprimer_numero($texte) {
935
-	return preg_replace(
936
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
937
-		"", $texte);
935
+    return preg_replace(
936
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
937
+        "", $texte);
938 938
 }
939 939
 
940 940
 /**
@@ -957,13 +957,13 @@  discard block
 block discarded – undo
957 957
  *     Numéro de titre, sinon chaîne vide
958 958
  **/
959 959
 function recuperer_numero($texte) {
960
-	if (preg_match(
961
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
962
-		$texte, $regs)) {
963
-		return strval($regs[1]);
964
-	} else {
965
-		return '';
966
-	}
960
+    if (preg_match(
961
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
962
+        $texte, $regs)) {
963
+        return strval($regs[1]);
964
+    } else {
965
+        return '';
966
+    }
967 967
 }
968 968
 
969 969
 /**
@@ -990,13 +990,13 @@  discard block
 block discarded – undo
990 990
  *     Texte converti
991 991
  **/
992 992
 function supprimer_tags($texte, $rempl = "") {
993
-	$texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
994
-	// ne pas oublier un < final non ferme car coupe
995
-	$texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
996
-	// mais qui peut aussi etre un simple signe plus petit que
997
-	$texte = str_replace('<', '&lt;', $texte);
993
+    $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
994
+    // ne pas oublier un < final non ferme car coupe
995
+    $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
996
+    // mais qui peut aussi etre un simple signe plus petit que
997
+    $texte = str_replace('<', '&lt;', $texte);
998 998
 
999
-	return $texte;
999
+    return $texte;
1000 1000
 }
1001 1001
 
1002 1002
 /**
@@ -1019,9 +1019,9 @@  discard block
 block discarded – undo
1019 1019
  *     Texte converti
1020 1020
  **/
1021 1021
 function echapper_tags($texte, $rempl = "") {
1022
-	$texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1022
+    $texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1023 1023
 
1024
-	return $texte;
1024
+    return $texte;
1025 1025
 }
1026 1026
 
1027 1027
 /**
@@ -1042,18 +1042,18 @@  discard block
 block discarded – undo
1042 1042
  *     Texte converti
1043 1043
  **/
1044 1044
 function textebrut($texte) {
1045
-	$u = $GLOBALS['meta']['pcre_u'];
1046
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1047
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1048
-	$texte = preg_replace("/^\n+/", "", $texte);
1049
-	$texte = preg_replace("/\n+$/", "", $texte);
1050
-	$texte = preg_replace("/\n +/", "\n", $texte);
1051
-	$texte = supprimer_tags($texte);
1052
-	$texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1053
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1054
-	$texte = str_replace("&#8217;", "'", $texte);
1045
+    $u = $GLOBALS['meta']['pcre_u'];
1046
+    $texte = preg_replace('/\s+/S' . $u, " ", $texte);
1047
+    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1048
+    $texte = preg_replace("/^\n+/", "", $texte);
1049
+    $texte = preg_replace("/\n+$/", "", $texte);
1050
+    $texte = preg_replace("/\n +/", "\n", $texte);
1051
+    $texte = supprimer_tags($texte);
1052
+    $texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1053
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1054
+    $texte = str_replace("&#8217;", "'", $texte);
1055 1055
 
1056
-	return $texte;
1056
+    return $texte;
1057 1057
 }
1058 1058
 
1059 1059
 
@@ -1069,17 +1069,17 @@  discard block
 block discarded – undo
1069 1069
  *     Texte avec liens ouvrants
1070 1070
  **/
1071 1071
 function liens_ouvrants($texte) {
1072
-	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1073
-		$texte, $liens, PREG_PATTERN_ORDER)) {
1074
-		foreach ($liens[0] as $a) {
1075
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1076
-			$ablank = inserer_attribut($a, 'rel', $rel);
1077
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1078
-			$texte = str_replace($a, $ablank, $texte);
1079
-		}
1080
-	}
1072
+    if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1073
+        $texte, $liens, PREG_PATTERN_ORDER)) {
1074
+        foreach ($liens[0] as $a) {
1075
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1076
+            $ablank = inserer_attribut($a, 'rel', $rel);
1077
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1078
+            $texte = str_replace($a, $ablank, $texte);
1079
+        }
1080
+    }
1081 1081
 
1082
-	return $texte;
1082
+    return $texte;
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1089,22 +1089,22 @@  discard block
 block discarded – undo
1089 1089
  * @return string
1090 1090
  */
1091 1091
 function liens_nofollow($texte) {
1092
-	if (stripos($texte, "<a") === false) {
1093
-		return $texte;
1094
-	}
1092
+    if (stripos($texte, "<a") === false) {
1093
+        return $texte;
1094
+    }
1095 1095
 
1096
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1097
-		foreach ($regs[0] as $a) {
1098
-			$rel = extraire_attribut($a, "rel");
1099
-			if (strpos($rel, "nofollow") === false) {
1100
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1101
-				$anofollow = inserer_attribut($a, "rel", $rel);
1102
-				$texte = str_replace($a, $anofollow, $texte);
1103
-			}
1104
-		}
1105
-	}
1096
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1097
+        foreach ($regs[0] as $a) {
1098
+            $rel = extraire_attribut($a, "rel");
1099
+            if (strpos($rel, "nofollow") === false) {
1100
+                $rel = "nofollow" . ($rel ? " $rel" : "");
1101
+                $anofollow = inserer_attribut($a, "rel", $rel);
1102
+                $texte = str_replace($a, $anofollow, $texte);
1103
+            }
1104
+        }
1105
+    }
1106 1106
 
1107
-	return $texte;
1107
+    return $texte;
1108 1108
 }
1109 1109
 
1110 1110
 /**
@@ -1123,12 +1123,12 @@  discard block
 block discarded – undo
1123 1123
  *     Texte sans paraghaphes
1124 1124
  **/
1125 1125
 function PtoBR($texte) {
1126
-	$u = $GLOBALS['meta']['pcre_u'];
1127
-	$texte = preg_replace("@</p>@iS", "\n", $texte);
1128
-	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1129
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1126
+    $u = $GLOBALS['meta']['pcre_u'];
1127
+    $texte = preg_replace("@</p>@iS", "\n", $texte);
1128
+    $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1129
+    $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1130 1130
 
1131
-	return $texte;
1131
+    return $texte;
1132 1132
 }
1133 1133
 
1134 1134
 
@@ -1152,14 +1152,14 @@  discard block
 block discarded – undo
1152 1152
  * @return string Texte encadré du style CSS
1153 1153
  */
1154 1154
 function lignes_longues($texte) {
1155
-	if (!strlen(trim($texte))) {
1156
-		return $texte;
1157
-	}
1158
-	include_spip('inc/texte');
1159
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1160
-		'div' : 'span';
1155
+    if (!strlen(trim($texte))) {
1156
+        return $texte;
1157
+    }
1158
+    include_spip('inc/texte');
1159
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1160
+        'div' : 'span';
1161 1161
 
1162
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1162
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1163 1163
 }
1164 1164
 
1165 1165
 /**
@@ -1178,30 +1178,30 @@  discard block
 block discarded – undo
1178 1178
  * @return string Texte en majuscule
1179 1179
  */
1180 1180
 function majuscules($texte) {
1181
-	if (!strlen($texte)) {
1182
-		return '';
1183
-	}
1181
+    if (!strlen($texte)) {
1182
+        return '';
1183
+    }
1184 1184
 
1185
-	// Cas du turc
1186
-	if ($GLOBALS['spip_lang'] == 'tr') {
1187
-		# remplacer hors des tags et des entites
1188
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1189
-			foreach ($regs as $n => $match) {
1190
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1191
-			}
1192
-		}
1185
+    // Cas du turc
1186
+    if ($GLOBALS['spip_lang'] == 'tr') {
1187
+        # remplacer hors des tags et des entites
1188
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1189
+            foreach ($regs as $n => $match) {
1190
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1191
+            }
1192
+        }
1193 1193
 
1194
-		$texte = str_replace('i', '&#304;', $texte);
1194
+        $texte = str_replace('i', '&#304;', $texte);
1195 1195
 
1196
-		if ($regs) {
1197
-			foreach ($regs as $n => $match) {
1198
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1199
-			}
1200
-		}
1201
-	}
1196
+        if ($regs) {
1197
+            foreach ($regs as $n => $match) {
1198
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1199
+            }
1200
+        }
1201
+    }
1202 1202
 
1203
-	// Cas general
1204
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1203
+    // Cas general
1204
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1205 1205
 }
1206 1206
 
1207 1207
 /**
@@ -1219,29 +1219,29 @@  discard block
 block discarded – undo
1219 1219
  * @return string
1220 1220
  **/
1221 1221
 function taille_en_octets($taille) {
1222
-	if (!defined('_KILOBYTE')) {
1223
-		/**
1224
-		 * Définit le nombre d'octets dans un Kilobyte
1225
-		 *
1226
-		 * @var int
1227
-		 **/
1228
-		define('_KILOBYTE', 1024);
1229
-	}
1222
+    if (!defined('_KILOBYTE')) {
1223
+        /**
1224
+         * Définit le nombre d'octets dans un Kilobyte
1225
+         *
1226
+         * @var int
1227
+         **/
1228
+        define('_KILOBYTE', 1024);
1229
+    }
1230 1230
 
1231
-	if ($taille < 1) {
1232
-		return '';
1233
-	}
1234
-	if ($taille < _KILOBYTE) {
1235
-		$taille = _T('taille_octets', array('taille' => $taille));
1236
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1237
-		$taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1238
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1239
-		$taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1240
-	} else {
1241
-		$taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1242
-	}
1231
+    if ($taille < 1) {
1232
+        return '';
1233
+    }
1234
+    if ($taille < _KILOBYTE) {
1235
+        $taille = _T('taille_octets', array('taille' => $taille));
1236
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1237
+        $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1238
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1239
+        $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1240
+    } else {
1241
+        $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1242
+    }
1243 1243
 
1244
-	return $taille;
1244
+    return $taille;
1245 1245
 }
1246 1246
 
1247 1247
 
@@ -1263,15 +1263,15 @@  discard block
 block discarded – undo
1263 1263
  *     Texte prêt pour être utilisé en attribut HTML
1264 1264
  **/
1265 1265
 function attribut_html($texte, $textebrut = true) {
1266
-	$u = $GLOBALS['meta']['pcre_u'];
1267
-	if ($textebrut) {
1268
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1269
-	}
1270
-	$texte = texte_backend($texte);
1271
-	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1266
+    $u = $GLOBALS['meta']['pcre_u'];
1267
+    if ($textebrut) {
1268
+        $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1269
+    }
1270
+    $texte = texte_backend($texte);
1271
+    $texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1272 1272
 
1273
-	return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1274
-		$texte);
1273
+    return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1274
+        $texte);
1275 1275
 }
1276 1276
 
1277 1277
 
@@ -1291,12 +1291,12 @@  discard block
 block discarded – undo
1291 1291
  *     URL ou chaîne vide
1292 1292
  **/
1293 1293
 function vider_url($url, $entites = true) {
1294
-	# un message pour abs_url
1295
-	$GLOBALS['mode_abs_url'] = 'url';
1296
-	$url = trim($url);
1297
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1294
+    # un message pour abs_url
1295
+    $GLOBALS['mode_abs_url'] = 'url';
1296
+    $url = trim($url);
1297
+    $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1298 1298
 
1299
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1299
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1300 1300
 }
1301 1301
 
1302 1302
 
@@ -1311,10 +1311,10 @@  discard block
 block discarded – undo
1311 1311
  * @return string Adresse email maquillée
1312 1312
  **/
1313 1313
 function antispam($texte) {
1314
-	include_spip('inc/acces');
1315
-	$masque = creer_pass_aleatoire(3);
1314
+    include_spip('inc/acces');
1315
+    $masque = creer_pass_aleatoire(3);
1316 1316
 
1317
-	return preg_replace("/@/", " $masque ", $texte);
1317
+    return preg_replace("/@/", " $masque ", $texte);
1318 1318
 }
1319 1319
 
1320 1320
 /**
@@ -1346,12 +1346,12 @@  discard block
 block discarded – undo
1346 1346
  *     True si on a le droit d'accès, false sinon.
1347 1347
  **/
1348 1348
 function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') {
1349
-	include_spip('inc/acces');
1350
-	if ($op) {
1351
-		$dir .= " $op $args";
1352
-	}
1349
+    include_spip('inc/acces');
1350
+    if ($op) {
1351
+        $dir .= " $op $args";
1352
+    }
1353 1353
 
1354
-	return verifier_low_sec($id_auteur, $cle, $dir);
1354
+    return verifier_low_sec($id_auteur, $cle, $dir);
1355 1355
 }
1356 1356
 
1357 1357
 /**
@@ -1376,11 +1376,11 @@  discard block
 block discarded – undo
1376 1376
  *     Retourne $texte, sinon $sinon.
1377 1377
  **/
1378 1378
 function sinon($texte, $sinon = '') {
1379
-	if ($texte or (!is_array($texte) and strlen($texte))) {
1380
-		return $texte;
1381
-	} else {
1382
-		return $sinon;
1383
-	}
1379
+    if ($texte or (!is_array($texte) and strlen($texte))) {
1380
+        return $texte;
1381
+    } else {
1382
+        return $sinon;
1383
+    }
1384 1384
 }
1385 1385
 
1386 1386
 /**
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
  * @return mixed
1405 1405
  **/
1406 1406
 function choixsivide($a, $vide, $pasvide) {
1407
-	return $a ? $pasvide : $vide;
1407
+    return $a ? $pasvide : $vide;
1408 1408
 }
1409 1409
 
1410 1410
 /**
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
  * @return mixed
1429 1429
  **/
1430 1430
 function choixsiegal($a1, $a2, $v, $f) {
1431
-	return ($a1 == $a2) ? $v : $f;
1431
+    return ($a1 == $a2) ? $v : $f;
1432 1432
 }
1433 1433
 
1434 1434
 //
@@ -1447,13 +1447,13 @@  discard block
 block discarded – undo
1447 1447
  * @return string
1448 1448
  **/
1449 1449
 function filtrer_ical($texte) {
1450
-	#include_spip('inc/charsets');
1451
-	$texte = html2unicode($texte);
1452
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1453
-	$texte = preg_replace("/\n/", " ", $texte);
1454
-	$texte = preg_replace("/,/", "\,", $texte);
1450
+    #include_spip('inc/charsets');
1451
+    $texte = html2unicode($texte);
1452
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1453
+    $texte = preg_replace("/\n/", " ", $texte);
1454
+    $texte = preg_replace("/,/", "\,", $texte);
1455 1455
 
1456
-	return $texte;
1456
+    return $texte;
1457 1457
 }
1458 1458
 
1459 1459
 
@@ -1478,53 +1478,53 @@  discard block
 block discarded – undo
1478 1478
  * @return string
1479 1479
  **/
1480 1480
 function post_autobr($texte, $delim = "\n_ ") {
1481
-	if (!function_exists('echappe_html')) {
1482
-		include_spip('inc/texte_mini');
1483
-	}
1484
-	$texte = str_replace("\r\n", "\r", $texte);
1485
-	$texte = str_replace("\r", "\n", $texte);
1486
-
1487
-	if (preg_match(",\n+$,", $texte, $fin)) {
1488
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1489
-	} else {
1490
-		$fin = '';
1491
-	}
1492
-
1493
-	$texte = echappe_html($texte, '', true);
1494
-
1495
-	// echapper les modeles
1496
-	if (strpos($texte, "<") !== false) {
1497
-		include_spip('inc/lien');
1498
-		if (defined('_PREG_MODELE')) {
1499
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1500
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1501
-		}
1502
-	}
1503
-
1504
-	$debut = '';
1505
-	$suite = $texte;
1506
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1507
-		$debut .= substr($suite, 0, $t - 1);
1508
-		$suite = substr($suite, $t);
1509
-		$car = substr($suite, 0, 1);
1510
-		if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1511
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1512
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1513
-		) {
1514
-			$debut .= $delim;
1515
-		} else {
1516
-			$debut .= "\n";
1517
-		}
1518
-		if (preg_match(",^\n+,", $suite, $regs)) {
1519
-			$debut .= $regs[0];
1520
-			$suite = substr($suite, strlen($regs[0]));
1521
-		}
1522
-	}
1523
-	$texte = $debut . $suite;
1524
-
1525
-	$texte = echappe_retour($texte);
1526
-
1527
-	return $texte . $fin;
1481
+    if (!function_exists('echappe_html')) {
1482
+        include_spip('inc/texte_mini');
1483
+    }
1484
+    $texte = str_replace("\r\n", "\r", $texte);
1485
+    $texte = str_replace("\r", "\n", $texte);
1486
+
1487
+    if (preg_match(",\n+$,", $texte, $fin)) {
1488
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1489
+    } else {
1490
+        $fin = '';
1491
+    }
1492
+
1493
+    $texte = echappe_html($texte, '', true);
1494
+
1495
+    // echapper les modeles
1496
+    if (strpos($texte, "<") !== false) {
1497
+        include_spip('inc/lien');
1498
+        if (defined('_PREG_MODELE')) {
1499
+            $preg_modeles = "@" . _PREG_MODELE . "@imsS";
1500
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1501
+        }
1502
+    }
1503
+
1504
+    $debut = '';
1505
+    $suite = $texte;
1506
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1507
+        $debut .= substr($suite, 0, $t - 1);
1508
+        $suite = substr($suite, $t);
1509
+        $car = substr($suite, 0, 1);
1510
+        if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1511
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1512
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1513
+        ) {
1514
+            $debut .= $delim;
1515
+        } else {
1516
+            $debut .= "\n";
1517
+        }
1518
+        if (preg_match(",^\n+,", $suite, $regs)) {
1519
+            $debut .= $regs[0];
1520
+            $suite = substr($suite, strlen($regs[0]));
1521
+        }
1522
+    }
1523
+    $texte = $debut . $suite;
1524
+
1525
+    $texte = echappe_retour($texte);
1526
+
1527
+    return $texte . $fin;
1528 1528
 }
1529 1529
 
1530 1530
 
@@ -1565,46 +1565,46 @@  discard block
 block discarded – undo
1565 1565
  * @return string
1566 1566
  **/
1567 1567
 function extraire_idiome($letexte, $lang = null, $options = array()) {
1568
-	static $traduire = false;
1569
-	if ($letexte
1570
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1571
-	) {
1572
-		if (!$traduire) {
1573
-			$traduire = charger_fonction('traduire', 'inc');
1574
-			include_spip('inc/lang');
1575
-		}
1576
-		if (!$lang) {
1577
-			$lang = $GLOBALS['spip_lang'];
1578
-		}
1579
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1580
-		if (is_bool($options)) {
1581
-			$options = array('echappe_span' => $options);
1582
-		}
1583
-		if (!isset($options['echappe_span'])) {
1584
-			$options = array_merge($options, array('echappe_span' => false));
1585
-		}
1586
-
1587
-		foreach ($regs as $reg) {
1588
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1589
-			$desc = $traduire($cle, $lang, true);
1590
-			$l = $desc->langue;
1591
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1592
-			if (strlen($desc->texte)) {
1593
-				$trad = code_echappement($desc->texte, 'idiome', false);
1594
-				if ($l !== $lang) {
1595
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1596
-				}
1597
-				if (lang_dir($l) !== lang_dir($lang)) {
1598
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1599
-				}
1600
-				if (!$options['echappe_span']) {
1601
-					$trad = echappe_retour($trad, 'idiome');
1602
-				}
1603
-				$letexte = str_replace($reg[0], $trad, $letexte);
1604
-			}
1605
-		}
1606
-	}
1607
-	return $letexte;
1568
+    static $traduire = false;
1569
+    if ($letexte
1570
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1571
+    ) {
1572
+        if (!$traduire) {
1573
+            $traduire = charger_fonction('traduire', 'inc');
1574
+            include_spip('inc/lang');
1575
+        }
1576
+        if (!$lang) {
1577
+            $lang = $GLOBALS['spip_lang'];
1578
+        }
1579
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1580
+        if (is_bool($options)) {
1581
+            $options = array('echappe_span' => $options);
1582
+        }
1583
+        if (!isset($options['echappe_span'])) {
1584
+            $options = array_merge($options, array('echappe_span' => false));
1585
+        }
1586
+
1587
+        foreach ($regs as $reg) {
1588
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1589
+            $desc = $traduire($cle, $lang, true);
1590
+            $l = $desc->langue;
1591
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1592
+            if (strlen($desc->texte)) {
1593
+                $trad = code_echappement($desc->texte, 'idiome', false);
1594
+                if ($l !== $lang) {
1595
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1596
+                }
1597
+                if (lang_dir($l) !== lang_dir($lang)) {
1598
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1599
+                }
1600
+                if (!$options['echappe_span']) {
1601
+                    $trad = echappe_retour($trad, 'idiome');
1602
+                }
1603
+                $letexte = str_replace($reg[0], $trad, $letexte);
1604
+            }
1605
+        }
1606
+    }
1607
+    return $letexte;
1608 1608
 }
1609 1609
 
1610 1610
 /**
@@ -1656,64 +1656,64 @@  discard block
 block discarded – undo
1656 1656
  **/
1657 1657
 function extraire_multi($letexte, $lang = null, $options = array()) {
1658 1658
 
1659
-	if ($letexte
1660
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1661
-	) {
1662
-		if (!$lang) {
1663
-			$lang = $GLOBALS['spip_lang'];
1664
-		}
1665
-
1666
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1667
-		if (is_bool($options)) {
1668
-			$options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1669
-		}
1670
-		if (!isset($options['echappe_span'])) {
1671
-			$options = array_merge($options, array('echappe_span' => false));
1672
-		}
1673
-		if (!isset($options['lang_defaut'])) {
1674
-			$options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1675
-		}
1676
-
1677
-		include_spip('inc/lang');
1678
-		foreach ($regs as $reg) {
1679
-			// chercher la version de la langue courante
1680
-			$trads = extraire_trads($reg[1]);
1681
-			if ($l = approcher_langue($trads, $lang)) {
1682
-				$trad = $trads[$l];
1683
-			} else {
1684
-				if ($options['lang_defaut'] == 'aucune') {
1685
-					$trad = '';
1686
-				} else {
1687
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1688
-					// ou la premiere dispo
1689
-					// mais typographier le texte selon les regles de celle-ci
1690
-					// Attention aux blocs multi sur plusieurs lignes
1691
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1692
-						$l = key($trads);
1693
-					}
1694
-					$trad = $trads[$l];
1695
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1696
-					$trad = $typographie($trad);
1697
-					// Tester si on echappe en span ou en div
1698
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1699
-					include_spip('inc/texte');
1700
-					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1701
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1702
-					$trad = code_echappement($trad, 'multi', false, $mode);
1703
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1704
-					if (lang_dir($l) !== lang_dir($lang)) {
1705
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1706
-					}
1707
-					if (!$options['echappe_span']) {
1708
-						$trad = echappe_retour($trad, 'multi');
1709
-					}
1710
-				}
1711
-			}
1712
-			$letexte = str_replace($reg[0], $trad, $letexte);
1713
-		}
1714
-	}
1715
-
1716
-	return $letexte;
1659
+    if ($letexte
1660
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1661
+    ) {
1662
+        if (!$lang) {
1663
+            $lang = $GLOBALS['spip_lang'];
1664
+        }
1665
+
1666
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1667
+        if (is_bool($options)) {
1668
+            $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1669
+        }
1670
+        if (!isset($options['echappe_span'])) {
1671
+            $options = array_merge($options, array('echappe_span' => false));
1672
+        }
1673
+        if (!isset($options['lang_defaut'])) {
1674
+            $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1675
+        }
1676
+
1677
+        include_spip('inc/lang');
1678
+        foreach ($regs as $reg) {
1679
+            // chercher la version de la langue courante
1680
+            $trads = extraire_trads($reg[1]);
1681
+            if ($l = approcher_langue($trads, $lang)) {
1682
+                $trad = $trads[$l];
1683
+            } else {
1684
+                if ($options['lang_defaut'] == 'aucune') {
1685
+                    $trad = '';
1686
+                } else {
1687
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1688
+                    // ou la premiere dispo
1689
+                    // mais typographier le texte selon les regles de celle-ci
1690
+                    // Attention aux blocs multi sur plusieurs lignes
1691
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1692
+                        $l = key($trads);
1693
+                    }
1694
+                    $trad = $trads[$l];
1695
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1696
+                    $trad = $typographie($trad);
1697
+                    // Tester si on echappe en span ou en div
1698
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1699
+                    include_spip('inc/texte');
1700
+                    $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1701
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1702
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1703
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1704
+                    if (lang_dir($l) !== lang_dir($lang)) {
1705
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1706
+                    }
1707
+                    if (!$options['echappe_span']) {
1708
+                        $trad = echappe_retour($trad, 'multi');
1709
+                    }
1710
+                }
1711
+            }
1712
+            $letexte = str_replace($reg[0], $trad, $letexte);
1713
+        }
1714
+    }
1715
+
1716
+    return $letexte;
1717 1717
 }
1718 1718
 
1719 1719
 /**
@@ -1729,20 +1729,20 @@  discard block
 block discarded – undo
1729 1729
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1730 1730
  **/
1731 1731
 function extraire_trads($bloc) {
1732
-	$lang = '';
1732
+    $lang = '';
1733 1733
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1734 1734
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1735
-	while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1736
-		$texte = trim($regs[1]);
1737
-		if ($texte or $lang) {
1738
-			$trads[$lang] = $texte;
1739
-		}
1740
-		$bloc = substr($bloc, strlen($regs[0]));
1741
-		$lang = $regs[2];
1742
-	}
1743
-	$trads[$lang] = $bloc;
1735
+    while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1736
+        $texte = trim($regs[1]);
1737
+        if ($texte or $lang) {
1738
+            $trads[$lang] = $texte;
1739
+        }
1740
+        $bloc = substr($bloc, strlen($regs[0]));
1741
+        $lang = $regs[2];
1742
+    }
1743
+    $trads[$lang] = $bloc;
1744 1744
 
1745
-	return $trads;
1745
+    return $trads;
1746 1746
 }
1747 1747
 
1748 1748
 
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
  * @return string L'initiale en majuscule
1754 1754
  */
1755 1755
 function filtre_initiale($nom) {
1756
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1756
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1757 1757
 }
1758 1758
 
1759 1759
 
@@ -1798,33 +1798,33 @@  discard block
 block discarded – undo
1798 1798
  *      - null (interne) : si on empile
1799 1799
  **/
1800 1800
 function unique($donnee, $famille = '', $cpt = false) {
1801
-	static $mem = array();
1802
-	// permettre de vider la pile et de la restaurer
1803
-	// pour le calcul de introduction...
1804
-	if ($famille == '_spip_raz_') {
1805
-		$tmp = $mem;
1806
-		$mem = array();
1807
-
1808
-		return $tmp;
1809
-	} elseif ($famille == '_spip_set_') {
1810
-		$mem = $donnee;
1811
-
1812
-		return;
1813
-	}
1814
-	// eviter une notice
1815
-	if (!isset($mem[$famille])) {
1816
-		$mem[$famille] = array();
1817
-	}
1818
-	if ($cpt) {
1819
-		return count($mem[$famille]);
1820
-	}
1821
-	// eviter une notice
1822
-	if (!isset($mem[$famille][$donnee])) {
1823
-		$mem[$famille][$donnee] = 0;
1824
-	}
1825
-	if (!($mem[$famille][$donnee]++)) {
1826
-		return $donnee;
1827
-	}
1801
+    static $mem = array();
1802
+    // permettre de vider la pile et de la restaurer
1803
+    // pour le calcul de introduction...
1804
+    if ($famille == '_spip_raz_') {
1805
+        $tmp = $mem;
1806
+        $mem = array();
1807
+
1808
+        return $tmp;
1809
+    } elseif ($famille == '_spip_set_') {
1810
+        $mem = $donnee;
1811
+
1812
+        return;
1813
+    }
1814
+    // eviter une notice
1815
+    if (!isset($mem[$famille])) {
1816
+        $mem[$famille] = array();
1817
+    }
1818
+    if ($cpt) {
1819
+        return count($mem[$famille]);
1820
+    }
1821
+    // eviter une notice
1822
+    if (!isset($mem[$famille][$donnee])) {
1823
+        $mem[$famille][$donnee] = 0;
1824
+    }
1825
+    if (!($mem[$famille][$donnee]++)) {
1826
+        return $donnee;
1827
+    }
1828 1828
 }
1829 1829
 
1830 1830
 
@@ -1852,18 +1852,18 @@  discard block
 block discarded – undo
1852 1852
  *     Une des valeurs en fonction du compteur.
1853 1853
  **/
1854 1854
 function alterner($i) {
1855
-	// recuperer les arguments (attention fonctions un peu space)
1856
-	$num = func_num_args();
1857
-	$args = func_get_args();
1855
+    // recuperer les arguments (attention fonctions un peu space)
1856
+    $num = func_num_args();
1857
+    $args = func_get_args();
1858 1858
 
1859
-	if ($num == 2 && is_array($args[1])) {
1860
-		$args = $args[1];
1861
-		array_unshift($args, '');
1862
-		$num = count($args);
1863
-	}
1859
+    if ($num == 2 && is_array($args[1])) {
1860
+        $args = $args[1];
1861
+        array_unshift($args, '');
1862
+        $num = count($args);
1863
+    }
1864 1864
 
1865
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1866
-	return $args[(intval($i) - 1) % ($num - 1) + 1];
1865
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1866
+    return $args[(intval($i) - 1) % ($num - 1) + 1];
1867 1867
 }
1868 1868
 
1869 1869
 
@@ -1888,46 +1888,46 @@  discard block
 block discarded – undo
1888 1888
  *     - Tableau complet (si 2e argument)
1889 1889
  **/
1890 1890
 function extraire_attribut($balise, $attribut, $complet = false) {
1891
-	if (is_array($balise)) {
1892
-		array_walk(
1893
-			$balise,
1894
-			function(&$a, $key, $t){
1895
-				$a = extraire_attribut($a, $t);
1896
-			},
1897
-			$attribut
1898
-		);
1899
-
1900
-		return $balise;
1901
-	}
1902
-	if (preg_match(
1903
-		',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1904
-		. $attribut
1905
-		. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1906
-
1907
-		$balise, $r)) {
1908
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1909
-			$r[4] = substr($r[3], 1, -1);
1910
-			$r[3] = $r[3][0];
1911
-		} elseif ($r[3] !== '') {
1912
-			$r[4] = $r[3];
1913
-			$r[3] = '';
1914
-		} else {
1915
-			$r[4] = trim($r[2]);
1916
-		}
1917
-		$att = $r[4];
1918
-		if (strpos($att, "&#") !== false) {
1919
-			$att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1920
-		}
1921
-		$att = filtrer_entites($att);
1922
-	} else {
1923
-		$att = null;
1924
-	}
1925
-
1926
-	if ($complet) {
1927
-		return array($att, $r);
1928
-	} else {
1929
-		return $att;
1930
-	}
1891
+    if (is_array($balise)) {
1892
+        array_walk(
1893
+            $balise,
1894
+            function(&$a, $key, $t){
1895
+                $a = extraire_attribut($a, $t);
1896
+            },
1897
+            $attribut
1898
+        );
1899
+
1900
+        return $balise;
1901
+    }
1902
+    if (preg_match(
1903
+        ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1904
+        . $attribut
1905
+        . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1906
+
1907
+        $balise, $r)) {
1908
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1909
+            $r[4] = substr($r[3], 1, -1);
1910
+            $r[3] = $r[3][0];
1911
+        } elseif ($r[3] !== '') {
1912
+            $r[4] = $r[3];
1913
+            $r[3] = '';
1914
+        } else {
1915
+            $r[4] = trim($r[2]);
1916
+        }
1917
+        $att = $r[4];
1918
+        if (strpos($att, "&#") !== false) {
1919
+            $att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1920
+        }
1921
+        $att = filtrer_entites($att);
1922
+    } else {
1923
+        $att = null;
1924
+    }
1925
+
1926
+    if ($complet) {
1927
+        return array($att, $r);
1928
+    } else {
1929
+        return $att;
1930
+    }
1931 1931
 }
1932 1932
 
1933 1933
 /**
@@ -1959,37 +1959,37 @@  discard block
 block discarded – undo
1959 1959
  *     Code html modifié
1960 1960
  **/
1961 1961
 function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) {
1962
-	// preparer l'attribut
1963
-	// supprimer les &nbsp; etc mais pas les balises html
1964
-	// qui ont un sens dans un attribut value d'un input
1965
-	if ($proteger) {
1966
-		$val = attribut_html($val, false);
1967
-	}
1968
-
1969
-	// echapper les ' pour eviter tout bug
1970
-	$val = str_replace("'", "&#039;", $val);
1971
-	if ($vider and strlen($val) == 0) {
1972
-		$insert = '';
1973
-	} else {
1974
-		$insert = " $attribut='$val'";
1975
-	}
1976
-
1977
-	list($old, $r) = extraire_attribut($balise, $attribut, true);
1978
-
1979
-	if ($old !== null) {
1980
-		// Remplacer l'ancien attribut du meme nom
1981
-		$balise = $r[1] . $insert . $r[5];
1982
-	} else {
1983
-		// preferer une balise " />" (comme <img />)
1984
-		if (preg_match(',/>,', $balise)) {
1985
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1986
-		} // sinon une balise <a ...> ... </a>
1987
-		else {
1988
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1989
-		}
1990
-	}
1991
-
1992
-	return $balise;
1962
+    // preparer l'attribut
1963
+    // supprimer les &nbsp; etc mais pas les balises html
1964
+    // qui ont un sens dans un attribut value d'un input
1965
+    if ($proteger) {
1966
+        $val = attribut_html($val, false);
1967
+    }
1968
+
1969
+    // echapper les ' pour eviter tout bug
1970
+    $val = str_replace("'", "&#039;", $val);
1971
+    if ($vider and strlen($val) == 0) {
1972
+        $insert = '';
1973
+    } else {
1974
+        $insert = " $attribut='$val'";
1975
+    }
1976
+
1977
+    list($old, $r) = extraire_attribut($balise, $attribut, true);
1978
+
1979
+    if ($old !== null) {
1980
+        // Remplacer l'ancien attribut du meme nom
1981
+        $balise = $r[1] . $insert . $r[5];
1982
+    } else {
1983
+        // preferer une balise " />" (comme <img />)
1984
+        if (preg_match(',/>,', $balise)) {
1985
+            $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1986
+        } // sinon une balise <a ...> ... </a>
1987
+        else {
1988
+            $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1989
+        }
1990
+    }
1991
+
1992
+    return $balise;
1993 1993
 }
1994 1994
 
1995 1995
 /**
@@ -2007,7 +2007,7 @@  discard block
 block discarded – undo
2007 2007
  * @return string Code HTML sans l'attribut
2008 2008
  **/
2009 2009
 function vider_attribut($balise, $attribut) {
2010
-	return inserer_attribut($balise, $attribut, '', false, true);
2010
+    return inserer_attribut($balise, $attribut, '', false, true);
2011 2011
 }
2012 2012
 
2013 2013
 
@@ -2019,9 +2019,9 @@  discard block
 block discarded – undo
2019 2019
  * @return string
2020 2020
  */
2021 2021
 function tester_config($id, $mode = '') {
2022
-	include_spip('action/inscrire_auteur');
2022
+    include_spip('action/inscrire_auteur');
2023 2023
 
2024
-	return tester_statut_inscription($mode, $id);
2024
+    return tester_statut_inscription($mode, $id);
2025 2025
 }
2026 2026
 
2027 2027
 //
@@ -2046,7 +2046,7 @@  discard block
 block discarded – undo
2046 2046
  * @return int $a+$b
2047 2047
  **/
2048 2048
 function plus($a, $b) {
2049
-	return $a + $b;
2049
+    return $a + $b;
2050 2050
 }
2051 2051
 function strplus($a, $b) {return strize('plus', $a, $b);}
2052 2052
 /**
@@ -2065,7 +2065,7 @@  discard block
 block discarded – undo
2065 2065
  * @return int $a-$b
2066 2066
  **/
2067 2067
 function moins($a, $b) {
2068
-	return $a - $b;
2068
+    return $a - $b;
2069 2069
 }
2070 2070
 function strmoins($a, $b) {return strize('moins', $a, $b);}
2071 2071
 
@@ -2086,7 +2086,7 @@  discard block
 block discarded – undo
2086 2086
  * @return int $a*$b
2087 2087
  **/
2088 2088
 function mult($a, $b) {
2089
-	return $a * $b;
2089
+    return $a * $b;
2090 2090
 }
2091 2091
 function strmult($a, $b) {return strize('mult', $a, $b);}
2092 2092
 
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
  * @return int $a/$b (ou 0 si $b est nul)
2108 2108
  **/
2109 2109
 function div($a, $b) {
2110
-	return $b ? $a / $b : 0;
2110
+    return $b ? $a / $b : 0;
2111 2111
 }
2112 2112
 function strdiv($a, $b) {return strize('div', $a, $b);}
2113 2113
 
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
  * @return int ($nb % $mod) + $add
2130 2130
  **/
2131 2131
 function modulo($nb, $mod, $add = 0) {
2132
-	return ($mod ? $nb % $mod : 0) + $add;
2132
+    return ($mod ? $nb % $mod : 0) + $add;
2133 2133
 }
2134 2134
 
2135 2135
 
@@ -2144,24 +2144,24 @@  discard block
 block discarded – undo
2144 2144
  *      - true sinon
2145 2145
  **/
2146 2146
 function nom_acceptable($nom) {
2147
-	if (!is_string($nom)) {
2148
-		return false;
2149
-	}
2150
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2151
-		define('_TAGS_NOM_AUTEUR', '');
2152
-	}
2153
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2154
-	foreach ($tags_acceptes as $tag) {
2155
-		if (strlen($tag)) {
2156
-			$remp1[] = '<' . trim($tag) . '>';
2157
-			$remp1[] = '</' . trim($tag) . '>';
2158
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2159
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2160
-		}
2161
-	}
2162
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2147
+    if (!is_string($nom)) {
2148
+        return false;
2149
+    }
2150
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2151
+        define('_TAGS_NOM_AUTEUR', '');
2152
+    }
2153
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2154
+    foreach ($tags_acceptes as $tag) {
2155
+        if (strlen($tag)) {
2156
+            $remp1[] = '<' . trim($tag) . '>';
2157
+            $remp1[] = '</' . trim($tag) . '>';
2158
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2159
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2160
+        }
2161
+    }
2162
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2163 2163
 
2164
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2164
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2165 2165
 }
2166 2166
 
2167 2167
 
@@ -2175,29 +2175,29 @@  discard block
 block discarded – undo
2175 2175
  *      - la normalisation de la dernière adresse donnée sinon
2176 2176
  **/
2177 2177
 function email_valide($adresses) {
2178
-	// eviter d'injecter n'importe quoi dans preg_match
2179
-	if (!is_string($adresses)) {
2180
-		return false;
2181
-	}
2178
+    // eviter d'injecter n'importe quoi dans preg_match
2179
+    if (!is_string($adresses)) {
2180
+        return false;
2181
+    }
2182 2182
 
2183
-	// Si c'est un spammeur autant arreter tout de suite
2184
-	if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2185
-		spip_log("Tentative d'injection de mail : $adresses");
2183
+    // Si c'est un spammeur autant arreter tout de suite
2184
+    if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2185
+        spip_log("Tentative d'injection de mail : $adresses");
2186 2186
 
2187
-		return false;
2188
-	}
2187
+        return false;
2188
+    }
2189 2189
 
2190
-	foreach (explode(',', $adresses) as $v) {
2191
-		// nettoyer certains formats
2192
-		// "Marie Toto <[email protected]>"
2193
-		$adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2194
-		// RFC 822
2195
-		if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2196
-			return false;
2197
-		}
2198
-	}
2190
+    foreach (explode(',', $adresses) as $v) {
2191
+        // nettoyer certains formats
2192
+        // "Marie Toto <[email protected]>"
2193
+        $adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2194
+        // RFC 822
2195
+        if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2196
+            return false;
2197
+        }
2198
+    }
2199 2199
 
2200
-	return $adresse;
2200
+    return $adresse;
2201 2201
 }
2202 2202
 
2203 2203
 /**
@@ -2211,20 +2211,20 @@  discard block
 block discarded – undo
2211 2211
  * @return string Texte
2212 2212
  **/
2213 2213
 function afficher_enclosures($tags) {
2214
-	$s = array();
2215
-	foreach (extraire_balises($tags, 'a') as $tag) {
2216
-		if (extraire_attribut($tag, 'rel') == 'enclosure'
2217
-			and $t = extraire_attribut($tag, 'href')
2218
-		) {
2219
-			$s[] = preg_replace(',>[^<]+</a>,S',
2220
-				'>'
2221
-				. http_img_pack('attachment-16.png', $t,
2222
-					'title="' . attribut_html($t) . '"')
2223
-				. '</a>', $tag);
2224
-		}
2225
-	}
2214
+    $s = array();
2215
+    foreach (extraire_balises($tags, 'a') as $tag) {
2216
+        if (extraire_attribut($tag, 'rel') == 'enclosure'
2217
+            and $t = extraire_attribut($tag, 'href')
2218
+        ) {
2219
+            $s[] = preg_replace(',>[^<]+</a>,S',
2220
+                '>'
2221
+                . http_img_pack('attachment-16.png', $t,
2222
+                    'title="' . attribut_html($t) . '"')
2223
+                . '</a>', $tag);
2224
+        }
2225
+    }
2226 2226
 
2227
-	return join('&nbsp;', $s);
2227
+    return join('&nbsp;', $s);
2228 2228
 }
2229 2229
 
2230 2230
 /**
@@ -2239,15 +2239,15 @@  discard block
 block discarded – undo
2239 2239
  * @return string Liens trouvés
2240 2240
  **/
2241 2241
 function afficher_tags($tags, $rels = 'tag,directory') {
2242
-	$s = array();
2243
-	foreach (extraire_balises($tags, 'a') as $tag) {
2244
-		$rel = extraire_attribut($tag, 'rel');
2245
-		if (strstr(",$rels,", ",$rel,")) {
2246
-			$s[] = $tag;
2247
-		}
2248
-	}
2242
+    $s = array();
2243
+    foreach (extraire_balises($tags, 'a') as $tag) {
2244
+        $rel = extraire_attribut($tag, 'rel');
2245
+        if (strstr(",$rels,", ",$rel,")) {
2246
+            $s[] = $tag;
2247
+        }
2248
+    }
2249 2249
 
2250
-	return join(', ', $s);
2250
+    return join(', ', $s);
2251 2251
 }
2252 2252
 
2253 2253
 
@@ -2269,21 +2269,21 @@  discard block
 block discarded – undo
2269 2269
  * @return string Tag HTML `<a>` avec microformat.
2270 2270
  **/
2271 2271
 function enclosure2microformat($e) {
2272
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2273
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2274
-	}
2275
-	$type = extraire_attribut($e, 'type');
2276
-	if (!$length = extraire_attribut($e, 'length')) {
2277
-		# <media:content : longeur dans fileSize. On tente.
2278
-		$length = extraire_attribut($e, 'fileSize');
2279
-	}
2280
-	$fichier = basename($url);
2272
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2273
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2274
+    }
2275
+    $type = extraire_attribut($e, 'type');
2276
+    if (!$length = extraire_attribut($e, 'length')) {
2277
+        # <media:content : longeur dans fileSize. On tente.
2278
+        $length = extraire_attribut($e, 'fileSize');
2279
+    }
2280
+    $fichier = basename($url);
2281 2281
 
2282
-	return '<a rel="enclosure"'
2283
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2284
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2285
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2286
-	. '>' . $fichier . '</a>';
2282
+    return '<a rel="enclosure"'
2283
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2284
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2285
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2286
+    . '>' . $fichier . '</a>';
2287 2287
 }
2288 2288
 
2289 2289
 /**
@@ -2301,24 +2301,24 @@  discard block
 block discarded – undo
2301 2301
  * @return string Tags RSS `<enclosure>`.
2302 2302
  **/
2303 2303
 function microformat2enclosure($tags) {
2304
-	$enclosures = array();
2305
-	foreach (extraire_balises($tags, 'a') as $e) {
2306
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2307
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2308
-			$type = extraire_attribut($e, 'type');
2309
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2310
-				$length = intval(extraire_attribut($e, 'length'));
2311
-			} # vieux data
2312
-			$fichier = basename($url);
2313
-			$enclosures[] = '<enclosure'
2314
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2315
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2316
-				. ($length ? ' length="' . $length . '"' : '')
2317
-				. ' />';
2318
-		}
2319
-	}
2304
+    $enclosures = array();
2305
+    foreach (extraire_balises($tags, 'a') as $e) {
2306
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2307
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2308
+            $type = extraire_attribut($e, 'type');
2309
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2310
+                $length = intval(extraire_attribut($e, 'length'));
2311
+            } # vieux data
2312
+            $fichier = basename($url);
2313
+            $enclosures[] = '<enclosure'
2314
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2315
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2316
+                . ($length ? ' length="' . $length . '"' : '')
2317
+                . ' />';
2318
+        }
2319
+    }
2320 2320
 
2321
-	return join("\n", $enclosures);
2321
+    return join("\n", $enclosures);
2322 2322
 }
2323 2323
 
2324 2324
 
@@ -2334,16 +2334,16 @@  discard block
 block discarded – undo
2334 2334
  * @return string Tags RSS Atom `<dc:subject>`.
2335 2335
  **/
2336 2336
 function tags2dcsubject($tags) {
2337
-	$subjects = '';
2338
-	foreach (extraire_balises($tags, 'a') as $e) {
2339
-		if (extraire_attribut($e, rel) == 'tag') {
2340
-			$subjects .= '<dc:subject>'
2341
-				. texte_backend(textebrut($e))
2342
-				. '</dc:subject>' . "\n";
2343
-		}
2344
-	}
2337
+    $subjects = '';
2338
+    foreach (extraire_balises($tags, 'a') as $e) {
2339
+        if (extraire_attribut($e, rel) == 'tag') {
2340
+            $subjects .= '<dc:subject>'
2341
+                . texte_backend(textebrut($e))
2342
+                . '</dc:subject>' . "\n";
2343
+        }
2344
+    }
2345 2345
 
2346
-	return $subjects;
2346
+    return $subjects;
2347 2347
 }
2348 2348
 
2349 2349
 /**
@@ -2372,23 +2372,23 @@  discard block
 block discarded – undo
2372 2372
  *     - Tableau de résultats, si tableau en entrée.
2373 2373
  **/
2374 2374
 function extraire_balise($texte, $tag = 'a') {
2375
-	if (is_array($texte)) {
2376
-		array_walk(
2377
-			$texte,
2378
-			function(&$a, $key, $t){
2379
-				$a = extraire_balise($a, $t);
2380
-			},
2381
-			$tag
2382
-		);
2375
+    if (is_array($texte)) {
2376
+        array_walk(
2377
+            $texte,
2378
+            function(&$a, $key, $t){
2379
+                $a = extraire_balise($a, $t);
2380
+            },
2381
+            $tag
2382
+        );
2383 2383
 
2384
-		return $texte;
2385
-	}
2384
+        return $texte;
2385
+    }
2386 2386
 
2387
-	if (preg_match(
2388
-		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2389
-		$texte, $regs)) {
2390
-		return $regs[0];
2391
-	}
2387
+    if (preg_match(
2388
+        ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2389
+        $texte, $regs)) {
2390
+        return $regs[0];
2391
+    }
2392 2392
 }
2393 2393
 
2394 2394
 /**
@@ -2416,25 +2416,25 @@  discard block
 block discarded – undo
2416 2416
  *     - Tableau de résultats, si tableau en entrée.
2417 2417
  **/
2418 2418
 function extraire_balises($texte, $tag = 'a') {
2419
-	if (is_array($texte)) {
2420
-		array_walk(
2421
-			$texte,
2422
-			function(&$a, $key, $t){
2423
-				$a = extraire_balises($a, $t);
2424
-			},
2425
-			$tag
2426
-		);
2419
+    if (is_array($texte)) {
2420
+        array_walk(
2421
+            $texte,
2422
+            function(&$a, $key, $t){
2423
+                $a = extraire_balises($a, $t);
2424
+            },
2425
+            $tag
2426
+        );
2427 2427
 
2428
-		return $texte;
2429
-	}
2428
+        return $texte;
2429
+    }
2430 2430
 
2431
-	if (preg_match_all(
2432
-		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2433
-		$texte, $regs, PREG_PATTERN_ORDER)) {
2434
-		return $regs[0];
2435
-	} else {
2436
-		return array();
2437
-	}
2431
+    if (preg_match_all(
2432
+        ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2433
+        $texte, $regs, PREG_PATTERN_ORDER)) {
2434
+        return $regs[0];
2435
+    } else {
2436
+        return array();
2437
+    }
2438 2438
 }
2439 2439
 
2440 2440
 /**
@@ -2463,11 +2463,11 @@  discard block
 block discarded – undo
2463 2463
  *     - `$def` si on n'a pas transmis de tableau
2464 2464
  **/
2465 2465
 function in_any($val, $vals, $def = '') {
2466
-	if (!is_array($vals) and $v = unserialize($vals)) {
2467
-		$vals = $v;
2468
-	}
2466
+    if (!is_array($vals) and $v = unserialize($vals)) {
2467
+        $vals = $v;
2468
+    }
2469 2469
 
2470
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2470
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2471 2471
 }
2472 2472
 
2473 2473
 
@@ -2488,12 +2488,12 @@  discard block
 block discarded – undo
2488 2488
  *     Résultat du calcul
2489 2489
  **/
2490 2490
 function valeur_numerique($expr) {
2491
-	$a = 0;
2492
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2493
-		eval("\$a = $expr;");
2494
-	}
2491
+    $a = 0;
2492
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2493
+        eval("\$a = $expr;");
2494
+    }
2495 2495
 
2496
-	return intval($a);
2496
+    return intval($a);
2497 2497
 }
2498 2498
 
2499 2499
 /**
@@ -2512,7 +2512,7 @@  discard block
 block discarded – undo
2512 2512
  *      Retourne `$a*$b/$c`
2513 2513
  **/
2514 2514
 function regledetrois($a, $b, $c) {
2515
-	return round($a * $b / $c);
2515
+    return round($a * $b / $c);
2516 2516
 }
2517 2517
 
2518 2518
 
@@ -2536,76 +2536,76 @@  discard block
 block discarded – undo
2536 2536
  **/
2537 2537
 function form_hidden($action) {
2538 2538
 
2539
-	$contexte = array();
2540
-	include_spip('inc/urls');
2541
-	if ($p = urls_decoder_url($action, '')
2542
-		and reset($p)
2543
-	) {
2544
-		$fond = array_shift($p);
2545
-		if ($fond != '404') {
2546
-			$contexte = array_shift($p);
2547
-			$contexte['page'] = $fond;
2548
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2549
-		}
2550
-	}
2551
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2552
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2553
-		unset($contexte['type']);
2554
-	}
2555
-	if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2556
-		unset($contexte['type-page']);
2557
-	}
2558
-
2559
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2560
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2561
-	$values = array();
2562
-
2563
-	// d'abord avec celles de l'url
2564
-	if (false !== ($p = strpos($action, '?'))) {
2565
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2566
-			$c = explode('=', $c, 2);
2567
-			$var = array_shift($c);
2568
-			$val = array_shift($c);
2569
-			if ($var) {
2570
-				$val = rawurldecode($val);
2571
-				$var = rawurldecode($var); // decoder les [] eventuels
2572
-				if (preg_match(',\[\]$,S', $var)) {
2573
-					$values[] = array($var, $val);
2574
-				} else {
2575
-					if (!isset($values[$var])) {
2576
-						$values[$var] = array($var, $val);
2577
-					}
2578
-				}
2579
-			}
2580
-		}
2581
-	}
2582
-
2583
-	// ensuite avec celles du contexte, sans doublonner !
2584
-	foreach ($contexte as $var => $val) {
2585
-		if (preg_match(',\[\]$,S', $var)) {
2586
-			$values[] = array($var, $val);
2587
-		} else {
2588
-			if (!isset($values[$var])) {
2589
-				$values[$var] = array($var, $val);
2590
-			}
2591
-		}
2592
-	}
2593
-
2594
-	// puis on rassemble le tout
2595
-	$hidden = array();
2596
-	foreach ($values as $value) {
2597
-		list($var, $val) = $value;
2598
-		$hidden[] = '<input name="'
2599
-			. entites_html($var)
2600
-			. '"'
2601
-			. (is_null($val)
2602
-				? ''
2603
-				: ' value="' . entites_html($val) . '"'
2604
-			)
2605
-			. ' type="hidden"' . "\n/>";
2606
-	}
2607
-
2608
-	return join("", $hidden);
2539
+    $contexte = array();
2540
+    include_spip('inc/urls');
2541
+    if ($p = urls_decoder_url($action, '')
2542
+        and reset($p)
2543
+    ) {
2544
+        $fond = array_shift($p);
2545
+        if ($fond != '404') {
2546
+            $contexte = array_shift($p);
2547
+            $contexte['page'] = $fond;
2548
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2549
+        }
2550
+    }
2551
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2552
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2553
+        unset($contexte['type']);
2554
+    }
2555
+    if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2556
+        unset($contexte['type-page']);
2557
+    }
2558
+
2559
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2560
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2561
+    $values = array();
2562
+
2563
+    // d'abord avec celles de l'url
2564
+    if (false !== ($p = strpos($action, '?'))) {
2565
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2566
+            $c = explode('=', $c, 2);
2567
+            $var = array_shift($c);
2568
+            $val = array_shift($c);
2569
+            if ($var) {
2570
+                $val = rawurldecode($val);
2571
+                $var = rawurldecode($var); // decoder les [] eventuels
2572
+                if (preg_match(',\[\]$,S', $var)) {
2573
+                    $values[] = array($var, $val);
2574
+                } else {
2575
+                    if (!isset($values[$var])) {
2576
+                        $values[$var] = array($var, $val);
2577
+                    }
2578
+                }
2579
+            }
2580
+        }
2581
+    }
2582
+
2583
+    // ensuite avec celles du contexte, sans doublonner !
2584
+    foreach ($contexte as $var => $val) {
2585
+        if (preg_match(',\[\]$,S', $var)) {
2586
+            $values[] = array($var, $val);
2587
+        } else {
2588
+            if (!isset($values[$var])) {
2589
+                $values[$var] = array($var, $val);
2590
+            }
2591
+        }
2592
+    }
2593
+
2594
+    // puis on rassemble le tout
2595
+    $hidden = array();
2596
+    foreach ($values as $value) {
2597
+        list($var, $val) = $value;
2598
+        $hidden[] = '<input name="'
2599
+            . entites_html($var)
2600
+            . '"'
2601
+            . (is_null($val)
2602
+                ? ''
2603
+                : ' value="' . entites_html($val) . '"'
2604
+            )
2605
+            . ' type="hidden"' . "\n/>";
2606
+    }
2607
+
2608
+    return join("", $hidden);
2609 2609
 }
2610 2610
 
2611 2611
 /**
@@ -2623,15 +2623,15 @@  discard block
 block discarded – undo
2623 2623
  *     Liste (première page, dernière page).
2624 2624
  **/
2625 2625
 function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) {
2626
-	if ($max <= 0 or $max >= $nombre) {
2627
-		return array(1, $nombre);
2628
-	}
2626
+    if ($max <= 0 or $max >= $nombre) {
2627
+        return array(1, $nombre);
2628
+    }
2629 2629
 
2630
-	$premiere = max(1, $courante - floor(($max - 1) / 2));
2631
-	$derniere = min($nombre, $premiere + $max - 2);
2632
-	$premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2630
+    $premiere = max(1, $courante - floor(($max - 1) / 2));
2631
+    $derniere = min($nombre, $premiere + $max - 2);
2632
+    $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2633 2633
 
2634
-	return array($premiere, $derniere);
2634
+    return array($premiere, $derniere);
2635 2635
 }
2636 2636
 
2637 2637
 
@@ -2653,7 +2653,7 @@  discard block
 block discarded – undo
2653 2653
  *    - la première valeur du tableau sinon.
2654 2654
  **/
2655 2655
 function filtre_reset($array) {
2656
-	return !is_array($array) ? null : reset($array);
2656
+    return !is_array($array) ? null : reset($array);
2657 2657
 }
2658 2658
 
2659 2659
 /**
@@ -2674,7 +2674,7 @@  discard block
 block discarded – undo
2674 2674
  *    - la dernière valeur du tableau sinon.
2675 2675
  **/
2676 2676
 function filtre_end($array) {
2677
-	return !is_array($array) ? null : end($array);
2677
+    return !is_array($array) ? null : end($array);
2678 2678
 }
2679 2679
 
2680 2680
 /**
@@ -2694,11 +2694,11 @@  discard block
 block discarded – undo
2694 2694
  *
2695 2695
  **/
2696 2696
 function filtre_push($array, $val) {
2697
-	if (!is_array($array) or !array_push($array, $val)) {
2698
-		return '';
2699
-	}
2697
+    if (!is_array($array) or !array_push($array, $val)) {
2698
+        return '';
2699
+    }
2700 2700
 
2701
-	return $array;
2701
+    return $array;
2702 2702
 }
2703 2703
 
2704 2704
 /**
@@ -2717,7 +2717,7 @@  discard block
 block discarded – undo
2717 2717
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2718 2718
  **/
2719 2719
 function filtre_find($array, $val) {
2720
-	return (is_array($array) and in_array($val, $array));
2720
+    return (is_array($array) and in_array($val, $array));
2721 2721
 }
2722 2722
 
2723 2723
 
@@ -2752,59 +2752,59 @@  discard block
 block discarded – undo
2752 2752
  *     Code HTML de la pagination
2753 2753
  **/
2754 2754
 function filtre_pagination_dist(
2755
-	$total,
2756
-	$nom,
2757
-	$position,
2758
-	$pas,
2759
-	$liste = true,
2760
-	$modele = '',
2761
-	$connect = '',
2762
-	$env = array()
2755
+    $total,
2756
+    $nom,
2757
+    $position,
2758
+    $pas,
2759
+    $liste = true,
2760
+    $modele = '',
2761
+    $connect = '',
2762
+    $env = array()
2763 2763
 ) {
2764
-	static $ancres = array();
2765
-	if ($pas < 1) {
2766
-		return '';
2767
-	}
2768
-	$ancre = 'pagination' . $nom; // #pagination_articles
2769
-	$debut = 'debut' . $nom; // 'debut_articles'
2770
-
2771
-	// n'afficher l'ancre qu'une fois
2772
-	if (!isset($ancres[$ancre])) {
2773
-		$bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2774
-	} else {
2775
-		$bloc_ancre = '';
2776
-	}
2777
-	// liste = false : on ne veut que l'ancre
2778
-	if (!$liste) {
2779
-		return $ancres[$ancre];
2780
-	}
2781
-
2782
-	$self = (empty($env['self']) ? self() : $env['self']);
2783
-	$pagination = array(
2784
-		'debut' => $debut,
2785
-		'url' => parametre_url($self, 'fragment', ''), // nettoyer l'id ahah eventuel
2786
-		'total' => $total,
2787
-		'position' => intval($position),
2788
-		'pas' => $pas,
2789
-		'nombre_pages' => floor(($total - 1) / $pas) + 1,
2790
-		'page_courante' => floor(intval($position) / $pas) + 1,
2791
-		'ancre' => $ancre,
2792
-		'bloc_ancre' => $bloc_ancre
2793
-	);
2794
-	if (is_array($env)) {
2795
-		$pagination = array_merge($env, $pagination);
2796
-	}
2797
-
2798
-	// Pas de pagination
2799
-	if ($pagination['nombre_pages'] <= 1) {
2800
-		return '';
2801
-	}
2802
-
2803
-	if ($modele) {
2804
-		$modele = '_' . $modele;
2805
-	}
2806
-
2807
-	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
2764
+    static $ancres = array();
2765
+    if ($pas < 1) {
2766
+        return '';
2767
+    }
2768
+    $ancre = 'pagination' . $nom; // #pagination_articles
2769
+    $debut = 'debut' . $nom; // 'debut_articles'
2770
+
2771
+    // n'afficher l'ancre qu'une fois
2772
+    if (!isset($ancres[$ancre])) {
2773
+        $bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2774
+    } else {
2775
+        $bloc_ancre = '';
2776
+    }
2777
+    // liste = false : on ne veut que l'ancre
2778
+    if (!$liste) {
2779
+        return $ancres[$ancre];
2780
+    }
2781
+
2782
+    $self = (empty($env['self']) ? self() : $env['self']);
2783
+    $pagination = array(
2784
+        'debut' => $debut,
2785
+        'url' => parametre_url($self, 'fragment', ''), // nettoyer l'id ahah eventuel
2786
+        'total' => $total,
2787
+        'position' => intval($position),
2788
+        'pas' => $pas,
2789
+        'nombre_pages' => floor(($total - 1) / $pas) + 1,
2790
+        'page_courante' => floor(intval($position) / $pas) + 1,
2791
+        'ancre' => $ancre,
2792
+        'bloc_ancre' => $bloc_ancre
2793
+    );
2794
+    if (is_array($env)) {
2795
+        $pagination = array_merge($env, $pagination);
2796
+    }
2797
+
2798
+    // Pas de pagination
2799
+    if ($pagination['nombre_pages'] <= 1) {
2800
+        return '';
2801
+    }
2802
+
2803
+    if ($modele) {
2804
+        $modele = '_' . $modele;
2805
+    }
2806
+
2807
+    return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
2808 2808
 }
2809 2809
 
2810 2810
 
@@ -2821,15 +2821,15 @@  discard block
 block discarded – undo
2821 2821
  *     Contenu avec urls en absolus
2822 2822
  **/
2823 2823
 function urls_absolues_css($contenu, $source) {
2824
-	$path = suivre_lien(url_absolue($source), './');
2824
+    $path = suivre_lien(url_absolue($source), './');
2825 2825
 
2826
-	return preg_replace_callback(
2827
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2828
-		function($x) use ($path) {
2829
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2830
-		},
2831
-		$contenu
2832
-	);
2826
+    return preg_replace_callback(
2827
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2828
+        function($x) use ($path) {
2829
+            return "url('" . suivre_lien($path, $x[1]) . "')";
2830
+        },
2831
+        $contenu
2832
+    );
2833 2833
 }
2834 2834
 
2835 2835
 
@@ -2858,118 +2858,118 @@  discard block
 block discarded – undo
2858 2858
  *     Chemin du fichier CSS inversé
2859 2859
  **/
2860 2860
 function direction_css($css, $voulue = '') {
2861
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2862
-		return $css;
2863
-	}
2864
-
2865
-	// si on a precise le sens voulu en argument, le prendre en compte
2866
-	if ($voulue = strtolower($voulue)) {
2867
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2868
-			$voulue = lang_dir($voulue);
2869
-		}
2870
-	} else {
2871
-		$voulue = lang_dir();
2872
-	}
2873
-
2874
-	$r = count($r) > 1;
2875
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2876
-	$dir = $r ? 'rtl' : 'ltr';
2877
-	$ndir = $r ? 'ltr' : 'rtl';
2878
-
2879
-	if ($voulue == $dir) {
2880
-		return $css;
2881
-	}
2882
-
2883
-	if (
2884
-		// url absolue
2885
-		preg_match(",^https?:,i", $css)
2886
-		// ou qui contient un ?
2887
-		or (($p = strpos($css, '?')) !== false)
2888
-	) {
2889
-		$distant = true;
2890
-		$cssf = parse_url($css);
2891
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2892
-		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2893
-	} else {
2894
-		$distant = false;
2895
-		$cssf = $css;
2896
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2897
-		//propose (rien a faire dans ce cas)
2898
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2899
-		if (@file_exists($f)) {
2900
-			return $f;
2901
-		}
2902
-	}
2903
-
2904
-	// 2.
2905
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2906
-	$f = $dir_var
2907
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2908
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2909
-
2910
-	// la css peut etre distante (url absolue !)
2911
-	if ($distant) {
2912
-		include_spip('inc/distant');
2913
-		$res = recuperer_url($css);
2914
-		if (!$res or !$contenu = $res['page']) {
2915
-			return $css;
2916
-		}
2917
-	} else {
2918
-		if ((@filemtime($f) > @filemtime($css))
2919
-			and (_VAR_MODE != 'recalcul')
2920
-		) {
2921
-			return $f;
2922
-		}
2923
-		if (!lire_fichier($css, $contenu)) {
2924
-			return $css;
2925
-		}
2926
-	}
2927
-
2928
-
2929
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2930
-	include_spip("lib/csstidy/class.csstidy");
2931
-	$parser = new csstidy();
2932
-	$parser->set_cfg('optimise_shorthands', 0);
2933
-	$parser->set_cfg('reverse_left_and_right', true);
2934
-	$parser->parse($contenu);
2935
-
2936
-	$contenu = $parser->print->plain();
2937
-
2938
-
2939
-	// reperer les @import auxquels il faut propager le direction_css
2940
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2941
-	$src = array();
2942
-	$src_direction_css = array();
2943
-	$src_faux_abs = array();
2944
-	$d = dirname($css);
2945
-	foreach ($regs[1] as $k => $import_css) {
2946
-		$css_direction = direction_css("$d/$import_css", $voulue);
2947
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2948
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2949
-			$css_direction = substr($css_direction, strlen($d) + 1);
2950
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2951
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2952
-			$css_direction = substr($css_direction, strlen($dir_var));
2953
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2954
-			$css_direction = "/@@@@@@/" . $css_direction;
2955
-		}
2956
-		$src[] = $regs[0][$k];
2957
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2958
-	}
2959
-	$contenu = str_replace($src, $src_direction_css, $contenu);
2960
-
2961
-	$contenu = urls_absolues_css($contenu, $css);
2962
-
2963
-	// virer les fausses url absolues que l'on a mis dans les import
2964
-	if (count($src_faux_abs)) {
2965
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2966
-	}
2967
-
2968
-	if (!ecrire_fichier($f, $contenu)) {
2969
-		return $css;
2970
-	}
2971
-
2972
-	return $f;
2861
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2862
+        return $css;
2863
+    }
2864
+
2865
+    // si on a precise le sens voulu en argument, le prendre en compte
2866
+    if ($voulue = strtolower($voulue)) {
2867
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2868
+            $voulue = lang_dir($voulue);
2869
+        }
2870
+    } else {
2871
+        $voulue = lang_dir();
2872
+    }
2873
+
2874
+    $r = count($r) > 1;
2875
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2876
+    $dir = $r ? 'rtl' : 'ltr';
2877
+    $ndir = $r ? 'ltr' : 'rtl';
2878
+
2879
+    if ($voulue == $dir) {
2880
+        return $css;
2881
+    }
2882
+
2883
+    if (
2884
+        // url absolue
2885
+        preg_match(",^https?:,i", $css)
2886
+        // ou qui contient un ?
2887
+        or (($p = strpos($css, '?')) !== false)
2888
+    ) {
2889
+        $distant = true;
2890
+        $cssf = parse_url($css);
2891
+        $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2892
+        $cssf = preg_replace(',[?:&=],', "_", $cssf);
2893
+    } else {
2894
+        $distant = false;
2895
+        $cssf = $css;
2896
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2897
+        //propose (rien a faire dans ce cas)
2898
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2899
+        if (@file_exists($f)) {
2900
+            return $f;
2901
+        }
2902
+    }
2903
+
2904
+    // 2.
2905
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2906
+    $f = $dir_var
2907
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2908
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2909
+
2910
+    // la css peut etre distante (url absolue !)
2911
+    if ($distant) {
2912
+        include_spip('inc/distant');
2913
+        $res = recuperer_url($css);
2914
+        if (!$res or !$contenu = $res['page']) {
2915
+            return $css;
2916
+        }
2917
+    } else {
2918
+        if ((@filemtime($f) > @filemtime($css))
2919
+            and (_VAR_MODE != 'recalcul')
2920
+        ) {
2921
+            return $f;
2922
+        }
2923
+        if (!lire_fichier($css, $contenu)) {
2924
+            return $css;
2925
+        }
2926
+    }
2927
+
2928
+
2929
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2930
+    include_spip("lib/csstidy/class.csstidy");
2931
+    $parser = new csstidy();
2932
+    $parser->set_cfg('optimise_shorthands', 0);
2933
+    $parser->set_cfg('reverse_left_and_right', true);
2934
+    $parser->parse($contenu);
2935
+
2936
+    $contenu = $parser->print->plain();
2937
+
2938
+
2939
+    // reperer les @import auxquels il faut propager le direction_css
2940
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2941
+    $src = array();
2942
+    $src_direction_css = array();
2943
+    $src_faux_abs = array();
2944
+    $d = dirname($css);
2945
+    foreach ($regs[1] as $k => $import_css) {
2946
+        $css_direction = direction_css("$d/$import_css", $voulue);
2947
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2948
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2949
+            $css_direction = substr($css_direction, strlen($d) + 1);
2950
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2951
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2952
+            $css_direction = substr($css_direction, strlen($dir_var));
2953
+            $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2954
+            $css_direction = "/@@@@@@/" . $css_direction;
2955
+        }
2956
+        $src[] = $regs[0][$k];
2957
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2958
+    }
2959
+    $contenu = str_replace($src, $src_direction_css, $contenu);
2960
+
2961
+    $contenu = urls_absolues_css($contenu, $css);
2962
+
2963
+    // virer les fausses url absolues que l'on a mis dans les import
2964
+    if (count($src_faux_abs)) {
2965
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2966
+    }
2967
+
2968
+    if (!ecrire_fichier($f, $contenu)) {
2969
+        return $css;
2970
+    }
2971
+
2972
+    return $f;
2973 2973
 }
2974 2974
 
2975 2975
 
@@ -2992,43 +2992,43 @@  discard block
 block discarded – undo
2992 2992
  *     - Chemin ou URL du fichier CSS source sinon.
2993 2993
  **/
2994 2994
 function url_absolue_css($css) {
2995
-	if (!preg_match(',\.css$,i', $css, $r)) {
2996
-		return $css;
2997
-	}
2995
+    if (!preg_match(',\.css$,i', $css, $r)) {
2996
+        return $css;
2997
+    }
2998 2998
 
2999
-	$url_absolue_css = url_absolue($css);
2999
+    $url_absolue_css = url_absolue($css);
3000 3000
 
3001
-	$f = basename($css, '.css');
3002
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3003
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3004
-		. '.css';
3001
+    $f = basename($css, '.css');
3002
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3003
+        . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3004
+        . '.css';
3005 3005
 
3006
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3007
-		return $f;
3008
-	}
3006
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3007
+        return $f;
3008
+    }
3009 3009
 
3010
-	if ($url_absolue_css == $css) {
3011
-		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3012
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3013
-		) {
3014
-			include_spip('inc/distant');
3015
-			if (!$contenu = recuperer_page($css)) {
3016
-				return $css;
3017
-			}
3018
-		}
3019
-	} elseif (!lire_fichier($css, $contenu)) {
3020
-		return $css;
3021
-	}
3010
+    if ($url_absolue_css == $css) {
3011
+        if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3012
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3013
+        ) {
3014
+            include_spip('inc/distant');
3015
+            if (!$contenu = recuperer_page($css)) {
3016
+                return $css;
3017
+            }
3018
+        }
3019
+    } elseif (!lire_fichier($css, $contenu)) {
3020
+        return $css;
3021
+    }
3022 3022
 
3023
-	// passer les url relatives a la css d'origine en url absolues
3024
-	$contenu = urls_absolues_css($contenu, $css);
3023
+    // passer les url relatives a la css d'origine en url absolues
3024
+    $contenu = urls_absolues_css($contenu, $css);
3025 3025
 
3026
-	// ecrire la css
3027
-	if (!ecrire_fichier($f, $contenu)) {
3028
-		return $css;
3029
-	}
3026
+    // ecrire la css
3027
+    if (!ecrire_fichier($f, $contenu)) {
3028
+        return $css;
3029
+    }
3030 3030
 
3031
-	return $f;
3031
+    return $f;
3032 3032
 }
3033 3033
 
3034 3034
 
@@ -3062,24 +3062,24 @@  discard block
 block discarded – undo
3062 3062
  *     Valeur trouvée ou valeur par défaut.
3063 3063
  **/
3064 3064
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3065
-	foreach (explode('/', $cle) as $k) {
3065
+    foreach (explode('/', $cle) as $k) {
3066 3066
 
3067
-		$table = is_string($table) ? @unserialize($table) : $table;
3067
+        $table = is_string($table) ? @unserialize($table) : $table;
3068 3068
 
3069
-		if (is_object($table)) {
3070
-			$table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3071
-		} elseif (is_array($table)) {
3072
-			if ($conserver_null) {
3073
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3074
-			} else {
3075
-				$table = isset($table[$k]) ? $table[$k] : $defaut;
3076
-			}
3077
-		} else {
3078
-			$table = $defaut;
3079
-		}
3080
-	}
3069
+        if (is_object($table)) {
3070
+            $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3071
+        } elseif (is_array($table)) {
3072
+            if ($conserver_null) {
3073
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3074
+            } else {
3075
+                $table = isset($table[$k]) ? $table[$k] : $defaut;
3076
+            }
3077
+        } else {
3078
+            $table = $defaut;
3079
+        }
3080
+    }
3081 3081
 
3082
-	return $table;
3082
+    return $table;
3083 3083
 }
3084 3084
 
3085 3085
 /**
@@ -3112,22 +3112,22 @@  discard block
 block discarded – undo
3112 3112
  *     - string : expression trouvée.
3113 3113
  **/
3114 3114
 function filtre_match_dist($texte, $expression, $modif = "UimsS", $capte = 0) {
3115
-	if (intval($modif) and $capte == 0) {
3116
-		$capte = $modif;
3117
-		$modif = "UimsS";
3118
-	}
3119
-	$expression = str_replace("\/", "/", $expression);
3120
-	$expression = str_replace("/", "\/", $expression);
3115
+    if (intval($modif) and $capte == 0) {
3116
+        $capte = $modif;
3117
+        $modif = "UimsS";
3118
+    }
3119
+    $expression = str_replace("\/", "/", $expression);
3120
+    $expression = str_replace("/", "\/", $expression);
3121 3121
 
3122
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3123
-		if (isset($r[$capte])) {
3124
-			return $r[$capte];
3125
-		} else {
3126
-			return true;
3127
-		}
3128
-	}
3122
+    if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3123
+        if (isset($r[$capte])) {
3124
+            return $r[$capte];
3125
+        } else {
3126
+            return true;
3127
+        }
3128
+    }
3129 3129
 
3130
-	return false;
3130
+    return false;
3131 3131
 }
3132 3132
 
3133 3133
 
@@ -3154,10 +3154,10 @@  discard block
 block discarded – undo
3154 3154
  *     Texte
3155 3155
  **/
3156 3156
 function replace($texte, $expression, $replace = '', $modif = "UimsS") {
3157
-	$expression = str_replace("\/", "/", $expression);
3158
-	$expression = str_replace("/", "\/", $expression);
3157
+    $expression = str_replace("\/", "/", $expression);
3158
+    $expression = str_replace("/", "\/", $expression);
3159 3159
 
3160
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3160
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3161 3161
 }
3162 3162
 
3163 3163
 
@@ -3175,21 +3175,21 @@  discard block
 block discarded – undo
3175 3175
  **/
3176 3176
 function traiter_doublons_documents(&$doublons, $letexte) {
3177 3177
 
3178
-	// Verifier dans le texte & les notes (pas beau, helas)
3179
-	$t = $letexte . $GLOBALS['les_notes'];
3178
+    // Verifier dans le texte & les notes (pas beau, helas)
3179
+    $t = $letexte . $GLOBALS['les_notes'];
3180 3180
 
3181
-	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3182
-		and preg_match_all(
3183
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3184
-			$t, $matches, PREG_PATTERN_ORDER)
3185
-	) {
3186
-		if (!isset($doublons['documents'])) {
3187
-			$doublons['documents'] = "";
3188
-		}
3189
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3190
-	}
3181
+    if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3182
+        and preg_match_all(
3183
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3184
+            $t, $matches, PREG_PATTERN_ORDER)
3185
+    ) {
3186
+        if (!isset($doublons['documents'])) {
3187
+            $doublons['documents'] = "";
3188
+        }
3189
+        $doublons['documents'] .= "," . join(',', $matches[1]);
3190
+    }
3191 3191
 
3192
-	return $letexte;
3192
+    return $letexte;
3193 3193
 }
3194 3194
 
3195 3195
 /**
@@ -3203,7 +3203,7 @@  discard block
 block discarded – undo
3203 3203
  * @return string Chaîne vide
3204 3204
  **/
3205 3205
 function vide($texte) {
3206
-	return "";
3206
+    return "";
3207 3207
 }
3208 3208
 
3209 3209
 //
@@ -3232,23 +3232,23 @@  discard block
 block discarded – undo
3232 3232
  *      Code HTML résultant
3233 3233
  **/
3234 3234
 function env_to_params($env, $ignore_params = array()) {
3235
-	$ignore_params = array_merge(
3236
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3237
-		$ignore_params
3238
-	);
3239
-	if (!is_array($env)) {
3240
-		$env = unserialize($env);
3241
-	}
3242
-	$texte = "";
3243
-	if ($env) {
3244
-		foreach ($env as $i => $j) {
3245
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3246
-				$texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />";
3247
-			}
3248
-		}
3249
-	}
3250
-
3251
-	return $texte;
3235
+    $ignore_params = array_merge(
3236
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3237
+        $ignore_params
3238
+    );
3239
+    if (!is_array($env)) {
3240
+        $env = unserialize($env);
3241
+    }
3242
+    $texte = "";
3243
+    if ($env) {
3244
+        foreach ($env as $i => $j) {
3245
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3246
+                $texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />";
3247
+            }
3248
+        }
3249
+    }
3250
+
3251
+    return $texte;
3252 3252
 }
3253 3253
 
3254 3254
 /**
@@ -3271,23 +3271,23 @@  discard block
 block discarded – undo
3271 3271
  *      Code HTML résultant
3272 3272
  **/
3273 3273
 function env_to_attributs($env, $ignore_params = array()) {
3274
-	$ignore_params = array_merge(
3275
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3276
-		$ignore_params
3277
-	);
3278
-	if (!is_array($env)) {
3279
-		$env = unserialize($env);
3280
-	}
3281
-	$texte = "";
3282
-	if ($env) {
3283
-		foreach ($env as $i => $j) {
3284
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3285
-				$texte .= $i . "='" . $j . "' ";
3286
-			}
3287
-		}
3288
-	}
3274
+    $ignore_params = array_merge(
3275
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3276
+        $ignore_params
3277
+    );
3278
+    if (!is_array($env)) {
3279
+        $env = unserialize($env);
3280
+    }
3281
+    $texte = "";
3282
+    if ($env) {
3283
+        foreach ($env as $i => $j) {
3284
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3285
+                $texte .= $i . "='" . $j . "' ";
3286
+            }
3287
+        }
3288
+    }
3289 3289
 
3290
-	return $texte;
3290
+    return $texte;
3291 3291
 }
3292 3292
 
3293 3293
 
@@ -3304,9 +3304,9 @@  discard block
 block discarded – undo
3304 3304
  * @return string Chaînes concaténés
3305 3305
  **/
3306 3306
 function concat() {
3307
-	$args = func_get_args();
3307
+    $args = func_get_args();
3308 3308
 
3309
-	return join('', $args);
3309
+    return join('', $args);
3310 3310
 }
3311 3311
 
3312 3312
 
@@ -3326,23 +3326,23 @@  discard block
 block discarded – undo
3326 3326
  *     Contenu du ou des fichiers, concaténé
3327 3327
  **/
3328 3328
 function charge_scripts($files, $script = true) {
3329
-	$flux = "";
3330
-	foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3331
-		if (!is_string($file)) {
3332
-			continue;
3333
-		}
3334
-		if ($script) {
3335
-			$file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3336
-		}
3337
-		if ($file) {
3338
-			$path = find_in_path($file);
3339
-			if ($path) {
3340
-				$flux .= spip_file_get_contents($path);
3341
-			}
3342
-		}
3343
-	}
3329
+    $flux = "";
3330
+    foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3331
+        if (!is_string($file)) {
3332
+            continue;
3333
+        }
3334
+        if ($script) {
3335
+            $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3336
+        }
3337
+        if ($file) {
3338
+            $path = find_in_path($file);
3339
+            if ($path) {
3340
+                $flux .= spip_file_get_contents($path);
3341
+            }
3342
+        }
3343
+    }
3344 3344
 
3345
-	return $flux;
3345
+    return $flux;
3346 3346
 }
3347 3347
 
3348 3348
 
@@ -3364,55 +3364,55 @@  discard block
 block discarded – undo
3364 3364
  */
3365 3365
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) {
3366 3366
 
3367
-	$img_file = $img;
3368
-	if ($p = strpos($img_file, '?')) {
3369
-		$img_file = substr($img_file,0, $p);
3370
-	}
3371
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3372
-		$img_file = chemin_image($img);
3373
-	}
3374
-	else {
3375
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3376
-			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3377
-			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3378
-			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3379
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3380
-			  and file_exists($variante_svg_generique)) {
3381
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3382
-					$img_file = $variante_svg_size;
3383
-				}
3384
-				else {
3385
-					$img_file = $variante_svg_generique;
3386
-				}
3387
-			}
3388
-		}
3389
-	}
3390
-	if (stripos($atts, 'width') === false) {
3391
-		// utiliser directement l'info de taille presente dans le nom
3392
-		if ((!isset($options['utiliser_suffixe_size'])
3393
-				or $options['utiliser_suffixe_size'] == true
3394
-			  or strpos($img_file, '-xx.svg') !== false)
3395
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3396
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3397
-		) {
3398
-			$largeur = $hauteur = intval($regs[1]);
3399
-		} else {
3400
-			$taille = taille_image($img_file);
3401
-			list($hauteur, $largeur) = $taille;
3402
-			if (!$hauteur or !$largeur) {
3403
-				return "";
3404
-			}
3405
-		}
3406
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3407
-	}
3408
-
3409
-	if (file_exists($img_file)) {
3410
-		$img_file = timestamp($img_file);
3411
-	}
3412
-	return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'"
3413
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3414
-	. " " . ltrim($atts)
3415
-	. " />";
3367
+    $img_file = $img;
3368
+    if ($p = strpos($img_file, '?')) {
3369
+        $img_file = substr($img_file,0, $p);
3370
+    }
3371
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3372
+        $img_file = chemin_image($img);
3373
+    }
3374
+    else {
3375
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3376
+            // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3377
+            // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3378
+            if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3379
+              and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3380
+              and file_exists($variante_svg_generique)) {
3381
+                if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3382
+                    $img_file = $variante_svg_size;
3383
+                }
3384
+                else {
3385
+                    $img_file = $variante_svg_generique;
3386
+                }
3387
+            }
3388
+        }
3389
+    }
3390
+    if (stripos($atts, 'width') === false) {
3391
+        // utiliser directement l'info de taille presente dans le nom
3392
+        if ((!isset($options['utiliser_suffixe_size'])
3393
+                or $options['utiliser_suffixe_size'] == true
3394
+              or strpos($img_file, '-xx.svg') !== false)
3395
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3396
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3397
+        ) {
3398
+            $largeur = $hauteur = intval($regs[1]);
3399
+        } else {
3400
+            $taille = taille_image($img_file);
3401
+            list($hauteur, $largeur) = $taille;
3402
+            if (!$hauteur or !$largeur) {
3403
+                return "";
3404
+            }
3405
+        }
3406
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3407
+    }
3408
+
3409
+    if (file_exists($img_file)) {
3410
+        $img_file = timestamp($img_file);
3411
+    }
3412
+    return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'"
3413
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3414
+    . " " . ltrim($atts)
3415
+    . " />";
3416 3416
 }
3417 3417
 
3418 3418
 /**
@@ -3424,13 +3424,13 @@  discard block
 block discarded – undo
3424 3424
  * @return string
3425 3425
  */
3426 3426
 function http_style_background($img, $att = '', $size=null) {
3427
-	if ($size and is_numeric($size)){
3428
-		$size = trim($size) . "px";
3429
-	}
3430
-	return " style='background" .
3431
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3432
-		. ($size ? "background-size:{$size};" : '')
3433
-		. "'";
3427
+    if ($size and is_numeric($size)){
3428
+        $size = trim($size) . "px";
3429
+    }
3430
+    return " style='background" .
3431
+        ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3432
+        . ($size ? "background-size:{$size};" : '')
3433
+        . "'";
3434 3434
 }
3435 3435
 
3436 3436
 /**
@@ -3446,17 +3446,17 @@  discard block
 block discarded – undo
3446 3446
  *     Code HTML de la balise IMG
3447 3447
  */
3448 3448
 function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3449
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3450
-	// ecriture courte : on donne le width en 2e arg
3451
-	if (empty($width) and is_numeric($alt)) {
3452
-		$width = $alt;
3453
-		$alt = '';
3454
-	}
3455
-	if ($width) {
3456
-		$atts .= " width='{$width}'";
3457
-	}
3458
-	return http_img_pack($img, $alt, $atts, '',
3459
-		array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3449
+    $atts = $class ? " class='" . attribut_html($class) . "'" : '';
3450
+    // ecriture courte : on donne le width en 2e arg
3451
+    if (empty($width) and is_numeric($alt)) {
3452
+        $width = $alt;
3453
+        $alt = '';
3454
+    }
3455
+    if ($width) {
3456
+        $atts .= " width='{$width}'";
3457
+    }
3458
+    return http_img_pack($img, $alt, $atts, '',
3459
+        array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3460 3460
 }
3461 3461
 
3462 3462
 
@@ -3472,42 +3472,42 @@  discard block
 block discarded – undo
3472 3472
  * @return string
3473 3473
  */
3474 3474
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3475
-	$img_file = $img;
3476
-	if ($p = strpos($img_file, '?')) {
3477
-		$img_file = substr($img_file,0, $p);
3478
-	}
3475
+    $img_file = $img;
3476
+    if ($p = strpos($img_file, '?')) {
3477
+        $img_file = substr($img_file,0, $p);
3478
+    }
3479 3479
 
3480
-	if (!$img_file or !$svg = file_get_contents($img_file)) {
3481
-		return '';
3482
-	}
3480
+    if (!$img_file or !$svg = file_get_contents($img_file)) {
3481
+        return '';
3482
+    }
3483 3483
 
3484
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3485
-		return '';
3486
-	}
3487
-	$balise_svg = $match[0];
3488
-	$balise_svg_source = $balise_svg;
3484
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3485
+        return '';
3486
+    }
3487
+    $balise_svg = $match[0];
3488
+    $balise_svg_source = $balise_svg;
3489 3489
 
3490
-	// entete XML à supprimer
3491
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3490
+    // entete XML à supprimer
3491
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3492 3492
 
3493
-	// IE est toujours mon ami
3494
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3495
-	if ($class) {
3496
-		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3497
-	}
3498
-	if ($alt){
3499
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3500
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3501
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3502
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3503
-		$balise_svg .= $title;
3504
-	}
3505
-	else {
3506
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3507
-	}
3508
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3493
+    // IE est toujours mon ami
3494
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3495
+    if ($class) {
3496
+        $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3497
+    }
3498
+    if ($alt){
3499
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3500
+        $id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3501
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3502
+        $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3503
+        $balise_svg .= $title;
3504
+    }
3505
+    else {
3506
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3507
+    }
3508
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3509 3509
 
3510
-	return $svg;
3510
+    return $svg;
3511 3511
 }
3512 3512
 
3513 3513
 
@@ -3530,17 +3530,17 @@  discard block
 block discarded – undo
3530 3530
  *     Code HTML résultant
3531 3531
  **/
3532 3532
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3533
-	$texte = '';
3534
-	if (is_array($tableau)) {
3535
-		foreach ($tableau as $k => $v) {
3536
-			$res = recuperer_fond('modeles/' . $modele,
3537
-				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3538
-			);
3539
-			$texte .= $res;
3540
-		}
3541
-	}
3533
+    $texte = '';
3534
+    if (is_array($tableau)) {
3535
+        foreach ($tableau as $k => $v) {
3536
+            $res = recuperer_fond('modeles/' . $modele,
3537
+                array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3538
+            );
3539
+            $texte .= $res;
3540
+        }
3541
+    }
3542 3542
 
3543
-	return $texte;
3543
+    return $texte;
3544 3544
 }
3545 3545
 
3546 3546
 
@@ -3565,37 +3565,37 @@  discard block
 block discarded – undo
3565 3565
  *         - tout : retourne toutes les informations du plugin actif
3566 3566
  **/
3567 3567
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3568
-	include_spip('inc/plugin');
3569
-	$plugin = strtoupper($plugin);
3570
-	$plugins_actifs = liste_plugin_actifs();
3571
-
3572
-	if (!$plugin) {
3573
-		return serialize(array_keys($plugins_actifs));
3574
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3575
-		return '';
3576
-	} elseif (($type_info == 'est_actif') and !$reload) {
3577
-		return $plugins_actifs[$plugin] ? 1 : 0;
3578
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3579
-		return $plugins_actifs[$plugin][$type_info];
3580
-	} else {
3581
-		$get_infos = charger_fonction('get_infos', 'plugins');
3582
-		// On prend en compte les extensions
3583
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3584
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3585
-		} else {
3586
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3587
-		}
3588
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3589
-			return '';
3590
-		}
3591
-		if ($type_info == 'tout') {
3592
-			return $infos;
3593
-		} elseif ($type_info == 'est_actif') {
3594
-			return $infos ? 1 : 0;
3595
-		} else {
3596
-			return strval($infos[$type_info]);
3597
-		}
3598
-	}
3568
+    include_spip('inc/plugin');
3569
+    $plugin = strtoupper($plugin);
3570
+    $plugins_actifs = liste_plugin_actifs();
3571
+
3572
+    if (!$plugin) {
3573
+        return serialize(array_keys($plugins_actifs));
3574
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3575
+        return '';
3576
+    } elseif (($type_info == 'est_actif') and !$reload) {
3577
+        return $plugins_actifs[$plugin] ? 1 : 0;
3578
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3579
+        return $plugins_actifs[$plugin][$type_info];
3580
+    } else {
3581
+        $get_infos = charger_fonction('get_infos', 'plugins');
3582
+        // On prend en compte les extensions
3583
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3584
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3585
+        } else {
3586
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3587
+        }
3588
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3589
+            return '';
3590
+        }
3591
+        if ($type_info == 'tout') {
3592
+            return $infos;
3593
+        } elseif ($type_info == 'est_actif') {
3594
+            return $infos ? 1 : 0;
3595
+        } else {
3596
+            return strval($infos[$type_info]);
3597
+        }
3598
+    }
3599 3599
 }
3600 3600
 
3601 3601
 
@@ -3622,9 +3622,9 @@  discard block
 block discarded – undo
3622 3622
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3623 3623
  */
3624 3624
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3625
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3625
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3626 3626
 
3627
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3627
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3628 3628
 }
3629 3629
 
3630 3630
 
@@ -3654,13 +3654,13 @@  discard block
 block discarded – undo
3654 3654
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3655 3655
  */
3656 3656
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3657
-	static $puce_statut = null;
3658
-	if (!$puce_statut) {
3659
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3660
-	}
3657
+    static $puce_statut = null;
3658
+    if (!$puce_statut) {
3659
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3660
+    }
3661 3661
 
3662
-	return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3663
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3662
+    return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3663
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3664 3664
 }
3665 3665
 
3666 3666
 
@@ -3687,100 +3687,100 @@  discard block
 block discarded – undo
3687 3687
  *   hash du contexte
3688 3688
  */
3689 3689
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3690
-	if (is_string($c)
3691
-		and @unserialize($c) !== false
3692
-	) {
3693
-		$c = unserialize($c);
3694
-	}
3695
-
3696
-	// supprimer les parametres debut_x
3697
-	// pour que la pagination ajax ne soit pas plantee
3698
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3699
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3700
-	if (is_array($c)) {
3701
-		foreach ($c as $k => $v) {
3702
-			if (strpos($k, 'debut_') === 0) {
3703
-				unset($c[$k]);
3704
-			}
3705
-		}
3706
-	}
3707
-
3708
-	if (!function_exists('calculer_cle_action')) {
3709
-		include_spip("inc/securiser_action");
3710
-	}
3711
-
3712
-	$c = serialize($c);
3713
-	$cle = calculer_cle_action($form . $c);
3714
-	$c = "$cle:$c";
3715
-
3716
-	// on ne stocke pas les contextes dans des fichiers en cache
3717
-	// par defaut, sauf si cette configuration a été forcée
3718
-	// OU que la longueur de l’argument géneré est plus long
3719
-	// que ce qui est toléré.
3720
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3721
-	if (!$cache_contextes_ajax) {
3722
-		$env = $c;
3723
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3724
-			$env = gzdeflate($env);
3725
-			// https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3726
-			if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3727
-				$cache_contextes_ajax = true;
3728
-				spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3729
-			}
3730
-		}
3731
-		$env = _xor($env);
3732
-		$env = base64_encode($env);
3733
-		$len = strlen($env);
3734
-		// Si l’url est trop longue pour le navigateur
3735
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3736
-		if ($len > $max_len) {
3737
-			$cache_contextes_ajax = true;
3738
-			spip_log("Contextes AJAX forces en fichiers !"
3739
-				. " Cela arrive lorsque la valeur du contexte" 
3740
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3741
-				, _LOG_AVERTISSEMENT);
3742
-		}
3743
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3744
-		elseif (
3745
-			$max_len = @ini_get('suhosin.get.max_value_length')
3746
-			and $max_len < $len
3747
-		) {
3748
-			$cache_contextes_ajax = true;
3749
-			spip_log("Contextes AJAX forces en fichiers !"
3750
-				. " Cela arrive lorsque la valeur du contexte"
3751
-				. " depasse la longueur maximale autorisee par Suhosin"
3752
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3753
-				. " Vous devriez modifier les parametres de Suhosin"
3754
-				. " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3755
-		} 
3756
-
3757
-	}
3758
-
3759
-	if ($cache_contextes_ajax) {
3760
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3761
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3762
-		$md5 = md5($c);
3763
-		ecrire_fichier("$dir/c$md5", $c);
3764
-		$env = $md5;
3765
-	}
3766
-
3767
-	if ($emboite === null) {
3768
-		return $env;
3769
-	}
3770
-	if (!trim($emboite)) {
3771
-		return "";
3772
-	}
3773
-	// toujours encoder l'url source dans le bloc ajax
3774
-	$r = self();
3775
-	$r = ' data-origin="' . $r . '"';
3776
-	$class = 'ajaxbloc';
3777
-	if ($ajaxid and is_string($ajaxid)) {
3778
-		// ajaxid est normalement conforme a un nom de classe css
3779
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3780
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3781
-	}
3782
-
3783
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3690
+    if (is_string($c)
3691
+        and @unserialize($c) !== false
3692
+    ) {
3693
+        $c = unserialize($c);
3694
+    }
3695
+
3696
+    // supprimer les parametres debut_x
3697
+    // pour que la pagination ajax ne soit pas plantee
3698
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3699
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3700
+    if (is_array($c)) {
3701
+        foreach ($c as $k => $v) {
3702
+            if (strpos($k, 'debut_') === 0) {
3703
+                unset($c[$k]);
3704
+            }
3705
+        }
3706
+    }
3707
+
3708
+    if (!function_exists('calculer_cle_action')) {
3709
+        include_spip("inc/securiser_action");
3710
+    }
3711
+
3712
+    $c = serialize($c);
3713
+    $cle = calculer_cle_action($form . $c);
3714
+    $c = "$cle:$c";
3715
+
3716
+    // on ne stocke pas les contextes dans des fichiers en cache
3717
+    // par defaut, sauf si cette configuration a été forcée
3718
+    // OU que la longueur de l’argument géneré est plus long
3719
+    // que ce qui est toléré.
3720
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3721
+    if (!$cache_contextes_ajax) {
3722
+        $env = $c;
3723
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3724
+            $env = gzdeflate($env);
3725
+            // https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3726
+            if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3727
+                $cache_contextes_ajax = true;
3728
+                spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3729
+            }
3730
+        }
3731
+        $env = _xor($env);
3732
+        $env = base64_encode($env);
3733
+        $len = strlen($env);
3734
+        // Si l’url est trop longue pour le navigateur
3735
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3736
+        if ($len > $max_len) {
3737
+            $cache_contextes_ajax = true;
3738
+            spip_log("Contextes AJAX forces en fichiers !"
3739
+                . " Cela arrive lorsque la valeur du contexte" 
3740
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3741
+                , _LOG_AVERTISSEMENT);
3742
+        }
3743
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3744
+        elseif (
3745
+            $max_len = @ini_get('suhosin.get.max_value_length')
3746
+            and $max_len < $len
3747
+        ) {
3748
+            $cache_contextes_ajax = true;
3749
+            spip_log("Contextes AJAX forces en fichiers !"
3750
+                . " Cela arrive lorsque la valeur du contexte"
3751
+                . " depasse la longueur maximale autorisee par Suhosin"
3752
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3753
+                . " Vous devriez modifier les parametres de Suhosin"
3754
+                . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3755
+        } 
3756
+
3757
+    }
3758
+
3759
+    if ($cache_contextes_ajax) {
3760
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3761
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3762
+        $md5 = md5($c);
3763
+        ecrire_fichier("$dir/c$md5", $c);
3764
+        $env = $md5;
3765
+    }
3766
+
3767
+    if ($emboite === null) {
3768
+        return $env;
3769
+    }
3770
+    if (!trim($emboite)) {
3771
+        return "";
3772
+    }
3773
+    // toujours encoder l'url source dans le bloc ajax
3774
+    $r = self();
3775
+    $r = ' data-origin="' . $r . '"';
3776
+    $class = 'ajaxbloc';
3777
+    if ($ajaxid and is_string($ajaxid)) {
3778
+        // ajaxid est normalement conforme a un nom de classe css
3779
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3780
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3781
+    }
3782
+
3783
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3784 3784
 }
3785 3785
 
3786 3786
 /**
@@ -3800,36 +3800,36 @@  discard block
 block discarded – undo
3800 3800
  *   - false : erreur de décodage
3801 3801
  */
3802 3802
 function decoder_contexte_ajax($c, $form = '') {
3803
-	if (!function_exists('calculer_cle_action')) {
3804
-		include_spip("inc/securiser_action");
3805
-	}
3806
-	if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3807
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3808
-		and lire_fichier("$dir/c$c", $contexte)
3809
-	) {
3810
-		$c = $contexte;
3811
-	} else {
3812
-		$c = @base64_decode($c);
3813
-		$c = _xor($c);
3814
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3815
-			$c = @gzinflate($c);
3816
-		}
3817
-	}
3818
-
3819
-	// extraire la signature en debut de contexte
3820
-	// et la verifier avant de deserializer
3821
-	// format : signature:donneesserializees
3822
-	if ($p = strpos($c,":")){
3823
-		$cle = substr($c,0,$p);
3824
-		$c = substr($c,$p+1);
3825
-
3826
-		if ($cle == calculer_cle_action($form . $c)) {
3827
-			$env = @unserialize($c);
3828
-			return $env;
3829
-		}
3830
-	}
3831
-
3832
-	return false;
3803
+    if (!function_exists('calculer_cle_action')) {
3804
+        include_spip("inc/securiser_action");
3805
+    }
3806
+    if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3807
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3808
+        and lire_fichier("$dir/c$c", $contexte)
3809
+    ) {
3810
+        $c = $contexte;
3811
+    } else {
3812
+        $c = @base64_decode($c);
3813
+        $c = _xor($c);
3814
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3815
+            $c = @gzinflate($c);
3816
+        }
3817
+    }
3818
+
3819
+    // extraire la signature en debut de contexte
3820
+    // et la verifier avant de deserializer
3821
+    // format : signature:donneesserializees
3822
+    if ($p = strpos($c,":")){
3823
+        $cle = substr($c,0,$p);
3824
+        $c = substr($c,$p+1);
3825
+
3826
+        if ($cle == calculer_cle_action($form . $c)) {
3827
+            $env = @unserialize($c);
3828
+            return $env;
3829
+        }
3830
+    }
3831
+
3832
+    return false;
3833 3833
 }
3834 3834
 
3835 3835
 
@@ -3847,20 +3847,20 @@  discard block
 block discarded – undo
3847 3847
  *    Message décrypté ou encrypté
3848 3848
  **/
3849 3849
 function _xor($message, $key = null) {
3850
-	if (is_null($key)) {
3851
-		if (!function_exists('calculer_cle_action')) {
3852
-			include_spip("inc/securiser_action");
3853
-		}
3854
-		$key = pack("H*", calculer_cle_action('_xor'));
3855
-	}
3850
+    if (is_null($key)) {
3851
+        if (!function_exists('calculer_cle_action')) {
3852
+            include_spip("inc/securiser_action");
3853
+        }
3854
+        $key = pack("H*", calculer_cle_action('_xor'));
3855
+    }
3856 3856
 
3857
-	$keylen = strlen($key);
3858
-	$messagelen = strlen($message);
3859
-	for ($i = 0; $i < $messagelen; $i++) {
3860
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3861
-	}
3857
+    $keylen = strlen($key);
3858
+    $messagelen = strlen($message);
3859
+    for ($i = 0; $i < $messagelen; $i++) {
3860
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3861
+    }
3862 3862
 
3863
-	return $message;
3863
+    return $message;
3864 3864
 }
3865 3865
 
3866 3866
 /**
@@ -3918,22 +3918,22 @@  discard block
 block discarded – undo
3918 3918
  *   Code HTML
3919 3919
  */
3920 3920
 function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') {
3921
-	if ($on) {
3922
-		$bal = "strong";
3923
-		$att = "class='on'";
3924
-	} else {
3925
-		$bal = 'a';
3926
-		$att = "href='$url'"
3927
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3928
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3929
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3930
-			. $evt;
3931
-	}
3932
-	if ($libelle === null) {
3933
-		$libelle = $url;
3934
-	}
3921
+    if ($on) {
3922
+        $bal = "strong";
3923
+        $att = "class='on'";
3924
+    } else {
3925
+        $bal = 'a';
3926
+        $att = "href='$url'"
3927
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
3928
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
3929
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3930
+            . $evt;
3931
+    }
3932
+    if ($libelle === null) {
3933
+        $libelle = $url;
3934
+    }
3935 3935
 
3936
-	return "<$bal $att>$libelle</$bal>";
3936
+    return "<$bal $att>$libelle</$bal>";
3937 3937
 }
3938 3938
 
3939 3939
 
@@ -3950,18 +3950,18 @@  discard block
 block discarded – undo
3950 3950
  * @return string : la chaine de langue finale en utilisant la fonction _T()
3951 3951
  */
3952 3952
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) {
3953
-	if (!is_numeric($nb) or $nb == 0) {
3954
-		return "";
3955
-	}
3956
-	if (!is_array($vars)) {
3957
-		return "";
3958
-	}
3959
-	$vars[$var] = $nb;
3960
-	if ($nb >= 2) {
3961
-		return _T($chaine_plusieurs, $vars);
3962
-	} else {
3963
-		return _T($chaine_un, $vars);
3964
-	}
3953
+    if (!is_numeric($nb) or $nb == 0) {
3954
+        return "";
3955
+    }
3956
+    if (!is_array($vars)) {
3957
+        return "";
3958
+    }
3959
+    $vars[$var] = $nb;
3960
+    if ($nb >= 2) {
3961
+        return _T($chaine_plusieurs, $vars);
3962
+    } else {
3963
+        return _T($chaine_un, $vars);
3964
+    }
3965 3965
 }
3966 3966
 
3967 3967
 
@@ -3986,56 +3986,56 @@  discard block
 block discarded – undo
3986 3986
  * @return string
3987 3987
  */
3988 3988
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
3989
-	if (in_array($fonction, array("del", "supprimer.gif"))) {
3990
-		$class .= ' danger';
3991
-	} elseif ($fonction == "rien.gif") {
3992
-		$fonction = "";
3993
-	} elseif ($fonction == "delsafe") {
3994
-		$fonction = "del";
3995
-	}
3996
-
3997
-	$fond_origine = $fond;
3998
-	// remappage des icone : article-24.png+new => article-new-24.png
3999
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4000
-		list($fond, $fonction) = $icone_renommer($fond, $fonction);
4001
-	}
4002
-
4003
-	// ajouter le type d'objet dans la class de l'icone
4004
-	$class .= " " . substr(basename($fond), 0, -4);
4005
-
4006
-	$alt = attribut_html($texte);
4007
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4008
-
4009
-	$ajax = "";
4010
-	if (strpos($class, "ajax") !== false) {
4011
-		$ajax = "ajax";
4012
-		if (strpos($class, "preload") !== false) {
4013
-			$ajax .= " preload";
4014
-		}
4015
-		if (strpos($class, "nocache") !== false) {
4016
-			$ajax .= " nocache";
4017
-		}
4018
-		$ajax = " class='$ajax'";
4019
-	}
4020
-
4021
-	$size = 24;
4022
-	if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4023
-	  or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4024
-		$size = $match[1];
4025
-	}
4026
-
4027
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4028
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4029
-
4030
-	if ($type == 'lien') {
4031
-		return "<span class='icone s$size $class'>"
4032
-		. "<a href='$lien'$title$ajax$javascript>"
4033
-		. $icone
4034
-		. "<b>$texte</b>"
4035
-		. "</a></span>\n";
4036
-	} else {
4037
-		return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4038
-	}
3989
+    if (in_array($fonction, array("del", "supprimer.gif"))) {
3990
+        $class .= ' danger';
3991
+    } elseif ($fonction == "rien.gif") {
3992
+        $fonction = "";
3993
+    } elseif ($fonction == "delsafe") {
3994
+        $fonction = "del";
3995
+    }
3996
+
3997
+    $fond_origine = $fond;
3998
+    // remappage des icone : article-24.png+new => article-new-24.png
3999
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4000
+        list($fond, $fonction) = $icone_renommer($fond, $fonction);
4001
+    }
4002
+
4003
+    // ajouter le type d'objet dans la class de l'icone
4004
+    $class .= " " . substr(basename($fond), 0, -4);
4005
+
4006
+    $alt = attribut_html($texte);
4007
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4008
+
4009
+    $ajax = "";
4010
+    if (strpos($class, "ajax") !== false) {
4011
+        $ajax = "ajax";
4012
+        if (strpos($class, "preload") !== false) {
4013
+            $ajax .= " preload";
4014
+        }
4015
+        if (strpos($class, "nocache") !== false) {
4016
+            $ajax .= " nocache";
4017
+        }
4018
+        $ajax = " class='$ajax'";
4019
+    }
4020
+
4021
+    $size = 24;
4022
+    if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
4023
+      or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
4024
+        $size = $match[1];
4025
+    }
4026
+
4027
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4028
+    $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4029
+
4030
+    if ($type == 'lien') {
4031
+        return "<span class='icone s$size $class'>"
4032
+        . "<a href='$lien'$title$ajax$javascript>"
4033
+        . $icone
4034
+        . "<b>$texte</b>"
4035
+        . "</a></span>\n";
4036
+    } else {
4037
+        return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
4038
+    }
4039 4039
 }
4040 4040
 
4041 4041
 /**
@@ -4059,7 +4059,7 @@  discard block
 block discarded – undo
4059 4059
  *     Code HTML du lien
4060 4060
  **/
4061 4061
 function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4062
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4062
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4063 4063
 }
4064 4064
 
4065 4065
 /**
@@ -4094,7 +4094,7 @@  discard block
 block discarded – undo
4094 4094
  *     Code HTML du lien
4095 4095
  **/
4096 4096
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4097
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4097
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4098 4098
 }
4099 4099
 
4100 4100
 /**
@@ -4139,7 +4139,7 @@  discard block
 block discarded – undo
4139 4139
  *     Code HTML du lien
4140 4140
  **/
4141 4141
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4142
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4142
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4143 4143
 }
4144 4144
 
4145 4145
 /**
@@ -4170,7 +4170,7 @@  discard block
 block discarded – undo
4170 4170
  *     Code HTML du lien
4171 4171
  **/
4172 4172
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") {
4173
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4173
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4174 4174
 }
4175 4175
 
4176 4176
 /**
@@ -4200,7 +4200,7 @@  discard block
 block discarded – undo
4200 4200
  *     Code HTML du lien
4201 4201
  */
4202 4202
 function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") {
4203
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4203
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4204 4204
 }
4205 4205
 
4206 4206
 
@@ -4248,26 +4248,26 @@  discard block
 block discarded – undo
4248 4248
  * @return string Code CSS
4249 4249
  */
4250 4250
 function bando_images_background() {
4251
-	include_spip('inc/bandeau');
4252
-	// recuperer tous les boutons et leurs images
4253
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4251
+    include_spip('inc/bandeau');
4252
+    // recuperer tous les boutons et leurs images
4253
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4254 4254
 
4255
-	$res = "";
4256
-	foreach ($boutons as $page => $detail) {
4257
-		if ($detail->icone and strlen(trim($detail->icone))) {
4258
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4259
-		}
4260
-		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4261
-		if (is_array($detail->sousmenu)) {
4262
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4263
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4264
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4265
-				}
4266
-			}
4267
-		}
4268
-	}
4255
+    $res = "";
4256
+    foreach ($boutons as $page => $detail) {
4257
+        if ($detail->icone and strlen(trim($detail->icone))) {
4258
+            $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4259
+        }
4260
+        $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4261
+        if (is_array($detail->sousmenu)) {
4262
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4263
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4264
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4265
+                }
4266
+            }
4267
+        }
4268
+    }
4269 4269
 
4270
-	return $res;
4270
+    return $res;
4271 4271
 }
4272 4272
 
4273 4273
 /**
@@ -4286,19 +4286,19 @@  discard block
 block discarded – undo
4286 4286
  * @return string
4287 4287
  */
4288 4288
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4289
-	if ($confirm) {
4290
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4291
-		if ($callback) {
4292
-			$callback = "$confirm?($callback):false";
4293
-		} else {
4294
-			$callback = $confirm;
4295
-		}
4296
-	}
4297
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4298
-	$title = $title ? " title='$title'" : "";
4289
+    if ($confirm) {
4290
+        $confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4291
+        if ($callback) {
4292
+            $callback = "$confirm?($callback):false";
4293
+        } else {
4294
+            $callback = $confirm;
4295
+        }
4296
+    }
4297
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4298
+    $title = $title ? " title='$title'" : "";
4299 4299
 
4300
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4301
-	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4300
+    return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4301
+    . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4302 4302
 }
4303 4303
 
4304 4304
 /**
@@ -4319,78 +4319,78 @@  discard block
 block discarded – undo
4319 4319
  * @return string
4320 4320
  */
4321 4321
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") {
4322
-	static $trouver_table = null;
4323
-	static $objets;
4324
-
4325
-	// On verifie qu'on a tout ce qu'il faut
4326
-	$id_objet = intval($id_objet);
4327
-	if (!($id_objet and $type_objet and $info)) {
4328
-		return '';
4329
-	}
4330
-
4331
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4332
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4333
-		return '';
4334
-	}
4335
-
4336
-	// Si on demande l'url, on retourne direct la fonction
4337
-	if ($info == 'url') {
4338
-		return generer_url_entite($id_objet, $type_objet);
4339
-	}
4340
-
4341
-	// Sinon on va tout chercher dans la table et on garde en memoire
4342
-	$demande_titre = ($info == 'titre');
4343
-
4344
-	// 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
4345
-	if (!isset($objets[$type_objet][$id_objet])
4346
-		or
4347
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4348
-	) {
4349
-		if (!$trouver_table) {
4350
-			$trouver_table = charger_fonction('trouver_table', 'base');
4351
-		}
4352
-		$desc = $trouver_table(table_objet_sql($type_objet));
4353
-		if (!$desc) {
4354
-			return $objets[$type_objet] = false;
4355
-		}
4356
-
4357
-		// Si on demande le titre, on le gere en interne
4358
-		$champ_titre = "";
4359
-		if ($demande_titre) {
4360
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4361
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4362
-		}
4363
-		include_spip('base/abstract_sql');
4364
-		include_spip('base/connect_sql');
4365
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4366
-			'*' . $champ_titre,
4367
-			$desc['table_sql'],
4368
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4369
-		);
4370
-	}
4371
-
4372
-	// Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4373
-	if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4374
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4375
-	} // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4376
-	else {
4377
-		if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4378
-			$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4379
-		} // Sinon on prend directement le champ SQL tel quel
4380
-		else {
4381
-			$info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4382
-		}
4383
-	}
4384
-
4385
-	// On va ensuite appliquer les traitements automatiques si besoin
4386
-	if (!$etoile) {
4387
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4388
-		// mais ce fonctionnement est a ameliorer !
4389
-		$info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4390
-			array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4391
-	}
4392
-
4393
-	return $info_generee;
4322
+    static $trouver_table = null;
4323
+    static $objets;
4324
+
4325
+    // On verifie qu'on a tout ce qu'il faut
4326
+    $id_objet = intval($id_objet);
4327
+    if (!($id_objet and $type_objet and $info)) {
4328
+        return '';
4329
+    }
4330
+
4331
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4332
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4333
+        return '';
4334
+    }
4335
+
4336
+    // Si on demande l'url, on retourne direct la fonction
4337
+    if ($info == 'url') {
4338
+        return generer_url_entite($id_objet, $type_objet);
4339
+    }
4340
+
4341
+    // Sinon on va tout chercher dans la table et on garde en memoire
4342
+    $demande_titre = ($info == 'titre');
4343
+
4344
+    // 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
4345
+    if (!isset($objets[$type_objet][$id_objet])
4346
+        or
4347
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4348
+    ) {
4349
+        if (!$trouver_table) {
4350
+            $trouver_table = charger_fonction('trouver_table', 'base');
4351
+        }
4352
+        $desc = $trouver_table(table_objet_sql($type_objet));
4353
+        if (!$desc) {
4354
+            return $objets[$type_objet] = false;
4355
+        }
4356
+
4357
+        // Si on demande le titre, on le gere en interne
4358
+        $champ_titre = "";
4359
+        if ($demande_titre) {
4360
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4361
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4362
+        }
4363
+        include_spip('base/abstract_sql');
4364
+        include_spip('base/connect_sql');
4365
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4366
+            '*' . $champ_titre,
4367
+            $desc['table_sql'],
4368
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4369
+        );
4370
+    }
4371
+
4372
+    // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4373
+    if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4374
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4375
+    } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4376
+    else {
4377
+        if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4378
+            $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4379
+        } // Sinon on prend directement le champ SQL tel quel
4380
+        else {
4381
+            $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4382
+        }
4383
+    }
4384
+
4385
+    // On va ensuite appliquer les traitements automatiques si besoin
4386
+    if (!$etoile) {
4387
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4388
+        // mais ce fonctionnement est a ameliorer !
4389
+        $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4390
+            array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4391
+    }
4392
+
4393
+    return $info_generee;
4394 4394
 }
4395 4395
 
4396 4396
 /**
@@ -4404,44 +4404,44 @@  discard block
 block discarded – undo
4404 4404
  * @return string
4405 4405
  */
4406 4406
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') {
4407
-	if (!$champ) {
4408
-		return $texte;
4409
-	}
4407
+    if (!$champ) {
4408
+        return $texte;
4409
+    }
4410 4410
 	
4411
-	// On charge toujours les filtres de texte car la majorité des traitements les utilisent
4412
-	// et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4413
-	include_spip('inc/texte');
4411
+    // On charge toujours les filtres de texte car la majorité des traitements les utilisent
4412
+    // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4413
+    include_spip('inc/texte');
4414 4414
 	
4415
-	$champ = strtoupper($champ);
4416
-	$traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4417
-	if (!$traitements or !is_array($traitements)) {
4418
-		return $texte;
4419
-	}
4415
+    $champ = strtoupper($champ);
4416
+    $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4417
+    if (!$traitements or !is_array($traitements)) {
4418
+        return $texte;
4419
+    }
4420 4420
 
4421
-	$traitement = '';
4422
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4423
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4424
-		$table_objet = table_objet($table_objet);
4425
-		if (isset($traitements[$table_objet])) {
4426
-			$traitement = $traitements[$table_objet];
4427
-		}
4428
-	}
4429
-	if (!$traitement and isset($traitements[0])) {
4430
-		$traitement = $traitements[0];
4431
-	}
4432
-	// (sinon prendre le premier de la liste par defaut ?)
4421
+    $traitement = '';
4422
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4423
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4424
+        $table_objet = table_objet($table_objet);
4425
+        if (isset($traitements[$table_objet])) {
4426
+            $traitement = $traitements[$table_objet];
4427
+        }
4428
+    }
4429
+    if (!$traitement and isset($traitements[0])) {
4430
+        $traitement = $traitements[0];
4431
+    }
4432
+    // (sinon prendre le premier de la liste par defaut ?)
4433 4433
 
4434
-	if (!$traitement) {
4435
-		return $texte;
4436
-	}
4434
+    if (!$traitement) {
4435
+        return $texte;
4436
+    }
4437 4437
 
4438
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4438
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4439 4439
 
4440
-	// Fournir $connect et $Pile[0] au traitement si besoin
4441
-	$Pile = array(0 => $env);
4442
-	eval("\$texte = $traitement;");
4440
+    // Fournir $connect et $Pile[0] au traitement si besoin
4441
+    $Pile = array(0 => $env);
4442
+    eval("\$texte = $traitement;");
4443 4443
 
4444
-	return $texte;
4444
+    return $texte;
4445 4445
 }
4446 4446
 
4447 4447
 
@@ -4455,21 +4455,21 @@  discard block
 block discarded – undo
4455 4455
  * @return string
4456 4456
  */
4457 4457
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4458
-	include_spip('inc/liens');
4459
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4460
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4461
-	// le raccourcis n'est plus valide
4462
-	$titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4463
-	// on essaye avec generer_info_entite ?
4464
-	if (!strlen($titre) and !$connect) {
4465
-		$titre = generer_info_entite($id_objet, $objet, 'titre');
4466
-	}
4467
-	if (!strlen($titre)) {
4468
-		$titre = _T('info_sans_titre');
4469
-	}
4470
-	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4458
+    include_spip('inc/liens');
4459
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4460
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4461
+    // le raccourcis n'est plus valide
4462
+    $titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4463
+    // on essaye avec generer_info_entite ?
4464
+    if (!strlen($titre) and !$connect) {
4465
+        $titre = generer_info_entite($id_objet, $objet, 'titre');
4466
+    }
4467
+    if (!strlen($titre)) {
4468
+        $titre = _T('info_sans_titre');
4469
+    }
4470
+    $url = generer_url_entite($id_objet, $objet, '', '', $connect);
4471 4471
 
4472
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4472
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4473 4473
 }
4474 4474
 
4475 4475
 
@@ -4486,15 +4486,15 @@  discard block
 block discarded – undo
4486 4486
  * @return string
4487 4487
  */
4488 4488
 function wrap($texte, $wrap) {
4489
-	$balises = extraire_balises($wrap);
4490
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4491
-		$texte = $wrap . $texte;
4492
-		$regs = array_reverse($regs[1]);
4493
-		$wrap = "</" . implode("></", $regs) . ">";
4494
-		$texte = $texte . $wrap;
4495
-	}
4489
+    $balises = extraire_balises($wrap);
4490
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4491
+        $texte = $wrap . $texte;
4492
+        $regs = array_reverse($regs[1]);
4493
+        $wrap = "</" . implode("></", $regs) . ">";
4494
+        $texte = $texte . $wrap;
4495
+    }
4496 4496
 
4497
-	return $texte;
4497
+    return $texte;
4498 4498
 }
4499 4499
 
4500 4500
 
@@ -4514,43 +4514,43 @@  discard block
 block discarded – undo
4514 4514
  * @return array|mixed|string
4515 4515
  */
4516 4516
 function filtre_print_dist($u, $join = "<br />", $indent = 0) {
4517
-	if (is_string($u)) {
4518
-		$u = typo($u);
4517
+    if (is_string($u)) {
4518
+        $u = typo($u);
4519 4519
 
4520
-		return $u;
4521
-	}
4520
+        return $u;
4521
+    }
4522 4522
 
4523
-	// caster $u en array si besoin
4524
-	if (is_object($u)) {
4525
-		$u = (array)$u;
4526
-	}
4523
+    // caster $u en array si besoin
4524
+    if (is_object($u)) {
4525
+        $u = (array)$u;
4526
+    }
4527 4527
 
4528
-	if (is_array($u)) {
4529
-		$out = "";
4530
-		// toutes les cles sont numeriques ?
4531
-		// et aucun enfant n'est un tableau
4532
-		// liste simple separee par des virgules
4533
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4534
-		$array_values = array_map('is_array', $u);
4535
-		$object_values = array_map('is_object', $u);
4536
-		if (array_sum($numeric_keys) == count($numeric_keys)
4537
-			and !array_sum($array_values)
4538
-			and !array_sum($object_values)
4539
-		) {
4540
-			return join(", ", array_map('filtre_print_dist', $u));
4541
-		}
4528
+    if (is_array($u)) {
4529
+        $out = "";
4530
+        // toutes les cles sont numeriques ?
4531
+        // et aucun enfant n'est un tableau
4532
+        // liste simple separee par des virgules
4533
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4534
+        $array_values = array_map('is_array', $u);
4535
+        $object_values = array_map('is_object', $u);
4536
+        if (array_sum($numeric_keys) == count($numeric_keys)
4537
+            and !array_sum($array_values)
4538
+            and !array_sum($object_values)
4539
+        ) {
4540
+            return join(", ", array_map('filtre_print_dist', $u));
4541
+        }
4542 4542
 
4543
-		// sinon on passe a la ligne et on indente
4544
-		$i_str = str_pad("", $indent, " ");
4545
-		foreach ($u as $k => $v) {
4546
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4547
-		}
4543
+        // sinon on passe a la ligne et on indente
4544
+        $i_str = str_pad("", $indent, " ");
4545
+        foreach ($u as $k => $v) {
4546
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4547
+        }
4548 4548
 
4549
-		return $out;
4550
-	}
4549
+        return $out;
4550
+    }
4551 4551
 
4552
-	// on sait pas quoi faire...
4553
-	return $u;
4552
+    // on sait pas quoi faire...
4553
+    return $u;
4554 4554
 }
4555 4555
 
4556 4556
 
@@ -4563,10 +4563,10 @@  discard block
 block discarded – undo
4563 4563
  * @return string|array
4564 4564
  */
4565 4565
 function objet_info($objet, $info) {
4566
-	$table = table_objet_sql($objet);
4567
-	$infos = lister_tables_objets_sql($table);
4566
+    $table = table_objet_sql($objet);
4567
+    $infos = lister_tables_objets_sql($table);
4568 4568
 
4569
-	return (isset($infos[$info]) ? $infos[$info] : '');
4569
+    return (isset($infos[$info]) ? $infos[$info] : '');
4570 4570
 }
4571 4571
 
4572 4572
 /**
@@ -4581,11 +4581,11 @@  discard block
 block discarded – undo
4581 4581
  *     Texte traduit du comptage, tel que '3 articles'
4582 4582
  */
4583 4583
 function objet_afficher_nb($nb, $objet) {
4584
-	if (!$nb) {
4585
-		return _T(objet_info($objet, 'info_aucun_objet'));
4586
-	} else {
4587
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4588
-	}
4584
+    if (!$nb) {
4585
+        return _T(objet_info($objet, 'info_aucun_objet'));
4586
+    } else {
4587
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4588
+    }
4589 4589
 }
4590 4590
 
4591 4591
 /**
@@ -4597,11 +4597,11 @@  discard block
 block discarded – undo
4597 4597
  * @return string
4598 4598
  */
4599 4599
 function objet_icone($objet, $taille = 24, $class='') {
4600
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4601
-	$icone = chemin_image($icone);
4602
-	$balise_img = charger_filtre('balise_img');
4600
+    $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4601
+    $icone = chemin_image($icone);
4602
+    $balise_img = charger_filtre('balise_img');
4603 4603
 
4604
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4604
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4605 4605
 }
4606 4606
 
4607 4607
 /**
@@ -4622,12 +4622,12 @@  discard block
 block discarded – undo
4622 4622
  * @return string
4623 4623
  */
4624 4624
 function objet_T($objet, $chaine, $args = array(), $options = array()){
4625
-	$chaine = explode(':',$chaine);
4626
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4627
-		return $t;
4628
-	}
4629
-	$chaine = implode(':',$chaine);
4630
-	return _T($chaine, $args, $options);
4625
+    $chaine = explode(':',$chaine);
4626
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4627
+        return $t;
4628
+    }
4629
+    $chaine = implode(':',$chaine);
4630
+    return _T($chaine, $args, $options);
4631 4631
 }
4632 4632
 
4633 4633
 /**
@@ -4641,17 +4641,17 @@  discard block
 block discarded – undo
4641 4641
  * @return string      Code HTML
4642 4642
  */
4643 4643
 function insert_head_css_conditionnel($flux) {
4644
-	if (strpos($flux, '<!-- insert_head_css -->') === false
4645
-		and $p = strpos($flux, '<!-- insert_head -->')
4646
-	) {
4647
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4648
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4649
-			$p = $p1;
4650
-		}
4651
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4652
-	}
4644
+    if (strpos($flux, '<!-- insert_head_css -->') === false
4645
+        and $p = strpos($flux, '<!-- insert_head -->')
4646
+    ) {
4647
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4648
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4649
+            $p = $p1;
4650
+        }
4651
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4652
+    }
4653 4653
 
4654
-	return $flux;
4654
+    return $flux;
4655 4655
 }
4656 4656
 
4657 4657
 /**
@@ -4672,69 +4672,69 @@  discard block
 block discarded – undo
4672 4672
  * @return string
4673 4673
  */
4674 4674
 function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') {
4675
-	if (isset($contexte['format'])) {
4676
-		$extension = $contexte['format'];
4677
-		unset($contexte['format']);
4678
-	} else {
4679
-		$extension = "html";
4680
-		if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4681
-			$extension = $m[1];
4682
-		}
4683
-	}
4684
-	// recuperer le contenu produit par le squelette
4685
-	$options['raw'] = true;
4686
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4687
-
4688
-	// calculer le nom de la css
4689
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4690
-	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4691
-	$contexte_implicite = calculer_contexte_implicite();
4692
-
4693
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4694
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4695
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4696
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4697
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4698
-	}
4699
-	else {
4700
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4701
-		ksort($contexte);
4702
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4703
-	}
4704
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4705
-
4706
-	// mettre a jour le fichier si il n'existe pas
4707
-	// ou trop ancien
4708
-	// le dernier fichier produit est toujours suffixe par .last
4709
-	// et recopie sur le fichier cible uniquement si il change
4710
-	if (!file_exists($filename)
4711
-		or !file_exists($filename . ".last")
4712
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4713
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4714
-	) {
4715
-		$contenu = $cache['texte'];
4716
-		// passer les urls en absolu si c'est une css
4717
-		if ($extension == "css") {
4718
-			$contenu = urls_absolues_css($contenu,
4719
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4720
-		}
4721
-
4722
-		$comment = '';
4723
-		// ne pas insérer de commentaire si c'est du json
4724
-		if ($extension != "json") {
4725
-			$comment = "/* #PRODUIRE{fond=$fond";
4726
-			foreach ($contexte as $k => $v) {
4727
-				$comment .= ",$k=$v";
4728
-			}
4729
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4730
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4731
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4732
-		}
4733
-		// et ecrire le fichier si il change
4734
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4735
-	}
4736
-
4737
-	return timestamp($filename);
4675
+    if (isset($contexte['format'])) {
4676
+        $extension = $contexte['format'];
4677
+        unset($contexte['format']);
4678
+    } else {
4679
+        $extension = "html";
4680
+        if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4681
+            $extension = $m[1];
4682
+        }
4683
+    }
4684
+    // recuperer le contenu produit par le squelette
4685
+    $options['raw'] = true;
4686
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4687
+
4688
+    // calculer le nom de la css
4689
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4690
+    $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4691
+    $contexte_implicite = calculer_contexte_implicite();
4692
+
4693
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4694
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4695
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4696
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4697
+        $hash = md5($contexte_implicite['host'] . '::'. $cache);
4698
+    }
4699
+    else {
4700
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4701
+        ksort($contexte);
4702
+        $hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4703
+    }
4704
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4705
+
4706
+    // mettre a jour le fichier si il n'existe pas
4707
+    // ou trop ancien
4708
+    // le dernier fichier produit est toujours suffixe par .last
4709
+    // et recopie sur le fichier cible uniquement si il change
4710
+    if (!file_exists($filename)
4711
+        or !file_exists($filename . ".last")
4712
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4713
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4714
+    ) {
4715
+        $contenu = $cache['texte'];
4716
+        // passer les urls en absolu si c'est une css
4717
+        if ($extension == "css") {
4718
+            $contenu = urls_absolues_css($contenu,
4719
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4720
+        }
4721
+
4722
+        $comment = '';
4723
+        // ne pas insérer de commentaire si c'est du json
4724
+        if ($extension != "json") {
4725
+            $comment = "/* #PRODUIRE{fond=$fond";
4726
+            foreach ($contexte as $k => $v) {
4727
+                $comment .= ",$k=$v";
4728
+            }
4729
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4730
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4731
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
4732
+        }
4733
+        // et ecrire le fichier si il change
4734
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4735
+    }
4736
+
4737
+    return timestamp($filename);
4738 4738
 }
4739 4739
 
4740 4740
 /**
@@ -4747,14 +4747,14 @@  discard block
 block discarded – undo
4747 4747
  *    $fichier auquel on a ajouté le timestamp
4748 4748
  */
4749 4749
 function timestamp($fichier) {
4750
-	if (!$fichier
4751
-		or !file_exists($fichier)
4752
-		or !$m = filemtime($fichier)
4753
-	) {
4754
-		return $fichier;
4755
-	}
4750
+    if (!$fichier
4751
+        or !file_exists($fichier)
4752
+        or !$m = filemtime($fichier)
4753
+    ) {
4754
+        return $fichier;
4755
+    }
4756 4756
 
4757
-	return "$fichier?$m";
4757
+    return "$fichier?$m";
4758 4758
 }
4759 4759
 
4760 4760
 /**
@@ -4764,11 +4764,11 @@  discard block
 block discarded – undo
4764 4764
  * @return string
4765 4765
  */
4766 4766
 function supprimer_timestamp($url) {
4767
-	if (strpos($url, "?") === false) {
4768
-		return $url;
4769
-	}
4767
+    if (strpos($url, "?") === false) {
4768
+        return $url;
4769
+    }
4770 4770
 
4771
-	return preg_replace(",\?[[:digit:]]+$,", "", $url);
4771
+    return preg_replace(",\?[[:digit:]]+$,", "", $url);
4772 4772
 }
4773 4773
 
4774 4774
 /**
@@ -4783,9 +4783,9 @@  discard block
 block discarded – undo
4783 4783
  * @return string
4784 4784
  */
4785 4785
 function filtre_nettoyer_titre_email_dist($titre) {
4786
-	include_spip('inc/envoyer_mail');
4786
+    include_spip('inc/envoyer_mail');
4787 4787
 
4788
-	return nettoyer_titre_email($titre);
4788
+    return nettoyer_titre_email($titre);
4789 4789
 }
4790 4790
 
4791 4791
 /**
@@ -4807,19 +4807,19 @@  discard block
 block discarded – undo
4807 4807
  * @return string
4808 4808
  */
4809 4809
 function filtre_chercher_rubrique_dist(
4810
-	$titre,
4811
-	$id_objet,
4812
-	$id_parent,
4813
-	$objet,
4814
-	$id_secteur,
4815
-	$restreint,
4816
-	$actionable = false,
4817
-	$retour_sans_cadre = false
4810
+    $titre,
4811
+    $id_objet,
4812
+    $id_parent,
4813
+    $objet,
4814
+    $id_secteur,
4815
+    $restreint,
4816
+    $actionable = false,
4817
+    $retour_sans_cadre = false
4818 4818
 ) {
4819
-	include_spip('inc/filtres_ecrire');
4819
+    include_spip('inc/filtres_ecrire');
4820 4820
 
4821
-	return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4822
-		$retour_sans_cadre);
4821
+    return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4822
+        $retour_sans_cadre);
4823 4823
 }
4824 4824
 
4825 4825
 /**
@@ -4848,56 +4848,56 @@  discard block
 block discarded – undo
4848 4848
  *     Chaîne vide si l'accès est autorisé
4849 4849
  */
4850 4850
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
4851
-	if ($ok) {
4852
-		return '';
4853
-	}
4854
-
4855
-	// Vider tous les tampons
4856
-	$level = @ob_get_level();
4857
-	while ($level--) {
4858
-		@ob_end_clean();
4859
-	}
4860
-
4861
-	include_spip('inc/headers');
4862
-
4863
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4864
-	if ($url) {
4865
-		redirige_par_entete($url, '', $statut);
4866
-	}
4867
-
4868
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
4869
-	if (!is_numeric($statut) and is_null($message)) {
4870
-		$message = $statut;
4871
-		$statut = 0;
4872
-	}
4873
-	if (!$message) {
4874
-		$message = '';
4875
-	}
4876
-	$statut = intval($statut);
4877
-
4878
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4879
-	if (test_espace_prive()) {
4880
-		if (!$statut or !in_array($statut, array(404, 403))) {
4881
-			$statut = 403;
4882
-		}
4883
-		http_status(403);
4884
-		$echec = charger_fonction('403', 'exec');
4885
-		$echec($message);
4886
-	} else {
4887
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4888
-		if (!$statut) {
4889
-			$statut = 404;
4890
-		}
4891
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
4892
-		http_status($statut);
4893
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4894
-		if ($statut >= 400) {
4895
-			echo recuperer_fond("$statut", array('erreur' => $message));
4896
-		}
4897
-	}
4898
-
4899
-
4900
-	exit;
4851
+    if ($ok) {
4852
+        return '';
4853
+    }
4854
+
4855
+    // Vider tous les tampons
4856
+    $level = @ob_get_level();
4857
+    while ($level--) {
4858
+        @ob_end_clean();
4859
+    }
4860
+
4861
+    include_spip('inc/headers');
4862
+
4863
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4864
+    if ($url) {
4865
+        redirige_par_entete($url, '', $statut);
4866
+    }
4867
+
4868
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
4869
+    if (!is_numeric($statut) and is_null($message)) {
4870
+        $message = $statut;
4871
+        $statut = 0;
4872
+    }
4873
+    if (!$message) {
4874
+        $message = '';
4875
+    }
4876
+    $statut = intval($statut);
4877
+
4878
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4879
+    if (test_espace_prive()) {
4880
+        if (!$statut or !in_array($statut, array(404, 403))) {
4881
+            $statut = 403;
4882
+        }
4883
+        http_status(403);
4884
+        $echec = charger_fonction('403', 'exec');
4885
+        $echec($message);
4886
+    } else {
4887
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4888
+        if (!$statut) {
4889
+            $statut = 404;
4890
+        }
4891
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
4892
+        http_status($statut);
4893
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4894
+        if ($statut >= 400) {
4895
+            echo recuperer_fond("$statut", array('erreur' => $message));
4896
+        }
4897
+    }
4898
+
4899
+
4900
+    exit;
4901 4901
 }
4902 4902
 
4903 4903
 /**
@@ -4908,11 +4908,11 @@  discard block
 block discarded – undo
4908 4908
  * @return string
4909 4909
  */
4910 4910
 function filtre_compacte_dist($source, $format = null) {
4911
-	if (function_exists('compacte')) {
4912
-		return compacte($source, $format);
4913
-	}
4911
+    if (function_exists('compacte')) {
4912
+        return compacte($source, $format);
4913
+    }
4914 4914
 
4915
-	return $source;
4915
+    return $source;
4916 4916
 }
4917 4917
 
4918 4918
 
@@ -4924,29 +4924,29 @@  discard block
 block discarded – undo
4924 4924
  * @return string
4925 4925
  */
4926 4926
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4927
-	$l = strlen($passe);
4928
-
4929
-	if ($l<=8 or !$afficher_partiellement){
4930
-		if (!$l) {
4931
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4932
-		}
4933
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4934
-	}
4935
-
4936
-	if (is_null($portion_pourcent)) {
4937
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4938
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4939
-		}
4940
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4941
-	}
4942
-	if ($portion_pourcent >= 100) {
4943
-		return $passe;
4944
-	}
4945
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4946
-	$e = max($e, 0);
4947
-	$mid = str_pad('',$l-2*$e,'*');
4948
-	if ($e>0 and strlen($mid)>8){
4949
-		$mid = '***...***';
4950
-	}
4951
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4927
+    $l = strlen($passe);
4928
+
4929
+    if ($l<=8 or !$afficher_partiellement){
4930
+        if (!$l) {
4931
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4932
+        }
4933
+        return str_pad('',$afficher_partiellement ? $l : 16,'*');
4934
+    }
4935
+
4936
+    if (is_null($portion_pourcent)) {
4937
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4938
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4939
+        }
4940
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4941
+    }
4942
+    if ($portion_pourcent >= 100) {
4943
+        return $passe;
4944
+    }
4945
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
4946
+    $e = max($e, 0);
4947
+    $mid = str_pad('',$l-2*$e,'*');
4948
+    if ($e>0 and strlen($mid)>8){
4949
+        $mid = '***...***';
4950
+    }
4951
+    return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4952 4952
 }
4953 4953
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 		return $f;
94 94
 	}
95
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
95
+	foreach (array('filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc) as $f) {
96 96
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
97 97
 		// fonction ou name\space\fonction
98 98
 		if (is_callable($f)) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	// affichage "GIT [master: abcdef]"
186 186
 	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
187 187
 	if ($desc['branch']) {
188
-		$commit = $desc['branch'] . ': ' . $commit;
188
+		$commit = $desc['branch'].': '.$commit;
189 189
 	}
190 190
 	return "{$desc['vcs']} [$commit]";
191 191
 }
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 	}
205 205
 
206 206
 	// version installee par GIT
207
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
207
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
208 208
 		$currentHead = trim(substr($c, 4));
209
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
209
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
210 210
 			return [
211 211
 				'vcs' => 'GIT',
212 212
 				'branch' => basename($currentHead),
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 		$dir = '.';
234 234
 	}
235 235
 	// version installee par SVN
236
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
237
-		$db = new SQLite3($dir . '/.svn/wc.db');
236
+	if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) {
237
+		$db = new SQLite3($dir.'/.svn/wc.db');
238 238
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
239 239
 		if ($result) {
240 240
 			$row = $result->fetchArray();
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
 
274 274
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
275 275
 // et laisser passer les fonctions personnelles baptisees image_...
276
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
277
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
278
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
279
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
280
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
276
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
277
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
278
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
279
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
280
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
281 281
 
282 282
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
283 283
 $GLOBALS['spip_matrice']['couleur_foncer'] = 'inc/filtres_images_mini.php';
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
  */
435 435
 function filtre_debug($val, $key = null) {
436 436
 	$debug = (
437
-		is_null($key) ? '' : (var_export($key, true) . " = ")
438
-		) . var_export($val, true);
437
+		is_null($key) ? '' : (var_export($key, true)." = ")
438
+		).var_export($val, true);
439 439
 
440 440
 	include_spip('inc/autoriser');
441 441
 	if (autoriser('webmestre')) {
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
524 524
 							$srcover = $match[1];
525 525
 							array_shift($args);
526
-							array_unshift($args, "<img src='" . $match[1] . "' />");
526
+							array_unshift($args, "<img src='".$match[1]."' />");
527 527
 							$srcover_filter = call_user_func_array($filtre, $args);
528 528
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
529 529
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 	// " -> &quot; et tout ce genre de choses
874 874
 	$u = $GLOBALS['meta']['pcre_u'];
875 875
 	$texte = str_replace("&nbsp;", " ", $texte);
876
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
876
+	$texte = preg_replace('/\s{2,}/S'.$u, " ", $texte);
877 877
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
878 878
 	$texte = entites_html($texte, false, false);
879 879
 	// mais bien echapper les double quotes !
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
  **/
934 934
 function supprimer_numero($texte) {
935 935
 	return preg_replace(
936
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
936
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
937 937
 		"", $texte);
938 938
 }
939 939
 
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
  **/
959 959
 function recuperer_numero($texte) {
960 960
 	if (preg_match(
961
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
961
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
962 962
 		$texte, $regs)) {
963 963
 		return strval($regs[1]);
964 964
 	} else {
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
  **/
1044 1044
 function textebrut($texte) {
1045 1045
 	$u = $GLOBALS['meta']['pcre_u'];
1046
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1047
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1046
+	$texte = preg_replace('/\s+/S'.$u, " ", $texte);
1047
+	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
1048 1048
 	$texte = preg_replace("/^\n+/", "", $texte);
1049 1049
 	$texte = preg_replace("/\n+$/", "", $texte);
1050 1050
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1073 1073
 		$texte, $liens, PREG_PATTERN_ORDER)) {
1074 1074
 		foreach ($liens[0] as $a) {
1075
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1075
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1076 1076
 			$ablank = inserer_attribut($a, 'rel', $rel);
1077 1077
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1078 1078
 			$texte = str_replace($a, $ablank, $texte);
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 		foreach ($regs[0] as $a) {
1098 1098
 			$rel = extraire_attribut($a, "rel");
1099 1099
 			if (strpos($rel, "nofollow") === false) {
1100
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1100
+				$rel = "nofollow".($rel ? " $rel" : "");
1101 1101
 				$anofollow = inserer_attribut($a, "rel", $rel);
1102 1102
 				$texte = str_replace($a, $anofollow, $texte);
1103 1103
 			}
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 	$u = $GLOBALS['meta']['pcre_u'];
1127 1127
 	$texte = preg_replace("@</p>@iS", "\n", $texte);
1128 1128
 	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1129
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1129
+	$texte = preg_replace("@^\s*<br />@S".$u, "", $texte);
1130 1130
 
1131 1131
 	return $texte;
1132 1132
 }
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
 		return $texte;
1157 1157
 	}
1158 1158
 	include_spip('inc/texte');
1159
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1159
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1160 1160
 		'div' : 'span';
1161 1161
 
1162 1162
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
 function attribut_html($texte, $textebrut = true) {
1266 1266
 	$u = $GLOBALS['meta']['pcre_u'];
1267 1267
 	if ($textebrut) {
1268
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1268
+		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte));
1269 1269
 	}
1270 1270
 	$texte = texte_backend($texte);
1271 1271
 	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 	# un message pour abs_url
1295 1295
 	$GLOBALS['mode_abs_url'] = 'url';
1296 1296
 	$url = trim($url);
1297
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1297
+	$r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS';
1298 1298
 
1299 1299
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1300 1300
 }
@@ -1496,14 +1496,14 @@  discard block
 block discarded – undo
1496 1496
 	if (strpos($texte, "<") !== false) {
1497 1497
 		include_spip('inc/lien');
1498 1498
 		if (defined('_PREG_MODELE')) {
1499
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1499
+			$preg_modeles = "@"._PREG_MODELE."@imsS";
1500 1500
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1501 1501
 		}
1502 1502
 	}
1503 1503
 
1504 1504
 	$debut = '';
1505 1505
 	$suite = $texte;
1506
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1506
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1507 1507
 		$debut .= substr($suite, 0, $t - 1);
1508 1508
 		$suite = substr($suite, $t);
1509 1509
 		$car = substr($suite, 0, 1);
@@ -1520,11 +1520,11 @@  discard block
 block discarded – undo
1520 1520
 			$suite = substr($suite, strlen($regs[0]));
1521 1521
 		}
1522 1522
 	}
1523
-	$texte = $debut . $suite;
1523
+	$texte = $debut.$suite;
1524 1524
 
1525 1525
 	$texte = echappe_retour($texte);
1526 1526
 
1527
-	return $texte . $fin;
1527
+	return $texte.$fin;
1528 1528
 }
1529 1529
 
1530 1530
 
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
 		}
1586 1586
 
1587 1587
 		foreach ($regs as $reg) {
1588
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1588
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1589 1589
 			$desc = $traduire($cle, $lang, true);
1590 1590
 			$l = $desc->langue;
1591 1591
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1699 1699
 					include_spip('inc/texte');
1700 1700
 					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1701
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1701
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1702 1702
 					$trad = code_echappement($trad, 'multi', false, $mode);
1703 1703
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1704 1704
 					if (lang_dir($l) !== lang_dir($lang)) {
@@ -1891,7 +1891,7 @@  discard block
 block discarded – undo
1891 1891
 	if (is_array($balise)) {
1892 1892
 		array_walk(
1893 1893
 			$balise,
1894
-			function(&$a, $key, $t){
1894
+			function(&$a, $key, $t) {
1895 1895
 				$a = extraire_attribut($a, $t);
1896 1896
 			},
1897 1897
 			$attribut
@@ -1978,14 +1978,14 @@  discard block
 block discarded – undo
1978 1978
 
1979 1979
 	if ($old !== null) {
1980 1980
 		// Remplacer l'ancien attribut du meme nom
1981
-		$balise = $r[1] . $insert . $r[5];
1981
+		$balise = $r[1].$insert.$r[5];
1982 1982
 	} else {
1983 1983
 		// preferer une balise " />" (comme <img />)
1984 1984
 		if (preg_match(',/>,', $balise)) {
1985
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1985
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
1986 1986
 		} // sinon une balise <a ...> ... </a>
1987 1987
 		else {
1988
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1988
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
1989 1989
 		}
1990 1990
 	}
1991 1991
 
@@ -2027,8 +2027,8 @@  discard block
 block discarded – undo
2027 2027
 //
2028 2028
 // Quelques fonctions de calcul arithmetique
2029 2029
 //
2030
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
2031
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
2030
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
2031
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
2032 2032
 
2033 2033
 /**
2034 2034
  * Additionne 2 nombres
@@ -2048,7 +2048,7 @@  discard block
 block discarded – undo
2048 2048
 function plus($a, $b) {
2049 2049
 	return $a + $b;
2050 2050
 }
2051
-function strplus($a, $b) {return strize('plus', $a, $b);}
2051
+function strplus($a, $b) {return strize('plus', $a, $b); }
2052 2052
 /**
2053 2053
  * Soustrait 2 nombres
2054 2054
  *
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
 function moins($a, $b) {
2068 2068
 	return $a - $b;
2069 2069
 }
2070
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2070
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2071 2071
 
2072 2072
 /**
2073 2073
  * Multiplie 2 nombres
@@ -2088,7 +2088,7 @@  discard block
 block discarded – undo
2088 2088
 function mult($a, $b) {
2089 2089
 	return $a * $b;
2090 2090
 }
2091
-function strmult($a, $b) {return strize('mult', $a, $b);}
2091
+function strmult($a, $b) {return strize('mult', $a, $b); }
2092 2092
 
2093 2093
 /**
2094 2094
  * Divise 2 nombres
@@ -2109,7 +2109,7 @@  discard block
 block discarded – undo
2109 2109
 function div($a, $b) {
2110 2110
 	return $b ? $a / $b : 0;
2111 2111
 }
2112
-function strdiv($a, $b) {return strize('div', $a, $b);}
2112
+function strdiv($a, $b) {return strize('div', $a, $b); }
2113 2113
 
2114 2114
 /**
2115 2115
  * Retourne le modulo 2 nombres
@@ -2150,13 +2150,13 @@  discard block
 block discarded – undo
2150 2150
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2151 2151
 		define('_TAGS_NOM_AUTEUR', '');
2152 2152
 	}
2153
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2153
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2154 2154
 	foreach ($tags_acceptes as $tag) {
2155 2155
 		if (strlen($tag)) {
2156
-			$remp1[] = '<' . trim($tag) . '>';
2157
-			$remp1[] = '</' . trim($tag) . '>';
2158
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2159
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2156
+			$remp1[] = '<'.trim($tag).'>';
2157
+			$remp1[] = '</'.trim($tag).'>';
2158
+			$remp2[] = '\x60'.trim($tag).'\x61';
2159
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2160 2160
 		}
2161 2161
 	}
2162 2162
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2219,7 +2219,7 @@  discard block
 block discarded – undo
2219 2219
 			$s[] = preg_replace(',>[^<]+</a>,S',
2220 2220
 				'>'
2221 2221
 				. http_img_pack('attachment-16.png', $t,
2222
-					'title="' . attribut_html($t) . '"')
2222
+					'title="'.attribut_html($t).'"')
2223 2223
 				. '</a>', $tag);
2224 2224
 		}
2225 2225
 	}
@@ -2280,10 +2280,10 @@  discard block
 block discarded – undo
2280 2280
 	$fichier = basename($url);
2281 2281
 
2282 2282
 	return '<a rel="enclosure"'
2283
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2284
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2285
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2286
-	. '>' . $fichier . '</a>';
2283
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2284
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2285
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2286
+	. '>'.$fichier.'</a>';
2287 2287
 }
2288 2288
 
2289 2289
 /**
@@ -2311,9 +2311,9 @@  discard block
 block discarded – undo
2311 2311
 			} # vieux data
2312 2312
 			$fichier = basename($url);
2313 2313
 			$enclosures[] = '<enclosure'
2314
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2315
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2316
-				. ($length ? ' length="' . $length . '"' : '')
2314
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2315
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2316
+				. ($length ? ' length="'.$length.'"' : '')
2317 2317
 				. ' />';
2318 2318
 		}
2319 2319
 	}
@@ -2339,7 +2339,7 @@  discard block
 block discarded – undo
2339 2339
 		if (extraire_attribut($e, rel) == 'tag') {
2340 2340
 			$subjects .= '<dc:subject>'
2341 2341
 				. texte_backend(textebrut($e))
2342
-				. '</dc:subject>' . "\n";
2342
+				. '</dc:subject>'."\n";
2343 2343
 		}
2344 2344
 	}
2345 2345
 
@@ -2375,7 +2375,7 @@  discard block
 block discarded – undo
2375 2375
 	if (is_array($texte)) {
2376 2376
 		array_walk(
2377 2377
 			$texte,
2378
-			function(&$a, $key, $t){
2378
+			function(&$a, $key, $t) {
2379 2379
 				$a = extraire_balise($a, $t);
2380 2380
 			},
2381 2381
 			$tag
@@ -2419,7 +2419,7 @@  discard block
 block discarded – undo
2419 2419
 	if (is_array($texte)) {
2420 2420
 		array_walk(
2421 2421
 			$texte,
2422
-			function(&$a, $key, $t){
2422
+			function(&$a, $key, $t) {
2423 2423
 				$a = extraire_balises($a, $t);
2424 2424
 			},
2425 2425
 			$tag
@@ -2545,7 +2545,7 @@  discard block
 block discarded – undo
2545 2545
 		if ($fond != '404') {
2546 2546
 			$contexte = array_shift($p);
2547 2547
 			$contexte['page'] = $fond;
2548
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2548
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2549 2549
 		}
2550 2550
 	}
2551 2551
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2600,9 +2600,9 @@  discard block
 block discarded – undo
2600 2600
 			. '"'
2601 2601
 			. (is_null($val)
2602 2602
 				? ''
2603
-				: ' value="' . entites_html($val) . '"'
2603
+				: ' value="'.entites_html($val).'"'
2604 2604
 			)
2605
-			. ' type="hidden"' . "\n/>";
2605
+			. ' type="hidden"'."\n/>";
2606 2606
 	}
2607 2607
 
2608 2608
 	return join("", $hidden);
@@ -2765,12 +2765,12 @@  discard block
 block discarded – undo
2765 2765
 	if ($pas < 1) {
2766 2766
 		return '';
2767 2767
 	}
2768
-	$ancre = 'pagination' . $nom; // #pagination_articles
2769
-	$debut = 'debut' . $nom; // 'debut_articles'
2768
+	$ancre = 'pagination'.$nom; // #pagination_articles
2769
+	$debut = 'debut'.$nom; // 'debut_articles'
2770 2770
 
2771 2771
 	// n'afficher l'ancre qu'une fois
2772 2772
 	if (!isset($ancres[$ancre])) {
2773
-		$bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2773
+		$bloc_ancre = $ancres[$ancre] = "<a name='".$ancre."' id='".$ancre."'></a>";
2774 2774
 	} else {
2775 2775
 		$bloc_ancre = '';
2776 2776
 	}
@@ -2801,7 +2801,7 @@  discard block
 block discarded – undo
2801 2801
 	}
2802 2802
 
2803 2803
 	if ($modele) {
2804
-		$modele = '_' . $modele;
2804
+		$modele = '_'.$modele;
2805 2805
 	}
2806 2806
 
2807 2807
 	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
@@ -2826,7 +2826,7 @@  discard block
 block discarded – undo
2826 2826
 	return preg_replace_callback(
2827 2827
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2828 2828
 		function($x) use ($path) {
2829
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2829
+			return "url('".suivre_lien($path, $x[1])."')";
2830 2830
 		},
2831 2831
 		$contenu
2832 2832
 	);
@@ -2888,14 +2888,14 @@  discard block
 block discarded – undo
2888 2888
 	) {
2889 2889
 		$distant = true;
2890 2890
 		$cssf = parse_url($css);
2891
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2891
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2892 2892
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2893 2893
 	} else {
2894 2894
 		$distant = false;
2895 2895
 		$cssf = $css;
2896 2896
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2897 2897
 		//propose (rien a faire dans ce cas)
2898
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2898
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2899 2899
 		if (@file_exists($f)) {
2900 2900
 			return $f;
2901 2901
 		}
@@ -2905,7 +2905,7 @@  discard block
 block discarded – undo
2905 2905
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2906 2906
 	$f = $dir_var
2907 2907
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2908
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2908
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2909 2909
 
2910 2910
 	// la css peut etre distante (url absolue !)
2911 2911
 	if ($distant) {
@@ -2950,8 +2950,8 @@  discard block
 block discarded – undo
2950 2950
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2951 2951
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2952 2952
 			$css_direction = substr($css_direction, strlen($dir_var));
2953
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2954
-			$css_direction = "/@@@@@@/" . $css_direction;
2953
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
2954
+			$css_direction = "/@@@@@@/".$css_direction;
2955 2955
 		}
2956 2956
 		$src[] = $regs[0][$k];
2957 2957
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -3000,7 +3000,7 @@  discard block
 block discarded – undo
3000 3000
 
3001 3001
 	$f = basename($css, '.css');
3002 3002
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3003
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3003
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3004 3004
 		. '.css';
3005 3005
 
3006 3006
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3009,7 +3009,7 @@  discard block
 block discarded – undo
3009 3009
 
3010 3010
 	if ($url_absolue_css == $css) {
3011 3011
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3012
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3012
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3013 3013
 		) {
3014 3014
 			include_spip('inc/distant');
3015 3015
 			if (!$contenu = recuperer_page($css)) {
@@ -3119,7 +3119,7 @@  discard block
 block discarded – undo
3119 3119
 	$expression = str_replace("\/", "/", $expression);
3120 3120
 	$expression = str_replace("/", "\/", $expression);
3121 3121
 
3122
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3122
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3123 3123
 		if (isset($r[$capte])) {
3124 3124
 			return $r[$capte];
3125 3125
 		} else {
@@ -3157,7 +3157,7 @@  discard block
 block discarded – undo
3157 3157
 	$expression = str_replace("\/", "/", $expression);
3158 3158
 	$expression = str_replace("/", "\/", $expression);
3159 3159
 
3160
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3160
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3161 3161
 }
3162 3162
 
3163 3163
 
@@ -3176,7 +3176,7 @@  discard block
 block discarded – undo
3176 3176
 function traiter_doublons_documents(&$doublons, $letexte) {
3177 3177
 
3178 3178
 	// Verifier dans le texte & les notes (pas beau, helas)
3179
-	$t = $letexte . $GLOBALS['les_notes'];
3179
+	$t = $letexte.$GLOBALS['les_notes'];
3180 3180
 
3181 3181
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3182 3182
 		and preg_match_all(
@@ -3186,7 +3186,7 @@  discard block
 block discarded – undo
3186 3186
 		if (!isset($doublons['documents'])) {
3187 3187
 			$doublons['documents'] = "";
3188 3188
 		}
3189
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3189
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3190 3190
 	}
3191 3191
 
3192 3192
 	return $letexte;
@@ -3243,7 +3243,7 @@  discard block
 block discarded – undo
3243 3243
 	if ($env) {
3244 3244
 		foreach ($env as $i => $j) {
3245 3245
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3246
-				$texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />";
3246
+				$texte .= "<param name='".$i."'\n\tvalue='".$j."' />";
3247 3247
 			}
3248 3248
 		}
3249 3249
 	}
@@ -3282,7 +3282,7 @@  discard block
 block discarded – undo
3282 3282
 	if ($env) {
3283 3283
 		foreach ($env as $i => $j) {
3284 3284
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3285
-				$texte .= $i . "='" . $j . "' ";
3285
+				$texte .= $i."='".$j."' ";
3286 3286
 			}
3287 3287
 		}
3288 3288
 	}
@@ -3366,19 +3366,19 @@  discard block
 block discarded – undo
3366 3366
 
3367 3367
 	$img_file = $img;
3368 3368
 	if ($p = strpos($img_file, '?')) {
3369
-		$img_file = substr($img_file,0, $p);
3369
+		$img_file = substr($img_file, 0, $p);
3370 3370
 	}
3371 3371
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3372 3372
 		$img_file = chemin_image($img);
3373 3373
 	}
3374 3374
 	else {
3375
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3375
+		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3376 3376
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3377 3377
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3378 3378
 			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3379
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3379
+			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg"
3380 3380
 			  and file_exists($variante_svg_generique)) {
3381
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3381
+				if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) {
3382 3382
 					$img_file = $variante_svg_size;
3383 3383
 				}
3384 3384
 				else {
@@ -3403,15 +3403,15 @@  discard block
 block discarded – undo
3403 3403
 				return "";
3404 3404
 			}
3405 3405
 		}
3406
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3406
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3407 3407
 	}
3408 3408
 
3409 3409
 	if (file_exists($img_file)) {
3410 3410
 		$img_file = timestamp($img_file);
3411 3411
 	}
3412
-	return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'"
3413
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3414
-	. " " . ltrim($atts)
3412
+	return "<img src='$img_file' alt='".attribut_html($alt ? $alt : $title)."'"
3413
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3414
+	. " ".ltrim($atts)
3415 3415
 	. " />";
3416 3416
 }
3417 3417
 
@@ -3423,12 +3423,12 @@  discard block
 block discarded – undo
3423 3423
  * @param string $size
3424 3424
  * @return string
3425 3425
  */
3426
-function http_style_background($img, $att = '', $size=null) {
3427
-	if ($size and is_numeric($size)){
3428
-		$size = trim($size) . "px";
3426
+function http_style_background($img, $att = '', $size = null) {
3427
+	if ($size and is_numeric($size)) {
3428
+		$size = trim($size)."px";
3429 3429
 	}
3430
-	return " style='background" .
3431
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3430
+	return " style='background".
3431
+		($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";"
3432 3432
 		. ($size ? "background-size:{$size};" : '')
3433 3433
 		. "'";
3434 3434
 }
@@ -3445,8 +3445,8 @@  discard block
 block discarded – undo
3445 3445
  * @return string
3446 3446
  *     Code HTML de la balise IMG
3447 3447
  */
3448
-function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3449
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3448
+function filtre_balise_img_dist($img, $alt = "", $class = "", $width = null) {
3449
+	$atts = $class ? " class='".attribut_html($class)."'" : '';
3450 3450
 	// ecriture courte : on donne le width en 2e arg
3451 3451
 	if (empty($width) and is_numeric($alt)) {
3452 3452
 		$width = $alt;
@@ -3474,7 +3474,7 @@  discard block
 block discarded – undo
3474 3474
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3475 3475
 	$img_file = $img;
3476 3476
 	if ($p = strpos($img_file, '?')) {
3477
-		$img_file = substr($img_file,0, $p);
3477
+		$img_file = substr($img_file, 0, $p);
3478 3478
 	}
3479 3479
 
3480 3480
 	if (!$img_file or !$svg = file_get_contents($img_file)) {
@@ -3488,18 +3488,18 @@  discard block
 block discarded – undo
3488 3488
 	$balise_svg_source = $balise_svg;
3489 3489
 
3490 3490
 	// entete XML à supprimer
3491
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3491
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3492 3492
 
3493 3493
 	// IE est toujours mon ami
3494 3494
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3495 3495
 	if ($class) {
3496 3496
 		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3497 3497
 	}
3498
-	if ($alt){
3498
+	if ($alt) {
3499 3499
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3500
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3500
+		$id = "img-svg-title-".substr(md5("$img_file:$svg:$alt"), 0, 4);
3501 3501
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3502
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3502
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3503 3503
 		$balise_svg .= $title;
3504 3504
 	}
3505 3505
 	else {
@@ -3533,7 +3533,7 @@  discard block
 block discarded – undo
3533 3533
 	$texte = '';
3534 3534
 	if (is_array($tableau)) {
3535 3535
 		foreach ($tableau as $k => $v) {
3536
-			$res = recuperer_fond('modeles/' . $modele,
3536
+			$res = recuperer_fond('modeles/'.$modele,
3537 3537
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3538 3538
 			);
3539 3539
 			$texte .= $res;
@@ -3710,7 +3710,7 @@  discard block
 block discarded – undo
3710 3710
 	}
3711 3711
 
3712 3712
 	$c = serialize($c);
3713
-	$cle = calculer_cle_action($form . $c);
3713
+	$cle = calculer_cle_action($form.$c);
3714 3714
 	$c = "$cle:$c";
3715 3715
 
3716 3716
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3772,15 +3772,15 @@  discard block
 block discarded – undo
3772 3772
 	}
3773 3773
 	// toujours encoder l'url source dans le bloc ajax
3774 3774
 	$r = self();
3775
-	$r = ' data-origin="' . $r . '"';
3775
+	$r = ' data-origin="'.$r.'"';
3776 3776
 	$class = 'ajaxbloc';
3777 3777
 	if ($ajaxid and is_string($ajaxid)) {
3778 3778
 		// ajaxid est normalement conforme a un nom de classe css
3779 3779
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3780
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3780
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3781 3781
 	}
3782 3782
 
3783
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3783
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3784 3784
 }
3785 3785
 
3786 3786
 /**
@@ -3819,11 +3819,11 @@  discard block
 block discarded – undo
3819 3819
 	// extraire la signature en debut de contexte
3820 3820
 	// et la verifier avant de deserializer
3821 3821
 	// format : signature:donneesserializees
3822
-	if ($p = strpos($c,":")){
3823
-		$cle = substr($c,0,$p);
3824
-		$c = substr($c,$p+1);
3822
+	if ($p = strpos($c, ":")) {
3823
+		$cle = substr($c, 0, $p);
3824
+		$c = substr($c, $p + 1);
3825 3825
 
3826
-		if ($cle == calculer_cle_action($form . $c)) {
3826
+		if ($cle == calculer_cle_action($form.$c)) {
3827 3827
 			$env = @unserialize($c);
3828 3828
 			return $env;
3829 3829
 		}
@@ -3924,9 +3924,9 @@  discard block
 block discarded – undo
3924 3924
 	} else {
3925 3925
 		$bal = 'a';
3926 3926
 		$att = "href='$url'"
3927
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3928
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3929
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3927
+			. ($title ? " title='".attribut_html($title)."'" : '')
3928
+			. ($class ? " class='".attribut_html($class)."'" : '')
3929
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
3930 3930
 			. $evt;
3931 3931
 	}
3932 3932
 	if ($libelle === null) {
@@ -4001,7 +4001,7 @@  discard block
 block discarded – undo
4001 4001
 	}
4002 4002
 
4003 4003
 	// ajouter le type d'objet dans la class de l'icone
4004
-	$class .= " " . substr(basename($fond), 0, -4);
4004
+	$class .= " ".substr(basename($fond), 0, -4);
4005 4005
 
4006 4006
 	$alt = attribut_html($texte);
4007 4007
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -4025,7 +4025,7 @@  discard block
 block discarded – undo
4025 4025
 	}
4026 4026
 
4027 4027
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4028
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4028
+	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "")."\">$icone</span>";
4029 4029
 
4030 4030
 	if ($type == 'lien') {
4031 4031
 		return "<span class='icone s$size $class'>"
@@ -4255,13 +4255,13 @@  discard block
 block discarded – undo
4255 4255
 	$res = "";
4256 4256
 	foreach ($boutons as $page => $detail) {
4257 4257
 		if ($detail->icone and strlen(trim($detail->icone))) {
4258
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4258
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4259 4259
 		}
4260 4260
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4261 4261
 		if (is_array($detail->sousmenu)) {
4262 4262
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4263 4263
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4264
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4264
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4265 4265
 				}
4266 4266
 			}
4267 4267
 		}
@@ -4287,17 +4287,17 @@  discard block
 block discarded – undo
4287 4287
  */
4288 4288
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4289 4289
 	if ($confirm) {
4290
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4290
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4291 4291
 		if ($callback) {
4292 4292
 			$callback = "$confirm?($callback):false";
4293 4293
 		} else {
4294 4294
 			$callback = $confirm;
4295 4295
 		}
4296 4296
 	}
4297
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4297
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4298 4298
 	$title = $title ? " title='$title'" : "";
4299 4299
 
4300
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4300
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4301 4301
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4302 4302
 }
4303 4303
 
@@ -4358,14 +4358,14 @@  discard block
 block discarded – undo
4358 4358
 		$champ_titre = "";
4359 4359
 		if ($demande_titre) {
4360 4360
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4361
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4361
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4362 4362
 		}
4363 4363
 		include_spip('base/abstract_sql');
4364 4364
 		include_spip('base/connect_sql');
4365 4365
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4366
-			'*' . $champ_titre,
4366
+			'*'.$champ_titre,
4367 4367
 			$desc['table_sql'],
4368
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4368
+			id_table_objet($type_objet).' = '.intval($id_objet)
4369 4369
 		);
4370 4370
 	}
4371 4371
 
@@ -4435,7 +4435,7 @@  discard block
 block discarded – undo
4435 4435
 		return $texte;
4436 4436
 	}
4437 4437
 
4438
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4438
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4439 4439
 
4440 4440
 	// Fournir $connect et $Pile[0] au traitement si besoin
4441 4441
 	$Pile = array(0 => $env);
@@ -4469,7 +4469,7 @@  discard block
 block discarded – undo
4469 4469
 	}
4470 4470
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4471 4471
 
4472
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4472
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4473 4473
 }
4474 4474
 
4475 4475
 
@@ -4488,10 +4488,10 @@  discard block
 block discarded – undo
4488 4488
 function wrap($texte, $wrap) {
4489 4489
 	$balises = extraire_balises($wrap);
4490 4490
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4491
-		$texte = $wrap . $texte;
4491
+		$texte = $wrap.$texte;
4492 4492
 		$regs = array_reverse($regs[1]);
4493
-		$wrap = "</" . implode("></", $regs) . ">";
4494
-		$texte = $texte . $wrap;
4493
+		$wrap = "</".implode("></", $regs).">";
4494
+		$texte = $texte.$wrap;
4495 4495
 	}
4496 4496
 
4497 4497
 	return $texte;
@@ -4522,7 +4522,7 @@  discard block
 block discarded – undo
4522 4522
 
4523 4523
 	// caster $u en array si besoin
4524 4524
 	if (is_object($u)) {
4525
-		$u = (array)$u;
4525
+		$u = (array) $u;
4526 4526
 	}
4527 4527
 
4528 4528
 	if (is_array($u)) {
@@ -4543,7 +4543,7 @@  discard block
 block discarded – undo
4543 4543
 		// sinon on passe a la ligne et on indente
4544 4544
 		$i_str = str_pad("", $indent, " ");
4545 4545
 		foreach ($u as $k => $v) {
4546
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4546
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4547 4547
 		}
4548 4548
 
4549 4549
 		return $out;
@@ -4596,8 +4596,8 @@  discard block
 block discarded – undo
4596 4596
  * @param string $class
4597 4597
  * @return string
4598 4598
  */
4599
-function objet_icone($objet, $taille = 24, $class='') {
4600
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4599
+function objet_icone($objet, $taille = 24, $class = '') {
4600
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4601 4601
 	$icone = chemin_image($icone);
4602 4602
 	$balise_img = charger_filtre('balise_img');
4603 4603
 
@@ -4621,12 +4621,12 @@  discard block
 block discarded – undo
4621 4621
  * @param array $options
4622 4622
  * @return string
4623 4623
  */
4624
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4625
-	$chaine = explode(':',$chaine);
4626
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4624
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4625
+	$chaine = explode(':', $chaine);
4626
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4627 4627
 		return $t;
4628 4628
 	}
4629
-	$chaine = implode(':',$chaine);
4629
+	$chaine = implode(':', $chaine);
4630 4630
 	return _T($chaine, $args, $options);
4631 4631
 }
4632 4632
 
@@ -4686,7 +4686,7 @@  discard block
 block discarded – undo
4686 4686
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4687 4687
 
4688 4688
 	// calculer le nom de la css
4689
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4689
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4690 4690
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4691 4691
 	$contexte_implicite = calculer_contexte_implicite();
4692 4692
 
@@ -4694,22 +4694,22 @@  discard block
 block discarded – undo
4694 4694
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4695 4695
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4696 4696
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4697
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4697
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
4698 4698
 	}
4699 4699
 	else {
4700 4700
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4701 4701
 		ksort($contexte);
4702
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4702
+		$hash = md5($fond.json_encode($contexte_implicite).json_encode($contexte).$connect);
4703 4703
 	}
4704
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4704
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4705 4705
 
4706 4706
 	// mettre a jour le fichier si il n'existe pas
4707 4707
 	// ou trop ancien
4708 4708
 	// le dernier fichier produit est toujours suffixe par .last
4709 4709
 	// et recopie sur le fichier cible uniquement si il change
4710 4710
 	if (!file_exists($filename)
4711
-		or !file_exists($filename . ".last")
4712
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4711
+		or !file_exists($filename.".last")
4712
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4713 4713
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4714 4714
 	) {
4715 4715
 		$contenu = $cache['texte'];
@@ -4728,10 +4728,10 @@  discard block
 block discarded – undo
4728 4728
 			}
4729 4729
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4730 4730
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4731
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4731
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4732 4732
 		}
4733 4733
 		// et ecrire le fichier si il change
4734
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4734
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
4735 4735
 	}
4736 4736
 
4737 4737
 	return timestamp($filename);
@@ -4926,11 +4926,11 @@  discard block
 block discarded – undo
4926 4926
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4927 4927
 	$l = strlen($passe);
4928 4928
 
4929
-	if ($l<=8 or !$afficher_partiellement){
4929
+	if ($l <= 8 or !$afficher_partiellement) {
4930 4930
 		if (!$l) {
4931 4931
 			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4932 4932
 		}
4933
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4933
+		return str_pad('', $afficher_partiellement ? $l : 16, '*');
4934 4934
 	}
4935 4935
 
4936 4936
 	if (is_null($portion_pourcent)) {
@@ -4944,9 +4944,9 @@  discard block
 block discarded – undo
4944 4944
 	}
4945 4945
 	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4946 4946
 	$e = max($e, 0);
4947
-	$mid = str_pad('',$l-2*$e,'*');
4948
-	if ($e>0 and strlen($mid)>8){
4947
+	$mid = str_pad('', $l - 2 * $e, '*');
4948
+	if ($e > 0 and strlen($mid) > 8) {
4949 4949
 		$mid = '***...***';
4950 4950
 	}
4951
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4951
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
4952 4952
 }
4953 4953
\ No newline at end of file
Please login to merge, or discard this patch.
ecrire/inc_version.php 1 patch
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 define('_PHP_MIN', '5.6.0');
37 37
 
38 38
 if (!defined('_DIR_RESTREINT_ABS')) {
39
-	/** le nom du repertoire ecrire/ */
40
-	define('_DIR_RESTREINT_ABS', 'ecrire/');
39
+    /** le nom du repertoire ecrire/ */
40
+    define('_DIR_RESTREINT_ABS', 'ecrire/');
41 41
 }
42 42
 
43 43
 /** Chemin relatif pour aller dans ecrire
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 
58 58
 // Icones
59 59
 if (!defined('_NOM_IMG_PACK')) {
60
-	/** Nom du dossier images */
61
-	define('_NOM_IMG_PACK', 'images/');
60
+    /** Nom du dossier images */
61
+    define('_NOM_IMG_PACK', 'images/');
62 62
 }
63 63
 /** le chemin http (relatif) vers les images standard */
64 64
 define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK));
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK);
68 68
 
69 69
 if (!defined('_JAVASCRIPT')) {
70
-	/** Nom du repertoire des  bibliotheques JavaScript */
71
-	define('_JAVASCRIPT', 'javascript/');
70
+    /** Nom du repertoire des  bibliotheques JavaScript */
71
+    define('_JAVASCRIPT', 'javascript/');
72 72
 } // utilisable avec #CHEMIN et find_in_path
73 73
 /** le nom du repertoire des  bibliotheques JavaScript du prive */
74 74
 define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT));
@@ -78,46 +78,46 @@  discard block
 block discarded – undo
78 78
 # mais on peut les mettre ailleurs et changer completement les noms
79 79
 
80 80
 if (!defined('_NOM_TEMPORAIRES_INACCESSIBLES')) {
81
-	/** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */
82
-	define('_NOM_TEMPORAIRES_INACCESSIBLES', "tmp/");
81
+    /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */
82
+    define('_NOM_TEMPORAIRES_INACCESSIBLES', "tmp/");
83 83
 }
84 84
 if (!defined('_NOM_TEMPORAIRES_ACCESSIBLES')) {
85
-	/** Nom du repertoire des fichiers Temporaires Accessibles par http:// */
86
-	define('_NOM_TEMPORAIRES_ACCESSIBLES', "local/");
85
+    /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */
86
+    define('_NOM_TEMPORAIRES_ACCESSIBLES', "local/");
87 87
 }
88 88
 if (!defined('_NOM_PERMANENTS_INACCESSIBLES')) {
89
-	/** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */
90
-	define('_NOM_PERMANENTS_INACCESSIBLES', "config/");
89
+    /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */
90
+    define('_NOM_PERMANENTS_INACCESSIBLES', "config/");
91 91
 }
92 92
 if (!defined('_NOM_PERMANENTS_ACCESSIBLES')) {
93
-	/** Nom du repertoire des fichiers Permanents Accessibles par http:// */
94
-	define('_NOM_PERMANENTS_ACCESSIBLES', "IMG/");
93
+    /** Nom du repertoire des fichiers Permanents Accessibles par http:// */
94
+    define('_NOM_PERMANENTS_ACCESSIBLES', "IMG/");
95 95
 }
96 96
 
97 97
 
98 98
 /** Le nom du fichier de personnalisation */
99 99
 if (!defined('_NOM_CONFIG')) {
100
-	define('_NOM_CONFIG', 'mes_options');
100
+    define('_NOM_CONFIG', 'mes_options');
101 101
 }
102 102
 
103 103
 // Son emplacement absolu si on le trouve
104 104
 if (@file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php')
105
-	or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php'))
105
+    or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php'))
106 106
 ) {
107
-	/** Emplacement absolu du fichier d'option */
108
-	define('_FILE_OPTIONS', $f);
107
+    /** Emplacement absolu du fichier d'option */
108
+    define('_FILE_OPTIONS', $f);
109 109
 } else {
110
-	define('_FILE_OPTIONS', '');
110
+    define('_FILE_OPTIONS', '');
111 111
 }
112 112
 
113 113
 if (!defined('MODULES_IDIOMES')) {
114
-	/**
115
-	 * Modules par défaut pour la traduction.
116
-	 *
117
-	 * Constante utilisée par le compilateur et le décompilateur
118
-	 * sa valeur etant traitée par inc_traduire_dist
119
-	 */
120
-	define('MODULES_IDIOMES', 'public|spip|ecrire');
114
+    /**
115
+     * Modules par défaut pour la traduction.
116
+     *
117
+     * Constante utilisée par le compilateur et le décompilateur
118
+     * sa valeur etant traitée par inc_traduire_dist
119
+     */
120
+    define('MODULES_IDIOMES', 'public|spip|ecrire');
121 121
 }
122 122
 
123 123
 // *** Fin des define *** //
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 
126 126
 // Inclure l'ecran de securite
127 127
 if (!defined('_ECRAN_SECURITE')
128
-	and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php')
128
+    and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php')
129 129
 ) {
130
-	include $f;
130
+    include $f;
131 131
 }
132 132
 
133 133
 
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
  * Détecteur de robot d'indexation
136 136
  */
137 137
 if (!defined('_IS_BOT')) {
138
-	define('_IS_BOT',
139
-		isset($_SERVER['HTTP_USER_AGENT'])
140
-		and preg_match(
141
-			// mots generiques
142
-			',bot|slurp|crawler|spider|webvac|yandex|'
143
-			// MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot
144
-			. 'MSIE 6\.0|'
145
-			// UA plus cibles
146
-			. '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
147
-			. ',i', (string)$_SERVER['HTTP_USER_AGENT'])
148
-	);
138
+    define('_IS_BOT',
139
+        isset($_SERVER['HTTP_USER_AGENT'])
140
+        and preg_match(
141
+            // mots generiques
142
+            ',bot|slurp|crawler|spider|webvac|yandex|'
143
+            // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot
144
+            . 'MSIE 6\.0|'
145
+            // UA plus cibles
146
+            . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
147
+            . ',i', (string)$_SERVER['HTTP_USER_AGENT'])
148
+    );
149 149
 }
150 150
 
151 151
 // *** Parametrage par defaut de SPIP ***
@@ -157,62 +157,62 @@  discard block
 block discarded – undo
157 157
 // Ne pas les rendre indefinies.
158 158
 
159 159
 global
160
-	$nombre_de_logs,
161
-	$taille_des_logs,
162
-	$table_prefix,
163
-	$cookie_prefix,
164
-	$dossier_squelettes,
165
-	$filtrer_javascript,
166
-	$type_urls,
167
-	$debut_date_publication,
168
-	$ip,
169
-	$mysql_rappel_connexion,
170
-	$mysql_rappel_nom_base,
171
-	$test_i18n,
172
-	$ignore_auth_http,
173
-	$ignore_remote_user,
174
-	$derniere_modif_invalide,
175
-	$quota_cache,
176
-	$home_server,
177
-	$help_server,
178
-	$url_glossaire_externe,
179
-	$tex_server,
180
-	$traiter_math,
181
-	$xhtml,
182
-	$xml_indent,
183
-	$source_vignettes,
184
-	$formats_logos,
185
-	$controler_dates_rss,
186
-	$spip_pipeline,
187
-	$spip_matrice,
188
-	$plugins,
189
-	$surcharges,
190
-	$exceptions_des_tables,
191
-	$tables_principales,
192
-	$table_des_tables,
193
-	$tables_auxiliaires,
194
-	$table_primary,
195
-	$table_date,
196
-	$table_titre,
197
-	$tables_jointures,
198
-	$liste_des_statuts,
199
-	$liste_des_etats,
200
-	$liste_des_authentifications,
201
-	$spip_version_branche,
202
-	$spip_version_code,
203
-	$spip_version_base,
204
-	$spip_sql_version,
205
-	$spip_version_affichee,
206
-	$visiteur_session,
207
-	$auteur_session,
208
-	$connect_statut,
209
-	$connect_toutes_rubriques,
210
-	$hash_recherche,
211
-	$hash_recherche_strict,
212
-	$ldap_present,
213
-	$meta,
214
-	$connect_id_rubrique,
215
-	$puce;
160
+    $nombre_de_logs,
161
+    $taille_des_logs,
162
+    $table_prefix,
163
+    $cookie_prefix,
164
+    $dossier_squelettes,
165
+    $filtrer_javascript,
166
+    $type_urls,
167
+    $debut_date_publication,
168
+    $ip,
169
+    $mysql_rappel_connexion,
170
+    $mysql_rappel_nom_base,
171
+    $test_i18n,
172
+    $ignore_auth_http,
173
+    $ignore_remote_user,
174
+    $derniere_modif_invalide,
175
+    $quota_cache,
176
+    $home_server,
177
+    $help_server,
178
+    $url_glossaire_externe,
179
+    $tex_server,
180
+    $traiter_math,
181
+    $xhtml,
182
+    $xml_indent,
183
+    $source_vignettes,
184
+    $formats_logos,
185
+    $controler_dates_rss,
186
+    $spip_pipeline,
187
+    $spip_matrice,
188
+    $plugins,
189
+    $surcharges,
190
+    $exceptions_des_tables,
191
+    $tables_principales,
192
+    $table_des_tables,
193
+    $tables_auxiliaires,
194
+    $table_primary,
195
+    $table_date,
196
+    $table_titre,
197
+    $tables_jointures,
198
+    $liste_des_statuts,
199
+    $liste_des_etats,
200
+    $liste_des_authentifications,
201
+    $spip_version_branche,
202
+    $spip_version_code,
203
+    $spip_version_base,
204
+    $spip_sql_version,
205
+    $spip_version_affichee,
206
+    $visiteur_session,
207
+    $auteur_session,
208
+    $connect_statut,
209
+    $connect_toutes_rubriques,
210
+    $hash_recherche,
211
+    $hash_recherche_strict,
212
+    $ldap_present,
213
+    $meta,
214
+    $connect_id_rubrique,
215
+    $puce;
216 216
 
217 217
 # comment on logge, defaut 4 tmp/spip.log de 100k, 0 ou 0 suppriment le log
218 218
 $nombre_de_logs = 4;
@@ -267,48 +267,48 @@  discard block
 block discarded – undo
267 267
 // Prendre en compte les entetes HTTP_X_FORWARDED_XX
268 268
 //
269 269
 if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO']==='https'){
270
-	if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
271
-		$_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST'];
272
-	}
273
-	if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
274
-		$_SERVER['HTTP_X_FORWARDED_PORT'] = 443;
275
-	}
270
+    if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
271
+        $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST'];
272
+    }
273
+    if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
274
+        $_SERVER['HTTP_X_FORWARDED_PORT'] = 443;
275
+    }
276 276
 }
277 277
 if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])){
278
-	if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])){
279
-		$_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
280
-		if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO']==='https'){
281
-			$_SERVER['HTTPS'] = 'on';
282
-			if (isset($_SERVER['REQUEST_SCHEME'])) {
283
-				$_SERVER['REQUEST_SCHEME'] = 'https';
284
-			}
285
-		}
286
-	}
287
-	$host = $_SERVER['HTTP_X_FORWARDED_HOST'];
288
-	if (strpos($host,',')!==false){
289
-		$h = explode(',',$host);
290
-		$host = trim(reset($h));
291
-	}
292
-	// securite sur le contenu de l'entete
293
-	$host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________');
294
-	$_SERVER['HTTP_HOST'] = $host;
278
+    if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])){
279
+        $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
280
+        if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO']==='https'){
281
+            $_SERVER['HTTPS'] = 'on';
282
+            if (isset($_SERVER['REQUEST_SCHEME'])) {
283
+                $_SERVER['REQUEST_SCHEME'] = 'https';
284
+            }
285
+        }
286
+    }
287
+    $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
288
+    if (strpos($host,',')!==false){
289
+        $h = explode(',',$host);
290
+        $host = trim(reset($h));
291
+    }
292
+    // securite sur le contenu de l'entete
293
+    $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________');
294
+    $_SERVER['HTTP_HOST'] = $host;
295 295
 }
296 296
 //
297 297
 // On note le numero IP du client dans la variable $ip
298 298
 //
299 299
 if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
300
-	$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
301
-	if (strpos($ip,',')!==false){
302
-		$ip = explode(',',$ip);
303
-		$ip = reset($ip);
304
-	}
305
-	// ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost
306
-	if (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR']==='127.0.0.1'){
307
-		$_SERVER['REMOTE_ADDR'] = $ip;
308
-	}
300
+    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
301
+    if (strpos($ip,',')!==false){
302
+        $ip = explode(',',$ip);
303
+        $ip = reset($ip);
304
+    }
305
+    // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost
306
+    if (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR']==='127.0.0.1'){
307
+        $_SERVER['REMOTE_ADDR'] = $ip;
308
+    }
309 309
 }
310 310
 if (isset($_SERVER['REMOTE_ADDR'])) {
311
-	$ip = $_SERVER['REMOTE_ADDR'];
311
+    $ip = $_SERVER['REMOTE_ADDR'];
312 312
 }
313 313
 
314 314
 // Pour renforcer la privacy, decommentez la ligne ci-dessous (ou recopiez-la
@@ -393,24 +393,24 @@  discard block
 block discarded – undo
393 393
 
394 394
 // Liste des statuts.
395 395
 $liste_des_statuts = array(
396
-	"info_administrateurs" => '0minirezo',
397
-	"info_redacteurs" => '1comite',
398
-	"info_visiteurs" => '6forum',
399
-	"texte_statut_poubelle" => '5poubelle'
396
+    "info_administrateurs" => '0minirezo',
397
+    "info_redacteurs" => '1comite',
398
+    "info_visiteurs" => '6forum',
399
+    "texte_statut_poubelle" => '5poubelle'
400 400
 );
401 401
 
402 402
 $liste_des_etats = array(
403
-	'texte_statut_en_cours_redaction' => 'prepa',
404
-	'texte_statut_propose_evaluation' => 'prop',
405
-	'texte_statut_publie' => 'publie',
406
-	'texte_statut_poubelle' => 'poubelle',
407
-	'texte_statut_refuse' => 'refuse'
403
+    'texte_statut_en_cours_redaction' => 'prepa',
404
+    'texte_statut_propose_evaluation' => 'prop',
405
+    'texte_statut_publie' => 'publie',
406
+    'texte_statut_poubelle' => 'poubelle',
407
+    'texte_statut_refuse' => 'refuse'
408 408
 );
409 409
 
410 410
 // liste des methodes d'authentifications
411 411
 $liste_des_authentifications = array(
412
-	'spip' => 'spip',
413
-	'ldap' => 'ldap'
412
+    'spip' => 'spip',
413
+    'ldap' => 'ldap'
414 414
 );
415 415
 
416 416
 // Experimental : pour supprimer systematiquement l'affichage des numeros
@@ -460,12 +460,12 @@  discard block
 block discarded – undo
460 460
 // Definition personnelles eventuelles
461 461
 
462 462
 if (_FILE_OPTIONS) {
463
-	include_once _FILE_OPTIONS;
463
+    include_once _FILE_OPTIONS;
464 464
 }
465 465
 
466 466
 if (!defined('SPIP_ERREUR_REPORT')) {
467
-	/** Masquer les warning */
468
-	define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED);
467
+    /** Masquer les warning */
468
+    define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED);
469 469
 }
470 470
 error_reporting(SPIP_ERREUR_REPORT);
471 471
 
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
 // ===> on execute en neutralisant les messages d'erreur
479 479
 
480 480
 spip_initialisation_core(
481
-	(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
482
-	(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
483
-	(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
484
-	(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
481
+    (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
482
+    (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
483
+    (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
484
+    (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
485 485
 );
486 486
 
487 487
 
@@ -491,76 +491,76 @@  discard block
 block discarded – undo
491 491
 // donc il faut avoir tout fini ici avant de charger les plugins
492 492
 
493 493
 if (@is_readable(_CACHE_PLUGINS_OPT) and @is_readable(_CACHE_PLUGINS_PATH)) {
494
-	// chargement optimise precompile
495
-	include_once(_CACHE_PLUGINS_OPT);
494
+    // chargement optimise precompile
495
+    include_once(_CACHE_PLUGINS_OPT);
496 496
 } else {
497
-	spip_initialisation_suite();
498
-	include_spip('inc/plugin');
499
-	// generer les fichiers php precompiles
500
-	// de chargement des plugins et des pipelines
501
-	actualise_plugins_actifs();
497
+    spip_initialisation_suite();
498
+    include_spip('inc/plugin');
499
+    // generer les fichiers php precompiles
500
+    // de chargement des plugins et des pipelines
501
+    actualise_plugins_actifs();
502 502
 }
503 503
 
504 504
 // Initialisations non critiques surchargeables par les plugins
505 505
 spip_initialisation_suite();
506 506
 
507 507
 if (!defined('_LOG_FILTRE_GRAVITE')) {
508
-	/** niveau maxi d'enregistrement des logs */
509
-	define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE);
508
+    /** niveau maxi d'enregistrement des logs */
509
+    define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE);
510 510
 }
511 511
 
512 512
 if (!defined('_OUTILS_DEVELOPPEURS')) {
513
-	/** Activer des outils pour développeurs ? */
514
-	define('_OUTILS_DEVELOPPEURS', false);
513
+    /** Activer des outils pour développeurs ? */
514
+    define('_OUTILS_DEVELOPPEURS', false);
515 515
 }
516 516
 
517 517
 if (!defined('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR')) {
518
-	/** 
519
-	 * Basculer les contextes ajax en fichier si la longueur d’url est trop grande 
520
-	 * @var int Nombre de caractères */
521
-	define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
518
+    /** 
519
+     * Basculer les contextes ajax en fichier si la longueur d’url est trop grande 
520
+     * @var int Nombre de caractères */
521
+    define('_CACHE_CONTEXTES_AJAX_SUR_LONGUEUR', 2000);
522 522
 }
523 523
 
524 524
 // charger systematiquement inc/autoriser dans l'espace restreint
525 525
 if (test_espace_prive()) {
526
-	include_spip('inc/autoriser');
526
+    include_spip('inc/autoriser');
527 527
 }
528 528
 //
529 529
 // Installer Spip si pas installe... sauf si justement on est en train
530 530
 //
531 531
 if (!(_FILE_CONNECT
532
-	or autoriser_sans_cookie(_request('exec'))
533
-	or _request('action') == 'cookie'
534
-	or _request('action') == 'converser'
535
-	or _request('action') == 'test_dirs')
532
+    or autoriser_sans_cookie(_request('exec'))
533
+    or _request('action') == 'cookie'
534
+    or _request('action') == 'converser'
535
+    or _request('action') == 'test_dirs')
536 536
 ) {
537 537
 
538
-	// Si on peut installer, on lance illico
539
-	if (test_espace_prive()) {
540
-		include_spip('inc/headers');
541
-		redirige_url_ecrire("install");
542
-	} else {
543
-		// Si on est dans le site public, dire que qq s'en occupe
544
-		include_spip('inc/minipres');
545
-		utiliser_langue_visiteur();
546
-		echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . "</p>", array('status' => 503));
547
-		exit;
548
-	}
549
-	// autrement c'est une install ad hoc (spikini...), on sait pas faire
538
+    // Si on peut installer, on lance illico
539
+    if (test_espace_prive()) {
540
+        include_spip('inc/headers');
541
+        redirige_url_ecrire("install");
542
+    } else {
543
+        // Si on est dans le site public, dire que qq s'en occupe
544
+        include_spip('inc/minipres');
545
+        utiliser_langue_visiteur();
546
+        echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . "</p>", array('status' => 503));
547
+        exit;
548
+    }
549
+    // autrement c'est une install ad hoc (spikini...), on sait pas faire
550 550
 }
551 551
 
552 552
 // memoriser un tri sessionne eventuel
553 553
 if (isset($_REQUEST['var_memotri'])
554
-	and $t = $_REQUEST['var_memotri']
555
-	and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0)
554
+    and $t = $_REQUEST['var_memotri']
555
+    and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0)
556 556
 ) {
557
-	if (!function_exists('session_set')) {
558
-		include_spip('inc/session');
559
-	}
560
-	$t = preg_replace(",\W,","_", $t);
561
-	if ($v = _request($t)) {
562
-		session_set($t, $v);
563
-	}
557
+    if (!function_exists('session_set')) {
558
+        include_spip('inc/session');
559
+    }
560
+    $t = preg_replace(",\W,","_", $t);
561
+    if ($v = _request($t)) {
562
+        session_set($t, $v);
563
+    }
564 564
 }
565 565
 
566 566
 /**
@@ -570,22 +570,22 @@  discard block
 block discarded – undo
570 570
  * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite
571 571
  */
572 572
 if (!defined('_HEADER_COMPOSED_BY')) {
573
-	define('_HEADER_COMPOSED_BY', "Composed-By: SPIP");
573
+    define('_HEADER_COMPOSED_BY', "Composed-By: SPIP");
574 574
 }
575 575
 if (!headers_sent() and _HEADER_COMPOSED_BY) {
576
-	if (!defined('_HEADER_VARY')) {
577
-		define('_HEADER_VARY', "Vary: Cookie, Accept-Encoding");
578
-	}
579
-	if (_HEADER_VARY) {
580
-		header(_HEADER_VARY);
581
-	}
582
-	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
583
-		include_spip('inc/filtres_mini');
584
-		header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . "config.txt"));
585
-	} else {
586
-		// header minimal
587
-		header(_HEADER_COMPOSED_BY . " @ www.spip.net");
588
-	}
576
+    if (!defined('_HEADER_VARY')) {
577
+        define('_HEADER_VARY', "Vary: Cookie, Accept-Encoding");
578
+    }
579
+    if (_HEADER_VARY) {
580
+        header(_HEADER_VARY);
581
+    }
582
+    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
583
+        include_spip('inc/filtres_mini');
584
+        header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . "config.txt"));
585
+    } else {
586
+        // header minimal
587
+        header(_HEADER_COMPOSED_BY . " @ www.spip.net");
588
+    }
589 589
 }
590 590
 
591 591
 $methode = (isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : ((php_sapi_name() == 'cli') ? 'cli' : ''));
Please login to merge, or discard this patch.