Completed
Push — master ( 5462b4...da2985 )
by cam
04:37
created
ecrire/inc/icone_renommer.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -11,69 +11,69 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/boutons');
18 18
 include_spip('base/objets');
19 19
 
20 20
 function inc_icone_renommer_dist($fond, $fonction) {
21
-	$size = 24;
22
-	if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i", $fond, $match)
23
-		and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1]))
24
-	) {
25
-		if (isset($match[1]) and $match[1]) {
26
-			$size = $match[1];
27
-		}
28
-		$type = substr($fond, 0, -strlen($match[0]));
29
-		if (!isset($match[2]) or !$match[2]) {
30
-			$fond .= ".png";
31
-		}
32
-	} else {
33
-		$type = $fond;
34
-		$fond .= ".png";
35
-	}
21
+    $size = 24;
22
+    if (preg_match("/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i", $fond, $match)
23
+        and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1]))
24
+    ) {
25
+        if (isset($match[1]) and $match[1]) {
26
+            $size = $match[1];
27
+        }
28
+        $type = substr($fond, 0, -strlen($match[0]));
29
+        if (!isset($match[2]) or !$match[2]) {
30
+            $fond .= ".png";
31
+        }
32
+    } else {
33
+        $type = $fond;
34
+        $fond .= ".png";
35
+    }
36 36
 
37
-	$rtl = false;
38
-	if (preg_match(',[-_]rtl$,i', $type, $match)) {
39
-		$rtl = true;
40
-		$type = substr($type, 0, -strlen($match[0]));
41
-	}
37
+    $rtl = false;
38
+    if (preg_match(',[-_]rtl$,i', $type, $match)) {
39
+        $rtl = true;
40
+        $type = substr($type, 0, -strlen($match[0]));
41
+    }
42 42
 
43
-	// objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
-	// et ne finit pas par un s, sauf si c'est une exception declaree
45
-	$type = objet_type($type, false);
43
+    // objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
+    // et ne finit pas par un s, sauf si c'est une exception declaree
45
+    $type = objet_type($type, false);
46 46
 
47
-	$dir = "images/";
48
-	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
50
-		$dir = dirname($icone);
51
-		$fond = $icone;
47
+    $dir = "images/";
48
+    $f = "$type-$size.png";
49
+    if ($icone = find_in_theme($dir . $f)) {
50
+        $dir = dirname($icone);
51
+        $fond = $icone;
52 52
 
53
-		if ($rtl
54
-			and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
55
-			and file_exists($fr)
56
-		) {
57
-			$fond = $fr;
58
-		}
53
+        if ($rtl
54
+            and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
55
+            and file_exists($fr)
56
+        ) {
57
+            $fond = $fr;
58
+        }
59 59
 
60
-		$action = $fonction;
61
-		if ($action == "supprimer.gif") {
62
-			$action = "del";
63
-		} elseif ($action == "creer.gif") {
64
-			$action = "new";
65
-		} elseif ($action == "edit.gif") {
66
-			$action = "edit";
67
-		}
60
+        $action = $fonction;
61
+        if ($action == "supprimer.gif") {
62
+            $action = "del";
63
+        } elseif ($action == "creer.gif") {
64
+            $action = "new";
65
+        } elseif ($action == "edit.gif") {
66
+            $action = "edit";
67
+        }
68 68
 
69
-		$fonction = "";
70
-		if (in_array($action, array('add','del', 'new', 'edit', 'config'))) {
71
-			$fonction = $action;
72
-		}
69
+        $fonction = "";
70
+        if (in_array($action, array('add','del', 'new', 'edit', 'config'))) {
71
+            $fonction = $action;
72
+        }
73 73
 
74
-		// c'est bon !
75
-		return array($fond, $fonction);
76
-	}
74
+        // c'est bon !
75
+        return array($fond, $fonction);
76
+    }
77 77
 
78
-	return array($fond, $fonction);
78
+    return array($fond, $fonction);
79 79
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 
47 47
 	$dir = "images/";
48 48
 	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
49
+	if ($icone = find_in_theme($dir.$f)) {
50 50
 		$dir = dirname($icone);
51 51
 		$fond = $icone;
52 52
 
53 53
 		if ($rtl
54
-			and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
54
+			and $fr = $dir.'/'.str_replace("$type-", "$type-rtl-", basename($icone))
55 55
 			and file_exists($fr)
56 56
 		) {
57 57
 			$fond = $fr;
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		}
68 68
 
69 69
 		$fonction = "";
70
-		if (in_array($action, array('add','del', 'new', 'edit', 'config'))) {
70
+		if (in_array($action, array('add', 'del', 'new', 'edit', 'config'))) {
71 71
 			$fonction = $action;
72 72
 		}
73 73
 
Please login to merge, or discard this patch.
ecrire/inc/utils.php 3 patches
Indentation   +2199 added lines, -2200 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
 
@@ -48,63 +48,63 @@  discard block
 block discarded – undo
48 48
  *     Nom de la fonction, ou false.
49 49
  */
50 50
 function charger_fonction($nom, $dossier = 'exec', $continue = false) {
51
-	static $echecs = array();
52
-
53
-	if (strlen($dossier) and substr($dossier, -1) != '/') {
54
-		$dossier .= '/';
55
-	}
56
-	$f = str_replace('/', '_', $dossier) . $nom;
57
-
58
-	if (function_exists($f)) {
59
-		return $f;
60
-	}
61
-	if (function_exists($g = $f . '_dist')) {
62
-		return $g;
63
-	}
64
-
65
-	if (isset($echecs[$f])) {
66
-		return $echecs[$f];
67
-	}
68
-	// Sinon charger le fichier de declaration si plausible
69
-
70
-	if (!preg_match(',^\w+$,', $f)) {
71
-		if ($continue) {
72
-			return false;
73
-		} //appel interne, on passe
74
-		include_spip('inc/minipres');
75
-		echo minipres();
76
-		exit;
77
-	}
78
-
79
-	// passer en minuscules (cf les balises de formulaires)
80
-	// et inclure le fichier
81
-	if (!$inc = include_spip($dossier . ($d = strtolower($nom)))
82
-		// si le fichier truc/machin/nom.php n'existe pas,
83
-		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
84
-		and strlen(dirname($dossier)) and dirname($dossier) != '.'
85
-	) {
86
-		include_spip(substr($dossier, 0, -1));
87
-	}
88
-	if (function_exists($f)) {
89
-		return $f;
90
-	}
91
-	if (function_exists($g)) {
92
-		return $g;
93
-	}
94
-
95
-	if ($continue) {
96
-		return $echecs[$f] = false;
97
-	}
98
-
99
-	// Echec : message d'erreur
100
-	spip_log("fonction $nom ($f ou $g) indisponible" .
101
-		($inc ? "" : " (fichier $d absent de $dossier)"));
102
-
103
-	include_spip('inc/minipres');
104
-	echo minipres(_T('forum_titre_erreur'),
105
-		_T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')),
106
-		array('all_inline'=>true,'status'=>404));
107
-	exit;
51
+    static $echecs = array();
52
+
53
+    if (strlen($dossier) and substr($dossier, -1) != '/') {
54
+        $dossier .= '/';
55
+    }
56
+    $f = str_replace('/', '_', $dossier) . $nom;
57
+
58
+    if (function_exists($f)) {
59
+        return $f;
60
+    }
61
+    if (function_exists($g = $f . '_dist')) {
62
+        return $g;
63
+    }
64
+
65
+    if (isset($echecs[$f])) {
66
+        return $echecs[$f];
67
+    }
68
+    // Sinon charger le fichier de declaration si plausible
69
+
70
+    if (!preg_match(',^\w+$,', $f)) {
71
+        if ($continue) {
72
+            return false;
73
+        } //appel interne, on passe
74
+        include_spip('inc/minipres');
75
+        echo minipres();
76
+        exit;
77
+    }
78
+
79
+    // passer en minuscules (cf les balises de formulaires)
80
+    // et inclure le fichier
81
+    if (!$inc = include_spip($dossier . ($d = strtolower($nom)))
82
+        // si le fichier truc/machin/nom.php n'existe pas,
83
+        // la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
84
+        and strlen(dirname($dossier)) and dirname($dossier) != '.'
85
+    ) {
86
+        include_spip(substr($dossier, 0, -1));
87
+    }
88
+    if (function_exists($f)) {
89
+        return $f;
90
+    }
91
+    if (function_exists($g)) {
92
+        return $g;
93
+    }
94
+
95
+    if ($continue) {
96
+        return $echecs[$f] = false;
97
+    }
98
+
99
+    // Echec : message d'erreur
100
+    spip_log("fonction $nom ($f ou $g) indisponible" .
101
+        ($inc ? "" : " (fichier $d absent de $dossier)"));
102
+
103
+    include_spip('inc/minipres');
104
+    echo minipres(_T('forum_titre_erreur'),
105
+        _T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')),
106
+        array('all_inline'=>true,'status'=>404));
107
+    exit;
108 108
 }
109 109
 
110 110
 /**
@@ -114,17 +114,17 @@  discard block
 block discarded – undo
114 114
  * @return bool
115 115
  */
116 116
 function include_once_check($file) {
117
-	if (file_exists($file)) {
118
-		include_once $file;
117
+    if (file_exists($file)) {
118
+        include_once $file;
119 119
 
120
-		return true;
121
-	}
122
-	$crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
123
-	$crash = ($crash ? $crash : array());
124
-	$crash[$file] = true;
125
-	ecrire_meta('message_crash_plugins', serialize($crash));
120
+        return true;
121
+    }
122
+    $crash = (isset($GLOBALS['meta']['message_crash_plugins']) ? unserialize($GLOBALS['meta']['message_crash_plugins']) : '');
123
+    $crash = ($crash ? $crash : array());
124
+    $crash[$file] = true;
125
+    ecrire_meta('message_crash_plugins', serialize($crash));
126 126
 
127
-	return false;
127
+    return false;
128 128
 }
129 129
 
130 130
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
  *     - string : chemin du fichier trouvé
149 149
  **/
150 150
 function include_spip($f, $include = true) {
151
-	return find_in_path($f . '.php', '', $include);
151
+    return find_in_path($f . '.php', '', $include);
152 152
 }
153 153
 
154 154
 /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
  *     - string : chemin du fichier trouvé
169 169
  **/
170 170
 function require_spip($f) {
171
-	return find_in_path($f . '.php', '', 'required');
171
+    return find_in_path($f . '.php', '', 'required');
172 172
 }
173 173
 
174 174
 /**
@@ -194,22 +194,22 @@  discard block
 block discarded – undo
194 194
  *     Les paramètres du pipeline modifiés
195 195
  **/
196 196
 function minipipe($fonc, &$val) {
197
-	// fonction
198
-	if (function_exists($fonc)) {
199
-		$val = call_user_func($fonc, $val);
200
-	} // Class::Methode
201
-	else {
202
-		if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs)
203
-			and $methode = array($regs[1], $regs[2])
204
-			and is_callable($methode)
205
-		) {
206
-			$val = call_user_func($methode, $val);
207
-		} else {
208
-			spip_log("Erreur - '$fonc' non definie !");
209
-		}
210
-	}
197
+    // fonction
198
+    if (function_exists($fonc)) {
199
+        $val = call_user_func($fonc, $val);
200
+    } // Class::Methode
201
+    else {
202
+        if (preg_match("/^(\w*)::(\w*)$/S", $fonc, $regs)
203
+            and $methode = array($regs[1], $regs[2])
204
+            and is_callable($methode)
205
+        ) {
206
+            $val = call_user_func($methode, $val);
207
+        } else {
208
+            spip_log("Erreur - '$fonc' non definie !");
209
+        }
210
+    }
211 211
 
212
-	return $val;
212
+    return $val;
213 213
 }
214 214
 
215 215
 /**
@@ -240,45 +240,45 @@  discard block
 block discarded – undo
240 240
  *     Résultat
241 241
  */
242 242
 function pipeline($action, $val = null) {
243
-	static $charger;
244
-
245
-	// chargement initial des fonctions mises en cache, ou generation du cache
246
-	if (!$charger) {
247
-		if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
248
-			include_spip('inc/plugin');
249
-			// generer les fichiers php precompiles
250
-			// de chargement des plugins et des pipelines
251
-			actualise_plugins_actifs();
252
-			if (!($ok = @is_readable($charger))) {
253
-				spip_log("fichier $charger pas cree");
254
-			}
255
-		}
256
-
257
-		if ($ok) {
258
-			include_once $charger;
259
-		}
260
-	}
261
-
262
-	// appliquer notre fonction si elle existe
263
-	$fonc = 'execute_pipeline_' . strtolower($action);
264
-	if (function_exists($fonc)) {
265
-		$val = $fonc($val);
266
-	} // plantage ?
267
-	else {
268
-		spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
269
-	}
270
-
271
-	// si le flux est une table avec 2 cle args&data
272
-	// on ne ressort du pipe que les donnees dans 'data'
273
-	// array_key_exists pour php 4.1.0
274
-	if (is_array($val)
275
-		and count($val) == 2
276
-		and (array_key_exists('data', $val))
277
-	) {
278
-		$val = $val['data'];
279
-	}
280
-
281
-	return $val;
243
+    static $charger;
244
+
245
+    // chargement initial des fonctions mises en cache, ou generation du cache
246
+    if (!$charger) {
247
+        if (!($ok = @is_readable($charger = _CACHE_PIPELINES))) {
248
+            include_spip('inc/plugin');
249
+            // generer les fichiers php precompiles
250
+            // de chargement des plugins et des pipelines
251
+            actualise_plugins_actifs();
252
+            if (!($ok = @is_readable($charger))) {
253
+                spip_log("fichier $charger pas cree");
254
+            }
255
+        }
256
+
257
+        if ($ok) {
258
+            include_once $charger;
259
+        }
260
+    }
261
+
262
+    // appliquer notre fonction si elle existe
263
+    $fonc = 'execute_pipeline_' . strtolower($action);
264
+    if (function_exists($fonc)) {
265
+        $val = $fonc($val);
266
+    } // plantage ?
267
+    else {
268
+        spip_log("fonction $fonc absente : pipeline desactive", _LOG_ERREUR);
269
+    }
270
+
271
+    // si le flux est une table avec 2 cle args&data
272
+    // on ne ressort du pipe que les donnees dans 'data'
273
+    // array_key_exists pour php 4.1.0
274
+    if (is_array($val)
275
+        and count($val) == 2
276
+        and (array_key_exists('data', $val))
277
+    ) {
278
+        $val = $val['data'];
279
+    }
280
+
281
+    return $val;
282 282
 }
283 283
 
284 284
 /**
@@ -322,35 +322,35 @@  discard block
 block discarded – undo
322 322
  *     paramètre est planté pour cause de compatibilité ascendante.
323 323
  */
324 324
 function spip_log($message = null, $name = null) {
325
-	static $pre = array();
326
-	static $log;
327
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
328
-	if (!isset($regs[1]) or !$logname = $regs[1]) {
329
-		$logname = null;
330
-	}
331
-	if (!isset($regs[2]) or !$niveau = $regs[2]) {
332
-		$niveau = _LOG_INFO;
333
-	}
334
-
335
-	if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
336
-		if (!$pre) {
337
-			$pre = array(
338
-				_LOG_HS => 'HS:',
339
-				_LOG_ALERTE_ROUGE => 'ALERTE:',
340
-				_LOG_CRITIQUE => 'CRITIQUE:',
341
-				_LOG_ERREUR => 'ERREUR:',
342
-				_LOG_AVERTISSEMENT => 'WARNING:',
343
-				_LOG_INFO_IMPORTANTE => '!INFO:',
344
-				_LOG_INFO => 'info:',
345
-				_LOG_DEBUG => 'debug:'
346
-			);
347
-			$log = charger_fonction('log', 'inc');
348
-		}
349
-		if (!is_string($message)) {
350
-			$message = print_r($message, true);
351
-		}
352
-		$log($pre[$niveau] . ' ' . $message, $logname);
353
-	}
325
+    static $pre = array();
326
+    static $log;
327
+    preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
328
+    if (!isset($regs[1]) or !$logname = $regs[1]) {
329
+        $logname = null;
330
+    }
331
+    if (!isset($regs[2]) or !$niveau = $regs[2]) {
332
+        $niveau = _LOG_INFO;
333
+    }
334
+
335
+    if ($niveau <= (defined('_LOG_FILTRE_GRAVITE') ? _LOG_FILTRE_GRAVITE : _LOG_INFO_IMPORTANTE)) {
336
+        if (!$pre) {
337
+            $pre = array(
338
+                _LOG_HS => 'HS:',
339
+                _LOG_ALERTE_ROUGE => 'ALERTE:',
340
+                _LOG_CRITIQUE => 'CRITIQUE:',
341
+                _LOG_ERREUR => 'ERREUR:',
342
+                _LOG_AVERTISSEMENT => 'WARNING:',
343
+                _LOG_INFO_IMPORTANTE => '!INFO:',
344
+                _LOG_INFO => 'info:',
345
+                _LOG_DEBUG => 'debug:'
346
+            );
347
+            $log = charger_fonction('log', 'inc');
348
+        }
349
+        if (!is_string($message)) {
350
+            $message = print_r($message, true);
351
+        }
352
+        $log($pre[$niveau] . ' ' . $message, $logname);
353
+    }
354 354
 }
355 355
 
356 356
 /**
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
  * @param array $opt Tableau d'options
362 362
  **/
363 363
 function journal($phrase, $opt = array()) {
364
-	$journal = charger_fonction('journal', 'inc');
365
-	$journal($phrase, $opt);
364
+    $journal = charger_fonction('journal', 'inc');
365
+    $journal($phrase, $opt);
366 366
 }
367 367
 
368 368
 
@@ -381,36 +381,36 @@  discard block
 block discarded – undo
381 381
  **/
382 382
 function _request($var, $c = false) {
383 383
 
384
-	if (is_array($c)) {
385
-		return isset($c[$var]) ? $c[$var] : null;
386
-	}
384
+    if (is_array($c)) {
385
+        return isset($c[$var]) ? $c[$var] : null;
386
+    }
387 387
 
388
-	if (isset($_GET[$var])) {
389
-		$a = $_GET[$var];
390
-	} elseif (isset($_POST[$var])) {
391
-		$a = $_POST[$var];
392
-	} else {
393
-		return null;
394
-	}
388
+    if (isset($_GET[$var])) {
389
+        $a = $_GET[$var];
390
+    } elseif (isset($_POST[$var])) {
391
+        $a = $_POST[$var];
392
+    } else {
393
+        return null;
394
+    }
395 395
 
396
-	// Si on est en ajax et en POST tout a ete encode
397
-	// via encodeURIComponent, il faut donc repasser
398
-	// dans le charset local...
399
-	if (defined('_AJAX')
400
-		and _AJAX
401
-		and isset($GLOBALS['meta']['charset'])
402
-		and $GLOBALS['meta']['charset'] != 'utf-8'
403
-		and is_string($a)
404
-		// check rapide mais pas fiable
405
-		and preg_match(',[\x80-\xFF],', $a)
406
-		// check fiable
407
-		and include_spip('inc/charsets')
408
-		and is_utf8($a)
409
-	) {
410
-		return importer_charset($a, 'utf-8');
411
-	}
396
+    // Si on est en ajax et en POST tout a ete encode
397
+    // via encodeURIComponent, il faut donc repasser
398
+    // dans le charset local...
399
+    if (defined('_AJAX')
400
+        and _AJAX
401
+        and isset($GLOBALS['meta']['charset'])
402
+        and $GLOBALS['meta']['charset'] != 'utf-8'
403
+        and is_string($a)
404
+        // check rapide mais pas fiable
405
+        and preg_match(',[\x80-\xFF],', $a)
406
+        // check fiable
407
+        and include_spip('inc/charsets')
408
+        and is_utf8($a)
409
+    ) {
410
+        return importer_charset($a, 'utf-8');
411
+    }
412 412
 
413
-	return $a;
413
+    return $a;
414 414
 }
415 415
 
416 416
 
@@ -428,22 +428,22 @@  discard block
 block discarded – undo
428 428
  *     - false sinon
429 429
  **/
430 430
 function set_request($var, $val = null, $c = false) {
431
-	if (is_array($c)) {
432
-		unset($c[$var]);
433
-		if ($val !== null) {
434
-			$c[$var] = $val;
435
-		}
431
+    if (is_array($c)) {
432
+        unset($c[$var]);
433
+        if ($val !== null) {
434
+            $c[$var] = $val;
435
+        }
436 436
 
437
-		return $c;
438
-	}
437
+        return $c;
438
+    }
439 439
 
440
-	unset($_GET[$var]);
441
-	unset($_POST[$var]);
442
-	if ($val !== null) {
443
-		$_GET[$var] = $val;
444
-	}
440
+    unset($_GET[$var]);
441
+    unset($_POST[$var]);
442
+    if ($val !== null) {
443
+        $_GET[$var] = $val;
444
+    }
445 445
 
446
-	return false; # n'affecte pas $c
446
+    return false; # n'affecte pas $c
447 447
 }
448 448
 
449 449
 
@@ -452,23 +452,22 @@  discard block
 block discarded – undo
452 452
  * 
453 453
  * On est sur le web, on exclut certains protocoles, 
454 454
  * notamment 'file://', 'php://' et d'autres…
455
-
456 455
  * @param string $url
457 456
  * @return bool
458 457
  */
459 458
 function tester_url_absolue($url) {
460
-	$url = trim($url);
461
-	if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) {
462
-		if (
463
-			isset($m[1])
464
-			and $p = strtolower(rtrim($m[1], ':'))
465
-			and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'))
466
-		  ) {
467
-			return false;
468
-		}
469
-		return true;
470
-	}
471
-	return false;
459
+    $url = trim($url);
460
+    if (preg_match(";^([a-z]{3,7}:)?//;Uims", $url, $m)) {
461
+        if (
462
+            isset($m[1])
463
+            and $p = strtolower(rtrim($m[1], ':'))
464
+            and in_array($p, array('file', 'php', 'zlib', 'glob', 'phar', 'ssh2', 'rar', 'ogg', 'expect', 'zip'))
465
+            ) {
466
+            return false;
467
+        }
468
+        return true;
469
+    }
470
+    return false;
472 471
 }
473 472
 
474 473
 /**
@@ -490,94 +489,94 @@  discard block
 block discarded – undo
490 489
  * @return string URL
491 490
  */
492 491
 function parametre_url($url, $c, $v = null, $sep = '&amp;') {
493
-	// requete erronnee : plusieurs variable dans $c et aucun $v
494
-	if (strpos($c, "|") !== false and is_null($v)) {
495
-		return null;
496
-	}
497
-
498
-	// lever l'#ancre
499
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
500
-		$url = $r[1];
501
-		$ancre = $r[2];
502
-	} else {
503
-		$ancre = '';
504
-	}
505
-
506
-	// eclater
507
-	$url = preg_split(',[?]|&amp;|&,', $url);
508
-
509
-	// recuperer la base
510
-	$a = array_shift($url);
511
-	if (!$a) {
512
-		$a = './';
513
-	}
514
-
515
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
516
-	$ajouts = array_flip(explode('|', $c));
517
-	$u = is_array($v) ? $v : rawurlencode($v);
518
-	$testv = (is_array($v) ? count($v) : strlen($v));
519
-	$v_read = null;
520
-	// lire les variables et agir
521
-	foreach ($url as $n => $val) {
522
-		if (preg_match($regexp, urldecode($val), $r)) {
523
-			$r = array_pad($r, 3, null);
524
-			if ($v === null) {
525
-				// c'est un tableau, on memorise les valeurs
526
-				if (substr($r[1], -2) == "[]") {
527
-					if (!$v_read) {
528
-						$v_read = array();
529
-					}
530
-					$v_read[] = $r[2] ? substr($r[2], 1) : '';
531
-				} // c'est un scalaire, on retourne direct
532
-				else {
533
-					return $r[2] ? substr($r[2], 1) : '';
534
-				}
535
-			} // suppression
536
-			elseif (!$testv) {
537
-				unset($url[$n]);
538
-			}
539
-			// Ajout. Pour une variable, remplacer au meme endroit,
540
-			// pour un tableau ce sera fait dans la prochaine boucle
541
-			elseif (substr($r[1], -2) != '[]') {
542
-				$url[$n] = $r[1] . '=' . $u;
543
-				unset($ajouts[$r[1]]);
544
-			}
545
-			// Pour les tableaux on laisse tomber les valeurs de
546
-			// départ, on remplira à l'étape suivante
547
-			else {
548
-				unset($url[$n]);
549
-			}
550
-		}
551
-	}
552
-
553
-	// traiter les parametres pas encore trouves
554
-	if ($v === null
555
-		and $args = func_get_args()
556
-		and count($args) == 2
557
-	) {
558
-		return $v_read; // rien trouve ou un tableau
559
-	} elseif ($testv) {
560
-		foreach ($ajouts as $k => $n) {
561
-			if (!is_array($v)) {
562
-				$url[] = $k . '=' . $u;
563
-			} else {
564
-				$id = (substr($k, -2) == '[]') ? $k : ($k . "[]");
565
-				foreach ($v as $w) {
566
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
567
-				}
568
-			}
569
-		}
570
-	}
571
-
572
-	// eliminer les vides
573
-	$url = array_filter($url);
574
-
575
-	// recomposer l'adresse
576
-	if ($url) {
577
-		$a .= '?' . join($sep, $url);
578
-	}
579
-
580
-	return $a . $ancre;
492
+    // requete erronnee : plusieurs variable dans $c et aucun $v
493
+    if (strpos($c, "|") !== false and is_null($v)) {
494
+        return null;
495
+    }
496
+
497
+    // lever l'#ancre
498
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
499
+        $url = $r[1];
500
+        $ancre = $r[2];
501
+    } else {
502
+        $ancre = '';
503
+    }
504
+
505
+    // eclater
506
+    $url = preg_split(',[?]|&amp;|&,', $url);
507
+
508
+    // recuperer la base
509
+    $a = array_shift($url);
510
+    if (!$a) {
511
+        $a = './';
512
+    }
513
+
514
+    $regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
515
+    $ajouts = array_flip(explode('|', $c));
516
+    $u = is_array($v) ? $v : rawurlencode($v);
517
+    $testv = (is_array($v) ? count($v) : strlen($v));
518
+    $v_read = null;
519
+    // lire les variables et agir
520
+    foreach ($url as $n => $val) {
521
+        if (preg_match($regexp, urldecode($val), $r)) {
522
+            $r = array_pad($r, 3, null);
523
+            if ($v === null) {
524
+                // c'est un tableau, on memorise les valeurs
525
+                if (substr($r[1], -2) == "[]") {
526
+                    if (!$v_read) {
527
+                        $v_read = array();
528
+                    }
529
+                    $v_read[] = $r[2] ? substr($r[2], 1) : '';
530
+                } // c'est un scalaire, on retourne direct
531
+                else {
532
+                    return $r[2] ? substr($r[2], 1) : '';
533
+                }
534
+            } // suppression
535
+            elseif (!$testv) {
536
+                unset($url[$n]);
537
+            }
538
+            // Ajout. Pour une variable, remplacer au meme endroit,
539
+            // pour un tableau ce sera fait dans la prochaine boucle
540
+            elseif (substr($r[1], -2) != '[]') {
541
+                $url[$n] = $r[1] . '=' . $u;
542
+                unset($ajouts[$r[1]]);
543
+            }
544
+            // Pour les tableaux on laisse tomber les valeurs de
545
+            // départ, on remplira à l'étape suivante
546
+            else {
547
+                unset($url[$n]);
548
+            }
549
+        }
550
+    }
551
+
552
+    // traiter les parametres pas encore trouves
553
+    if ($v === null
554
+        and $args = func_get_args()
555
+        and count($args) == 2
556
+    ) {
557
+        return $v_read; // rien trouve ou un tableau
558
+    } elseif ($testv) {
559
+        foreach ($ajouts as $k => $n) {
560
+            if (!is_array($v)) {
561
+                $url[] = $k . '=' . $u;
562
+            } else {
563
+                $id = (substr($k, -2) == '[]') ? $k : ($k . "[]");
564
+                foreach ($v as $w) {
565
+                    $url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
566
+                }
567
+            }
568
+        }
569
+    }
570
+
571
+    // eliminer les vides
572
+    $url = array_filter($url);
573
+
574
+    // recomposer l'adresse
575
+    if ($url) {
576
+        $a .= '?' . join($sep, $url);
577
+    }
578
+
579
+    return $a . $ancre;
581 580
 }
582 581
 
583 582
 /**
@@ -595,21 +594,21 @@  discard block
 block discarded – undo
595 594
  * @return string
596 595
  */
597 596
 function ancre_url($url, $ancre) {
598
-	// lever l'#ancre
599
-	if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
600
-		$url = $r[1];
601
-	}
602
-	if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
603
-		if (!function_exists('translitteration')) {
604
-			include_spip('inc/charsets');
605
-		}
606
-		$ancre = preg_replace(
607
-			array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'),
608
-			array('', '-'),
609
-			translitteration($ancre)
610
-		);
611
-	}
612
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
597
+    // lever l'#ancre
598
+    if (preg_match(',^([^#]*)(#.*)$,', $url, $r)) {
599
+        $url = $r[1];
600
+    }
601
+    if (preg_match('/[^-_a-zA-Z0-9]+/S', $ancre)) {
602
+        if (!function_exists('translitteration')) {
603
+            include_spip('inc/charsets');
604
+        }
605
+        $ancre = preg_replace(
606
+            array('/^[^-_a-zA-Z0-9]+/', '/[^-_a-zA-Z0-9]/'),
607
+            array('', '-'),
608
+            translitteration($ancre)
609
+        );
610
+    }
611
+    return $url . (strlen($ancre) ? '#' . $ancre : '');
613 612
 }
614 613
 
615 614
 /**
@@ -619,16 +618,16 @@  discard block
 block discarded – undo
619 618
  * @return string
620 619
  */
621 620
 function nettoyer_uri($reset = null) {
622
-	static $done = false;
623
-	static $propre = '';
624
-	if (!is_null($reset)) {
625
-		return $propre = $reset;
626
-	}
627
-	if ($done) {
628
-		return $propre;
629
-	}
630
-	$done = true;
631
-	return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
621
+    static $done = false;
622
+    static $propre = '';
623
+    if (!is_null($reset)) {
624
+        return $propre = $reset;
625
+    }
626
+    if ($done) {
627
+        return $propre;
628
+    }
629
+    $done = true;
630
+    return $propre = nettoyer_uri_var($GLOBALS['REQUEST_URI']);
632 631
 }
633 632
 
634 633
 /**
@@ -640,13 +639,13 @@  discard block
 block discarded – undo
640 639
  * @return string
641 640
  */
642 641
 function nettoyer_uri_var($request_uri) {
643
-	$uri1 = $request_uri;
644
-	do {
645
-		$uri = $uri1;
646
-		$uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
647
-			'\1', $uri);
648
-	} while ($uri <> $uri1);
649
-	return preg_replace(',[?&]$,', '', $uri1);
642
+    $uri1 = $request_uri;
643
+    do {
644
+        $uri = $uri1;
645
+        $uri1 = preg_replace(',([?&])(var_[^=&]*|PHPSESSID|fbclid|utm_[^=&]*)=[^&]*(&|$),i',
646
+            '\1', $uri);
647
+    } while ($uri <> $uri1);
648
+    return preg_replace(',[?&]$,', '', $uri1);
650 649
 }
651 650
 
652 651
 
@@ -660,47 +659,47 @@  discard block
 block discarded – undo
660 659
  *    URL vers soi-même
661 660
  **/
662 661
 function self($amp = '&amp;', $root = false) {
663
-	$url = nettoyer_uri();
664
-	if (!$root
665
-		and (
666
-			// si pas de profondeur on peut tronquer
667
-			$GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
668
-			// sinon c'est OK si _SET_HTML_BASE a ete force a false
669
-			or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
670
-	) {
671
-		$url = preg_replace(',^[^?]*/,', '', $url);
672
-	}
673
-	// ajouter le cas echeant les variables _POST['id_...']
674
-	foreach ($_POST as $v => $c) {
675
-		if (substr($v, 0, 3) == 'id_') {
676
-			$url = parametre_url($url, $v, $c, '&');
677
-		}
678
-	}
679
-
680
-	// supprimer les variables sans interet
681
-	if (test_espace_prive()) {
682
-		$url = preg_replace(',([?&])('
683
-			. 'lang|show_docs|'
684
-			. 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
685
-		$url = preg_replace(',([?&])[&]+,', '\1', $url);
686
-		$url = preg_replace(',[&]$,', '\1', $url);
687
-	}
688
-
689
-	// eviter les hacks
690
-	include_spip('inc/filtres_mini');
691
-	$url = spip_htmlspecialchars($url);
662
+    $url = nettoyer_uri();
663
+    if (!$root
664
+        and (
665
+            // si pas de profondeur on peut tronquer
666
+            $GLOBALS['profondeur_url'] < (_DIR_RESTREINT ? 1 : 2)
667
+            // sinon c'est OK si _SET_HTML_BASE a ete force a false
668
+            or (defined('_SET_HTML_BASE') and !_SET_HTML_BASE))
669
+    ) {
670
+        $url = preg_replace(',^[^?]*/,', '', $url);
671
+    }
672
+    // ajouter le cas echeant les variables _POST['id_...']
673
+    foreach ($_POST as $v => $c) {
674
+        if (substr($v, 0, 3) == 'id_') {
675
+            $url = parametre_url($url, $v, $c, '&');
676
+        }
677
+    }
678
+
679
+    // supprimer les variables sans interet
680
+    if (test_espace_prive()) {
681
+        $url = preg_replace(',([?&])('
682
+            . 'lang|show_docs|'
683
+            . 'changer_lang|var_lang|action)=[^&]*,i', '\1', $url);
684
+        $url = preg_replace(',([?&])[&]+,', '\1', $url);
685
+        $url = preg_replace(',[&]$,', '\1', $url);
686
+    }
687
+
688
+    // eviter les hacks
689
+    include_spip('inc/filtres_mini');
690
+    $url = spip_htmlspecialchars($url);
692 691
 	
693
-	$url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url);
692
+    $url = str_replace(array("'", '"', '<', '[', ']', ':'), array('%27', '%22', '%3C', '%5B', '%5D', '%3A'), $url);
694 693
 
695
-	// &amp; ?
696
-	if ($amp != '&amp;') {
697
-		$url = str_replace('&amp;', $amp, $url);
698
-	}
694
+    // &amp; ?
695
+    if ($amp != '&amp;') {
696
+        $url = str_replace('&amp;', $amp, $url);
697
+    }
699 698
 
700
-	// Si ca demarre par ? ou vide, donner './'
701
-	$url = preg_replace(',^([?].*)?$,', './\1', $url);
699
+    // Si ca demarre par ? ou vide, donner './'
700
+    $url = preg_replace(',^([?].*)?$,', './\1', $url);
702 701
 
703
-	return $url;
702
+    return $url;
704 703
 }
705 704
 
706 705
 
@@ -711,7 +710,7 @@  discard block
 block discarded – undo
711 710
  *     true si c'est le cas, false sinon.
712 711
  */
713 712
 function test_espace_prive() {
714
-	return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
713
+    return defined('_ESPACE_PRIVE') ? _ESPACE_PRIVE : false;
715 714
 }
716 715
 
717 716
 /**
@@ -721,7 +720,7 @@  discard block
 block discarded – undo
721 720
  * @return bool
722 721
  */
723 722
 function test_plugin_actif($plugin) {
724
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
723
+    return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
725 724
 }
726 725
 
727 726
 /**
@@ -752,51 +751,51 @@  discard block
 block discarded – undo
752 751
  *     Texte
753 752
  */
754 753
 function _T($texte, $args = array(), $options = array()) {
755
-	static $traduire = false;
756
-	$o = array('class' => '', 'force' => true, 'sanitize' => true);
757
-	if ($options) {
758
-		// support de l'ancien argument $class
759
-		if (is_string($options)) {
760
-			$options = array('class' => $options);
761
-		}
762
-		$o = array_merge($o, $options);
763
-	}
754
+    static $traduire = false;
755
+    $o = array('class' => '', 'force' => true, 'sanitize' => true);
756
+    if ($options) {
757
+        // support de l'ancien argument $class
758
+        if (is_string($options)) {
759
+            $options = array('class' => $options);
760
+        }
761
+        $o = array_merge($o, $options);
762
+    }
764 763
 
765
-	if (!$traduire) {
766
-		$traduire = charger_fonction('traduire', 'inc');
767
-		include_spip('inc/lang');
768
-	}
764
+    if (!$traduire) {
765
+        $traduire = charger_fonction('traduire', 'inc');
766
+        include_spip('inc/lang');
767
+    }
769 768
 
770
-	// On peut passer explicitement la langue dans le tableau
771
-	// On utilise le même nom de variable que la globale
772
-	if (isset($args['spip_lang'])) {
773
-		$lang = $args['spip_lang'];
774
-		// On l'enleve pour ne pas le passer au remplacement
775
-		unset($args['spip_lang']);
776
-	} // Sinon on prend la langue du contexte
777
-	else {
778
-		$lang = $GLOBALS['spip_lang'];
779
-	}
780
-	$text = $traduire($texte, $lang);
769
+    // On peut passer explicitement la langue dans le tableau
770
+    // On utilise le même nom de variable que la globale
771
+    if (isset($args['spip_lang'])) {
772
+        $lang = $args['spip_lang'];
773
+        // On l'enleve pour ne pas le passer au remplacement
774
+        unset($args['spip_lang']);
775
+    } // Sinon on prend la langue du contexte
776
+    else {
777
+        $lang = $GLOBALS['spip_lang'];
778
+    }
779
+    $text = $traduire($texte, $lang);
781 780
 
782
-	if (!strlen($text)) {
783
-		if (!$o['force']) {
784
-			return '';
785
-		}
781
+    if (!strlen($text)) {
782
+        if (!$o['force']) {
783
+            return '';
784
+        }
786 785
 
787
-		$text = $texte;
786
+        $text = $texte;
788 787
 
789
-		// pour les chaines non traduites, assurer un service minimum
790
-		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
791
-			$text = str_replace('_', ' ',
792
-				(($n = strpos($text, ':')) === false ? $texte :
793
-					substr($texte, $n + 1)));
794
-		}
795
-		$o['class'] = null;
788
+        // pour les chaines non traduites, assurer un service minimum
789
+        if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
790
+            $text = str_replace('_', ' ',
791
+                (($n = strpos($text, ':')) === false ? $texte :
792
+                    substr($texte, $n + 1)));
793
+        }
794
+        $o['class'] = null;
796 795
 
797
-	}
796
+    }
798 797
 
799
-	return _L($text, $args, $o);
798
+    return _L($text, $args, $o);
800 799
 
801 800
 }
802 801
 
@@ -824,53 +823,53 @@  discard block
 block discarded – undo
824 823
  *     Texte
825 824
  */
826 825
 function _L($text, $args = array(), $options = array()) {
827
-	$f = $text;
828
-	$defaut_options = array(
829
-		'class' => null,
830
-		'sanitize' => true,
831
-	);
832
-	// support de l'ancien argument $class
833
-	if ($options and is_string($options)) {
834
-		$options = array('class' => $options);
835
-	}
836
-	if (is_array($options)) {
837
-		$options += $defaut_options;
838
-	} else {
839
-		$options = $defaut_options;
840
-	}
841
-
842
-	if (is_array($args) and count($args)) {
843
-		if (!function_exists('interdire_scripts')) {
844
-			include_spip('inc/texte');
845
-		}
846
-		if (!function_exists('echapper_html_suspect')) {
847
-			include_spip('inc/texte_mini');
848
-		}
849
-		foreach ($args as $name => $value) {
850
-			if (strpos($text, "@$name@") !== false) {
851
-				if ($options['sanitize']) {
852
-					$value = echapper_html_suspect($value);
853
-					$value = interdire_scripts($value, -1);
854
-				}
855
-				if (!empty($options['class'])) {
856
-					$value = "<span class='".$options['class']."'>$value</span>";
857
-				}
858
-				$text = str_replace("@$name@", $value, $text);
859
-				unset($args[$name]);
860
-			}
861
-		}
862
-		// Si des variables n'ont pas ete inserees, le signaler
863
-		// (chaines de langues pas a jour)
864
-		if ($args) {
865
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
866
-		}
867
-	}
868
-
869
-	if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
870
-		return "<span class=debug-traduction-erreur>$text</span>";
871
-	} else {
872
-		return $text;
873
-	}
826
+    $f = $text;
827
+    $defaut_options = array(
828
+        'class' => null,
829
+        'sanitize' => true,
830
+    );
831
+    // support de l'ancien argument $class
832
+    if ($options and is_string($options)) {
833
+        $options = array('class' => $options);
834
+    }
835
+    if (is_array($options)) {
836
+        $options += $defaut_options;
837
+    } else {
838
+        $options = $defaut_options;
839
+    }
840
+
841
+    if (is_array($args) and count($args)) {
842
+        if (!function_exists('interdire_scripts')) {
843
+            include_spip('inc/texte');
844
+        }
845
+        if (!function_exists('echapper_html_suspect')) {
846
+            include_spip('inc/texte_mini');
847
+        }
848
+        foreach ($args as $name => $value) {
849
+            if (strpos($text, "@$name@") !== false) {
850
+                if ($options['sanitize']) {
851
+                    $value = echapper_html_suspect($value);
852
+                    $value = interdire_scripts($value, -1);
853
+                }
854
+                if (!empty($options['class'])) {
855
+                    $value = "<span class='".$options['class']."'>$value</span>";
856
+                }
857
+                $text = str_replace("@$name@", $value, $text);
858
+                unset($args[$name]);
859
+            }
860
+        }
861
+        // Si des variables n'ont pas ete inserees, le signaler
862
+        // (chaines de langues pas a jour)
863
+        if ($args) {
864
+            spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
865
+        }
866
+    }
867
+
868
+    if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) {
869
+        return "<span class=debug-traduction-erreur>$text</span>";
870
+    } else {
871
+        return $text;
872
+    }
874 873
 }
875 874
 
876 875
 
@@ -884,13 +883,13 @@  discard block
 block discarded – undo
884 883
  * @return string
885 884
  */
886 885
 function joli_repertoire($rep) {
887
-	$a = substr($rep, 0, 1);
888
-	if ($a <> '.' and $a <> '/') {
889
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
890
-	}
891
-	$rep = preg_replace(',(^\.\.\/),', '', $rep);
886
+    $a = substr($rep, 0, 1);
887
+    if ($a <> '.' and $a <> '/') {
888
+        $rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
889
+    }
890
+    $rep = preg_replace(',(^\.\.\/),', '', $rep);
892 891
 
893
-	return $rep;
892
+    return $rep;
894 893
 }
895 894
 
896 895
 
@@ -915,33 +914,33 @@  discard block
 block discarded – undo
915 914
  * @return float|int|string|void
916 915
  */
917 916
 function spip_timer($t = 'rien', $raw = false) {
918
-	static $time;
919
-	$a = time();
920
-	$b = microtime();
921
-	// microtime peut contenir les microsecondes et le temps
922
-	$b = explode(' ', $b);
923
-	if (count($b) == 2) {
924
-		$a = end($b);
925
-	} // plus precis !
926
-	$b = reset($b);
927
-	if (!isset($time[$t])) {
928
-		$time[$t] = $a + $b;
929
-	} else {
930
-		$p = ($a + $b - $time[$t]) * 1000;
931
-		unset($time[$t]);
917
+    static $time;
918
+    $a = time();
919
+    $b = microtime();
920
+    // microtime peut contenir les microsecondes et le temps
921
+    $b = explode(' ', $b);
922
+    if (count($b) == 2) {
923
+        $a = end($b);
924
+    } // plus precis !
925
+    $b = reset($b);
926
+    if (!isset($time[$t])) {
927
+        $time[$t] = $a + $b;
928
+    } else {
929
+        $p = ($a + $b - $time[$t]) * 1000;
930
+        unset($time[$t]);
932 931
 #			echo "'$p'";exit;
933
-		if ($raw) {
934
-			return $p;
935
-		}
936
-		if ($p < 1000) {
937
-			$s = '';
938
-		} else {
939
-			$s = sprintf("%d ", $x = floor($p / 1000));
940
-			$p -= ($x * 1000);
941
-		}
932
+        if ($raw) {
933
+            return $p;
934
+        }
935
+        if ($p < 1000) {
936
+            $s = '';
937
+        } else {
938
+            $s = sprintf("%d ", $x = floor($p / 1000));
939
+            $p -= ($x * 1000);
940
+        }
942 941
 
943
-		return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
944
-	}
942
+        return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
943
+    }
945 944
 }
946 945
 
947 946
 
@@ -949,21 +948,21 @@  discard block
 block discarded – undo
949 948
 // sinon renvoie True et le date sauf si ca n'est pas souhaite
950 949
 // http://code.spip.net/@spip_touch
951 950
 function spip_touch($fichier, $duree = 0, $touch = true) {
952
-	if ($duree) {
953
-		clearstatcache();
954
-		if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
955
-			return false;
956
-		}
957
-	}
958
-	if ($touch !== false) {
959
-		if (!@touch($fichier)) {
960
-			spip_unlink($fichier);
961
-			@touch($fichier);
962
-		};
963
-		@chmod($fichier, _SPIP_CHMOD & ~0111);
964
-	}
951
+    if ($duree) {
952
+        clearstatcache();
953
+        if ((@$f = filemtime($fichier)) and ($f >= time() - $duree)) {
954
+            return false;
955
+        }
956
+    }
957
+    if ($touch !== false) {
958
+        if (!@touch($fichier)) {
959
+            spip_unlink($fichier);
960
+            @touch($fichier);
961
+        };
962
+        @chmod($fichier, _SPIP_CHMOD & ~0111);
963
+    }
965 964
 
966
-	return true;
965
+    return true;
967 966
 }
968 967
 
969 968
 
@@ -975,11 +974,11 @@  discard block
 block discarded – undo
975 974
  * @uses cron()
976 975
  **/
977 976
 function action_cron() {
978
-	include_spip('inc/headers');
979
-	http_status(204); // No Content
980
-	header("Connection: close");
981
-	define('_DIRECT_CRON_FORCE', true);
982
-	cron();
977
+    include_spip('inc/headers');
978
+    http_status(204); // No Content
979
+    header("Connection: close");
980
+    define('_DIRECT_CRON_FORCE', true);
981
+    cron();
983 982
 }
984 983
 
985 984
 /**
@@ -995,26 +994,26 @@  discard block
 block discarded – undo
995 994
  *     True si la tache a pu être effectuée
996 995
  */
997 996
 function cron($taches = array(), $taches_old = array()) {
998
-	// si pas en mode cron force, laisser tomber.
999
-	if (!defined('_DIRECT_CRON_FORCE')) {
1000
-		return false;
1001
-	}
1002
-	if (!is_array($taches)) {
1003
-		$taches = $taches_old;
1004
-	} // compat anciens appels
1005
-	// si taches a inserer en base et base inaccessible, laisser tomber
1006
-	// sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1007
-	// queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1008
-	// et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1009
-	if ($taches and count($taches) and !spip_connect()) {
1010
-		return false;
1011
-	}
1012
-	spip_log("cron !", 'jq' . _LOG_DEBUG);
1013
-	if ($genie = charger_fonction('genie', 'inc', true)) {
1014
-		return $genie($taches);
1015
-	}
1016
-
1017
-	return false;
997
+    // si pas en mode cron force, laisser tomber.
998
+    if (!defined('_DIRECT_CRON_FORCE')) {
999
+        return false;
1000
+    }
1001
+    if (!is_array($taches)) {
1002
+        $taches = $taches_old;
1003
+    } // compat anciens appels
1004
+    // si taches a inserer en base et base inaccessible, laisser tomber
1005
+    // sinon on ne verifie pas la connexion tout de suite, car si ca se trouve
1006
+    // queue_sleep_time_to_next_job() dira qu'il n'y a rien a faire
1007
+    // et on evite d'ouvrir une connexion pour rien (utilisation de _DIRECT_CRON_FORCE dans mes_options.php)
1008
+    if ($taches and count($taches) and !spip_connect()) {
1009
+        return false;
1010
+    }
1011
+    spip_log("cron !", 'jq' . _LOG_DEBUG);
1012
+    if ($genie = charger_fonction('genie', 'inc', true)) {
1013
+        return $genie($taches);
1014
+    }
1015
+
1016
+    return false;
1018 1017
 }
1019 1018
 
1020 1019
 /**
@@ -1046,17 +1045,17 @@  discard block
 block discarded – undo
1046 1045
  *     Le numéro de travail ajouté ou `0` si aucun travail n’a été ajouté.
1047 1046
  */
1048 1047
 function job_queue_add(
1049
-	$function,
1050
-	$description,
1051
-	$arguments = array(),
1052
-	$file = '',
1053
-	$no_duplicate = false,
1054
-	$time = 0,
1055
-	$priority = 0
1048
+    $function,
1049
+    $description,
1050
+    $arguments = array(),
1051
+    $file = '',
1052
+    $no_duplicate = false,
1053
+    $time = 0,
1054
+    $priority = 0
1056 1055
 ) {
1057
-	include_spip('inc/queue');
1056
+    include_spip('inc/queue');
1058 1057
 
1059
-	return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1058
+    return queue_add_job($function, $description, $arguments, $file, $no_duplicate, $time, $priority);
1060 1059
 }
1061 1060
 
1062 1061
 /**
@@ -1067,9 +1066,9 @@  discard block
 block discarded – undo
1067 1066
  * @return bool
1068 1067
  */
1069 1068
 function job_queue_remove($id_job) {
1070
-	include_spip('inc/queue');
1069
+    include_spip('inc/queue');
1071 1070
 
1072
-	return queue_remove_job($id_job);
1071
+    return queue_remove_job($id_job);
1073 1072
 }
1074 1073
 
1075 1074
 /**
@@ -1082,9 +1081,9 @@  discard block
 block discarded – undo
1082 1081
  *     or an array of simple array to link multiples objet in one time
1083 1082
  */
1084 1083
 function job_queue_link($id_job, $objets) {
1085
-	include_spip('inc/queue');
1084
+    include_spip('inc/queue');
1086 1085
 
1087
-	return queue_link_job($id_job, $objets);
1086
+    return queue_link_job($id_job, $objets);
1088 1087
 }
1089 1088
 
1090 1089
 
@@ -1104,36 +1103,36 @@  discard block
 block discarded – undo
1104 1103
  *  - `null` si la queue n'est pas encore initialisée
1105 1104
  */
1106 1105
 function queue_sleep_time_to_next_job($force = null) {
1107
-	static $queue_next_job_time = -1;
1108
-	if ($force === true) {
1109
-		$queue_next_job_time = -1;
1110
-	} elseif ($force) {
1111
-		$queue_next_job_time = $force;
1112
-	}
1113
-
1114
-	if ($queue_next_job_time == -1) {
1115
-		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1116
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt");
1117
-		}
1118
-		// utiliser un cache memoire si dispo
1119
-		if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1120
-			$queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1121
-		} else {
1122
-			$queue_next_job_time = null;
1123
-			if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1124
-				$queue_next_job_time = intval($contenu);
1125
-			}
1126
-		}
1127
-	}
1128
-
1129
-	if (is_null($queue_next_job_time)) {
1130
-		return null;
1131
-	}
1132
-	if (!$_SERVER['REQUEST_TIME']) {
1133
-		$_SERVER['REQUEST_TIME'] = time();
1134
-	}
1135
-
1136
-	return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1106
+    static $queue_next_job_time = -1;
1107
+    if ($force === true) {
1108
+        $queue_next_job_time = -1;
1109
+    } elseif ($force) {
1110
+        $queue_next_job_time = $force;
1111
+    }
1112
+
1113
+    if ($queue_next_job_time == -1) {
1114
+        if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1115
+            define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt");
1116
+        }
1117
+        // utiliser un cache memoire si dispo
1118
+        if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
1119
+            $queue_next_job_time = cache_get(_JQ_NEXT_JOB_TIME_FILENAME);
1120
+        } else {
1121
+            $queue_next_job_time = null;
1122
+            if (lire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, $contenu)) {
1123
+                $queue_next_job_time = intval($contenu);
1124
+            }
1125
+        }
1126
+    }
1127
+
1128
+    if (is_null($queue_next_job_time)) {
1129
+        return null;
1130
+    }
1131
+    if (!$_SERVER['REQUEST_TIME']) {
1132
+        $_SERVER['REQUEST_TIME'] = time();
1133
+    }
1134
+
1135
+    return $queue_next_job_time - $_SERVER['REQUEST_TIME'];
1137 1136
 }
1138 1137
 
1139 1138
 
@@ -1145,9 +1144,9 @@  discard block
 block discarded – undo
1145 1144
  * @return string
1146 1145
  */
1147 1146
 function quote_amp($u) {
1148
-	return preg_replace(
1149
-		"/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i",
1150
-		"&amp;", $u);
1147
+    return preg_replace(
1148
+        "/&(?![a-z]{0,4}\w{2,3};|#x?[0-9a-f]{2,6};)/i",
1149
+        "&amp;", $u);
1151 1150
 }
1152 1151
 
1153 1152
 
@@ -1170,27 +1169,27 @@  discard block
 block discarded – undo
1170 1169
  *     Balise HTML `<script>` et son contenu
1171 1170
  **/
1172 1171
 function http_script($script, $src = '', $noscript = '') {
1173
-	static $done = array();
1172
+    static $done = array();
1174 1173
 
1175
-	if ($src && !isset($done[$src])) {
1176
-		$done[$src] = true;
1177
-		$src = find_in_path($src, _JAVASCRIPT);
1178
-		$src = " src='$src'";
1179
-	} else {
1180
-		$src = '';
1181
-	}
1182
-	if ($script) {
1183
-		$script = ("/*<![CDATA[*/\n" .
1184
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1185
-			"/*]]>*/");
1186
-	}
1187
-	if ($noscript) {
1188
-		$noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1189
-	}
1174
+    if ($src && !isset($done[$src])) {
1175
+        $done[$src] = true;
1176
+        $src = find_in_path($src, _JAVASCRIPT);
1177
+        $src = " src='$src'";
1178
+    } else {
1179
+        $src = '';
1180
+    }
1181
+    if ($script) {
1182
+        $script = ("/*<![CDATA[*/\n" .
1183
+            preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1184
+            "/*]]>*/");
1185
+    }
1186
+    if ($noscript) {
1187
+        $noscript = "<noscript>\n\t$noscript\n</noscript>\n";
1188
+    }
1190 1189
 
1191
-	return ($src or $script or $noscript)
1192
-		? "<script type='text/javascript'$src>$script</script>$noscript"
1193
-		: '';
1190
+    return ($src or $script or $noscript)
1191
+        ? "<script type='text/javascript'$src>$script</script>$noscript"
1192
+        : '';
1194 1193
 }
1195 1194
 
1196 1195
 
@@ -1225,7 +1224,7 @@  discard block
 block discarded – undo
1225 1224
  *     Texte échappé
1226 1225
  **/
1227 1226
 function texte_script($texte) {
1228
-	return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1227
+    return str_replace('\'', '\\\'', str_replace('\\', '\\\\', $texte));
1229 1228
 }
1230 1229
 
1231 1230
 
@@ -1262,69 +1261,69 @@  discard block
 block discarded – undo
1262 1261
  *     Liste des chemins, par ordre de priorité.
1263 1262
  **/
1264 1263
 function _chemin($dir_path = null) {
1265
-	static $path_base = null;
1266
-	static $path_full = null;
1267
-	if ($path_base == null) {
1268
-		// Chemin standard depuis l'espace public
1269
-		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1270
-			_DIR_RACINE . ':' .
1271
-			_DIR_RACINE . 'squelettes-dist/:' .
1272
-			_DIR_RACINE . 'prive/:' .
1273
-			_DIR_RESTREINT;
1274
-		// Ajouter squelettes/
1275
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1276
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1277
-		}
1278
-		foreach (explode(':', $path) as $dir) {
1279
-			if (strlen($dir) and substr($dir, -1) != '/') {
1280
-				$dir .= "/";
1281
-			}
1282
-			$path_base[] = $dir;
1283
-		}
1284
-		$path_full = $path_base;
1285
-		// Et le(s) dossier(s) des squelettes nommes
1286
-		if (strlen($GLOBALS['dossier_squelettes'])) {
1287
-			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1288
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1289
-			}
1290
-		}
1291
-		$GLOBALS['path_sig'] = md5(serialize($path_full));
1292
-	}
1293
-	if ($dir_path === null) {
1294
-		return $path_full;
1295
-	}
1296
-
1297
-	if (strlen($dir_path)) {
1298
-		$tete = "";
1299
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1300
-			$tete = array_shift($path_base);
1301
-		}
1302
-		$dirs = array_reverse(explode(':', $dir_path));
1303
-		foreach ($dirs as $dir_path) {
1304
-			#if ($dir_path{0}!='/')
1305
-			#	$dir_path = $dir_path;
1306
-			if (substr($dir_path, -1) != '/') {
1307
-				$dir_path .= "/";
1308
-			}
1309
-			if (!in_array($dir_path, $path_base)) {
1310
-				array_unshift($path_base, $dir_path);
1311
-			}
1312
-		}
1313
-		if (strlen($tete)) {
1314
-			array_unshift($path_base, $tete);
1315
-		}
1316
-	}
1317
-	$path_full = $path_base;
1318
-	// Et le(s) dossier(s) des squelettes nommes
1319
-	if (strlen($GLOBALS['dossier_squelettes'])) {
1320
-		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1321
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1322
-		}
1323
-	}
1324
-
1325
-	$GLOBALS['path_sig'] = md5(serialize($path_full));
1326
-
1327
-	return $path_full;
1264
+    static $path_base = null;
1265
+    static $path_full = null;
1266
+    if ($path_base == null) {
1267
+        // Chemin standard depuis l'espace public
1268
+        $path = defined('_SPIP_PATH') ? _SPIP_PATH :
1269
+            _DIR_RACINE . ':' .
1270
+            _DIR_RACINE . 'squelettes-dist/:' .
1271
+            _DIR_RACINE . 'prive/:' .
1272
+            _DIR_RESTREINT;
1273
+        // Ajouter squelettes/
1274
+        if (@is_dir(_DIR_RACINE . 'squelettes')) {
1275
+            $path = _DIR_RACINE . 'squelettes/:' . $path;
1276
+        }
1277
+        foreach (explode(':', $path) as $dir) {
1278
+            if (strlen($dir) and substr($dir, -1) != '/') {
1279
+                $dir .= "/";
1280
+            }
1281
+            $path_base[] = $dir;
1282
+        }
1283
+        $path_full = $path_base;
1284
+        // Et le(s) dossier(s) des squelettes nommes
1285
+        if (strlen($GLOBALS['dossier_squelettes'])) {
1286
+            foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1287
+                array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1288
+            }
1289
+        }
1290
+        $GLOBALS['path_sig'] = md5(serialize($path_full));
1291
+    }
1292
+    if ($dir_path === null) {
1293
+        return $path_full;
1294
+    }
1295
+
1296
+    if (strlen($dir_path)) {
1297
+        $tete = "";
1298
+        if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1299
+            $tete = array_shift($path_base);
1300
+        }
1301
+        $dirs = array_reverse(explode(':', $dir_path));
1302
+        foreach ($dirs as $dir_path) {
1303
+            #if ($dir_path{0}!='/')
1304
+            #	$dir_path = $dir_path;
1305
+            if (substr($dir_path, -1) != '/') {
1306
+                $dir_path .= "/";
1307
+            }
1308
+            if (!in_array($dir_path, $path_base)) {
1309
+                array_unshift($path_base, $dir_path);
1310
+            }
1311
+        }
1312
+        if (strlen($tete)) {
1313
+            array_unshift($path_base, $tete);
1314
+        }
1315
+    }
1316
+    $path_full = $path_base;
1317
+    // Et le(s) dossier(s) des squelettes nommes
1318
+    if (strlen($GLOBALS['dossier_squelettes'])) {
1319
+        foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1320
+            array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1321
+        }
1322
+    }
1323
+
1324
+    $GLOBALS['path_sig'] = md5(serialize($path_full));
1325
+
1326
+    return $path_full;
1328 1327
 }
1329 1328
 
1330 1329
 /**
@@ -1337,76 +1336,76 @@  discard block
 block discarded – undo
1337 1336
  * @return array Liste de chemins
1338 1337
  **/
1339 1338
 function creer_chemin() {
1340
-	$path_a = _chemin();
1341
-	static $c = '';
1339
+    $path_a = _chemin();
1340
+    static $c = '';
1342 1341
 
1343
-	// on calcule le chemin si le dossier skel a change
1344
-	if ($c != $GLOBALS['dossier_squelettes']) {
1345
-		// assurer le non plantage lors de la montee de version :
1346
-		$c = $GLOBALS['dossier_squelettes'];
1347
-		$path_a = _chemin(''); // forcer un recalcul du chemin
1348
-	}
1342
+    // on calcule le chemin si le dossier skel a change
1343
+    if ($c != $GLOBALS['dossier_squelettes']) {
1344
+        // assurer le non plantage lors de la montee de version :
1345
+        $c = $GLOBALS['dossier_squelettes'];
1346
+        $path_a = _chemin(''); // forcer un recalcul du chemin
1347
+    }
1349 1348
 
1350
-	return $path_a;
1349
+    return $path_a;
1351 1350
 }
1352 1351
 
1353 1352
 
1354 1353
 function lister_themes_prives() {
1355
-	static $themes = null;
1356
-	if (is_null($themes)) {
1357
-		// si pas encore definie
1358
-		if (!defined('_SPIP_THEME_PRIVE')) {
1359
-			define('_SPIP_THEME_PRIVE', 'spip');
1360
-		}
1361
-		$themes = array(_SPIP_THEME_PRIVE);
1362
-		// lors d'une installation neuve, prefs n'est pas definie.
1363
-		if (isset($GLOBALS['visiteur_session']['prefs'])) {
1364
-			$prefs = $GLOBALS['visiteur_session']['prefs'];
1365
-		} else {
1366
-			$prefs = array();
1367
-		}
1368
-		if (is_string($prefs)) {
1369
-			$prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1370
-		}
1371
-		if (
1372
-			((isset($prefs['theme']) and $theme = $prefs['theme'])
1373
-				or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1374
-			and $theme != _SPIP_THEME_PRIVE
1375
-		) {
1376
-			array_unshift($themes, $theme);
1377
-		} // placer le theme choisi en tete
1378
-	}
1379
-
1380
-	return $themes;
1354
+    static $themes = null;
1355
+    if (is_null($themes)) {
1356
+        // si pas encore definie
1357
+        if (!defined('_SPIP_THEME_PRIVE')) {
1358
+            define('_SPIP_THEME_PRIVE', 'spip');
1359
+        }
1360
+        $themes = array(_SPIP_THEME_PRIVE);
1361
+        // lors d'une installation neuve, prefs n'est pas definie.
1362
+        if (isset($GLOBALS['visiteur_session']['prefs'])) {
1363
+            $prefs = $GLOBALS['visiteur_session']['prefs'];
1364
+        } else {
1365
+            $prefs = array();
1366
+        }
1367
+        if (is_string($prefs)) {
1368
+            $prefs = unserialize($GLOBALS['visiteur_session']['prefs']);
1369
+        }
1370
+        if (
1371
+            ((isset($prefs['theme']) and $theme = $prefs['theme'])
1372
+                or (isset($GLOBALS['theme_prive_defaut']) and $theme = $GLOBALS['theme_prive_defaut']))
1373
+            and $theme != _SPIP_THEME_PRIVE
1374
+        ) {
1375
+            array_unshift($themes, $theme);
1376
+        } // placer le theme choisi en tete
1377
+    }
1378
+
1379
+    return $themes;
1381 1380
 }
1382 1381
 
1383 1382
 function find_in_theme($file, $subdir = '', $include = false) {
1384
-	static $themefiles = array();
1385
-	if (isset($themefiles["$subdir$file"])) {
1386
-		return $themefiles["$subdir$file"];
1387
-	}
1388
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1389
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1390
-	if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1391
-	  and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg"
1392
-		and $f = find_in_theme("$file_svg_generique")) {
1393
-		if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1394
-			return $themefiles["$subdir$file"] = $fsize;
1395
-		}
1396
-		else {
1397
-			return $themefiles["$subdir$file"] = "$f?".$m[1]."px";
1398
-		}
1399
-	}
1400
-
1401
-	$themes = lister_themes_prives();
1402
-	foreach ($themes as $theme) {
1403
-		if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1404
-			return $themefiles["$subdir$file"] = $f;
1405
-		}
1406
-	}
1407
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1408
-
1409
-	return $themefiles["$subdir$file"] = "";
1383
+    static $themefiles = array();
1384
+    if (isset($themefiles["$subdir$file"])) {
1385
+        return $themefiles["$subdir$file"];
1386
+    }
1387
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1388
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1389
+    if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1390
+      and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg"
1391
+        and $f = find_in_theme("$file_svg_generique")) {
1392
+        if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1393
+            return $themefiles["$subdir$file"] = $fsize;
1394
+        }
1395
+        else {
1396
+            return $themefiles["$subdir$file"] = "$f?".$m[1]."px";
1397
+        }
1398
+    }
1399
+
1400
+    $themes = lister_themes_prives();
1401
+    foreach ($themes as $theme) {
1402
+        if ($f = find_in_path($file, "prive/themes/$theme/$subdir", $include)) {
1403
+            return $themefiles["$subdir$file"] = $f;
1404
+        }
1405
+    }
1406
+    spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1407
+
1408
+    return $themefiles["$subdir$file"] = "";
1410 1409
 }
1411 1410
 
1412 1411
 
@@ -1430,31 +1429,31 @@  discard block
 block discarded – undo
1430 1429
  *     sinon chaîne vide.
1431 1430
  **/
1432 1431
 function chemin_image($icone) {
1433
-	static $icone_renommer;
1434
-	if ($p = strpos($icone, '?')) {
1435
-		$icone = substr($icone,0, $p);
1436
-	}
1437
-	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1438
-	if (strpos($icone, "/") !== false and file_exists($icone)) {
1439
-		return $icone;
1440
-	}
1441
-
1442
-	// si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1443
-	if (preg_match(',[.](png|gif|jpg|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1444
-		return $f;
1445
-	}
1446
-	// sinon passer par le module de renommage
1447
-	if (is_null($icone_renommer)) {
1448
-		$icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1449
-	}
1450
-	if ($icone_renommer) {
1451
-		list($icone, $fonction) = $icone_renommer($icone, "");
1452
-		if (file_exists($icone)) {
1453
-			return $icone;
1454
-		}
1455
-	}
1456
-
1457
-	return find_in_path($icone, _NOM_IMG_PACK);
1432
+    static $icone_renommer;
1433
+    if ($p = strpos($icone, '?')) {
1434
+        $icone = substr($icone,0, $p);
1435
+    }
1436
+    // gerer le cas d'un double appel en evitant de refaire le travail inutilement
1437
+    if (strpos($icone, "/") !== false and file_exists($icone)) {
1438
+        return $icone;
1439
+    }
1440
+
1441
+    // si c'est un nom d'image complet (article-24.png) essayer de le renvoyer direct
1442
+    if (preg_match(',[.](png|gif|jpg|svg)$,', $icone) and $f = find_in_theme("images/$icone")) {
1443
+        return $f;
1444
+    }
1445
+    // sinon passer par le module de renommage
1446
+    if (is_null($icone_renommer)) {
1447
+        $icone_renommer = charger_fonction('icone_renommer', 'inc', true);
1448
+    }
1449
+    if ($icone_renommer) {
1450
+        list($icone, $fonction) = $icone_renommer($icone, "");
1451
+        if (file_exists($icone)) {
1452
+            return $icone;
1453
+        }
1454
+    }
1455
+
1456
+    return find_in_path($icone, _NOM_IMG_PACK);
1458 1457
 }
1459 1458
 
1460 1459
 //
@@ -1492,123 +1491,123 @@  discard block
 block discarded – undo
1492 1491
  *     - false : fichier introuvable
1493 1492
  **/
1494 1493
 function find_in_path($file, $dirname = '', $include = false) {
1495
-	static $dirs = array();
1496
-	static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743
1497
-	static $c = '';
1498
-
1499
-	// on calcule le chemin si le dossier skel a change
1500
-	if ($c != $GLOBALS['dossier_squelettes']) {
1501
-		// assurer le non plantage lors de la montee de version :
1502
-		$c = $GLOBALS['dossier_squelettes'];
1503
-		creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1504
-	}
1505
-
1506
-	if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1507
-		if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1508
-			return false;
1509
-		}
1510
-		if ($include and !isset($inc[$dirname][$file])) {
1511
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1512
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1513
-		}
1514
-
1515
-		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1516
-	}
1517
-
1518
-	$a = strrpos($file, '/');
1519
-	if ($a !== false) {
1520
-		$dirname .= substr($file, 0, ++$a);
1521
-		$file = substr($file, $a);
1522
-	}
1523
-
1524
-	foreach (creer_chemin() as $dir) {
1525
-		if (!isset($dirs[$a = $dir . $dirname])) {
1526
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1527
-		}
1528
-		if ($dirs[$a]) {
1529
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1530
-				if ($include and !isset($inc[$dirname][$file])) {
1531
-					include_once _ROOT_CWD . $a;
1532
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1533
-				}
1534
-				if (!defined('_SAUVER_CHEMIN')) {
1535
-					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1536
-					if (is_null($GLOBALS['path_files'])) {
1537
-						return $a;
1538
-					}
1539
-					define('_SAUVER_CHEMIN', true);
1540
-				}
1541
-
1542
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1543
-			}
1544
-		}
1545
-	}
1546
-
1547
-	if ($include) {
1548
-		spip_log("include_spip $dirname$file non trouve");
1549
-		if ($include === 'required') {
1550
-			echo '<pre>',
1551
-			"<strong>Erreur Fatale</strong><br />";
1552
-			if (function_exists('debug_print_backtrace')) {
1553
-				echo debug_print_backtrace();
1554
-			}
1555
-			echo '</pre>';
1556
-			die("Erreur interne: ne peut inclure $dirname$file");
1557
-		}
1558
-	}
1559
-
1560
-	if (!defined('_SAUVER_CHEMIN')) {
1561
-		// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1562
-		if (is_null($GLOBALS['path_files'])) {
1563
-			return false;
1564
-		}
1565
-		define('_SAUVER_CHEMIN', true);
1566
-	}
1567
-
1568
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1494
+    static $dirs = array();
1495
+    static $inc = array(); # cf http://trac.rezo.net/trac/spip/changeset/14743
1496
+    static $c = '';
1497
+
1498
+    // on calcule le chemin si le dossier skel a change
1499
+    if ($c != $GLOBALS['dossier_squelettes']) {
1500
+        // assurer le non plantage lors de la montee de version :
1501
+        $c = $GLOBALS['dossier_squelettes'];
1502
+        creer_chemin(); // forcer un recalcul du chemin et la mise a jour de path_sig
1503
+    }
1504
+
1505
+    if (isset($GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file])) {
1506
+        if (!$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file]) {
1507
+            return false;
1508
+        }
1509
+        if ($include and !isset($inc[$dirname][$file])) {
1510
+            include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1511
+            $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1512
+        }
1513
+
1514
+        return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1515
+    }
1516
+
1517
+    $a = strrpos($file, '/');
1518
+    if ($a !== false) {
1519
+        $dirname .= substr($file, 0, ++$a);
1520
+        $file = substr($file, $a);
1521
+    }
1522
+
1523
+    foreach (creer_chemin() as $dir) {
1524
+        if (!isset($dirs[$a = $dir . $dirname])) {
1525
+            $dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1526
+        }
1527
+        if ($dirs[$a]) {
1528
+            if (file_exists(_ROOT_CWD . ($a .= $file))) {
1529
+                if ($include and !isset($inc[$dirname][$file])) {
1530
+                    include_once _ROOT_CWD . $a;
1531
+                    $inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1532
+                }
1533
+                if (!defined('_SAUVER_CHEMIN')) {
1534
+                    // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1535
+                    if (is_null($GLOBALS['path_files'])) {
1536
+                        return $a;
1537
+                    }
1538
+                    define('_SAUVER_CHEMIN', true);
1539
+                }
1540
+
1541
+                return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1542
+            }
1543
+        }
1544
+    }
1545
+
1546
+    if ($include) {
1547
+        spip_log("include_spip $dirname$file non trouve");
1548
+        if ($include === 'required') {
1549
+            echo '<pre>',
1550
+            "<strong>Erreur Fatale</strong><br />";
1551
+            if (function_exists('debug_print_backtrace')) {
1552
+                echo debug_print_backtrace();
1553
+            }
1554
+            echo '</pre>';
1555
+            die("Erreur interne: ne peut inclure $dirname$file");
1556
+        }
1557
+    }
1558
+
1559
+    if (!defined('_SAUVER_CHEMIN')) {
1560
+        // si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
1561
+        if (is_null($GLOBALS['path_files'])) {
1562
+            return false;
1563
+        }
1564
+        define('_SAUVER_CHEMIN', true);
1565
+    }
1566
+
1567
+    return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1569 1568
 }
1570 1569
 
1571 1570
 function clear_path_cache() {
1572
-	$GLOBALS['path_files'] = array();
1573
-	spip_unlink(_CACHE_CHEMIN);
1571
+    $GLOBALS['path_files'] = array();
1572
+    spip_unlink(_CACHE_CHEMIN);
1574 1573
 }
1575 1574
 
1576 1575
 function load_path_cache() {
1577
-	// charger le path des plugins
1578
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1579
-		include_once(_CACHE_PLUGINS_PATH);
1580
-	}
1581
-	$GLOBALS['path_files'] = array();
1582
-	// si le visiteur est admin,
1583
-	// on ne recharge pas le cache pour forcer sa mise a jour
1584
-	if (
1585
-		// la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1586
-		//AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1587
-		// utiliser le cookie est un pis aller qui marche 'en general'
1588
-		// on blinde par un second test au moment de la lecture de la session
1589
-		// !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1590
-		// et en ignorant ce cache en cas de recalcul explicite
1591
-	!_request('var_mode')
1592
-	) {
1593
-		// on essaye de lire directement sans verrou pour aller plus vite
1594
-		if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1595
-			// mais si semble corrompu on relit avec un verrou
1596
-			if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1597
-				lire_fichier(_CACHE_CHEMIN, $contenu);
1598
-				if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1599
-					$GLOBALS['path_files'] = array();
1600
-				}
1601
-			}
1602
-		}
1603
-	}
1576
+    // charger le path des plugins
1577
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1578
+        include_once(_CACHE_PLUGINS_PATH);
1579
+    }
1580
+    $GLOBALS['path_files'] = array();
1581
+    // si le visiteur est admin,
1582
+    // on ne recharge pas le cache pour forcer sa mise a jour
1583
+    if (
1584
+        // la session n'est pas encore chargee a ce moment, on ne peut donc pas s'y fier
1585
+        //AND (!isset($GLOBALS['visiteur_session']['statut']) OR $GLOBALS['visiteur_session']['statut']!='0minirezo')
1586
+        // utiliser le cookie est un pis aller qui marche 'en general'
1587
+        // on blinde par un second test au moment de la lecture de la session
1588
+        // !isset($_COOKIE[$GLOBALS['cookie_prefix'].'_admin'])
1589
+        // et en ignorant ce cache en cas de recalcul explicite
1590
+    !_request('var_mode')
1591
+    ) {
1592
+        // on essaye de lire directement sans verrou pour aller plus vite
1593
+        if ($contenu = spip_file_get_contents(_CACHE_CHEMIN)) {
1594
+            // mais si semble corrompu on relit avec un verrou
1595
+            if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1596
+                lire_fichier(_CACHE_CHEMIN, $contenu);
1597
+                if (!$GLOBALS['path_files'] = unserialize($contenu)) {
1598
+                    $GLOBALS['path_files'] = array();
1599
+                }
1600
+            }
1601
+        }
1602
+    }
1604 1603
 }
1605 1604
 
1606 1605
 function save_path_cache() {
1607
-	if (defined('_SAUVER_CHEMIN')
1608
-		and _SAUVER_CHEMIN
1609
-	) {
1610
-		ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1611
-	}
1606
+    if (defined('_SAUVER_CHEMIN')
1607
+        and _SAUVER_CHEMIN
1608
+    ) {
1609
+        ecrire_fichier(_CACHE_CHEMIN, serialize($GLOBALS['path_files']));
1610
+    }
1612 1611
 }
1613 1612
 
1614 1613
 
@@ -1628,33 +1627,33 @@  discard block
 block discarded – undo
1628 1627
  * @return array
1629 1628
  */
1630 1629
 function find_all_in_path($dir, $pattern, $recurs = false) {
1631
-	$liste_fichiers = array();
1632
-	$maxfiles = 10000;
1633
-
1634
-	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1635
-	// on a pas encore inclus flock.php
1636
-	if (!function_exists('preg_files')) {
1637
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1638
-	}
1639
-
1640
-	// Parcourir le chemin
1641
-	foreach (creer_chemin() as $d) {
1642
-		$f = $d . $dir;
1643
-		if (@is_dir($f)) {
1644
-			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1645
-			foreach ($liste as $chemin) {
1646
-				$nom = basename($chemin);
1647
-				// ne prendre que les fichiers pas deja trouves
1648
-				// car find_in_path prend le premier qu'il trouve,
1649
-				// les autres sont donc masques
1650
-				if (!isset($liste_fichiers[$nom])) {
1651
-					$liste_fichiers[$nom] = $chemin;
1652
-				}
1653
-			}
1654
-		}
1655
-	}
1656
-
1657
-	return $liste_fichiers;
1630
+    $liste_fichiers = array();
1631
+    $maxfiles = 10000;
1632
+
1633
+    // cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1634
+    // on a pas encore inclus flock.php
1635
+    if (!function_exists('preg_files')) {
1636
+        include_once _ROOT_RESTREINT . 'inc/flock.php';
1637
+    }
1638
+
1639
+    // Parcourir le chemin
1640
+    foreach (creer_chemin() as $d) {
1641
+        $f = $d . $dir;
1642
+        if (@is_dir($f)) {
1643
+            $liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1644
+            foreach ($liste as $chemin) {
1645
+                $nom = basename($chemin);
1646
+                // ne prendre que les fichiers pas deja trouves
1647
+                // car find_in_path prend le premier qu'il trouve,
1648
+                // les autres sont donc masques
1649
+                if (!isset($liste_fichiers[$nom])) {
1650
+                    $liste_fichiers[$nom] = $chemin;
1651
+                }
1652
+            }
1653
+        }
1654
+    }
1655
+
1656
+    return $liste_fichiers;
1658 1657
 }
1659 1658
 
1660 1659
 /**
@@ -1666,17 +1665,17 @@  discard block
 block discarded – undo
1666 1665
  * @return bool
1667 1666
  */
1668 1667
 function autoriser_sans_cookie($nom, $strict = false) {
1669
-	static $autsanscookie = array('install', 'base_repair');
1668
+    static $autsanscookie = array('install', 'base_repair');
1670 1669
 
1671
-	if (in_array($nom, $autsanscookie)) {
1672
-		if (test_espace_prive()){
1673
-			include_spip('base/connect_sql');
1674
-			if (!$strict or !spip_connect()){
1675
-				return true;
1676
-			}
1677
-		}
1678
-	}
1679
-	return false;
1670
+    if (in_array($nom, $autsanscookie)) {
1671
+        if (test_espace_prive()){
1672
+            include_spip('base/connect_sql');
1673
+            if (!$strict or !spip_connect()){
1674
+                return true;
1675
+            }
1676
+        }
1677
+    }
1678
+    return false;
1680 1679
 }
1681 1680
 
1682 1681
 /**
@@ -1702,99 +1701,99 @@  discard block
 block discarded – undo
1702 1701
  *           (cas des raccourcis personalises [->spip20] : il faut implementer une fonction generer_url_spip et une fonction generer_url_ecrire_spip)
1703 1702
  */
1704 1703
 function generer_url_entite($id = '', $entite = '', $args = '', $ancre = '', $public = null, $type = null) {
1705
-	if ($public === null) {
1706
-		$public = !test_espace_prive();
1707
-	}
1708
-	$entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1709
-
1710
-	if (!$public) {
1711
-		if (!$entite) {
1712
-			return '';
1713
-		}
1714
-		if (!function_exists('generer_url_ecrire_objet')) {
1715
-			include_spip('inc/urls');
1716
-		}
1717
-		$res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1718
-	} else {
1719
-		if ($type === null) {
1720
-			$type = (isset($GLOBALS['type_urls']))
1721
-				? $GLOBALS['type_urls'] // pour surcharge via fichier d'options
1722
-				: ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues
1723
-					? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut
1724
-		}
1725
-
1726
-		$f = charger_fonction($type, 'urls', true);
1727
-		// se rabattre sur les urls page si les urls perso non dispo
1728
-		if (!$f) {
1729
-			$f = charger_fonction('page', 'urls', true);
1730
-		}
1731
-
1732
-		// si $entite='', on veut la fonction de passage URL ==> id
1733
-		// sinon on veut effectuer le passage id ==> URL
1734
-		if (!$entite) {
1735
-			return $f;
1736
-		}
1737
-
1738
-		// mais d'abord il faut tester le cas des urls sur une
1739
-		// base distante
1740
-		if (is_string($public)
1741
-			and $g = charger_fonction('connect', 'urls', true)
1742
-		) {
1743
-			$f = $g;
1744
-		}
1745
-
1746
-		$res = $f(intval($id), $entite, $args, $ancre, $public);
1747
-
1748
-	}
1749
-	if ($res) {
1750
-		return $res;
1751
-	}
1752
-	// Sinon c'est un raccourci ou compat SPIP < 2
1753
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1754
-		if (!function_exists($f .= '_dist')) {
1755
-			$f = '';
1756
-		}
1757
-	}
1758
-	if ($f) {
1759
-		$url = $f($id, $args, $ancre);
1760
-		if (strlen($args)) {
1761
-			$url .= strstr($url, '?')
1762
-				? '&amp;' . $args
1763
-				: '?' . $args;
1764
-		}
1765
-
1766
-		return $url;
1767
-	}
1768
-	// On a ete gentil mais la ....
1769
-	spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1770
-
1771
-	return '';
1704
+    if ($public === null) {
1705
+        $public = !test_espace_prive();
1706
+    }
1707
+    $entite = objet_type($entite); // cas particulier d'appels sur objet/id_objet...
1708
+
1709
+    if (!$public) {
1710
+        if (!$entite) {
1711
+            return '';
1712
+        }
1713
+        if (!function_exists('generer_url_ecrire_objet')) {
1714
+            include_spip('inc/urls');
1715
+        }
1716
+        $res = generer_url_ecrire_objet($entite, $id, $args, $ancre, false);
1717
+    } else {
1718
+        if ($type === null) {
1719
+            $type = (isset($GLOBALS['type_urls']))
1720
+                ? $GLOBALS['type_urls'] // pour surcharge via fichier d'options
1721
+                : ((isset($GLOBALS['meta']['type_urls'])) // sinon la config url_etendues
1722
+                    ? ($GLOBALS['meta']['type_urls']) : "page"); // sinon type "page" par défaut
1723
+        }
1724
+
1725
+        $f = charger_fonction($type, 'urls', true);
1726
+        // se rabattre sur les urls page si les urls perso non dispo
1727
+        if (!$f) {
1728
+            $f = charger_fonction('page', 'urls', true);
1729
+        }
1730
+
1731
+        // si $entite='', on veut la fonction de passage URL ==> id
1732
+        // sinon on veut effectuer le passage id ==> URL
1733
+        if (!$entite) {
1734
+            return $f;
1735
+        }
1736
+
1737
+        // mais d'abord il faut tester le cas des urls sur une
1738
+        // base distante
1739
+        if (is_string($public)
1740
+            and $g = charger_fonction('connect', 'urls', true)
1741
+        ) {
1742
+            $f = $g;
1743
+        }
1744
+
1745
+        $res = $f(intval($id), $entite, $args, $ancre, $public);
1746
+
1747
+    }
1748
+    if ($res) {
1749
+        return $res;
1750
+    }
1751
+    // Sinon c'est un raccourci ou compat SPIP < 2
1752
+    if (!function_exists($f = 'generer_url_' . $entite)) {
1753
+        if (!function_exists($f .= '_dist')) {
1754
+            $f = '';
1755
+        }
1756
+    }
1757
+    if ($f) {
1758
+        $url = $f($id, $args, $ancre);
1759
+        if (strlen($args)) {
1760
+            $url .= strstr($url, '?')
1761
+                ? '&amp;' . $args
1762
+                : '?' . $args;
1763
+        }
1764
+
1765
+        return $url;
1766
+    }
1767
+    // On a ete gentil mais la ....
1768
+    spip_log("generer_url_entite: entite $entite ($f) inconnue $type $public");
1769
+
1770
+    return '';
1772 1771
 }
1773 1772
 
1774 1773
 function generer_url_ecrire_entite_edit($id, $entite, $args = '', $ancre = '') {
1775
-	$exec = objet_info($entite, 'url_edit');
1776
-	$url = generer_url_ecrire($exec, $args);
1777
-	if (intval($id)) {
1778
-		$url = parametre_url($url, id_table_objet($entite), $id);
1779
-	} else {
1780
-		$url = parametre_url($url, 'new', 'oui');
1781
-	}
1782
-	if ($ancre) {
1783
-		$url = ancre_url($url, $ancre);
1784
-	}
1774
+    $exec = objet_info($entite, 'url_edit');
1775
+    $url = generer_url_ecrire($exec, $args);
1776
+    if (intval($id)) {
1777
+        $url = parametre_url($url, id_table_objet($entite), $id);
1778
+    } else {
1779
+        $url = parametre_url($url, 'new', 'oui');
1780
+    }
1781
+    if ($ancre) {
1782
+        $url = ancre_url($url, $ancre);
1783
+    }
1785 1784
 
1786
-	return $url;
1785
+    return $url;
1787 1786
 }
1788 1787
 
1789 1788
 // http://code.spip.net/@urls_connect_dist
1790 1789
 function urls_connect_dist($i, &$entite, $args = '', $ancre = '', $public = null) {
1791
-	include_spip('base/connect_sql');
1792
-	$id_type = id_table_objet($entite, $public);
1790
+    include_spip('base/connect_sql');
1791
+    $id_type = id_table_objet($entite, $public);
1793 1792
 
1794
-	return _DIR_RACINE . get_spip_script('./')
1795
-	. "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1796
-	. (!$args ? '' : "&$args")
1797
-	. (!$ancre ? '' : "#$ancre");
1793
+    return _DIR_RACINE . get_spip_script('./')
1794
+    . "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1795
+    . (!$args ? '' : "&$args")
1796
+    . (!$ancre ? '' : "#$ancre");
1798 1797
 }
1799 1798
 
1800 1799
 
@@ -1805,32 +1804,32 @@  discard block
 block discarded – undo
1805 1804
  * @return string
1806 1805
  */
1807 1806
 function urlencode_1738($url) {
1808
-	if (preg_match(',[^\x00-\x7E],sS', $url)) {
1809
-		$uri = '';
1810
-		for ($i = 0; $i < strlen($url); $i++) {
1811
-			if (ord($a = $url[$i]) > 127) {
1812
-				$a = rawurlencode($a);
1813
-			}
1814
-			$uri .= $a;
1815
-		}
1816
-		$url = $uri;
1817
-	}
1807
+    if (preg_match(',[^\x00-\x7E],sS', $url)) {
1808
+        $uri = '';
1809
+        for ($i = 0; $i < strlen($url); $i++) {
1810
+            if (ord($a = $url[$i]) > 127) {
1811
+                $a = rawurlencode($a);
1812
+            }
1813
+            $uri .= $a;
1814
+        }
1815
+        $url = $uri;
1816
+    }
1818 1817
 
1819
-	return quote_amp($url);
1818
+    return quote_amp($url);
1820 1819
 }
1821 1820
 
1822 1821
 // http://code.spip.net/@generer_url_entite_absolue
1823 1822
 function generer_url_entite_absolue($id = '', $entite = '', $args = '', $ancre = '', $connect = null) {
1824
-	if (!$connect) {
1825
-		$connect = true;
1826
-	}
1827
-	$h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1828
-	if (!preg_match(',^\w+:,', $h)) {
1829
-		include_spip('inc/filtres_mini');
1830
-		$h = url_absolue($h);
1831
-	}
1823
+    if (!$connect) {
1824
+        $connect = true;
1825
+    }
1826
+    $h = generer_url_entite($id, $entite, $args, $ancre, $connect);
1827
+    if (!preg_match(',^\w+:,', $h)) {
1828
+        include_spip('inc/filtres_mini');
1829
+        $h = url_absolue($h);
1830
+    }
1832 1831
 
1833
-	return $h;
1832
+    return $h;
1834 1833
 }
1835 1834
 
1836 1835
 
@@ -1846,11 +1845,11 @@  discard block
 block discarded – undo
1846 1845
  *     true si la valeur est considérée active ; false sinon.
1847 1846
  **/
1848 1847
 function test_valeur_serveur($truc) {
1849
-	if (!$truc) {
1850
-		return false;
1851
-	}
1848
+    if (!$truc) {
1849
+        return false;
1850
+    }
1852 1851
 
1853
-	return (strtolower($truc) !== 'off');
1852
+    return (strtolower($truc) !== 'off');
1854 1853
 }
1855 1854
 
1856 1855
 //
@@ -1878,80 +1877,80 @@  discard block
 block discarded – undo
1878 1877
  */
1879 1878
 function url_de_base($profondeur = null) {
1880 1879
 
1881
-	static $url = array();
1882
-	if (is_array($profondeur)) {
1883
-		return $url = $profondeur;
1884
-	}
1885
-	if ($profondeur === false) {
1886
-		return $url;
1887
-	}
1888
-
1889
-	if (is_null($profondeur)) {
1890
-		$profondeur = $GLOBALS['profondeur_url'];
1891
-	}
1892
-
1893
-	if (isset($url[$profondeur])) {
1894
-		return $url[$profondeur];
1895
-	}
1896
-
1897
-	$http = 'http';
1898
-
1899
-	if (
1900
-		isset($_SERVER["SCRIPT_URI"])
1901
-		and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https'
1902
-	) {
1903
-		$http = 'https';
1904
-	} elseif (
1905
-		isset($_SERVER['HTTPS'])
1906
-		and test_valeur_serveur($_SERVER['HTTPS'])
1907
-	) {
1908
-		$http = 'https';
1909
-	}
1910
-
1911
-	// note : HTTP_HOST contient le :port si necessaire
1912
-	$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
1913
-	// si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
1914
-	if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
1915
-		$host = $GLOBALS['meta']['adresse_site'];
1916
-		if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
1917
-			$http = $scheme;
1918
-			$host = str_replace("{$scheme}://", '', $host);
1919
-		}
1920
-	}
1921
-	if (isset($_SERVER['SERVER_PORT'])
1922
-		and $port = $_SERVER['SERVER_PORT']
1923
-		and strpos($host, ":") == false
1924
-	) {
1925
-		if (!defined('_PORT_HTTP_STANDARD')) {
1926
-			define('_PORT_HTTP_STANDARD', '80');
1927
-		}
1928
-		if (!defined('_PORT_HTTPS_STANDARD')) {
1929
-			define('_PORT_HTTPS_STANDARD', '443');
1930
-		}
1931
-		if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
1932
-			$host .= ":$port";
1933
-		}
1934
-		if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
1935
-			$host .= ":$port";
1936
-		}
1937
-	}
1938
-
1939
-	if (!$GLOBALS['REQUEST_URI']) {
1940
-		if (isset($_SERVER['REQUEST_URI'])) {
1941
-			$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
1942
-		} else {
1943
-			$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
1944
-			if (!empty($_SERVER['QUERY_STRING'])
1945
-				and !strpos($_SERVER['REQUEST_URI'], '?')
1946
-			) {
1947
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
1948
-			}
1949
-		}
1950
-	}
1951
-
1952
-	$url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
1953
-
1954
-	return $url[$profondeur];
1880
+    static $url = array();
1881
+    if (is_array($profondeur)) {
1882
+        return $url = $profondeur;
1883
+    }
1884
+    if ($profondeur === false) {
1885
+        return $url;
1886
+    }
1887
+
1888
+    if (is_null($profondeur)) {
1889
+        $profondeur = $GLOBALS['profondeur_url'];
1890
+    }
1891
+
1892
+    if (isset($url[$profondeur])) {
1893
+        return $url[$profondeur];
1894
+    }
1895
+
1896
+    $http = 'http';
1897
+
1898
+    if (
1899
+        isset($_SERVER["SCRIPT_URI"])
1900
+        and substr($_SERVER["SCRIPT_URI"], 0, 5) == 'https'
1901
+    ) {
1902
+        $http = 'https';
1903
+    } elseif (
1904
+        isset($_SERVER['HTTPS'])
1905
+        and test_valeur_serveur($_SERVER['HTTPS'])
1906
+    ) {
1907
+        $http = 'https';
1908
+    }
1909
+
1910
+    // note : HTTP_HOST contient le :port si necessaire
1911
+    $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
1912
+    // si on n'a pas trouvé d'hôte du tout, en dernier recours on utilise adresse_site comme fallback
1913
+    if (is_null($host) and isset($GLOBALS['meta']['adresse_site'])) {
1914
+        $host = $GLOBALS['meta']['adresse_site'];
1915
+        if ($scheme = parse_url($host, PHP_URL_SCHEME)) {
1916
+            $http = $scheme;
1917
+            $host = str_replace("{$scheme}://", '', $host);
1918
+        }
1919
+    }
1920
+    if (isset($_SERVER['SERVER_PORT'])
1921
+        and $port = $_SERVER['SERVER_PORT']
1922
+        and strpos($host, ":") == false
1923
+    ) {
1924
+        if (!defined('_PORT_HTTP_STANDARD')) {
1925
+            define('_PORT_HTTP_STANDARD', '80');
1926
+        }
1927
+        if (!defined('_PORT_HTTPS_STANDARD')) {
1928
+            define('_PORT_HTTPS_STANDARD', '443');
1929
+        }
1930
+        if ($http == "http" and !in_array($port, explode(',', _PORT_HTTP_STANDARD))) {
1931
+            $host .= ":$port";
1932
+        }
1933
+        if ($http == "https" and !in_array($port, explode(',', _PORT_HTTPS_STANDARD))) {
1934
+            $host .= ":$port";
1935
+        }
1936
+    }
1937
+
1938
+    if (!$GLOBALS['REQUEST_URI']) {
1939
+        if (isset($_SERVER['REQUEST_URI'])) {
1940
+            $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
1941
+        } else {
1942
+            $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
1943
+            if (!empty($_SERVER['QUERY_STRING'])
1944
+                and !strpos($_SERVER['REQUEST_URI'], '?')
1945
+            ) {
1946
+                $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
1947
+            }
1948
+        }
1949
+    }
1950
+
1951
+    $url[$profondeur] = url_de_($http, $host, $GLOBALS['REQUEST_URI'], $profondeur);
1952
+
1953
+    return $url[$profondeur];
1955 1954
 }
1956 1955
 
1957 1956
 /**
@@ -1964,26 +1963,26 @@  discard block
 block discarded – undo
1964 1963
  * @return string
1965 1964
  */
1966 1965
 function url_de_($http, $host, $request, $prof = 0) {
1967
-	$prof = max($prof, 0);
1966
+    $prof = max($prof, 0);
1968 1967
 
1969
-	$myself = ltrim($request, '/');
1970
-	# supprimer la chaine de GET
1971
-	list($myself) = explode('?', $myself);
1972
-	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
1973
-	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
1974
-	if (strpos($myself,'://') !== false) {
1975
-		$myself = explode('://',$myself);
1976
-		array_shift($myself);
1977
-		$myself = implode('://',$myself);
1978
-		$myself = explode('/',$myself);
1979
-		array_shift($myself);
1980
-		$myself = implode('/',$myself);
1981
-	}
1982
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
1968
+    $myself = ltrim($request, '/');
1969
+    # supprimer la chaine de GET
1970
+    list($myself) = explode('?', $myself);
1971
+    // vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
1972
+    // protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
1973
+    if (strpos($myself,'://') !== false) {
1974
+        $myself = explode('://',$myself);
1975
+        array_shift($myself);
1976
+        $myself = implode('://',$myself);
1977
+        $myself = explode('/',$myself);
1978
+        array_shift($myself);
1979
+        $myself = implode('/',$myself);
1980
+    }
1981
+    $url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
1983 1982
 
1984
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
1983
+    $url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
1985 1984
 
1986
-	return $url;
1985
+    return $url;
1987 1986
 }
1988 1987
 
1989 1988
 
@@ -2018,26 +2017,26 @@  discard block
 block discarded – undo
2018 2017
  * @return string URL
2019 2018
  **/
2020 2019
 function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) {
2021
-	if (!$rel) {
2022
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2023
-	} else {
2024
-		if (!is_string($rel)) {
2025
-			$rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2026
-				('./' . _SPIP_ECRIRE_SCRIPT);
2027
-		}
2028
-	}
2029
-
2030
-	list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2031
-	if ($script and ($script <> 'accueil' or $rel)) {
2032
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2033
-	} elseif ($args) {
2034
-		$args = "?$args";
2035
-	}
2036
-	if ($ancre) {
2037
-		$args .= "#$ancre";
2038
-	}
2039
-
2040
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2020
+    if (!$rel) {
2021
+        $rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2022
+    } else {
2023
+        if (!is_string($rel)) {
2024
+            $rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2025
+                ('./' . _SPIP_ECRIRE_SCRIPT);
2026
+        }
2027
+    }
2028
+
2029
+    list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2030
+    if ($script and ($script <> 'accueil' or $rel)) {
2031
+        $args = "?exec=$script" . (!$args ? '' : "&$args");
2032
+    } elseif ($args) {
2033
+        $args = "?$args";
2034
+    }
2035
+    if ($ancre) {
2036
+        $args .= "#$ancre";
2037
+    }
2038
+
2039
+    return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2041 2040
 }
2042 2041
 
2043 2042
 //
@@ -2059,12 +2058,12 @@  discard block
 block discarded – undo
2059 2058
  *     Nom du fichier (constante _SPIP_SCRIPT), sinon nom par défaut
2060 2059
  **/
2061 2060
 function get_spip_script($default = '') {
2062
-	# cas define('_SPIP_SCRIPT', '');
2063
-	if (_SPIP_SCRIPT) {
2064
-		return _SPIP_SCRIPT;
2065
-	} else {
2066
-		return $default;
2067
-	}
2061
+    # cas define('_SPIP_SCRIPT', '');
2062
+    if (_SPIP_SCRIPT) {
2063
+        return _SPIP_SCRIPT;
2064
+    } else {
2065
+        return $default;
2066
+    }
2068 2067
 }
2069 2068
 
2070 2069
 /**
@@ -2093,39 +2092,39 @@  discard block
 block discarded – undo
2093 2092
  * @return string URL
2094 2093
  **/
2095 2094
 function generer_url_public($script = '', $args = "", $no_entities = false, $rel = true, $action = '') {
2096
-	// si le script est une action (spip_pass, spip_inscription),
2097
-	// standardiser vers la nouvelle API
2098
-
2099
-	if (!$action) {
2100
-		$action = get_spip_script();
2101
-	}
2102
-	if ($script) {
2103
-		$action = parametre_url($action, _SPIP_PAGE, $script, '&');
2104
-	}
2105
-
2106
-	if ($args) {
2107
-		if (is_array($args)) {
2108
-			$r = '';
2109
-			foreach ($args as $k => $v) {
2110
-				$r .= '&' . $k . '=' . $v;
2111
-			}
2112
-			$args = substr($r, 1);
2113
-		}
2114
-		$action .=
2115
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2116
-	}
2117
-	if (!$no_entities) {
2118
-		$action = quote_amp($action);
2119
-	}
2120
-
2121
-	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2122
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action"));
2095
+    // si le script est une action (spip_pass, spip_inscription),
2096
+    // standardiser vers la nouvelle API
2097
+
2098
+    if (!$action) {
2099
+        $action = get_spip_script();
2100
+    }
2101
+    if ($script) {
2102
+        $action = parametre_url($action, _SPIP_PAGE, $script, '&');
2103
+    }
2104
+
2105
+    if ($args) {
2106
+        if (is_array($args)) {
2107
+            $r = '';
2108
+            foreach ($args as $k => $v) {
2109
+                $r .= '&' . $k . '=' . $v;
2110
+            }
2111
+            $args = substr($r, 1);
2112
+        }
2113
+        $action .=
2114
+            (strpos($action, '?') !== false ? '&' : '?') . $args;
2115
+    }
2116
+    if (!$no_entities) {
2117
+        $action = quote_amp($action);
2118
+    }
2119
+
2120
+    // ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2121
+    return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action"));
2123 2122
 }
2124 2123
 
2125 2124
 // http://code.spip.net/@generer_url_prive
2126 2125
 function generer_url_prive($script, $args = "", $no_entities = false) {
2127 2126
 
2128
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2127
+    return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2129 2128
 }
2130 2129
 
2131 2130
 // Pour les formulaires en methode POST,
@@ -2150,19 +2149,19 @@  discard block
 block discarded – undo
2150 2149
  **/
2151 2150
 function generer_form_ecrire($script, $corps, $atts = '', $submit = '') {
2152 2151
 
2153
-	$script1 = explode('&', $script);
2154
-	$script1 = reset($script1);
2152
+    $script1 = explode('&', $script);
2153
+    $script1 = reset($script1);
2155 2154
 
2156
-	return "<form action='"
2157
-	. ($script ? generer_url_ecrire($script) : '')
2158
-	. "' "
2159
-	. ($atts ? $atts : " method='post'")
2160
-	. "><div>\n"
2161
-	. "<input type='hidden' name='exec' value='$script1' />"
2162
-	. $corps
2163
-	. (!$submit ? '' :
2164
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>"))
2165
-	. "</div></form>\n";
2155
+    return "<form action='"
2156
+    . ($script ? generer_url_ecrire($script) : '')
2157
+    . "' "
2158
+    . ($atts ? $atts : " method='post'")
2159
+    . "><div>\n"
2160
+    . "<input type='hidden' name='exec' value='$script1' />"
2161
+    . $corps
2162
+    . (!$submit ? '' :
2163
+        ("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>"))
2164
+    . "</div></form>\n";
2166 2165
 }
2167 2166
 
2168 2167
 /**
@@ -2179,22 +2178,22 @@  discard block
 block discarded – undo
2179 2178
  * @return string
2180 2179
  */
2181 2180
 function generer_form_action($script, $corps, $atts = '', $public = false) {
2182
-	// si l'on est dans l'espace prive, on garde dans l'url
2183
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2184
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2185
-	$h = (_DIR_RACINE and !$public)
2186
-		? generer_url_ecrire(_request('exec'))
2187
-		: generer_url_public();
2181
+    // si l'on est dans l'espace prive, on garde dans l'url
2182
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2183
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2184
+    $h = (_DIR_RACINE and !$public)
2185
+        ? generer_url_ecrire(_request('exec'))
2186
+        : generer_url_public();
2188 2187
 
2189
-	return "\n<form action='" .
2190
-	$h .
2191
-	"'" .
2192
-	$atts .
2193
-	">\n" .
2194
-	"<div>" .
2195
-	"\n<input type='hidden' name='action' value='$script' />" .
2196
-	$corps .
2197
-	"</div></form>";
2188
+    return "\n<form action='" .
2189
+    $h .
2190
+    "'" .
2191
+    $atts .
2192
+    ">\n" .
2193
+    "<div>" .
2194
+    "\n<input type='hidden' name='action' value='$script' />" .
2195
+    $corps .
2196
+    "</div></form>";
2198 2197
 }
2199 2198
 
2200 2199
 /**
@@ -2213,22 +2212,22 @@  discard block
 block discarded – undo
2213 2212
  *     URL
2214 2213
  */
2215 2214
 function generer_url_action($script, $args = "", $no_entities = false, $public = false) {
2216
-	// si l'on est dans l'espace prive, on garde dans l'url
2217
-	// l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2218
-	// ou non de proceder a l'authentification (cas typique de l'install par exemple)
2219
-	$url = (_DIR_RACINE and !$public)
2220
-		? generer_url_ecrire(_request('exec'))
2221
-		: generer_url_public('', '', false, false);
2222
-	$url = parametre_url($url, 'action', $script);
2223
-	if ($args) {
2224
-		$url .= quote_amp('&' . $args);
2225
-	}
2215
+    // si l'on est dans l'espace prive, on garde dans l'url
2216
+    // l'exec a l'origine de l'action, qui permet de savoir si il est necessaire
2217
+    // ou non de proceder a l'authentification (cas typique de l'install par exemple)
2218
+    $url = (_DIR_RACINE and !$public)
2219
+        ? generer_url_ecrire(_request('exec'))
2220
+        : generer_url_public('', '', false, false);
2221
+    $url = parametre_url($url, 'action', $script);
2222
+    if ($args) {
2223
+        $url .= quote_amp('&' . $args);
2224
+    }
2226 2225
 
2227
-	if ($no_entities) {
2228
-		$url = str_replace('&amp;', '&', $url);
2229
-	}
2226
+    if ($no_entities) {
2227
+        $url = str_replace('&amp;', '&', $url);
2228
+    }
2230 2229
 
2231
-	return $url;
2230
+    return $url;
2232 2231
 }
2233 2232
 
2234 2233
 
@@ -2241,8 +2240,8 @@  discard block
 block discarded – undo
2241 2240
  * @param string $ta Répertoire temporaire accessible
2242 2241
  */
2243 2242
 function spip_initialisation($pi = null, $pa = null, $ti = null, $ta = null) {
2244
-	spip_initialisation_core($pi, $pa, $ti, $ta);
2245
-	spip_initialisation_suite();
2243
+    spip_initialisation_core($pi, $pa, $ti, $ta);
2244
+    spip_initialisation_suite();
2246 2245
 }
2247 2246
 
2248 2247
 /**
@@ -2262,315 +2261,315 @@  discard block
 block discarded – undo
2262 2261
  * @param string $ta Répertoire temporaire accessible
2263 2262
  */
2264 2263
 function spip_initialisation_core($pi = null, $pa = null, $ti = null, $ta = null) {
2265
-	static $too_late = 0;
2266
-	if ($too_late++) {
2267
-		return;
2268
-	}
2269
-
2270
-	// Declaration des repertoires
2271
-
2272
-	// le nom du repertoire plugins/ activables/desactivables
2273
-	if (!defined('_DIR_PLUGINS')) {
2274
-		define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
2275
-	}
2276
-
2277
-	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2278
-	if (!defined('_DIR_PLUGINS_DIST')) {
2279
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
2280
-	}
2281
-
2282
-	// le nom du repertoire des librairies
2283
-	if (!defined('_DIR_LIB')) {
2284
-		define('_DIR_LIB', _DIR_RACINE . "lib/");
2285
-	}
2286
-
2287
-	if (!defined('_DIR_IMG')) {
2288
-		define('_DIR_IMG', $pa);
2289
-	}
2290
-	if (!defined('_DIR_LOGOS')) {
2291
-		define('_DIR_LOGOS', $pa);
2292
-	}
2293
-	if (!defined('_DIR_IMG_ICONES')) {
2294
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
2295
-	}
2296
-
2297
-	if (!defined('_DIR_DUMP')) {
2298
-		define('_DIR_DUMP', $ti . "dump/");
2299
-	}
2300
-	if (!defined('_DIR_SESSIONS')) {
2301
-		define('_DIR_SESSIONS', $ti . "sessions/");
2302
-	}
2303
-	if (!defined('_DIR_TRANSFERT')) {
2304
-		define('_DIR_TRANSFERT', $ti . "upload/");
2305
-	}
2306
-	if (!defined('_DIR_CACHE')) {
2307
-		define('_DIR_CACHE', $ti . "cache/");
2308
-	}
2309
-	if (!defined('_DIR_CACHE_XML')) {
2310
-		define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
2311
-	}
2312
-	if (!defined('_DIR_SKELS')) {
2313
-		define('_DIR_SKELS', _DIR_CACHE . "skel/");
2314
-	}
2315
-	if (!defined('_DIR_AIDE')) {
2316
-		define('_DIR_AIDE', _DIR_CACHE . "aide/");
2317
-	}
2318
-	if (!defined('_DIR_TMP')) {
2319
-		define('_DIR_TMP', $ti);
2320
-	}
2321
-
2322
-	if (!defined('_DIR_VAR')) {
2323
-		define('_DIR_VAR', $ta);
2324
-	}
2325
-
2326
-	if (!defined('_DIR_ETC')) {
2327
-		define('_DIR_ETC', $pi);
2328
-	}
2329
-	if (!defined('_DIR_CONNECT')) {
2330
-		define('_DIR_CONNECT', $pi);
2331
-	}
2332
-	if (!defined('_DIR_CHMOD')) {
2333
-		define('_DIR_CHMOD', $pi);
2334
-	}
2335
-
2336
-	if (!isset($GLOBALS['test_dirs']))
2337
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2338
-		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2339
-	{
2340
-		$GLOBALS['test_dirs'] = array($pa, $ti, $ta);
2341
-	}
2342
-
2343
-	// Declaration des fichiers
2344
-
2345
-	if (!defined('_CACHE_PLUGINS_PATH')) {
2346
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
2347
-	}
2348
-	if (!defined('_CACHE_PLUGINS_OPT')) {
2349
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
2350
-	}
2351
-	if (!defined('_CACHE_PLUGINS_FCT')) {
2352
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
2353
-	}
2354
-	if (!defined('_CACHE_PIPELINES')) {
2355
-		define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
2356
-	}
2357
-	if (!defined('_CACHE_CHEMIN')) {
2358
-		define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
2359
-	}
2360
-
2361
-	# attention .php obligatoire pour ecrire_fichier_securise
2362
-	if (!defined('_FILE_META')) {
2363
-		define('_FILE_META', $ti . 'meta_cache.php');
2364
-	}
2365
-	if (!defined('_DIR_LOG')) {
2366
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2367
-	}
2368
-	if (!defined('_FILE_LOG')) {
2369
-		define('_FILE_LOG', 'spip');
2370
-	}
2371
-	if (!defined('_FILE_LOG_SUFFIX')) {
2372
-		define('_FILE_LOG_SUFFIX', '.log');
2373
-	}
2374
-
2375
-	// Le fichier de connexion a la base de donnees
2376
-	// tient compte des anciennes versions (inc_connect...)
2377
-	if (!defined('_FILE_CONNECT_INS')) {
2378
-		define('_FILE_CONNECT_INS', 'connect');
2379
-	}
2380
-	if (!defined('_FILE_CONNECT')) {
2381
-		define('_FILE_CONNECT',
2382
-		(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2383
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2384
-				: false)));
2385
-	}
2386
-
2387
-	// Le fichier de reglages des droits
2388
-	if (!defined('_FILE_CHMOD_INS')) {
2389
-		define('_FILE_CHMOD_INS', 'chmod');
2390
-	}
2391
-	if (!defined('_FILE_CHMOD')) {
2392
-		define('_FILE_CHMOD',
2393
-		(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2394
-			: false));
2395
-	}
2396
-
2397
-	if (!defined('_FILE_LDAP')) {
2398
-		define('_FILE_LDAP', 'ldap.php');
2399
-	}
2400
-
2401
-	if (!defined('_FILE_TMP_SUFFIX')) {
2402
-		define('_FILE_TMP_SUFFIX', '.tmp.php');
2403
-	}
2404
-	if (!defined('_FILE_CONNECT_TMP')) {
2405
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2406
-	}
2407
-	if (!defined('_FILE_CHMOD_TMP')) {
2408
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2409
-	}
2410
-
2411
-	// Definition des droits d'acces en ecriture
2412
-	if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2413
-		include_once _FILE_CHMOD;
2414
-	}
2415
-
2416
-	// Se mefier des fichiers mal remplis!
2417
-	if (!defined('_SPIP_CHMOD')) {
2418
-		define('_SPIP_CHMOD', 0777);
2419
-	}
2420
-
2421
-	if (!defined('_DEFAULT_CHARSET')) {
2422
-		/** Le charset par défaut lors de l'installation */
2423
-		define('_DEFAULT_CHARSET', 'utf-8');
2424
-	}
2425
-	if (!defined('_ROOT_PLUGINS')) {
2426
-		define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
2427
-	}
2428
-	if (!defined('_ROOT_PLUGINS_DIST')) {
2429
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
2430
-	}
2431
-	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2432
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2433
-	}
2434
-
2435
-	// La taille des Log
2436
-	if (!defined('_MAX_LOG')) {
2437
-		define('_MAX_LOG', 100);
2438
-	}
2439
-
2440
-	// Sommes-nous dans l'empire du Mal ?
2441
-	// (ou sous le signe du Pingouin, ascendant GNU ?)
2442
-	if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2443
-		if (!defined('_OS_SERVEUR')) {
2444
-			define('_OS_SERVEUR', 'windows');
2445
-		}
2446
-		if (!defined('_SPIP_LOCK_MODE')) {
2447
-			define('_SPIP_LOCK_MODE', 1);
2448
-		} // utiliser le flock php
2449
-	} else {
2450
-		if (!defined('_OS_SERVEUR')) {
2451
-			define('_OS_SERVEUR', '');
2452
-		}
2453
-		if (!defined('_SPIP_LOCK_MODE')) {
2454
-			define('_SPIP_LOCK_MODE', 1);
2455
-		} // utiliser le flock php
2456
-		#if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2457
-	}
2458
-
2459
-	// Langue par defaut
2460
-	if (!defined('_LANGUE_PAR_DEFAUT')) {
2461
-		define('_LANGUE_PAR_DEFAUT', 'fr');
2462
-	}
2463
-
2464
-	//
2465
-	// Module de lecture/ecriture/suppression de fichiers utilisant flock()
2466
-	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2467
-	// pour le rendre surchargeable, on va provoquer un reecriture
2468
-	// systematique du noyau ou une baisse de perfs => a etudier)
2469
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2470
-
2471
-	// charger tout de suite le path et son cache
2472
-	load_path_cache();
2473
-
2474
-	// *********** traiter les variables ************
2475
-
2476
-	//
2477
-	// Securite
2478
-	//
2479
-
2480
-	// Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2481
-	if (isset($_REQUEST['GLOBALS'])) {
2482
-		die();
2483
-	}
2484
-	// nettoyer les magic quotes \' et les caracteres nuls %00
2485
-	spip_desinfecte($_GET);
2486
-	spip_desinfecte($_POST);
2487
-	spip_desinfecte($_COOKIE);
2488
-	spip_desinfecte($_REQUEST);
2489
-
2490
-	// appliquer le cookie_prefix
2491
-	if ($GLOBALS['cookie_prefix'] != 'spip') {
2492
-		include_spip('inc/cookie');
2493
-		recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2494
-	}
2495
-
2496
-	//
2497
-	// Capacites php (en fonction de la version)
2498
-	//
2499
-	$GLOBALS['flag_ob'] = (function_exists("ob_start")
2500
-		&& function_exists("ini_get")
2501
-		&& !strstr(@ini_get('disable_functions'), 'ob_'));
2502
-	$GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name");
2503
-	$GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != "");
2504
-	$GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2505
-		(get_cfg_var('upload_max_filesize') > 0));
2506
-
2507
-
2508
-	// Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2509
-	if (isset($_SERVER['REQUEST_URI'])) {
2510
-		$GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2511
-	} else {
2512
-		$GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2513
-		if (!empty($_SERVER['QUERY_STRING'])
2514
-			and !strpos($_SERVER['REQUEST_URI'], '?')
2515
-		) {
2516
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2517
-		}
2518
-	}
2519
-
2520
-	// Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2521
-	if (!defined('_RENOUVELLE_ALEA')) {
2522
-		define('_RENOUVELLE_ALEA', 12 * 3600);
2523
-	}
2524
-	if (!defined('_DUREE_COOKIE_ADMIN')) {
2525
-		define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2526
-	}
2527
-
2528
-	// charger les meta si possible et renouveller l'alea au besoin
2529
-	// charge aussi effacer_meta et ecrire_meta
2530
-	$inc_meta = charger_fonction('meta', 'inc');
2531
-	$inc_meta();
2532
-
2533
-	// nombre de repertoires depuis la racine
2534
-	// on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2535
-	// ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2536
-	// le calcul est faux)
2537
-	if (!_DIR_RESTREINT) {
2538
-		$GLOBALS['profondeur_url'] = 1;
2539
-	} else {
2540
-		$uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2541
-		$uri_ref = $_SERVER["SCRIPT_NAME"];
2542
-		if (!$uri_ref
2543
-			// si on est appele avec un autre ti, on est sans doute en mutu
2544
-			// si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2545
-			// a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2546
-			// s'en remettre a l'adresse du site. alea jacta est.
2547
-			or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2548
-		) {
2549
-
2550
-			if (isset($GLOBALS['meta']['adresse_site'])) {
2551
-				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2552
-				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2553
-			} else {
2554
-				$uri_ref = "";
2555
-			}
2556
-		}
2557
-		if (!$uri or !$uri_ref) {
2558
-			$GLOBALS['profondeur_url'] = 0;
2559
-		} else {
2560
-			$GLOBALS['profondeur_url'] = max(0,
2561
-				substr_count($uri[0], '/')
2562
-				- substr_count($uri_ref, '/'));
2563
-		}
2564
-	}
2565
-	// s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2566
-	if (_FILE_CONNECT) {
2567
-		if (verifier_visiteur() == '0minirezo'
2568
-			// si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2569
-			and !isset($_COOKIE['spip_admin'])
2570
-		) {
2571
-			clear_path_cache();
2572
-		}
2573
-	}
2264
+    static $too_late = 0;
2265
+    if ($too_late++) {
2266
+        return;
2267
+    }
2268
+
2269
+    // Declaration des repertoires
2270
+
2271
+    // le nom du repertoire plugins/ activables/desactivables
2272
+    if (!defined('_DIR_PLUGINS')) {
2273
+        define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
2274
+    }
2275
+
2276
+    // le nom du repertoire des extensions/ permanentes du core, toujours actives
2277
+    if (!defined('_DIR_PLUGINS_DIST')) {
2278
+        define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
2279
+    }
2280
+
2281
+    // le nom du repertoire des librairies
2282
+    if (!defined('_DIR_LIB')) {
2283
+        define('_DIR_LIB', _DIR_RACINE . "lib/");
2284
+    }
2285
+
2286
+    if (!defined('_DIR_IMG')) {
2287
+        define('_DIR_IMG', $pa);
2288
+    }
2289
+    if (!defined('_DIR_LOGOS')) {
2290
+        define('_DIR_LOGOS', $pa);
2291
+    }
2292
+    if (!defined('_DIR_IMG_ICONES')) {
2293
+        define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
2294
+    }
2295
+
2296
+    if (!defined('_DIR_DUMP')) {
2297
+        define('_DIR_DUMP', $ti . "dump/");
2298
+    }
2299
+    if (!defined('_DIR_SESSIONS')) {
2300
+        define('_DIR_SESSIONS', $ti . "sessions/");
2301
+    }
2302
+    if (!defined('_DIR_TRANSFERT')) {
2303
+        define('_DIR_TRANSFERT', $ti . "upload/");
2304
+    }
2305
+    if (!defined('_DIR_CACHE')) {
2306
+        define('_DIR_CACHE', $ti . "cache/");
2307
+    }
2308
+    if (!defined('_DIR_CACHE_XML')) {
2309
+        define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
2310
+    }
2311
+    if (!defined('_DIR_SKELS')) {
2312
+        define('_DIR_SKELS', _DIR_CACHE . "skel/");
2313
+    }
2314
+    if (!defined('_DIR_AIDE')) {
2315
+        define('_DIR_AIDE', _DIR_CACHE . "aide/");
2316
+    }
2317
+    if (!defined('_DIR_TMP')) {
2318
+        define('_DIR_TMP', $ti);
2319
+    }
2320
+
2321
+    if (!defined('_DIR_VAR')) {
2322
+        define('_DIR_VAR', $ta);
2323
+    }
2324
+
2325
+    if (!defined('_DIR_ETC')) {
2326
+        define('_DIR_ETC', $pi);
2327
+    }
2328
+    if (!defined('_DIR_CONNECT')) {
2329
+        define('_DIR_CONNECT', $pi);
2330
+    }
2331
+    if (!defined('_DIR_CHMOD')) {
2332
+        define('_DIR_CHMOD', $pi);
2333
+    }
2334
+
2335
+    if (!isset($GLOBALS['test_dirs']))
2336
+        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
2337
+        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2338
+    {
2339
+        $GLOBALS['test_dirs'] = array($pa, $ti, $ta);
2340
+    }
2341
+
2342
+    // Declaration des fichiers
2343
+
2344
+    if (!defined('_CACHE_PLUGINS_PATH')) {
2345
+        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
2346
+    }
2347
+    if (!defined('_CACHE_PLUGINS_OPT')) {
2348
+        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
2349
+    }
2350
+    if (!defined('_CACHE_PLUGINS_FCT')) {
2351
+        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
2352
+    }
2353
+    if (!defined('_CACHE_PIPELINES')) {
2354
+        define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
2355
+    }
2356
+    if (!defined('_CACHE_CHEMIN')) {
2357
+        define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
2358
+    }
2359
+
2360
+    # attention .php obligatoire pour ecrire_fichier_securise
2361
+    if (!defined('_FILE_META')) {
2362
+        define('_FILE_META', $ti . 'meta_cache.php');
2363
+    }
2364
+    if (!defined('_DIR_LOG')) {
2365
+        define('_DIR_LOG', _DIR_TMP . 'log/');
2366
+    }
2367
+    if (!defined('_FILE_LOG')) {
2368
+        define('_FILE_LOG', 'spip');
2369
+    }
2370
+    if (!defined('_FILE_LOG_SUFFIX')) {
2371
+        define('_FILE_LOG_SUFFIX', '.log');
2372
+    }
2373
+
2374
+    // Le fichier de connexion a la base de donnees
2375
+    // tient compte des anciennes versions (inc_connect...)
2376
+    if (!defined('_FILE_CONNECT_INS')) {
2377
+        define('_FILE_CONNECT_INS', 'connect');
2378
+    }
2379
+    if (!defined('_FILE_CONNECT')) {
2380
+        define('_FILE_CONNECT',
2381
+        (@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2382
+            : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2383
+                : false)));
2384
+    }
2385
+
2386
+    // Le fichier de reglages des droits
2387
+    if (!defined('_FILE_CHMOD_INS')) {
2388
+        define('_FILE_CHMOD_INS', 'chmod');
2389
+    }
2390
+    if (!defined('_FILE_CHMOD')) {
2391
+        define('_FILE_CHMOD',
2392
+        (@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2393
+            : false));
2394
+    }
2395
+
2396
+    if (!defined('_FILE_LDAP')) {
2397
+        define('_FILE_LDAP', 'ldap.php');
2398
+    }
2399
+
2400
+    if (!defined('_FILE_TMP_SUFFIX')) {
2401
+        define('_FILE_TMP_SUFFIX', '.tmp.php');
2402
+    }
2403
+    if (!defined('_FILE_CONNECT_TMP')) {
2404
+        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2405
+    }
2406
+    if (!defined('_FILE_CHMOD_TMP')) {
2407
+        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2408
+    }
2409
+
2410
+    // Definition des droits d'acces en ecriture
2411
+    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
2412
+        include_once _FILE_CHMOD;
2413
+    }
2414
+
2415
+    // Se mefier des fichiers mal remplis!
2416
+    if (!defined('_SPIP_CHMOD')) {
2417
+        define('_SPIP_CHMOD', 0777);
2418
+    }
2419
+
2420
+    if (!defined('_DEFAULT_CHARSET')) {
2421
+        /** Le charset par défaut lors de l'installation */
2422
+        define('_DEFAULT_CHARSET', 'utf-8');
2423
+    }
2424
+    if (!defined('_ROOT_PLUGINS')) {
2425
+        define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
2426
+    }
2427
+    if (!defined('_ROOT_PLUGINS_DIST')) {
2428
+        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
2429
+    }
2430
+    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2431
+        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2432
+    }
2433
+
2434
+    // La taille des Log
2435
+    if (!defined('_MAX_LOG')) {
2436
+        define('_MAX_LOG', 100);
2437
+    }
2438
+
2439
+    // Sommes-nous dans l'empire du Mal ?
2440
+    // (ou sous le signe du Pingouin, ascendant GNU ?)
2441
+    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
2442
+        if (!defined('_OS_SERVEUR')) {
2443
+            define('_OS_SERVEUR', 'windows');
2444
+        }
2445
+        if (!defined('_SPIP_LOCK_MODE')) {
2446
+            define('_SPIP_LOCK_MODE', 1);
2447
+        } // utiliser le flock php
2448
+    } else {
2449
+        if (!defined('_OS_SERVEUR')) {
2450
+            define('_OS_SERVEUR', '');
2451
+        }
2452
+        if (!defined('_SPIP_LOCK_MODE')) {
2453
+            define('_SPIP_LOCK_MODE', 1);
2454
+        } // utiliser le flock php
2455
+        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
2456
+    }
2457
+
2458
+    // Langue par defaut
2459
+    if (!defined('_LANGUE_PAR_DEFAUT')) {
2460
+        define('_LANGUE_PAR_DEFAUT', 'fr');
2461
+    }
2462
+
2463
+    //
2464
+    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
2465
+    // (non surchargeable en l'etat ; attention si on utilise include_spip()
2466
+    // pour le rendre surchargeable, on va provoquer un reecriture
2467
+    // systematique du noyau ou une baisse de perfs => a etudier)
2468
+    include_once _ROOT_RESTREINT . 'inc/flock.php';
2469
+
2470
+    // charger tout de suite le path et son cache
2471
+    load_path_cache();
2472
+
2473
+    // *********** traiter les variables ************
2474
+
2475
+    //
2476
+    // Securite
2477
+    //
2478
+
2479
+    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
2480
+    if (isset($_REQUEST['GLOBALS'])) {
2481
+        die();
2482
+    }
2483
+    // nettoyer les magic quotes \' et les caracteres nuls %00
2484
+    spip_desinfecte($_GET);
2485
+    spip_desinfecte($_POST);
2486
+    spip_desinfecte($_COOKIE);
2487
+    spip_desinfecte($_REQUEST);
2488
+
2489
+    // appliquer le cookie_prefix
2490
+    if ($GLOBALS['cookie_prefix'] != 'spip') {
2491
+        include_spip('inc/cookie');
2492
+        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
2493
+    }
2494
+
2495
+    //
2496
+    // Capacites php (en fonction de la version)
2497
+    //
2498
+    $GLOBALS['flag_ob'] = (function_exists("ob_start")
2499
+        && function_exists("ini_get")
2500
+        && !strstr(@ini_get('disable_functions'), 'ob_'));
2501
+    $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name");
2502
+    $GLOBALS['flag_get_cfg_var'] = (@get_cfg_var('error_reporting') != "");
2503
+    $GLOBALS['flag_upload'] = (!$GLOBALS['flag_get_cfg_var'] ||
2504
+        (get_cfg_var('upload_max_filesize') > 0));
2505
+
2506
+
2507
+    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
2508
+    if (isset($_SERVER['REQUEST_URI'])) {
2509
+        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
2510
+    } else {
2511
+        $GLOBALS['REQUEST_URI'] = (php_sapi_name() !== 'cli') ? $_SERVER['PHP_SELF'] : '';
2512
+        if (!empty($_SERVER['QUERY_STRING'])
2513
+            and !strpos($_SERVER['REQUEST_URI'], '?')
2514
+        ) {
2515
+            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2516
+        }
2517
+    }
2518
+
2519
+    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
2520
+    if (!defined('_RENOUVELLE_ALEA')) {
2521
+        define('_RENOUVELLE_ALEA', 12 * 3600);
2522
+    }
2523
+    if (!defined('_DUREE_COOKIE_ADMIN')) {
2524
+        define('_DUREE_COOKIE_ADMIN', 14 * 24 * 3600);
2525
+    }
2526
+
2527
+    // charger les meta si possible et renouveller l'alea au besoin
2528
+    // charge aussi effacer_meta et ecrire_meta
2529
+    $inc_meta = charger_fonction('meta', 'inc');
2530
+    $inc_meta();
2531
+
2532
+    // nombre de repertoires depuis la racine
2533
+    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
2534
+    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
2535
+    // le calcul est faux)
2536
+    if (!_DIR_RESTREINT) {
2537
+        $GLOBALS['profondeur_url'] = 1;
2538
+    } else {
2539
+        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
2540
+        $uri_ref = $_SERVER["SCRIPT_NAME"];
2541
+        if (!$uri_ref
2542
+            // si on est appele avec un autre ti, on est sans doute en mutu
2543
+            // si jamais c'est de la mutu avec sous rep, on est perdu si on se fie
2544
+            // a spip.php qui est a la racine du spip, et vue qu'on sait pas se reperer
2545
+            // s'en remettre a l'adresse du site. alea jacta est.
2546
+            or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES
2547
+        ) {
2548
+
2549
+            if (isset($GLOBALS['meta']['adresse_site'])) {
2550
+                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2551
+                $uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2552
+            } else {
2553
+                $uri_ref = "";
2554
+            }
2555
+        }
2556
+        if (!$uri or !$uri_ref) {
2557
+            $GLOBALS['profondeur_url'] = 0;
2558
+        } else {
2559
+            $GLOBALS['profondeur_url'] = max(0,
2560
+                substr_count($uri[0], '/')
2561
+                - substr_count($uri_ref, '/'));
2562
+        }
2563
+    }
2564
+    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
2565
+    if (_FILE_CONNECT) {
2566
+        if (verifier_visiteur() == '0minirezo'
2567
+            // si c'est un admin sans cookie admin, il faut ignorer le cache chemin !
2568
+            and !isset($_COOKIE['spip_admin'])
2569
+        ) {
2570
+            clear_path_cache();
2571
+        }
2572
+    }
2574 2573
 
2575 2574
 }
2576 2575
 
@@ -2580,174 +2579,174 @@  discard block
 block discarded – undo
2580 2579
  *
2581 2580
  */
2582 2581
 function spip_initialisation_suite() {
2583
-	static $too_late = 0;
2584
-	if ($too_late++) {
2585
-		return;
2586
-	}
2587
-
2588
-	// taille mini des login
2589
-	if (!defined('_LOGIN_TROP_COURT')) {
2590
-		define('_LOGIN_TROP_COURT', 4);
2591
-	}
2592
-
2593
-	// la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2594
-	#if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2595
-	#if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2596
-	#if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2597
-
2598
-	// la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2599
-	#if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2600
-	#if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2601
-	#if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2602
-	#if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2603
-
2604
-	if (!defined('_PASS_LONGUEUR_MINI')) {
2605
-		define('_PASS_LONGUEUR_MINI', 6);
2606
-	}
2607
-
2608
-
2609
-	// Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2610
-	if (!defined('_IMG_QUALITE')) {
2611
-		define('_IMG_QUALITE', 85);
2612
-	} # valeur par defaut
2613
-	if (!defined('_IMG_GD_QUALITE')) {
2614
-		define('_IMG_GD_QUALITE', _IMG_QUALITE);
2615
-	} # surcharge pour la lib GD
2616
-	if (!defined('_IMG_CONVERT_QUALITE')) {
2617
-		define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2618
-	} # surcharge pour imagick en ligne de commande
2619
-	// Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2620
-	if (!defined('_IMG_IMAGICK_QUALITE')) {
2621
-		define('_IMG_IMAGICK_QUALITE', 75);
2622
-	} # surcharge pour imagick en PHP
2623
-
2624
-	if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2625
-		define('_COPIE_LOCALE_MAX_SIZE', 33554432);
2626
-	} // poids en octet
2627
-
2628
-	// qq chaines standard
2629
-	if (!defined('_ACCESS_FILE_NAME')) {
2630
-		define('_ACCESS_FILE_NAME', '.htaccess');
2631
-	}
2632
-	if (!defined('_AUTH_USER_FILE')) {
2633
-		define('_AUTH_USER_FILE', '.htpasswd');
2634
-	}
2635
-	if (!defined('_SPIP_DUMP')) {
2636
-		define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2637
-	}
2638
-	if (!defined('_CACHE_RUBRIQUES')) {
2639
-		/** Fichier cache pour le navigateur de rubrique du bandeau */
2640
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2641
-	}
2642
-	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2643
-		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2644
-		define('_CACHE_RUBRIQUES_MAX', 500);
2645
-	}
2646
-
2647
-	if (!defined('_EXTENSION_SQUELETTES')) {
2648
-		define('_EXTENSION_SQUELETTES', 'html');
2649
-	}
2650
-
2651
-	if (!defined('_DOCTYPE_ECRIRE')) {
2652
-		/** Définit le doctype de l’espace privé */
2653
-		define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2654
-	}
2655
-	if (!defined('_DOCTYPE_AIDE')) {
2656
-		/** Définit le doctype de l’aide en ligne */
2657
-		define('_DOCTYPE_AIDE',
2658
-		"<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");
2659
-	}
2660
-
2661
-	if (!defined('_SPIP_SCRIPT')) {
2662
-		/** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2663
-		 * le script de l'espace public, alias index.php */
2664
-		define('_SPIP_SCRIPT', 'spip.php');
2665
-	}
2666
-	if (!defined('_SPIP_PAGE')) {
2667
-		/** Argument page, personalisable en cas de conflit avec un autre script */
2668
-		define('_SPIP_PAGE', 'page');
2669
-	}
2670
-
2671
-	// le script de l'espace prive
2672
-	// Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2673
-	// les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2674
-	// meme pb sur thttpd cf. http://forum.spip.net/fr_184153.html
2675
-	if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2676
-		if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2677
-			define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2678
-		} else {
2679
-			define('_SPIP_ECRIRE_SCRIPT', '');
2680
-		}
2681
-	}
2682
-
2683
-
2684
-	if (!defined('_SPIP_AJAX')) {
2685
-		define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2686
-			? 1
2687
-			: (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2688
-	}
2689
-
2690
-	// La requete est-elle en ajax ?
2691
-	if (!defined('_AJAX')) {
2692
-		define('_AJAX',
2693
-			(isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2694
-				or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2695
-				or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2696
-				or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2697
-			)
2698
-			and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient
2699
-		);
2700
-	}
2701
-
2702
-	# nombre de pixels maxi pour calcul de la vignette avec gd
2703
-	# au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2704
-	# les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2705
-	if (!defined('_IMG_GD_MAX_PIXELS')) {
2706
-		define('_IMG_GD_MAX_PIXELS',
2707
-		(isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2708
-			? $GLOBALS['meta']['max_taille_vignettes']
2709
-			: 0);
2710
-	}
2711
-
2712
-	if (!defined('_MEMORY_LIMIT_MIN')) {
2713
-		define('_MEMORY_LIMIT_MIN', 16);
2714
-	} // en Mo
2715
-	// si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2716
-	// on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2717
-	// il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2718
-	if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2719
-		if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2720
-			$unit = strtolower(substr($memory, -1));
2721
-			$memory = substr($memory, 0, -1);
2722
-			switch ($unit) {
2723
-				// Le modifieur 'G' est disponible depuis PHP 5.1.0
2724
-				case 'g':
2725
-					$memory *= 1024;
2726
-				case 'm':
2727
-					$memory *= 1024;
2728
-				case 'k':
2729
-					$memory *= 1024;
2730
-			}
2731
-			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2732
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2733
-				if (trim(ini_get('memory_limit')) != $m) {
2734
-					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2735
-						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2736
-					} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2737
-				}
2738
-			}
2739
-		} else {
2740
-			if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2741
-				define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2742
-			}
2743
-		} // evite une page blanche car on ne saura pas calculer la css dans ce hit
2744
-	}
2745
-	// Protocoles a normaliser dans les chaines de langues
2746
-	if (!defined('_PROTOCOLES_STD')) {
2747
-		define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2748
-	}
2749
-
2750
-	init_var_mode();
2582
+    static $too_late = 0;
2583
+    if ($too_late++) {
2584
+        return;
2585
+    }
2586
+
2587
+    // taille mini des login
2588
+    if (!defined('_LOGIN_TROP_COURT')) {
2589
+        define('_LOGIN_TROP_COURT', 4);
2590
+    }
2591
+
2592
+    // la taille maxi des logos (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2593
+    #if (!defined('_LOGO_MAX_SIZE')) define('_LOGO_MAX_SIZE', 0); # poids en ko
2594
+    #if (!defined('_LOGO_MAX_WIDTH')) define('_LOGO_MAX_WIDTH', 0); # largeur en pixels
2595
+    #if (!defined('_LOGO_MAX_HEIGHT')) define('_LOGO_MAX_HEIGHT', 0); # hauteur en pixels
2596
+
2597
+    // la taille maxi des images (0 : pas de limite) (pas de define par defaut, ce n'est pas utile)
2598
+    #if (!defined('_DOC_MAX_SIZE')) define('_DOC_MAX_SIZE', 0); # poids en ko
2599
+    #if (!defined('_IMG_MAX_SIZE')) define('_IMG_MAX_SIZE', 0); # poids en ko
2600
+    #if (!defined('_IMG_MAX_WIDTH')) define('_IMG_MAX_WIDTH', 0); # largeur en pixels
2601
+    #if (!defined('_IMG_MAX_HEIGHT')) define('_IMG_MAX_HEIGHT', 0); # hauteur en pixels
2602
+
2603
+    if (!defined('_PASS_LONGUEUR_MINI')) {
2604
+        define('_PASS_LONGUEUR_MINI', 6);
2605
+    }
2606
+
2607
+
2608
+    // Qualite des images calculees automatiquement. C'est un nombre entre 0 et 100, meme pour imagick (on ramene a 0..1 par la suite)
2609
+    if (!defined('_IMG_QUALITE')) {
2610
+        define('_IMG_QUALITE', 85);
2611
+    } # valeur par defaut
2612
+    if (!defined('_IMG_GD_QUALITE')) {
2613
+        define('_IMG_GD_QUALITE', _IMG_QUALITE);
2614
+    } # surcharge pour la lib GD
2615
+    if (!defined('_IMG_CONVERT_QUALITE')) {
2616
+        define('_IMG_CONVERT_QUALITE', _IMG_QUALITE);
2617
+    } # surcharge pour imagick en ligne de commande
2618
+    // Historiquement la valeur pour imagick semble differente. Si ca n'est pas necessaire, il serait preferable de garder _IMG_QUALITE
2619
+    if (!defined('_IMG_IMAGICK_QUALITE')) {
2620
+        define('_IMG_IMAGICK_QUALITE', 75);
2621
+    } # surcharge pour imagick en PHP
2622
+
2623
+    if (!defined('_COPIE_LOCALE_MAX_SIZE')) {
2624
+        define('_COPIE_LOCALE_MAX_SIZE', 33554432);
2625
+    } // poids en octet
2626
+
2627
+    // qq chaines standard
2628
+    if (!defined('_ACCESS_FILE_NAME')) {
2629
+        define('_ACCESS_FILE_NAME', '.htaccess');
2630
+    }
2631
+    if (!defined('_AUTH_USER_FILE')) {
2632
+        define('_AUTH_USER_FILE', '.htpasswd');
2633
+    }
2634
+    if (!defined('_SPIP_DUMP')) {
2635
+        define('_SPIP_DUMP', 'dump@nom_site@@[email protected]');
2636
+    }
2637
+    if (!defined('_CACHE_RUBRIQUES')) {
2638
+        /** Fichier cache pour le navigateur de rubrique du bandeau */
2639
+        define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2640
+    }
2641
+    if (!defined('_CACHE_RUBRIQUES_MAX')) {
2642
+        /** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
2643
+        define('_CACHE_RUBRIQUES_MAX', 500);
2644
+    }
2645
+
2646
+    if (!defined('_EXTENSION_SQUELETTES')) {
2647
+        define('_EXTENSION_SQUELETTES', 'html');
2648
+    }
2649
+
2650
+    if (!defined('_DOCTYPE_ECRIRE')) {
2651
+        /** Définit le doctype de l’espace privé */
2652
+        define('_DOCTYPE_ECRIRE', "<!DOCTYPE html>\n");
2653
+    }
2654
+    if (!defined('_DOCTYPE_AIDE')) {
2655
+        /** Définit le doctype de l’aide en ligne */
2656
+        define('_DOCTYPE_AIDE',
2657
+        "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Frameset//EN' 'http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd'>");
2658
+    }
2659
+
2660
+    if (!defined('_SPIP_SCRIPT')) {
2661
+        /** L'adresse de base du site ; on peut mettre '' si la racine est gerée par
2662
+         * le script de l'espace public, alias index.php */
2663
+        define('_SPIP_SCRIPT', 'spip.php');
2664
+    }
2665
+    if (!defined('_SPIP_PAGE')) {
2666
+        /** Argument page, personalisable en cas de conflit avec un autre script */
2667
+        define('_SPIP_PAGE', 'page');
2668
+    }
2669
+
2670
+    // le script de l'espace prive
2671
+    // Mettre a "index.php" si DirectoryIndex ne le fait pas ou pb connexes:
2672
+    // les anciens IIS n'acceptent pas les POST sur ecrire/ (#419)
2673
+    // meme pb sur thttpd cf. http://forum.spip.net/fr_184153.html
2674
+    if (!defined('_SPIP_ECRIRE_SCRIPT')) {
2675
+        if (!empty($_SERVER['SERVER_SOFTWARE']) and preg_match(',IIS|thttpd,', $_SERVER['SERVER_SOFTWARE'])) {
2676
+            define('_SPIP_ECRIRE_SCRIPT', 'index.php');
2677
+        } else {
2678
+            define('_SPIP_ECRIRE_SCRIPT', '');
2679
+        }
2680
+    }
2681
+
2682
+
2683
+    if (!defined('_SPIP_AJAX')) {
2684
+        define('_SPIP_AJAX', ((!isset($_COOKIE['spip_accepte_ajax']))
2685
+            ? 1
2686
+            : (($_COOKIE['spip_accepte_ajax'] != -1) ? 1 : 0)));
2687
+    }
2688
+
2689
+    // La requete est-elle en ajax ?
2690
+    if (!defined('_AJAX')) {
2691
+        define('_AJAX',
2692
+            (isset($_SERVER['HTTP_X_REQUESTED_WITH']) # ajax jQuery
2693
+                or !empty($_REQUEST['var_ajax_redir']) # redirection 302 apres ajax jQuery
2694
+                or !empty($_REQUEST['var_ajaxcharset']) # compat ascendante pour plugins
2695
+                or !empty($_REQUEST['var_ajax']) # forms ajax & inclure ajax de spip
2696
+            )
2697
+            and empty($_REQUEST['var_noajax']) # horrible exception, car c'est pas parce que la requete est ajax jquery qu'il faut tuer tous les formulaires ajax qu'elle contient
2698
+        );
2699
+    }
2700
+
2701
+    # nombre de pixels maxi pour calcul de la vignette avec gd
2702
+    # au dela de 5500000 on considere que php n'est pas limite en memoire pour cette operation
2703
+    # les configurations limitees en memoire ont un seuil plutot vers 1MPixel
2704
+    if (!defined('_IMG_GD_MAX_PIXELS')) {
2705
+        define('_IMG_GD_MAX_PIXELS',
2706
+        (isset($GLOBALS['meta']['max_taille_vignettes']) and $GLOBALS['meta']['max_taille_vignettes'])
2707
+            ? $GLOBALS['meta']['max_taille_vignettes']
2708
+            : 0);
2709
+    }
2710
+
2711
+    if (!defined('_MEMORY_LIMIT_MIN')) {
2712
+        define('_MEMORY_LIMIT_MIN', 16);
2713
+    } // en Mo
2714
+    // si on est dans l'espace prive et si le besoin est superieur a 8Mo (qui est vraiment le standard)
2715
+    // on verifie que la memoire est suffisante pour le compactage css+js pour eviter la page blanche
2716
+    // il y aura d'autres problemes et l'utilisateur n'ira pas tres loin, mais ce sera plus comprehensible qu'une page blanche
2717
+    if (test_espace_prive() and _MEMORY_LIMIT_MIN > 8) {
2718
+        if ($memory = trim(ini_get('memory_limit')) and $memory != -1) {
2719
+            $unit = strtolower(substr($memory, -1));
2720
+            $memory = substr($memory, 0, -1);
2721
+            switch ($unit) {
2722
+                // Le modifieur 'G' est disponible depuis PHP 5.1.0
2723
+                case 'g':
2724
+                    $memory *= 1024;
2725
+                case 'm':
2726
+                    $memory *= 1024;
2727
+                case 'k':
2728
+                    $memory *= 1024;
2729
+            }
2730
+            if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2731
+                @ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2732
+                if (trim(ini_get('memory_limit')) != $m) {
2733
+                    if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2734
+                        define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2735
+                    } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2736
+                }
2737
+            }
2738
+        } else {
2739
+            if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2740
+                define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
2741
+            }
2742
+        } // evite une page blanche car on ne saura pas calculer la css dans ce hit
2743
+    }
2744
+    // Protocoles a normaliser dans les chaines de langues
2745
+    if (!defined('_PROTOCOLES_STD')) {
2746
+        define('_PROTOCOLES_STD', 'http|https|ftp|mailto|webcal');
2747
+    }
2748
+
2749
+    init_var_mode();
2751 2750
 }
2752 2751
 
2753 2752
 /**
@@ -2781,129 +2780,129 @@  discard block
 block discarded – undo
2781 2780
  * `   var_mode` (calcul ou recalcul).
2782 2781
  */
2783 2782
 function init_var_mode() {
2784
-	static $done = false;
2785
-	if (!$done) {
2786
-
2787
-		if (isset($_GET['var_mode'])) {
2788
-			$var_mode = explode(',', $_GET['var_mode']);
2789
-			// tout le monde peut calcul/recalcul
2790
-			if (!defined('_VAR_MODE')) {
2791
-				if (in_array('recalcul', $var_mode)) {
2792
-					define('_VAR_MODE', 'recalcul');
2793
-				} elseif (in_array('calcul', $var_mode)) {
2794
-					define('_VAR_MODE', 'calcul');
2795
-				}
2796
-			}
2797
-			$var_mode = array_diff($var_mode, array('calcul', 'recalcul'));
2798
-			if ($var_mode) {
2799
-				include_spip('inc/autoriser');
2800
-				// autoriser preview si preview seulement, et sinon autoriser debug
2801
-				if (autoriser(
2802
-					($_GET['var_mode'] == 'preview')
2803
-						? 'previsualiser'
2804
-						: 'debug'
2805
-				)) {
2806
-					if (in_array('traduction', $var_mode)) {
2807
-						// forcer le calcul pour passer dans traduire
2808
-						if (!defined('_VAR_MODE')) {
2809
-							define('_VAR_MODE', 'calcul');
2810
-						}
2811
-						// et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2812
-						if (!defined('_VAR_NOCACHE')) {
2813
-							define('_VAR_NOCACHE', true);
2814
-						}
2815
-						$var_mode = array_diff($var_mode, array('traduction'));
2816
-					}
2817
-					if (in_array('preview', $var_mode)) {
2818
-						// basculer sur les criteres de preview dans les boucles
2819
-						if (!defined('_VAR_PREVIEW')) {
2820
-							define('_VAR_PREVIEW', true);
2821
-						}
2822
-						// forcer le calcul
2823
-						if (!defined('_VAR_MODE')) {
2824
-							define('_VAR_MODE', 'calcul');
2825
-						}
2826
-						// et ne pas enregistrer de cache
2827
-						if (!defined('_VAR_NOCACHE')) {
2828
-							define('_VAR_NOCACHE', true);
2829
-						}
2830
-						$var_mode = array_diff($var_mode, array('preview'));
2831
-					}
2832
-					if (in_array('inclure', $var_mode)) {
2833
-						// forcer le compilo et ignorer les caches existants
2834
-						if (!defined('_VAR_MODE')) {
2835
-							define('_VAR_MODE', 'calcul');
2836
-						}
2837
-						if (!defined('_VAR_INCLURE')) {
2838
-							define('_VAR_INCLURE', true);
2839
-						}
2840
-						// et ne pas enregistrer de cache
2841
-						if (!defined('_VAR_NOCACHE')) {
2842
-							define('_VAR_NOCACHE', true);
2843
-						}
2844
-						$var_mode = array_diff($var_mode, array('inclure'));
2845
-					}
2846
-					if (in_array('urls', $var_mode)) {
2847
-						// forcer le compilo et ignorer les caches existants
2848
-						if (!defined('_VAR_MODE')) {
2849
-							define('_VAR_MODE', 'calcul');
2850
-						}
2851
-						if (!defined('_VAR_URLS')) {
2852
-							define('_VAR_URLS', true);
2853
-						}
2854
-						$var_mode = array_diff($var_mode, array('urls'));
2855
-					}
2856
-					if (in_array('images', $var_mode)) {
2857
-						// forcer le compilo et ignorer les caches existants
2858
-						if (!defined('_VAR_MODE')) {
2859
-							define('_VAR_MODE', 'calcul');
2860
-						}
2861
-						// indiquer qu'on doit recalculer les images
2862
-						if (!defined('_VAR_IMAGES')) {
2863
-							define('_VAR_IMAGES', true);
2864
-						}
2865
-						$var_mode = array_diff($var_mode, array('images'));
2866
-					}
2867
-					if (in_array('debug', $var_mode)) {
2868
-						if (!defined('_VAR_MODE')) {
2869
-							define('_VAR_MODE', 'debug');
2870
-						}
2871
-						// et ne pas enregistrer de cache
2872
-						if (!defined('_VAR_NOCACHE')) {
2873
-							define('_VAR_NOCACHE', true);
2874
-						}
2875
-						$var_mode = array_diff($var_mode, array('debug'));
2876
-					}
2877
-					if (count($var_mode) and !defined('_VAR_MODE')) {
2878
-						define('_VAR_MODE', reset($var_mode));
2879
-					}
2880
-					if (isset($GLOBALS['visiteur_session']['nom'])) {
2881
-						spip_log($GLOBALS['visiteur_session']['nom']
2882
-							. " " . _VAR_MODE);
2883
-					}
2884
-				} // pas autorise ?
2885
-				else {
2886
-					// si on n'est pas connecte on se redirige
2887
-					if (!$GLOBALS['visiteur_session']) {
2888
-						include_spip('inc/headers');
2889
-						redirige_par_entete(generer_url_public('login',
2890
-							'url=' . rawurlencode(
2891
-								parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')
2892
-							), true));
2893
-					}
2894
-					// sinon tant pis
2895
-				}
2896
-			}
2897
-		}
2898
-		if (!defined('_VAR_MODE')) {
2899
-			/**
2900
-			 * Indique le mode de calcul ou d'affichage de la page.
2901
-			 * @see init_var_mode()
2902
-			 */
2903
-			define('_VAR_MODE', false);
2904
-		}
2905
-		$done = true;
2906
-	}
2783
+    static $done = false;
2784
+    if (!$done) {
2785
+
2786
+        if (isset($_GET['var_mode'])) {
2787
+            $var_mode = explode(',', $_GET['var_mode']);
2788
+            // tout le monde peut calcul/recalcul
2789
+            if (!defined('_VAR_MODE')) {
2790
+                if (in_array('recalcul', $var_mode)) {
2791
+                    define('_VAR_MODE', 'recalcul');
2792
+                } elseif (in_array('calcul', $var_mode)) {
2793
+                    define('_VAR_MODE', 'calcul');
2794
+                }
2795
+            }
2796
+            $var_mode = array_diff($var_mode, array('calcul', 'recalcul'));
2797
+            if ($var_mode) {
2798
+                include_spip('inc/autoriser');
2799
+                // autoriser preview si preview seulement, et sinon autoriser debug
2800
+                if (autoriser(
2801
+                    ($_GET['var_mode'] == 'preview')
2802
+                        ? 'previsualiser'
2803
+                        : 'debug'
2804
+                )) {
2805
+                    if (in_array('traduction', $var_mode)) {
2806
+                        // forcer le calcul pour passer dans traduire
2807
+                        if (!defined('_VAR_MODE')) {
2808
+                            define('_VAR_MODE', 'calcul');
2809
+                        }
2810
+                        // et ne pas enregistrer de cache pour ne pas trainer les surlignages sur d'autres pages
2811
+                        if (!defined('_VAR_NOCACHE')) {
2812
+                            define('_VAR_NOCACHE', true);
2813
+                        }
2814
+                        $var_mode = array_diff($var_mode, array('traduction'));
2815
+                    }
2816
+                    if (in_array('preview', $var_mode)) {
2817
+                        // basculer sur les criteres de preview dans les boucles
2818
+                        if (!defined('_VAR_PREVIEW')) {
2819
+                            define('_VAR_PREVIEW', true);
2820
+                        }
2821
+                        // forcer le calcul
2822
+                        if (!defined('_VAR_MODE')) {
2823
+                            define('_VAR_MODE', 'calcul');
2824
+                        }
2825
+                        // et ne pas enregistrer de cache
2826
+                        if (!defined('_VAR_NOCACHE')) {
2827
+                            define('_VAR_NOCACHE', true);
2828
+                        }
2829
+                        $var_mode = array_diff($var_mode, array('preview'));
2830
+                    }
2831
+                    if (in_array('inclure', $var_mode)) {
2832
+                        // forcer le compilo et ignorer les caches existants
2833
+                        if (!defined('_VAR_MODE')) {
2834
+                            define('_VAR_MODE', 'calcul');
2835
+                        }
2836
+                        if (!defined('_VAR_INCLURE')) {
2837
+                            define('_VAR_INCLURE', true);
2838
+                        }
2839
+                        // et ne pas enregistrer de cache
2840
+                        if (!defined('_VAR_NOCACHE')) {
2841
+                            define('_VAR_NOCACHE', true);
2842
+                        }
2843
+                        $var_mode = array_diff($var_mode, array('inclure'));
2844
+                    }
2845
+                    if (in_array('urls', $var_mode)) {
2846
+                        // forcer le compilo et ignorer les caches existants
2847
+                        if (!defined('_VAR_MODE')) {
2848
+                            define('_VAR_MODE', 'calcul');
2849
+                        }
2850
+                        if (!defined('_VAR_URLS')) {
2851
+                            define('_VAR_URLS', true);
2852
+                        }
2853
+                        $var_mode = array_diff($var_mode, array('urls'));
2854
+                    }
2855
+                    if (in_array('images', $var_mode)) {
2856
+                        // forcer le compilo et ignorer les caches existants
2857
+                        if (!defined('_VAR_MODE')) {
2858
+                            define('_VAR_MODE', 'calcul');
2859
+                        }
2860
+                        // indiquer qu'on doit recalculer les images
2861
+                        if (!defined('_VAR_IMAGES')) {
2862
+                            define('_VAR_IMAGES', true);
2863
+                        }
2864
+                        $var_mode = array_diff($var_mode, array('images'));
2865
+                    }
2866
+                    if (in_array('debug', $var_mode)) {
2867
+                        if (!defined('_VAR_MODE')) {
2868
+                            define('_VAR_MODE', 'debug');
2869
+                        }
2870
+                        // et ne pas enregistrer de cache
2871
+                        if (!defined('_VAR_NOCACHE')) {
2872
+                            define('_VAR_NOCACHE', true);
2873
+                        }
2874
+                        $var_mode = array_diff($var_mode, array('debug'));
2875
+                    }
2876
+                    if (count($var_mode) and !defined('_VAR_MODE')) {
2877
+                        define('_VAR_MODE', reset($var_mode));
2878
+                    }
2879
+                    if (isset($GLOBALS['visiteur_session']['nom'])) {
2880
+                        spip_log($GLOBALS['visiteur_session']['nom']
2881
+                            . " " . _VAR_MODE);
2882
+                    }
2883
+                } // pas autorise ?
2884
+                else {
2885
+                    // si on n'est pas connecte on se redirige
2886
+                    if (!$GLOBALS['visiteur_session']) {
2887
+                        include_spip('inc/headers');
2888
+                        redirige_par_entete(generer_url_public('login',
2889
+                            'url=' . rawurlencode(
2890
+                                parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')
2891
+                            ), true));
2892
+                    }
2893
+                    // sinon tant pis
2894
+                }
2895
+            }
2896
+        }
2897
+        if (!defined('_VAR_MODE')) {
2898
+            /**
2899
+             * Indique le mode de calcul ou d'affichage de la page.
2900
+             * @see init_var_mode()
2901
+             */
2902
+            define('_VAR_MODE', false);
2903
+        }
2904
+        $done = true;
2905
+    }
2907 2906
 }
2908 2907
 
2909 2908
 // Annuler les magic quotes \' sur GET POST COOKIE et GLOBALS ;
@@ -2911,93 +2910,93 @@  discard block
 block discarded – undo
2911 2910
 // la commande is_readable('chemin/vers/fichier/interdit%00truc_normal')
2912 2911
 // http://code.spip.net/@spip_desinfecte
2913 2912
 function spip_desinfecte(&$t, $deep = true) {
2914
-	static $magic_quotes;
2915
-	if (!isset($magic_quotes)) {
2916
-		$magic_quotes = @get_magic_quotes_gpc();
2917
-	}
2918
-
2919
-	foreach ($t as $key => $val) {
2920
-		if (is_string($t[$key])) {
2921
-			if ($magic_quotes) {
2922
-				$t[$key] = stripslashes($t[$key]);
2923
-			}
2924
-			$t[$key] = str_replace(chr(0), '-', $t[$key]);
2925
-		} // traiter aussi les "texte_plus" de article_edit
2926
-		else {
2927
-			if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
2928
-				spip_desinfecte($t[$key], $deep);
2929
-			}
2930
-		}
2931
-	}
2913
+    static $magic_quotes;
2914
+    if (!isset($magic_quotes)) {
2915
+        $magic_quotes = @get_magic_quotes_gpc();
2916
+    }
2917
+
2918
+    foreach ($t as $key => $val) {
2919
+        if (is_string($t[$key])) {
2920
+            if ($magic_quotes) {
2921
+                $t[$key] = stripslashes($t[$key]);
2922
+            }
2923
+            $t[$key] = str_replace(chr(0), '-', $t[$key]);
2924
+        } // traiter aussi les "texte_plus" de article_edit
2925
+        else {
2926
+            if ($deep and is_array($t[$key]) and $key !== 'GLOBALS') {
2927
+                spip_desinfecte($t[$key], $deep);
2928
+            }
2929
+        }
2930
+    }
2932 2931
 }
2933 2932
 
2934 2933
 //  retourne le statut du visiteur s'il s'annonce
2935 2934
 
2936 2935
 // http://code.spip.net/@verifier_visiteur
2937 2936
 function verifier_visiteur() {
2938
-	// Rq: pour que cette fonction marche depuis mes_options
2939
-	// il faut forcer l'init si ce n'est fait
2940
-	// mais on risque de perturber des plugins en initialisant trop tot
2941
-	// certaines constantes
2942
-	@spip_initialisation_core(
2943
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
2944
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
2945
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
2946
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
2947
-	);
2948
-
2949
-	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
2950
-	// dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
2951
-	// Attention on separe bien session_nom et nom, pour eviter
2952
-	// les melanges entre donnees SQL et variables plus aleatoires
2953
-	$variables_session = array('session_nom', 'session_email');
2954
-	foreach ($variables_session as $var) {
2955
-		if (_request($var) !== null) {
2956
-			$init = true;
2957
-			break;
2958
-		}
2959
-	}
2960
-	if (isset($init)) {
2961
-		#@spip_initialisation_suite();
2962
-		$session = charger_fonction('session', 'inc');
2963
-		$session();
2964
-		include_spip('inc/texte');
2965
-		foreach ($variables_session as $var) {
2966
-			if (($a = _request($var)) !== null) {
2967
-				$GLOBALS['visiteur_session'][$var] = safehtml($a);
2968
-			}
2969
-		}
2970
-		if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
2971
-			$GLOBALS['visiteur_session']['id_auteur'] = 0;
2972
-		}
2973
-		$session($GLOBALS['visiteur_session']);
2974
-
2975
-		return 0;
2976
-	}
2977
-
2978
-	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
2979
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
2980
-
2981
-		$session = charger_fonction('session', 'inc');
2982
-		if ($session()) {
2983
-			return $GLOBALS['visiteur_session']['statut'];
2984
-		}
2985
-		if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
2986
-			include_spip('inc/auth');
2987
-			$h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
2988
-		}
2989
-		if ($h) {
2990
-			$GLOBALS['visiteur_session'] = $h;
2991
-
2992
-			return $GLOBALS['visiteur_session']['statut'];
2993
-		}
2994
-	}
2995
-
2996
-	// au moins son navigateur nous dit la langue preferee de cet inconnu
2997
-	include_spip('inc/lang');
2998
-	utiliser_langue_visiteur();
2999
-
3000
-	return false;
2937
+    // Rq: pour que cette fonction marche depuis mes_options
2938
+    // il faut forcer l'init si ce n'est fait
2939
+    // mais on risque de perturber des plugins en initialisant trop tot
2940
+    // certaines constantes
2941
+    @spip_initialisation_core(
2942
+        (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
2943
+        (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
2944
+        (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
2945
+        (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
2946
+    );
2947
+
2948
+    // Demarrer une session NON AUTHENTIFIEE si on donne son nom
2949
+    // dans un formulaire sans login (ex: #FORMULAIRE_FORUM)
2950
+    // Attention on separe bien session_nom et nom, pour eviter
2951
+    // les melanges entre donnees SQL et variables plus aleatoires
2952
+    $variables_session = array('session_nom', 'session_email');
2953
+    foreach ($variables_session as $var) {
2954
+        if (_request($var) !== null) {
2955
+            $init = true;
2956
+            break;
2957
+        }
2958
+    }
2959
+    if (isset($init)) {
2960
+        #@spip_initialisation_suite();
2961
+        $session = charger_fonction('session', 'inc');
2962
+        $session();
2963
+        include_spip('inc/texte');
2964
+        foreach ($variables_session as $var) {
2965
+            if (($a = _request($var)) !== null) {
2966
+                $GLOBALS['visiteur_session'][$var] = safehtml($a);
2967
+            }
2968
+        }
2969
+        if (!isset($GLOBALS['visiteur_session']['id_auteur'])) {
2970
+            $GLOBALS['visiteur_session']['id_auteur'] = 0;
2971
+        }
2972
+        $session($GLOBALS['visiteur_session']);
2973
+
2974
+        return 0;
2975
+    }
2976
+
2977
+    $h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
2978
+    if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
2979
+
2980
+        $session = charger_fonction('session', 'inc');
2981
+        if ($session()) {
2982
+            return $GLOBALS['visiteur_session']['statut'];
2983
+        }
2984
+        if ($h and isset($_SERVER['PHP_AUTH_PW'])) {
2985
+            include_spip('inc/auth');
2986
+            $h = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
2987
+        }
2988
+        if ($h) {
2989
+            $GLOBALS['visiteur_session'] = $h;
2990
+
2991
+            return $GLOBALS['visiteur_session']['statut'];
2992
+        }
2993
+    }
2994
+
2995
+    // au moins son navigateur nous dit la langue preferee de cet inconnu
2996
+    include_spip('inc/lang');
2997
+    utiliser_langue_visiteur();
2998
+
2999
+    return false;
3001 3000
 }
3002 3001
 
3003 3002
 
@@ -3020,21 +3019,21 @@  discard block
 block discarded – undo
3020 3019
  *     - string Langue utilisée.
3021 3020
  **/
3022 3021
 function lang_select($lang = null) {
3023
-	static $pile_langues = array();
3024
-	if (!function_exists('changer_langue')) {
3025
-		include_spip('inc/lang');
3026
-	}
3027
-	if ($lang === null) {
3028
-		$lang = array_pop($pile_langues);
3029
-	} else {
3030
-		array_push($pile_langues, $GLOBALS['spip_lang']);
3031
-	}
3032
-	if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3033
-		return $lang;
3034
-	}
3035
-	changer_langue($lang);
3022
+    static $pile_langues = array();
3023
+    if (!function_exists('changer_langue')) {
3024
+        include_spip('inc/lang');
3025
+    }
3026
+    if ($lang === null) {
3027
+        $lang = array_pop($pile_langues);
3028
+    } else {
3029
+        array_push($pile_langues, $GLOBALS['spip_lang']);
3030
+    }
3031
+    if (isset($GLOBALS['spip_lang']) and $lang == $GLOBALS['spip_lang']) {
3032
+        return $lang;
3033
+    }
3034
+    changer_langue($lang);
3036 3035
 
3037
-	return $lang;
3036
+    return $lang;
3038 3037
 }
3039 3038
 
3040 3039
 /**
@@ -3051,19 +3050,19 @@  discard block
 block discarded – undo
3051 3050
  *     Identifiant de la session
3052 3051
  **/
3053 3052
 function spip_session($force = false) {
3054
-	static $session;
3055
-	if ($force or !isset($session)) {
3056
-		$s = pipeline('definir_session',
3057
-			$GLOBALS['visiteur_session']
3058
-				? serialize($GLOBALS['visiteur_session'])
3059
-				. '_' . @$_COOKIE['spip_session']
3060
-				: ''
3061
-		);
3062
-		$session = $s ? substr(md5($s), 0, 8) : '';
3063
-	}
3053
+    static $session;
3054
+    if ($force or !isset($session)) {
3055
+        $s = pipeline('definir_session',
3056
+            $GLOBALS['visiteur_session']
3057
+                ? serialize($GLOBALS['visiteur_session'])
3058
+                . '_' . @$_COOKIE['spip_session']
3059
+                : ''
3060
+        );
3061
+        $session = $s ? substr(md5($s), 0, 8) : '';
3062
+    }
3064 3063
 
3065
-	#spip_log('session: '.$session);
3066
-	return $session;
3064
+    #spip_log('session: '.$session);
3065
+    return $session;
3067 3066
 }
3068 3067
 
3069 3068
 
@@ -3082,9 +3081,9 @@  discard block
 block discarded – undo
3082 3081
  *    Lien sur une icone d'aide
3083 3082
  **/
3084 3083
 function aider($aide = '', $distante = false) {
3085
-	$aider = charger_fonction('aide', 'inc', true);
3084
+    $aider = charger_fonction('aide', 'inc', true);
3086 3085
 
3087
-	return $aider ? $aider($aide, '', array(), $distante) : '';
3086
+    return $aider ? $aider($aide, '', array(), $distante) : '';
3088 3087
 }
3089 3088
 
3090 3089
 /**
@@ -3094,13 +3093,13 @@  discard block
 block discarded – undo
3094 3093
  */
3095 3094
 function exec_info_dist() {
3096 3095
 
3097
-	include_spip('inc/autoriser');
3098
-	if (autoriser('webmestre')) {
3099
-		phpinfo();
3100
-	} else {
3101
-		include_spip('inc/filtres');
3102
-		sinon_interdire_acces();
3103
-	}
3096
+    include_spip('inc/autoriser');
3097
+    if (autoriser('webmestre')) {
3098
+        phpinfo();
3099
+    } else {
3100
+        include_spip('inc/filtres');
3101
+        sinon_interdire_acces();
3102
+    }
3104 3103
 }
3105 3104
 
3106 3105
 /**
@@ -3120,13 +3119,13 @@  discard block
 block discarded – undo
3120 3119
  *     - string si $message à false.
3121 3120
  **/
3122 3121
 function erreur_squelette($message = '', $lieu = '') {
3123
-	$debusquer = charger_fonction('debusquer', 'public');
3124
-	if (is_array($lieu)) {
3125
-		include_spip('public/compiler');
3126
-		$lieu = reconstruire_contexte_compil($lieu);
3127
-	}
3122
+    $debusquer = charger_fonction('debusquer', 'public');
3123
+    if (is_array($lieu)) {
3124
+        include_spip('public/compiler');
3125
+        $lieu = reconstruire_contexte_compil($lieu);
3126
+    }
3128 3127
 
3129
-	return $debusquer($message, $lieu);
3128
+    return $debusquer($message, $lieu);
3130 3129
 }
3131 3130
 
3132 3131
 /**
@@ -3163,109 +3162,109 @@  discard block
 block discarded – undo
3163 3162
  *     - ou tableau d'information sur le squelette.
3164 3163
  */
3165 3164
 function recuperer_fond($fond, $contexte = array(), $options = array(), $connect = '') {
3166
-	if (!function_exists('evaluer_fond')) {
3167
-		include_spip('public/assembler');
3168
-	}
3169
-	// assurer la compat avec l'ancienne syntaxe
3170
-	// (trim etait le 3eme argument, par defaut a true)
3171
-	if (!is_array($options)) {
3172
-		$options = array('trim' => $options);
3173
-	}
3174
-	if (!isset($options['trim'])) {
3175
-		$options['trim'] = true;
3176
-	}
3177
-
3178
-	if (isset($contexte['connect'])) {
3179
-		$connect = $contexte['connect'];
3180
-		unset($contexte['connect']);
3181
-	}
3182
-
3183
-	$texte = "";
3184
-	$pages = array();
3185
-	$lang_select = '';
3186
-	if (!isset($options['etoile']) or !$options['etoile']) {
3187
-		// Si on a inclus sans fixer le critere de lang, on prend la langue courante
3188
-		if (!isset($contexte['lang'])) {
3189
-			$contexte['lang'] = $GLOBALS['spip_lang'];
3190
-		}
3191
-
3192
-		if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3193
-			$lang_select = lang_select($contexte['lang']);
3194
-		}
3195
-	}
3196
-
3197
-	if (!isset($GLOBALS['_INC_PUBLIC'])) {
3198
-		$GLOBALS['_INC_PUBLIC'] = 0;
3199
-	}
3200
-
3201
-	$GLOBALS['_INC_PUBLIC']++;
3202
-
3203
-	// fix #4235
3204
-	$cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3205
-
3206
-
3207
-	foreach (is_array($fond) ? $fond : array($fond) as $f) {
3165
+    if (!function_exists('evaluer_fond')) {
3166
+        include_spip('public/assembler');
3167
+    }
3168
+    // assurer la compat avec l'ancienne syntaxe
3169
+    // (trim etait le 3eme argument, par defaut a true)
3170
+    if (!is_array($options)) {
3171
+        $options = array('trim' => $options);
3172
+    }
3173
+    if (!isset($options['trim'])) {
3174
+        $options['trim'] = true;
3175
+    }
3176
+
3177
+    if (isset($contexte['connect'])) {
3178
+        $connect = $contexte['connect'];
3179
+        unset($contexte['connect']);
3180
+    }
3181
+
3182
+    $texte = "";
3183
+    $pages = array();
3184
+    $lang_select = '';
3185
+    if (!isset($options['etoile']) or !$options['etoile']) {
3186
+        // Si on a inclus sans fixer le critere de lang, on prend la langue courante
3187
+        if (!isset($contexte['lang'])) {
3188
+            $contexte['lang'] = $GLOBALS['spip_lang'];
3189
+        }
3190
+
3191
+        if ($contexte['lang'] != $GLOBALS['meta']['langue_site']) {
3192
+            $lang_select = lang_select($contexte['lang']);
3193
+        }
3194
+    }
3195
+
3196
+    if (!isset($GLOBALS['_INC_PUBLIC'])) {
3197
+        $GLOBALS['_INC_PUBLIC'] = 0;
3198
+    }
3199
+
3200
+    $GLOBALS['_INC_PUBLIC']++;
3201
+
3202
+    // fix #4235
3203
+    $cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3204
+
3205
+
3206
+    foreach (is_array($fond) ? $fond : array($fond) as $f) {
3208 3207
 		
3209
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3210
-
3211
-		$page = evaluer_fond($f, $contexte, $connect);
3212
-		if ($page === '') {
3213
-			$c = isset($options['compil']) ? $options['compil'] : '';
3214
-			$a = array('fichier' => $f);
3215
-			$erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3216
-			erreur_squelette($erreur, $c);
3217
-			// eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3218
-			$page = array('texte' => '', 'erreur' => $erreur);
3219
-		}
3220
-
3221
-		$page = pipeline('recuperer_fond', array(
3222
-			'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect),
3223
-			'data' => $page
3224
-		));
3225
-		if (isset($options['ajax']) and $options['ajax']) {
3226
-			if (!function_exists('encoder_contexte_ajax')) {
3227
-				include_spip('inc/filtres');
3228
-			}
3229
-			$page['texte'] = encoder_contexte_ajax(
3230
-				array_merge(
3231
-					$contexte,
3232
-					array('fond' => $f),
3233
-					($connect ? array('connect' => $connect) : array())
3234
-				),
3235
-				'',
3236
-				$page['texte'],
3237
-				$options['ajax']
3238
-			);
3239
-		}
3240
-
3241
-		if (isset($options['raw']) and $options['raw']) {
3242
-			$pages[] = $page;
3243
-		} else {
3244
-			$texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3245
-		}
3208
+        unset($GLOBALS['cache_utilise_session']);	// fix #4235
3209
+
3210
+        $page = evaluer_fond($f, $contexte, $connect);
3211
+        if ($page === '') {
3212
+            $c = isset($options['compil']) ? $options['compil'] : '';
3213
+            $a = array('fichier' => $f);
3214
+            $erreur = _T('info_erreur_squelette2', $a); // squelette introuvable
3215
+            erreur_squelette($erreur, $c);
3216
+            // eviter des erreurs strictes ensuite sur $page['cle'] en PHP >= 5.4
3217
+            $page = array('texte' => '', 'erreur' => $erreur);
3218
+        }
3219
+
3220
+        $page = pipeline('recuperer_fond', array(
3221
+            'args' => array('fond' => $f, 'contexte' => $contexte, 'options' => $options, 'connect' => $connect),
3222
+            'data' => $page
3223
+        ));
3224
+        if (isset($options['ajax']) and $options['ajax']) {
3225
+            if (!function_exists('encoder_contexte_ajax')) {
3226
+                include_spip('inc/filtres');
3227
+            }
3228
+            $page['texte'] = encoder_contexte_ajax(
3229
+                array_merge(
3230
+                    $contexte,
3231
+                    array('fond' => $f),
3232
+                    ($connect ? array('connect' => $connect) : array())
3233
+                ),
3234
+                '',
3235
+                $page['texte'],
3236
+                $options['ajax']
3237
+            );
3238
+        }
3239
+
3240
+        if (isset($options['raw']) and $options['raw']) {
3241
+            $pages[] = $page;
3242
+        } else {
3243
+            $texte .= $options['trim'] ? rtrim($page['texte']) : $page['texte'];
3244
+        }
3246 3245
 		
3247
-		// contamination de la session appelante, pour les inclusions statiques
3248
-		if (isset($page['invalideurs']['session'])){
3249
-			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3250
-		}
3251
-	}
3246
+        // contamination de la session appelante, pour les inclusions statiques
3247
+        if (isset($page['invalideurs']['session'])){
3248
+            $cache_utilise_session_appelant = $page['invalideurs']['session'];
3249
+        }
3250
+    }
3252 3251
 
3253
-	// restaurer le sessionnement du contexte appelant, 
3254
-	// éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3255
-	if (isset($cache_utilise_session_appelant)) {
3256
-		$GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3257
-	}
3252
+    // restaurer le sessionnement du contexte appelant, 
3253
+    // éventuellement contaminé si on vient de récupérer une inclusion statique sessionnée
3254
+    if (isset($cache_utilise_session_appelant)) {
3255
+        $GLOBALS['cache_utilise_session'] = $cache_utilise_session_appelant;
3256
+    }
3258 3257
 
3259
-	$GLOBALS['_INC_PUBLIC']--;
3258
+    $GLOBALS['_INC_PUBLIC']--;
3260 3259
 
3261
-	if ($lang_select) {
3262
-		lang_select();
3263
-	}
3264
-	if (isset($options['raw']) and $options['raw']) {
3265
-		return is_array($fond) ? $pages : reset($pages);
3266
-	} else {
3267
-		return $options['trim'] ? ltrim($texte) : $texte;
3268
-	}
3260
+    if ($lang_select) {
3261
+        lang_select();
3262
+    }
3263
+    if (isset($options['raw']) and $options['raw']) {
3264
+        return is_array($fond) ? $pages : reset($pages);
3265
+    } else {
3266
+        return $options['trim'] ? ltrim($texte) : $texte;
3267
+    }
3269 3268
 }
3270 3269
 
3271 3270
 /**
@@ -3275,7 +3274,7 @@  discard block
 block discarded – undo
3275 3274
  * @return string
3276 3275
  */
3277 3276
 function trouve_modele($nom) {
3278
-	return trouver_fond($nom, 'modeles/');
3277
+    return trouver_fond($nom, 'modeles/');
3279 3278
 }
3280 3279
 
3281 3280
 /**
@@ -3291,21 +3290,21 @@  discard block
 block discarded – undo
3291 3290
  * @return array|string
3292 3291
  */
3293 3292
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3294
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3295
-	if (!$pathinfo) {
3296
-		return $f;
3297
-	}
3298
-	// renvoyer un tableau detaille si $pathinfo==true
3299
-	$p = pathinfo($f);
3300
-	if (!isset($p['extension']) or !$p['extension']) {
3301
-		$p['extension'] = _EXTENSION_SQUELETTES;
3302
-	}
3303
-	if (!isset($p['extension']) or !$p['filename']) {
3304
-		$p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3305
-	}
3306
-	$p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3293
+    $f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3294
+    if (!$pathinfo) {
3295
+        return $f;
3296
+    }
3297
+    // renvoyer un tableau detaille si $pathinfo==true
3298
+    $p = pathinfo($f);
3299
+    if (!isset($p['extension']) or !$p['extension']) {
3300
+        $p['extension'] = _EXTENSION_SQUELETTES;
3301
+    }
3302
+    if (!isset($p['extension']) or !$p['filename']) {
3303
+        $p['filename'] = ($p['basename'] ? substr($p['basename'], 0, -strlen($p['extension']) - 1) : '');
3304
+    }
3305
+    $p['fond'] = ($f ? substr($f, 0, -strlen($p['extension']) - 1) : '');
3307 3306
 
3308
-	return $p;
3307
+    return $p;
3309 3308
 }
3310 3309
 
3311 3310
 /**
@@ -3326,24 +3325,24 @@  discard block
 block discarded – undo
3326 3325
  *     Nom de l'exec, sinon chaîne vide.
3327 3326
  **/
3328 3327
 function tester_url_ecrire($nom) {
3329
-	static $exec = array();
3330
-	if (isset($exec[$nom])) {
3331
-		return $exec[$nom];
3332
-	}
3333
-	// tester si c'est une page en squelette
3334
-	if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3335
-		return $exec[$nom] = 'fond';
3336
-	} // compat skels orthogonaux version precedente
3337
-	elseif (trouver_fond($nom, 'prive/exec/')) {
3338
-		return $exec[$nom] = 'fond_monobloc';
3339
-	} // echafaudage d'un fond !
3340
-	elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3341
-		return $exec[$nom] = 'fond';
3342
-	}
3343
-	// attention, il ne faut pas inclure l'exec ici
3344
-	// car sinon #URL_ECRIRE provoque des inclusions
3345
-	// et des define intrusifs potentiels
3346
-	return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3328
+    static $exec = array();
3329
+    if (isset($exec[$nom])) {
3330
+        return $exec[$nom];
3331
+    }
3332
+    // tester si c'est une page en squelette
3333
+    if (trouver_fond($nom, 'prive/squelettes/contenu/')) {
3334
+        return $exec[$nom] = 'fond';
3335
+    } // compat skels orthogonaux version precedente
3336
+    elseif (trouver_fond($nom, 'prive/exec/')) {
3337
+        return $exec[$nom] = 'fond_monobloc';
3338
+    } // echafaudage d'un fond !
3339
+    elseif (include_spip('public/styliser_par_z') and z_echafaudable($nom)) {
3340
+        return $exec[$nom] = 'fond';
3341
+    }
3342
+    // attention, il ne faut pas inclure l'exec ici
3343
+    // car sinon #URL_ECRIRE provoque des inclusions
3344
+    // et des define intrusifs potentiels
3345
+    return $exec[$nom] = ((find_in_path("{$nom}.php", 'exec/') or charger_fonction($nom, 'exec', true)) ? $nom : '');
3347 3346
 }
3348 3347
 
3349 3348
 
@@ -3359,10 +3358,10 @@  discard block
 block discarded – undo
3359 3358
  * @return bool true si le module est chargé
3360 3359
  **/
3361 3360
 function charger_php_extension($module) {
3362
-	if (extension_loaded($module)) {
3363
-		return true;
3364
-	}
3365
-	return false;
3361
+    if (extension_loaded($module)) {
3362
+        return true;
3363
+    }
3364
+    return false;
3366 3365
 }
3367 3366
 
3368 3367
 
@@ -3373,8 +3372,8 @@  discard block
 block discarded – undo
3373 3372
  *     true si et seulement si la configuration autorise le code HTML5 sur le site public
3374 3373
  **/
3375 3374
 function html5_permis() {
3376
-	return (isset($GLOBALS['meta']['version_html_max'])
3377
-		and ('html5' == $GLOBALS['meta']['version_html_max']));
3375
+    return (isset($GLOBALS['meta']['version_html_max'])
3376
+        and ('html5' == $GLOBALS['meta']['version_html_max']));
3378 3377
 }
3379 3378
 
3380 3379
 /**
@@ -3384,17 +3383,17 @@  discard block
 block discarded – undo
3384 3383
  * @return array
3385 3384
  */
3386 3385
 function formats_image_acceptables($gd = false, $svg_allowed = true) {
3387
-	$config = ($gd ? "gd_formats" : "formats_graphiques");
3388
-	$formats = (isset($GLOBALS['meta'][$config]) ? $GLOBALS['meta'][$config] : 'png,gif,jpg');
3389
-	$formats = explode(',', $formats);
3390
-	$formats = array_filter($formats);
3391
-	$formats = array_map('trim', $formats);
3386
+    $config = ($gd ? "gd_formats" : "formats_graphiques");
3387
+    $formats = (isset($GLOBALS['meta'][$config]) ? $GLOBALS['meta'][$config] : 'png,gif,jpg');
3388
+    $formats = explode(',', $formats);
3389
+    $formats = array_filter($formats);
3390
+    $formats = array_map('trim', $formats);
3392 3391
 
3393
-	if ($svg_allowed) {
3394
-		$formats[] = 'svg';
3395
-	}
3392
+    if ($svg_allowed) {
3393
+        $formats[] = 'svg';
3394
+    }
3396 3395
 
3397
-	return $formats;
3396
+    return $formats;
3398 3397
 }
3399 3398
 
3400 3399
 /**
@@ -3403,40 +3402,40 @@  discard block
 block discarded – undo
3403 3402
  * @return array|bool
3404 3403
  */
3405 3404
 function spip_getimagesize($fichier) {
3406
-	if (!$imagesize = @getimagesize($fichier)) {
3407
-
3408
-		include_spip("inc/svg");
3409
-		if ($attrs = svg_lire_attributs($fichier)) {
3410
-			$width = 350; // default width
3411
-			$height = 150; // default height
3412
-			if (isset($attrs['width'])
3413
-			  and $w = svg_dimension_to_pixels($attrs['width'])
3414
-				and isset($attrs['height'])
3415
-			  and $h = svg_dimension_to_pixels($attrs['height'])) {
3416
-				$width = $w;
3417
-				$height = $h;
3418
-			}
3419
-			elseif (isset($attrs['viewBox'])) {
3420
-				$viewbox = trim($attrs['viewBox']);
3421
-				$viewbox = preg_replace(",\s+,", " ", $viewbox);
3422
-				$viewbox = explode(" ", $viewbox);
3423
-				if (count($viewbox) === 4
3424
-				  and $w = svg_dimension_to_pixels($viewbox[2])
3425
-				  and $h = svg_dimension_to_pixels($viewbox[3])) {
3426
-					$width = $w;
3427
-					$height = $h;
3428
-				}
3429
-			}
3430
-			$imagesize = [
3431
-				$width,
3432
-				$height,
3433
-				IMAGETYPE_SVG,
3434
-				"width=\"{$width}\" height=\"{$height}\"",
3435
-				"mime" => "image/svg+xml"
3436
-			];
3437
-		}
3438
-	}
3439
-	return $imagesize;
3405
+    if (!$imagesize = @getimagesize($fichier)) {
3406
+
3407
+        include_spip("inc/svg");
3408
+        if ($attrs = svg_lire_attributs($fichier)) {
3409
+            $width = 350; // default width
3410
+            $height = 150; // default height
3411
+            if (isset($attrs['width'])
3412
+              and $w = svg_dimension_to_pixels($attrs['width'])
3413
+                and isset($attrs['height'])
3414
+              and $h = svg_dimension_to_pixels($attrs['height'])) {
3415
+                $width = $w;
3416
+                $height = $h;
3417
+            }
3418
+            elseif (isset($attrs['viewBox'])) {
3419
+                $viewbox = trim($attrs['viewBox']);
3420
+                $viewbox = preg_replace(",\s+,", " ", $viewbox);
3421
+                $viewbox = explode(" ", $viewbox);
3422
+                if (count($viewbox) === 4
3423
+                  and $w = svg_dimension_to_pixels($viewbox[2])
3424
+                  and $h = svg_dimension_to_pixels($viewbox[3])) {
3425
+                    $width = $w;
3426
+                    $height = $h;
3427
+                }
3428
+            }
3429
+            $imagesize = [
3430
+                $width,
3431
+                $height,
3432
+                IMAGETYPE_SVG,
3433
+                "width=\"{$width}\" height=\"{$height}\"",
3434
+                "mime" => "image/svg+xml"
3435
+            ];
3436
+        }
3437
+    }
3438
+    return $imagesize;
3440 3439
 }
3441 3440
 
3442 3441
 
@@ -3456,7 +3455,7 @@  discard block
 block discarded – undo
3456 3455
  * @return mixed Valeur de la meta.
3457 3456
  **/
3458 3457
 function lire_meta($nom) {
3459
-	return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null;
3458
+    return isset($GLOBALS['meta'][$nom]) ? $GLOBALS['meta'][$nom] : null;
3460 3459
 }
3461 3460
 
3462 3461
 
@@ -3478,128 +3477,128 @@  discard block
 block discarded – undo
3478 3477
  * @param string $statut
3479 3478
  */
3480 3479
 function avertir_auteurs($nom, $message, $statut = '') {
3481
-	$alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3482
-	if (!$alertes
3483
-		or !is_array($alertes = unserialize($alertes))
3484
-	) {
3485
-		$alertes = array();
3486
-	}
3480
+    $alertes = $GLOBALS['meta']['message_alertes_auteurs'];
3481
+    if (!$alertes
3482
+        or !is_array($alertes = unserialize($alertes))
3483
+    ) {
3484
+        $alertes = array();
3485
+    }
3487 3486
 
3488
-	if (!isset($alertes[$statut])) {
3489
-		$alertes[$statut] = array();
3490
-	}
3491
-	$alertes[$statut][$nom] = $message;
3492
-	ecrire_meta("message_alertes_auteurs", serialize($alertes));
3487
+    if (!isset($alertes[$statut])) {
3488
+        $alertes[$statut] = array();
3489
+    }
3490
+    $alertes[$statut][$nom] = $message;
3491
+    ecrire_meta("message_alertes_auteurs", serialize($alertes));
3493 3492
 }
3494 3493
 
3495 3494
 if (PHP_VERSION_ID < 50500) {
3496
-	if (!function_exists('array_column')) {
3497
-		/**
3498
-		 * Returns the values from a single column of the input array, identified by
3499
-		 * the $columnKey.
3500
-		 *
3501
-		 * Optionally, you may provide an $indexKey to index the values in the returned
3502
-		 * array by the values from the $indexKey column in the input array.
3503
-		 *
3504
-		 * @link http://php.net/manual/fr/function.array-column.php
3505
-		 * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php
3506
-		 * @copyright Copyright (c) Ben Ramsey (http://benramsey.com)
3507
-		 * @license http://opensource.org/licenses/MIT MIT
3508
-		 *
3509
-		 * @param array $input A multi-dimensional array (record set) from which to pull
3510
-		 *                     a column of values.
3511
-		 * @param mixed $columnKey The column of values to return. This value may be the
3512
-		 *                         integer key of the column you wish to retrieve, or it
3513
-		 *                         may be the string key name for an associative array.
3514
-		 * @param mixed $indexKey (Optional.) The column to use as the index/keys for
3515
-		 *                        the returned array. This value may be the integer key
3516
-		 *                        of the column, or it may be the string key name.
3517
-		 * @return array
3518
-		 */
3519
-		function array_column($input = null, $columnKey = null, $indexKey = null)
3520
-		{
3521
-			// Using func_get_args() in order to check for proper number of
3522
-			// parameters and trigger errors exactly as the built-in array_column()
3523
-			// does in PHP 5.5.
3524
-			$argc = func_num_args();
3525
-			$params = func_get_args();
3526
-
3527
-			if ($argc < 2) {
3528
-				trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
3529
-				return null;
3530
-			}
3531
-
3532
-			if (!is_array($params[0])) {
3533
-				trigger_error(
3534
-					'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
3535
-					E_USER_WARNING
3536
-				);
3537
-				return null;
3538
-			}
3539
-
3540
-			if (!is_int($params[1])
3541
-				&& !is_float($params[1])
3542
-				&& !is_string($params[1])
3543
-				&& $params[1] !== null
3544
-				&& !(is_object($params[1]) && method_exists($params[1], '__toString'))
3545
-			) {
3546
-				trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
3547
-				return false;
3548
-			}
3549
-
3550
-			if (isset($params[2])
3551
-				&& !is_int($params[2])
3552
-				&& !is_float($params[2])
3553
-				&& !is_string($params[2])
3554
-				&& !(is_object($params[2]) && method_exists($params[2], '__toString'))
3555
-			) {
3556
-				trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
3557
-				return false;
3558
-			}
3559
-
3560
-			$paramsInput = $params[0];
3561
-			$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
3562
-
3563
-			$paramsIndexKey = null;
3564
-			if (isset($params[2])) {
3565
-				if (is_float($params[2]) || is_int($params[2])) {
3566
-					$paramsIndexKey = (int) $params[2];
3567
-				} else {
3568
-					$paramsIndexKey = (string) $params[2];
3569
-				}
3570
-			}
3571
-
3572
-			$resultArray = array();
3573
-
3574
-			foreach ($paramsInput as $row) {
3575
-				$key = $value = null;
3576
-				$keySet = $valueSet = false;
3577
-
3578
-				if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
3579
-					$keySet = true;
3580
-					$key = (string) $row[$paramsIndexKey];
3581
-				}
3582
-
3583
-				if ($paramsColumnKey === null) {
3584
-					$valueSet = true;
3585
-					$value = $row;
3586
-				} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
3587
-					$valueSet = true;
3588
-					$value = $row[$paramsColumnKey];
3589
-				}
3590
-
3591
-				if ($valueSet) {
3592
-					if ($keySet) {
3593
-						$resultArray[$key] = $value;
3594
-					} else {
3595
-						$resultArray[] = $value;
3596
-					}
3597
-				}
3598
-
3599
-			}
3600
-
3601
-			return $resultArray;
3602
-		}
3603
-
3604
-	}
3495
+    if (!function_exists('array_column')) {
3496
+        /**
3497
+         * Returns the values from a single column of the input array, identified by
3498
+         * the $columnKey.
3499
+         *
3500
+         * Optionally, you may provide an $indexKey to index the values in the returned
3501
+         * array by the values from the $indexKey column in the input array.
3502
+         *
3503
+         * @link http://php.net/manual/fr/function.array-column.php
3504
+         * @link https://github.com/ramsey/array_column/blob/master/src/array_column.php
3505
+         * @copyright Copyright (c) Ben Ramsey (http://benramsey.com)
3506
+         * @license http://opensource.org/licenses/MIT MIT
3507
+         *
3508
+         * @param array $input A multi-dimensional array (record set) from which to pull
3509
+         *                     a column of values.
3510
+         * @param mixed $columnKey The column of values to return. This value may be the
3511
+         *                         integer key of the column you wish to retrieve, or it
3512
+         *                         may be the string key name for an associative array.
3513
+         * @param mixed $indexKey (Optional.) The column to use as the index/keys for
3514
+         *                        the returned array. This value may be the integer key
3515
+         *                        of the column, or it may be the string key name.
3516
+         * @return array
3517
+         */
3518
+        function array_column($input = null, $columnKey = null, $indexKey = null)
3519
+        {
3520
+            // Using func_get_args() in order to check for proper number of
3521
+            // parameters and trigger errors exactly as the built-in array_column()
3522
+            // does in PHP 5.5.
3523
+            $argc = func_num_args();
3524
+            $params = func_get_args();
3525
+
3526
+            if ($argc < 2) {
3527
+                trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
3528
+                return null;
3529
+            }
3530
+
3531
+            if (!is_array($params[0])) {
3532
+                trigger_error(
3533
+                    'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
3534
+                    E_USER_WARNING
3535
+                );
3536
+                return null;
3537
+            }
3538
+
3539
+            if (!is_int($params[1])
3540
+                && !is_float($params[1])
3541
+                && !is_string($params[1])
3542
+                && $params[1] !== null
3543
+                && !(is_object($params[1]) && method_exists($params[1], '__toString'))
3544
+            ) {
3545
+                trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
3546
+                return false;
3547
+            }
3548
+
3549
+            if (isset($params[2])
3550
+                && !is_int($params[2])
3551
+                && !is_float($params[2])
3552
+                && !is_string($params[2])
3553
+                && !(is_object($params[2]) && method_exists($params[2], '__toString'))
3554
+            ) {
3555
+                trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
3556
+                return false;
3557
+            }
3558
+
3559
+            $paramsInput = $params[0];
3560
+            $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
3561
+
3562
+            $paramsIndexKey = null;
3563
+            if (isset($params[2])) {
3564
+                if (is_float($params[2]) || is_int($params[2])) {
3565
+                    $paramsIndexKey = (int) $params[2];
3566
+                } else {
3567
+                    $paramsIndexKey = (string) $params[2];
3568
+                }
3569
+            }
3570
+
3571
+            $resultArray = array();
3572
+
3573
+            foreach ($paramsInput as $row) {
3574
+                $key = $value = null;
3575
+                $keySet = $valueSet = false;
3576
+
3577
+                if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
3578
+                    $keySet = true;
3579
+                    $key = (string) $row[$paramsIndexKey];
3580
+                }
3581
+
3582
+                if ($paramsColumnKey === null) {
3583
+                    $valueSet = true;
3584
+                    $value = $row;
3585
+                } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
3586
+                    $valueSet = true;
3587
+                    $value = $row[$paramsColumnKey];
3588
+                }
3589
+
3590
+                if ($valueSet) {
3591
+                    if ($keySet) {
3592
+                        $resultArray[$key] = $value;
3593
+                    } else {
3594
+                        $resultArray[] = $value;
3595
+                    }
3596
+                }
3597
+
3598
+            }
3599
+
3600
+            return $resultArray;
3601
+        }
3602
+
3603
+    }
3605 3604
 }
Please login to merge, or discard this patch.
Spacing   +128 added lines, -130 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	if (strlen($dossier) and substr($dossier, -1) != '/') {
54 54
 		$dossier .= '/';
55 55
 	}
56
-	$f = str_replace('/', '_', $dossier) . $nom;
56
+	$f = str_replace('/', '_', $dossier).$nom;
57 57
 
58 58
 	if (function_exists($f)) {
59 59
 		return $f;
60 60
 	}
61
-	if (function_exists($g = $f . '_dist')) {
61
+	if (function_exists($g = $f.'_dist')) {
62 62
 		return $g;
63 63
 	}
64 64
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 	// passer en minuscules (cf les balises de formulaires)
80 80
 	// et inclure le fichier
81
-	if (!$inc = include_spip($dossier . ($d = strtolower($nom)))
81
+	if (!$inc = include_spip($dossier.($d = strtolower($nom)))
82 82
 		// si le fichier truc/machin/nom.php n'existe pas,
83 83
 		// la fonction peut etre definie dans truc/machin.php qui regroupe plusieurs petites fonctions
84 84
 		and strlen(dirname($dossier)) and dirname($dossier) != '.'
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	// Echec : message d'erreur
100
-	spip_log("fonction $nom ($f ou $g) indisponible" .
100
+	spip_log("fonction $nom ($f ou $g) indisponible".
101 101
 		($inc ? "" : " (fichier $d absent de $dossier)"));
102 102
 
103 103
 	include_spip('inc/minipres');
104 104
 	echo minipres(_T('forum_titre_erreur'),
105
-		_T('fichier_introuvable', array('fichier' => '<b>' . spip_htmlentities($d) . '</b>')),
106
-		array('all_inline'=>true,'status'=>404));
105
+		_T('fichier_introuvable', array('fichier' => '<b>'.spip_htmlentities($d).'</b>')),
106
+		array('all_inline'=>true, 'status'=>404));
107 107
 	exit;
108 108
 }
109 109
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
  *     - string : chemin du fichier trouvé
149 149
  **/
150 150
 function include_spip($f, $include = true) {
151
-	return find_in_path($f . '.php', '', $include);
151
+	return find_in_path($f.'.php', '', $include);
152 152
 }
153 153
 
154 154
 /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
  *     - string : chemin du fichier trouvé
169 169
  **/
170 170
 function require_spip($f) {
171
-	return find_in_path($f . '.php', '', 'required');
171
+	return find_in_path($f.'.php', '', 'required');
172 172
 }
173 173
 
174 174
 /**
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	}
261 261
 
262 262
 	// appliquer notre fonction si elle existe
263
-	$fonc = 'execute_pipeline_' . strtolower($action);
263
+	$fonc = 'execute_pipeline_'.strtolower($action);
264 264
 	if (function_exists($fonc)) {
265 265
 		$val = $fonc($val);
266 266
 	} // plantage ?
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 function spip_log($message = null, $name = null) {
325 325
 	static $pre = array();
326 326
 	static $log;
327
-	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string)$name, $regs);
327
+	preg_match('/^([a-z_]*)\.?(\d)?$/iS', (string) $name, $regs);
328 328
 	if (!isset($regs[1]) or !$logname = $regs[1]) {
329 329
 		$logname = null;
330 330
 	}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 		if (!is_string($message)) {
350 350
 			$message = print_r($message, true);
351 351
 		}
352
-		$log($pre[$niveau] . ' ' . $message, $logname);
352
+		$log($pre[$niveau].' '.$message, $logname);
353 353
 	}
354 354
 }
355 355
 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 		$a = './';
513 513
 	}
514 514
 
515
-	$regexp = ',^(' . str_replace('[]', '\[\]', $c) . '[[]?[]]?)(=.*)?$,';
515
+	$regexp = ',^('.str_replace('[]', '\[\]', $c).'[[]?[]]?)(=.*)?$,';
516 516
 	$ajouts = array_flip(explode('|', $c));
517 517
 	$u = is_array($v) ? $v : rawurlencode($v);
518 518
 	$testv = (is_array($v) ? count($v) : strlen($v));
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 			// Ajout. Pour une variable, remplacer au meme endroit,
540 540
 			// pour un tableau ce sera fait dans la prochaine boucle
541 541
 			elseif (substr($r[1], -2) != '[]') {
542
-				$url[$n] = $r[1] . '=' . $u;
542
+				$url[$n] = $r[1].'='.$u;
543 543
 				unset($ajouts[$r[1]]);
544 544
 			}
545 545
 			// Pour les tableaux on laisse tomber les valeurs de
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
 	} elseif ($testv) {
560 560
 		foreach ($ajouts as $k => $n) {
561 561
 			if (!is_array($v)) {
562
-				$url[] = $k . '=' . $u;
562
+				$url[] = $k.'='.$u;
563 563
 			} else {
564
-				$id = (substr($k, -2) == '[]') ? $k : ($k . "[]");
564
+				$id = (substr($k, -2) == '[]') ? $k : ($k."[]");
565 565
 				foreach ($v as $w) {
566
-					$url[] = $id . '=' . (is_array($w) ? 'Array' : $w);
566
+					$url[] = $id.'='.(is_array($w) ? 'Array' : $w);
567 567
 				}
568 568
 			}
569 569
 		}
@@ -574,10 +574,10 @@  discard block
 block discarded – undo
574 574
 
575 575
 	// recomposer l'adresse
576 576
 	if ($url) {
577
-		$a .= '?' . join($sep, $url);
577
+		$a .= '?'.join($sep, $url);
578 578
 	}
579 579
 
580
-	return $a . $ancre;
580
+	return $a.$ancre;
581 581
 }
582 582
 
583 583
 /**
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 			translitteration($ancre)
610 610
 		);
611 611
 	}
612
-	return $url . (strlen($ancre) ? '#' . $ancre : '');
612
+	return $url.(strlen($ancre) ? '#'.$ancre : '');
613 613
 }
614 614
 
615 615
 /**
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
  * @return bool
722 722
  */
723 723
 function test_plugin_actif($plugin) {
724
-	return ($plugin and defined('_DIR_PLUGIN_' . strtoupper($plugin))) ? true : false;
724
+	return ($plugin and defined('_DIR_PLUGIN_'.strtoupper($plugin))) ? true : false;
725 725
 }
726 726
 
727 727
 /**
@@ -789,8 +789,7 @@  discard block
 block discarded – undo
789 789
 		// pour les chaines non traduites, assurer un service minimum
790 790
 		if (!$GLOBALS['test_i18n'] and (_request('var_mode') != 'traduction')) {
791 791
 			$text = str_replace('_', ' ',
792
-				(($n = strpos($text, ':')) === false ? $texte :
793
-					substr($texte, $n + 1)));
792
+				(($n = strpos($text, ':')) === false ? $texte : substr($texte, $n + 1)));
794 793
 		}
795 794
 		$o['class'] = null;
796 795
 
@@ -862,7 +861,7 @@  discard block
 block discarded – undo
862 861
 		// Si des variables n'ont pas ete inserees, le signaler
863 862
 		// (chaines de langues pas a jour)
864 863
 		if ($args) {
865
-			spip_log("$f:  variables inutilisees " . join(', ', array_keys($args)), _LOG_DEBUG);
864
+			spip_log("$f:  variables inutilisees ".join(', ', array_keys($args)), _LOG_DEBUG);
866 865
 		}
867 866
 	}
868 867
 
@@ -886,7 +885,7 @@  discard block
 block discarded – undo
886 885
 function joli_repertoire($rep) {
887 886
 	$a = substr($rep, 0, 1);
888 887
 	if ($a <> '.' and $a <> '/') {
889
-		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS) . $rep;
888
+		$rep = (_DIR_RESTREINT ? '' : _DIR_RESTREINT_ABS).$rep;
890 889
 	}
891 890
 	$rep = preg_replace(',(^\.\.\/),', '', $rep);
892 891
 
@@ -940,7 +939,7 @@  discard block
 block discarded – undo
940 939
 			$p -= ($x * 1000);
941 940
 		}
942 941
 
943
-		return $s . sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
942
+		return $s.sprintf($s ? "%07.3f ms" : "%.3f ms", $p);
944 943
 	}
945 944
 }
946 945
 
@@ -1009,7 +1008,7 @@  discard block
 block discarded – undo
1009 1008
 	if ($taches and count($taches) and !spip_connect()) {
1010 1009
 		return false;
1011 1010
 	}
1012
-	spip_log("cron !", 'jq' . _LOG_DEBUG);
1011
+	spip_log("cron !", 'jq'._LOG_DEBUG);
1013 1012
 	if ($genie = charger_fonction('genie', 'inc', true)) {
1014 1013
 		return $genie($taches);
1015 1014
 	}
@@ -1113,7 +1112,7 @@  discard block
 block discarded – undo
1113 1112
 
1114 1113
 	if ($queue_next_job_time == -1) {
1115 1114
 		if (!defined('_JQ_NEXT_JOB_TIME_FILENAME')) {
1116
-			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP . "job_queue_next.txt");
1115
+			define('_JQ_NEXT_JOB_TIME_FILENAME', _DIR_TMP."job_queue_next.txt");
1117 1116
 		}
1118 1117
 		// utiliser un cache memoire si dispo
1119 1118
 		if (function_exists("cache_get") and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) {
@@ -1180,8 +1179,8 @@  discard block
 block discarded – undo
1180 1179
 		$src = '';
1181 1180
 	}
1182 1181
 	if ($script) {
1183
-		$script = ("/*<![CDATA[*/\n" .
1184
-			preg_replace(',</([^>]*)>,', '<\/\1>', $script) .
1182
+		$script = ("/*<![CDATA[*/\n".
1183
+			preg_replace(',</([^>]*)>,', '<\/\1>', $script).
1185 1184
 			"/*]]>*/");
1186 1185
 	}
1187 1186
 	if ($noscript) {
@@ -1267,13 +1266,13 @@  discard block
 block discarded – undo
1267 1266
 	if ($path_base == null) {
1268 1267
 		// Chemin standard depuis l'espace public
1269 1268
 		$path = defined('_SPIP_PATH') ? _SPIP_PATH :
1270
-			_DIR_RACINE . ':' .
1271
-			_DIR_RACINE . 'squelettes-dist/:' .
1272
-			_DIR_RACINE . 'prive/:' .
1269
+			_DIR_RACINE.':'.
1270
+			_DIR_RACINE.'squelettes-dist/:'.
1271
+			_DIR_RACINE.'prive/:'.
1273 1272
 			_DIR_RESTREINT;
1274 1273
 		// Ajouter squelettes/
1275
-		if (@is_dir(_DIR_RACINE . 'squelettes')) {
1276
-			$path = _DIR_RACINE . 'squelettes/:' . $path;
1274
+		if (@is_dir(_DIR_RACINE.'squelettes')) {
1275
+			$path = _DIR_RACINE.'squelettes/:'.$path;
1277 1276
 		}
1278 1277
 		foreach (explode(':', $path) as $dir) {
1279 1278
 			if (strlen($dir) and substr($dir, -1) != '/') {
@@ -1285,7 +1284,7 @@  discard block
 block discarded – undo
1285 1284
 		// Et le(s) dossier(s) des squelettes nommes
1286 1285
 		if (strlen($GLOBALS['dossier_squelettes'])) {
1287 1286
 			foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1288
-				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE) . $d . '/');
1287
+				array_unshift($path_full, ($d[0] == '/' ? '' : _DIR_RACINE).$d.'/');
1289 1288
 			}
1290 1289
 		}
1291 1290
 		$GLOBALS['path_sig'] = md5(serialize($path_full));
@@ -1296,7 +1295,7 @@  discard block
 block discarded – undo
1296 1295
 
1297 1296
 	if (strlen($dir_path)) {
1298 1297
 		$tete = "";
1299
-		if (reset($path_base) == _DIR_RACINE . 'squelettes/') {
1298
+		if (reset($path_base) == _DIR_RACINE.'squelettes/') {
1300 1299
 			$tete = array_shift($path_base);
1301 1300
 		}
1302 1301
 		$dirs = array_reverse(explode(':', $dir_path));
@@ -1318,7 +1317,7 @@  discard block
 block discarded – undo
1318 1317
 	// Et le(s) dossier(s) des squelettes nommes
1319 1318
 	if (strlen($GLOBALS['dossier_squelettes'])) {
1320 1319
 		foreach (array_reverse(explode(':', $GLOBALS['dossier_squelettes'])) as $d) {
1321
-			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE) . $d . '/');
1320
+			array_unshift($path_full, ((isset($d[0]) and $d[0] == '/') ? '' : _DIR_RACINE).$d.'/');
1322 1321
 		}
1323 1322
 	}
1324 1323
 
@@ -1388,9 +1387,9 @@  discard block
 block discarded – undo
1388 1387
 	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
1389 1388
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
1390 1389
 	if (preg_match(',-(\d+)[.](png|gif|svg)$,', $file, $m)
1391
-	  and $file_svg_generique = substr($file,0, -strlen($m[0])) . "-xx.svg"
1390
+	  and $file_svg_generique = substr($file, 0, -strlen($m[0]))."-xx.svg"
1392 1391
 		and $f = find_in_theme("$file_svg_generique")) {
1393
-		if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1392
+		if ($fsize = substr($f, 0, -6).$m[1].".svg" and file_exists($fsize)) {
1394 1393
 			return $themefiles["$subdir$file"] = $fsize;
1395 1394
 		}
1396 1395
 		else {
@@ -1404,7 +1403,7 @@  discard block
 block discarded – undo
1404 1403
 			return $themefiles["$subdir$file"] = $f;
1405 1404
 		}
1406 1405
 	}
1407
-	spip_log("$file introuvable dans le theme prive " . reset($themes), 'theme');
1406
+	spip_log("$file introuvable dans le theme prive ".reset($themes), 'theme');
1408 1407
 
1409 1408
 	return $themefiles["$subdir$file"] = "";
1410 1409
 }
@@ -1432,7 +1431,7 @@  discard block
 block discarded – undo
1432 1431
 function chemin_image($icone) {
1433 1432
 	static $icone_renommer;
1434 1433
 	if ($p = strpos($icone, '?')) {
1435
-		$icone = substr($icone,0, $p);
1434
+		$icone = substr($icone, 0, $p);
1436 1435
 	}
1437 1436
 	// gerer le cas d'un double appel en evitant de refaire le travail inutilement
1438 1437
 	if (strpos($icone, "/") !== false and file_exists($icone)) {
@@ -1508,8 +1507,8 @@  discard block
 block discarded – undo
1508 1507
 			return false;
1509 1508
 		}
1510 1509
 		if ($include and !isset($inc[$dirname][$file])) {
1511
-			include_once _ROOT_CWD . $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1512
-			$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1510
+			include_once _ROOT_CWD.$GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
1511
+			$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1513 1512
 		}
1514 1513
 
1515 1514
 		return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file];
@@ -1522,14 +1521,14 @@  discard block
 block discarded – undo
1522 1521
 	}
1523 1522
 
1524 1523
 	foreach (creer_chemin() as $dir) {
1525
-		if (!isset($dirs[$a = $dir . $dirname])) {
1526
-			$dirs[$a] = (is_dir(_ROOT_CWD . $a) || !$a);
1524
+		if (!isset($dirs[$a = $dir.$dirname])) {
1525
+			$dirs[$a] = (is_dir(_ROOT_CWD.$a) || !$a);
1527 1526
 		}
1528 1527
 		if ($dirs[$a]) {
1529
-			if (file_exists(_ROOT_CWD . ($a .= $file))) {
1528
+			if (file_exists(_ROOT_CWD.($a .= $file))) {
1530 1529
 				if ($include and !isset($inc[$dirname][$file])) {
1531
-					include_once _ROOT_CWD . $a;
1532
-					$inc[$dirname][$file] = $inc[''][$dirname . $file] = true;
1530
+					include_once _ROOT_CWD.$a;
1531
+					$inc[$dirname][$file] = $inc[''][$dirname.$file] = true;
1533 1532
 				}
1534 1533
 				if (!defined('_SAUVER_CHEMIN')) {
1535 1534
 					// si le chemin n'a pas encore ete charge, ne pas lever le flag, ne pas cacher
@@ -1539,7 +1538,7 @@  discard block
 block discarded – undo
1539 1538
 					define('_SAUVER_CHEMIN', true);
1540 1539
 				}
1541 1540
 
1542
-				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = $a;
1541
+				return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = $a;
1543 1542
 			}
1544 1543
 		}
1545 1544
 	}
@@ -1565,7 +1564,7 @@  discard block
 block discarded – undo
1565 1564
 		define('_SAUVER_CHEMIN', true);
1566 1565
 	}
1567 1566
 
1568
-	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname . $file] = false;
1567
+	return $GLOBALS['path_files'][$GLOBALS['path_sig']][$dirname][$file] = $GLOBALS['path_files'][$GLOBALS['path_sig']][''][$dirname.$file] = false;
1569 1568
 }
1570 1569
 
1571 1570
 function clear_path_cache() {
@@ -1634,12 +1633,12 @@  discard block
 block discarded – undo
1634 1633
 	// cas borderline si dans mes_options on appelle redirige_par_entete qui utilise _T et charge un fichier de langue
1635 1634
 	// on a pas encore inclus flock.php
1636 1635
 	if (!function_exists('preg_files')) {
1637
-		include_once _ROOT_RESTREINT . 'inc/flock.php';
1636
+		include_once _ROOT_RESTREINT.'inc/flock.php';
1638 1637
 	}
1639 1638
 
1640 1639
 	// Parcourir le chemin
1641 1640
 	foreach (creer_chemin() as $d) {
1642
-		$f = $d . $dir;
1641
+		$f = $d.$dir;
1643 1642
 		if (@is_dir($f)) {
1644 1643
 			$liste = preg_files($f, $pattern, $maxfiles - count($liste_fichiers), $recurs === true ? array() : $recurs);
1645 1644
 			foreach ($liste as $chemin) {
@@ -1669,9 +1668,9 @@  discard block
 block discarded – undo
1669 1668
 	static $autsanscookie = array('install', 'base_repair');
1670 1669
 
1671 1670
 	if (in_array($nom, $autsanscookie)) {
1672
-		if (test_espace_prive()){
1671
+		if (test_espace_prive()) {
1673 1672
 			include_spip('base/connect_sql');
1674
-			if (!$strict or !spip_connect()){
1673
+			if (!$strict or !spip_connect()) {
1675 1674
 				return true;
1676 1675
 			}
1677 1676
 		}
@@ -1750,7 +1749,7 @@  discard block
 block discarded – undo
1750 1749
 		return $res;
1751 1750
 	}
1752 1751
 	// Sinon c'est un raccourci ou compat SPIP < 2
1753
-	if (!function_exists($f = 'generer_url_' . $entite)) {
1752
+	if (!function_exists($f = 'generer_url_'.$entite)) {
1754 1753
 		if (!function_exists($f .= '_dist')) {
1755 1754
 			$f = '';
1756 1755
 		}
@@ -1759,8 +1758,8 @@  discard block
 block discarded – undo
1759 1758
 		$url = $f($id, $args, $ancre);
1760 1759
 		if (strlen($args)) {
1761 1760
 			$url .= strstr($url, '?')
1762
-				? '&amp;' . $args
1763
-				: '?' . $args;
1761
+				? '&amp;'.$args
1762
+				: '?'.$args;
1764 1763
 		}
1765 1764
 
1766 1765
 		return $url;
@@ -1791,8 +1790,8 @@  discard block
 block discarded – undo
1791 1790
 	include_spip('base/connect_sql');
1792 1791
 	$id_type = id_table_objet($entite, $public);
1793 1792
 
1794
-	return _DIR_RACINE . get_spip_script('./')
1795
-	. "?" . _SPIP_PAGE . "=$entite&$id_type=$i&connect=$public"
1793
+	return _DIR_RACINE.get_spip_script('./')
1794
+	. "?"._SPIP_PAGE."=$entite&$id_type=$i&connect=$public"
1796 1795
 	. (!$args ? '' : "&$args")
1797 1796
 	. (!$ancre ? '' : "#$ancre");
1798 1797
 }
@@ -1944,7 +1943,7 @@  discard block
 block discarded – undo
1944 1943
 			if (!empty($_SERVER['QUERY_STRING'])
1945 1944
 				and !strpos($_SERVER['REQUEST_URI'], '?')
1946 1945
 			) {
1947
-				$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
1946
+				$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
1948 1947
 			}
1949 1948
 		}
1950 1949
 	}
@@ -1971,17 +1970,17 @@  discard block
 block discarded – undo
1971 1970
 	list($myself) = explode('?', $myself);
1972 1971
 	// vieux mode HTTP qui envoie après le nom de la methode l'URL compléte
1973 1972
 	// protocole, "://", nom du serveur avant le path dans _SERVER["REQUEST_URI"]
1974
-	if (strpos($myself,'://') !== false) {
1975
-		$myself = explode('://',$myself);
1973
+	if (strpos($myself, '://') !== false) {
1974
+		$myself = explode('://', $myself);
1976 1975
 		array_shift($myself);
1977
-		$myself = implode('://',$myself);
1978
-		$myself = explode('/',$myself);
1976
+		$myself = implode('://', $myself);
1977
+		$myself = explode('/', $myself);
1979 1978
 		array_shift($myself);
1980
-		$myself = implode('/',$myself);
1979
+		$myself = implode('/', $myself);
1981 1980
 	}
1982
-	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)) . '/';
1981
+	$url = join('/', array_slice(explode('/', $myself), 0, -1 - $prof)).'/';
1983 1982
 
1984
-	$url = $http . '://' . rtrim($host, '/') . '/' . ltrim($url, '/');
1983
+	$url = $http.'://'.rtrim($host, '/').'/'.ltrim($url, '/');
1985 1984
 
1986 1985
 	return $url;
1987 1986
 }
@@ -2019,17 +2018,17 @@  discard block
 block discarded – undo
2019 2018
  **/
2020 2019
 function generer_url_ecrire($script = '', $args = "", $no_entities = false, $rel = false) {
2021 2020
 	if (!$rel) {
2022
-		$rel = url_de_base() . _DIR_RESTREINT_ABS . _SPIP_ECRIRE_SCRIPT;
2021
+		$rel = url_de_base()._DIR_RESTREINT_ABS._SPIP_ECRIRE_SCRIPT;
2023 2022
 	} else {
2024 2023
 		if (!is_string($rel)) {
2025 2024
 			$rel = _DIR_RESTREINT ? _DIR_RESTREINT :
2026
-				('./' . _SPIP_ECRIRE_SCRIPT);
2025
+				('./'._SPIP_ECRIRE_SCRIPT);
2027 2026
 		}
2028 2027
 	}
2029 2028
 
2030 2029
 	list($script, $ancre) = array_pad(explode('#', $script), 2, null);
2031 2030
 	if ($script and ($script <> 'accueil' or $rel)) {
2032
-		$args = "?exec=$script" . (!$args ? '' : "&$args");
2031
+		$args = "?exec=$script".(!$args ? '' : "&$args");
2033 2032
 	} elseif ($args) {
2034 2033
 		$args = "?$args";
2035 2034
 	}
@@ -2037,7 +2036,7 @@  discard block
 block discarded – undo
2037 2036
 		$args .= "#$ancre";
2038 2037
 	}
2039 2038
 
2040
-	return $rel . ($no_entities ? $args : str_replace('&', '&amp;', $args));
2039
+	return $rel.($no_entities ? $args : str_replace('&', '&amp;', $args));
2041 2040
 }
2042 2041
 
2043 2042
 //
@@ -2107,25 +2106,25 @@  discard block
 block discarded – undo
2107 2106
 		if (is_array($args)) {
2108 2107
 			$r = '';
2109 2108
 			foreach ($args as $k => $v) {
2110
-				$r .= '&' . $k . '=' . $v;
2109
+				$r .= '&'.$k.'='.$v;
2111 2110
 			}
2112 2111
 			$args = substr($r, 1);
2113 2112
 		}
2114 2113
 		$action .=
2115
-			(strpos($action, '?') !== false ? '&' : '?') . $args;
2114
+			(strpos($action, '?') !== false ? '&' : '?').$args;
2116 2115
 	}
2117 2116
 	if (!$no_entities) {
2118 2117
 		$action = quote_amp($action);
2119 2118
 	}
2120 2119
 
2121 2120
 	// ne pas generer une url avec /./?page= en cas d'url absolue et de _SPIP_SCRIPT vide
2122
-	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/') . preg_replace(",^/[.]/,", "/", "/$action"));
2121
+	return ($rel ? _DIR_RACINE . $action : rtrim(url_de_base(), '/').preg_replace(",^/[.]/,", "/", "/$action"));
2123 2122
 }
2124 2123
 
2125 2124
 // http://code.spip.net/@generer_url_prive
2126 2125
 function generer_url_prive($script, $args = "", $no_entities = false) {
2127 2126
 
2128
-	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS . 'prive.php');
2127
+	return generer_url_public($script, $args, $no_entities, false, _DIR_RESTREINT_ABS.'prive.php');
2129 2128
 }
2130 2129
 
2131 2130
 // Pour les formulaires en methode POST,
@@ -2160,8 +2159,7 @@  discard block
 block discarded – undo
2160 2159
 	. "><div>\n"
2161 2160
 	. "<input type='hidden' name='exec' value='$script1' />"
2162 2161
 	. $corps
2163
-	. (!$submit ? '' :
2164
-		("<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><input class='fondo' type='submit' value=\"" . entites_html($submit) . "\" /></div>"))
2162
+	. (!$submit ? '' : ("<div style='text-align: ".$GLOBALS['spip_lang_right']."'><input class='fondo' type='submit' value=\"".entites_html($submit)."\" /></div>"))
2165 2163
 	. "</div></form>\n";
2166 2164
 }
2167 2165
 
@@ -2186,14 +2184,14 @@  discard block
 block discarded – undo
2186 2184
 		? generer_url_ecrire(_request('exec'))
2187 2185
 		: generer_url_public();
2188 2186
 
2189
-	return "\n<form action='" .
2190
-	$h .
2191
-	"'" .
2192
-	$atts .
2193
-	">\n" .
2194
-	"<div>" .
2195
-	"\n<input type='hidden' name='action' value='$script' />" .
2196
-	$corps .
2187
+	return "\n<form action='".
2188
+	$h.
2189
+	"'".
2190
+	$atts.
2191
+	">\n".
2192
+	"<div>".
2193
+	"\n<input type='hidden' name='action' value='$script' />".
2194
+	$corps.
2197 2195
 	"</div></form>";
2198 2196
 }
2199 2197
 
@@ -2221,7 +2219,7 @@  discard block
 block discarded – undo
2221 2219
 		: generer_url_public('', '', false, false);
2222 2220
 	$url = parametre_url($url, 'action', $script);
2223 2221
 	if ($args) {
2224
-		$url .= quote_amp('&' . $args);
2222
+		$url .= quote_amp('&'.$args);
2225 2223
 	}
2226 2224
 
2227 2225
 	if ($no_entities) {
@@ -2271,17 +2269,17 @@  discard block
 block discarded – undo
2271 2269
 
2272 2270
 	// le nom du repertoire plugins/ activables/desactivables
2273 2271
 	if (!defined('_DIR_PLUGINS')) {
2274
-		define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
2272
+		define('_DIR_PLUGINS', _DIR_RACINE."plugins/");
2275 2273
 	}
2276 2274
 
2277 2275
 	// le nom du repertoire des extensions/ permanentes du core, toujours actives
2278 2276
 	if (!defined('_DIR_PLUGINS_DIST')) {
2279
-		define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
2277
+		define('_DIR_PLUGINS_DIST', _DIR_RACINE."plugins-dist/");
2280 2278
 	}
2281 2279
 
2282 2280
 	// le nom du repertoire des librairies
2283 2281
 	if (!defined('_DIR_LIB')) {
2284
-		define('_DIR_LIB', _DIR_RACINE . "lib/");
2282
+		define('_DIR_LIB', _DIR_RACINE."lib/");
2285 2283
 	}
2286 2284
 
2287 2285
 	if (!defined('_DIR_IMG')) {
@@ -2291,29 +2289,29 @@  discard block
 block discarded – undo
2291 2289
 		define('_DIR_LOGOS', $pa);
2292 2290
 	}
2293 2291
 	if (!defined('_DIR_IMG_ICONES')) {
2294
-		define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
2292
+		define('_DIR_IMG_ICONES', _DIR_LOGOS."icones/");
2295 2293
 	}
2296 2294
 
2297 2295
 	if (!defined('_DIR_DUMP')) {
2298
-		define('_DIR_DUMP', $ti . "dump/");
2296
+		define('_DIR_DUMP', $ti."dump/");
2299 2297
 	}
2300 2298
 	if (!defined('_DIR_SESSIONS')) {
2301
-		define('_DIR_SESSIONS', $ti . "sessions/");
2299
+		define('_DIR_SESSIONS', $ti."sessions/");
2302 2300
 	}
2303 2301
 	if (!defined('_DIR_TRANSFERT')) {
2304
-		define('_DIR_TRANSFERT', $ti . "upload/");
2302
+		define('_DIR_TRANSFERT', $ti."upload/");
2305 2303
 	}
2306 2304
 	if (!defined('_DIR_CACHE')) {
2307
-		define('_DIR_CACHE', $ti . "cache/");
2305
+		define('_DIR_CACHE', $ti."cache/");
2308 2306
 	}
2309 2307
 	if (!defined('_DIR_CACHE_XML')) {
2310
-		define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
2308
+		define('_DIR_CACHE_XML', _DIR_CACHE."xml/");
2311 2309
 	}
2312 2310
 	if (!defined('_DIR_SKELS')) {
2313
-		define('_DIR_SKELS', _DIR_CACHE . "skel/");
2311
+		define('_DIR_SKELS', _DIR_CACHE."skel/");
2314 2312
 	}
2315 2313
 	if (!defined('_DIR_AIDE')) {
2316
-		define('_DIR_AIDE', _DIR_CACHE . "aide/");
2314
+		define('_DIR_AIDE', _DIR_CACHE."aide/");
2317 2315
 	}
2318 2316
 	if (!defined('_DIR_TMP')) {
2319 2317
 		define('_DIR_TMP', $ti);
@@ -2343,27 +2341,27 @@  discard block
 block discarded – undo
2343 2341
 	// Declaration des fichiers
2344 2342
 
2345 2343
 	if (!defined('_CACHE_PLUGINS_PATH')) {
2346
-		define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
2344
+		define('_CACHE_PLUGINS_PATH', _DIR_CACHE."charger_plugins_chemins.php");
2347 2345
 	}
2348 2346
 	if (!defined('_CACHE_PLUGINS_OPT')) {
2349
-		define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
2347
+		define('_CACHE_PLUGINS_OPT', _DIR_CACHE."charger_plugins_options.php");
2350 2348
 	}
2351 2349
 	if (!defined('_CACHE_PLUGINS_FCT')) {
2352
-		define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
2350
+		define('_CACHE_PLUGINS_FCT', _DIR_CACHE."charger_plugins_fonctions.php");
2353 2351
 	}
2354 2352
 	if (!defined('_CACHE_PIPELINES')) {
2355
-		define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
2353
+		define('_CACHE_PIPELINES', _DIR_CACHE."charger_pipelines.php");
2356 2354
 	}
2357 2355
 	if (!defined('_CACHE_CHEMIN')) {
2358
-		define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
2356
+		define('_CACHE_CHEMIN', _DIR_CACHE."chemin.txt");
2359 2357
 	}
2360 2358
 
2361 2359
 	# attention .php obligatoire pour ecrire_fichier_securise
2362 2360
 	if (!defined('_FILE_META')) {
2363
-		define('_FILE_META', $ti . 'meta_cache.php');
2361
+		define('_FILE_META', $ti.'meta_cache.php');
2364 2362
 	}
2365 2363
 	if (!defined('_DIR_LOG')) {
2366
-		define('_DIR_LOG', _DIR_TMP . 'log/');
2364
+		define('_DIR_LOG', _DIR_TMP.'log/');
2367 2365
 	}
2368 2366
 	if (!defined('_FILE_LOG')) {
2369 2367
 		define('_FILE_LOG', 'spip');
@@ -2379,8 +2377,8 @@  discard block
 block discarded – undo
2379 2377
 	}
2380 2378
 	if (!defined('_FILE_CONNECT')) {
2381 2379
 		define('_FILE_CONNECT',
2382
-		(@is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f
2383
-			: (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f
2380
+		(@is_readable($f = _DIR_CONNECT._FILE_CONNECT_INS.'.php') ? $f
2381
+			: (@is_readable($f = _DIR_RESTREINT.'inc_connect.php') ? $f
2384 2382
 				: false)));
2385 2383
 	}
2386 2384
 
@@ -2390,7 +2388,7 @@  discard block
 block discarded – undo
2390 2388
 	}
2391 2389
 	if (!defined('_FILE_CHMOD')) {
2392 2390
 		define('_FILE_CHMOD',
2393
-		(@is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f
2391
+		(@is_readable($f = _DIR_CHMOD._FILE_CHMOD_INS.'.php') ? $f
2394 2392
 			: false));
2395 2393
 	}
2396 2394
 
@@ -2402,10 +2400,10 @@  discard block
 block discarded – undo
2402 2400
 		define('_FILE_TMP_SUFFIX', '.tmp.php');
2403 2401
 	}
2404 2402
 	if (!defined('_FILE_CONNECT_TMP')) {
2405
-		define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
2403
+		define('_FILE_CONNECT_TMP', _DIR_CONNECT._FILE_CONNECT_INS._FILE_TMP_SUFFIX);
2406 2404
 	}
2407 2405
 	if (!defined('_FILE_CHMOD_TMP')) {
2408
-		define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
2406
+		define('_FILE_CHMOD_TMP', _DIR_CHMOD._FILE_CHMOD_INS._FILE_TMP_SUFFIX);
2409 2407
 	}
2410 2408
 
2411 2409
 	// Definition des droits d'acces en ecriture
@@ -2423,13 +2421,13 @@  discard block
 block discarded – undo
2423 2421
 		define('_DEFAULT_CHARSET', 'utf-8');
2424 2422
 	}
2425 2423
 	if (!defined('_ROOT_PLUGINS')) {
2426
-		define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
2424
+		define('_ROOT_PLUGINS', _ROOT_RACINE."plugins/");
2427 2425
 	}
2428 2426
 	if (!defined('_ROOT_PLUGINS_DIST')) {
2429
-		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
2427
+		define('_ROOT_PLUGINS_DIST', _ROOT_RACINE."plugins-dist/");
2430 2428
 	}
2431 2429
 	if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
2432
-		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2430
+		define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE.str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
2433 2431
 	}
2434 2432
 
2435 2433
 	// La taille des Log
@@ -2466,7 +2464,7 @@  discard block
 block discarded – undo
2466 2464
 	// (non surchargeable en l'etat ; attention si on utilise include_spip()
2467 2465
 	// pour le rendre surchargeable, on va provoquer un reecriture
2468 2466
 	// systematique du noyau ou une baisse de perfs => a etudier)
2469
-	include_once _ROOT_RESTREINT . 'inc/flock.php';
2467
+	include_once _ROOT_RESTREINT.'inc/flock.php';
2470 2468
 
2471 2469
 	// charger tout de suite le path et son cache
2472 2470
 	load_path_cache();
@@ -2513,7 +2511,7 @@  discard block
 block discarded – undo
2513 2511
 		if (!empty($_SERVER['QUERY_STRING'])
2514 2512
 			and !strpos($_SERVER['REQUEST_URI'], '?')
2515 2513
 		) {
2516
-			$GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
2514
+			$GLOBALS['REQUEST_URI'] .= '?'.$_SERVER['QUERY_STRING'];
2517 2515
 		}
2518 2516
 	}
2519 2517
 
@@ -2549,7 +2547,7 @@  discard block
 block discarded – undo
2549 2547
 
2550 2548
 			if (isset($GLOBALS['meta']['adresse_site'])) {
2551 2549
 				$uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
2552
-				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '') . '/';
2550
+				$uri_ref = (isset($uri_ref['path']) ? $uri_ref['path'] : '').'/';
2553 2551
 			} else {
2554 2552
 				$uri_ref = "";
2555 2553
 			}
@@ -2637,7 +2635,7 @@  discard block
 block discarded – undo
2637 2635
 	}
2638 2636
 	if (!defined('_CACHE_RUBRIQUES')) {
2639 2637
 		/** Fichier cache pour le navigateur de rubrique du bandeau */
2640
-		define('_CACHE_RUBRIQUES', _DIR_TMP . 'menu-rubriques-cache.txt');
2638
+		define('_CACHE_RUBRIQUES', _DIR_TMP.'menu-rubriques-cache.txt');
2641 2639
 	}
2642 2640
 	if (!defined('_CACHE_RUBRIQUES_MAX')) {
2643 2641
 		/** Nombre maxi de rubriques enfants affichées pour chaque rubrique du navigateur de rubrique du bandeau */
@@ -2729,7 +2727,7 @@  discard block
 block discarded – undo
2729 2727
 					$memory *= 1024;
2730 2728
 			}
2731 2729
 			if ($memory < _MEMORY_LIMIT_MIN * 1024 * 1024) {
2732
-				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN . 'M');
2730
+				@ini_set('memory_limit', $m = _MEMORY_LIMIT_MIN.'M');
2733 2731
 				if (trim(ini_get('memory_limit')) != $m) {
2734 2732
 					if (!defined('_INTERDIRE_COMPACTE_HEAD_ECRIRE')) {
2735 2733
 						define('_INTERDIRE_COMPACTE_HEAD_ECRIRE', true);
@@ -2879,7 +2877,7 @@  discard block
 block discarded – undo
2879 2877
 					}
2880 2878
 					if (isset($GLOBALS['visiteur_session']['nom'])) {
2881 2879
 						spip_log($GLOBALS['visiteur_session']['nom']
2882
-							. " " . _VAR_MODE);
2880
+							. " "._VAR_MODE);
2883 2881
 					}
2884 2882
 				} // pas autorise ?
2885 2883
 				else {
@@ -2887,7 +2885,7 @@  discard block
 block discarded – undo
2887 2885
 					if (!$GLOBALS['visiteur_session']) {
2888 2886
 						include_spip('inc/headers');
2889 2887
 						redirige_par_entete(generer_url_public('login',
2890
-							'url=' . rawurlencode(
2888
+							'url='.rawurlencode(
2891 2889
 								parametre_url(self(), 'var_mode', $_GET['var_mode'], '&')
2892 2890
 							), true));
2893 2891
 					}
@@ -2940,10 +2938,10 @@  discard block
 block discarded – undo
2940 2938
 	// mais on risque de perturber des plugins en initialisant trop tot
2941 2939
 	// certaines constantes
2942 2940
 	@spip_initialisation_core(
2943
-		(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
2944
-		(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
2945
-		(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
2946
-		(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
2941
+		(_DIR_RACINE._NOM_PERMANENTS_INACCESSIBLES),
2942
+		(_DIR_RACINE._NOM_PERMANENTS_ACCESSIBLES),
2943
+		(_DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES),
2944
+		(_DIR_RACINE._NOM_TEMPORAIRES_ACCESSIBLES)
2947 2945
 	);
2948 2946
 
2949 2947
 	// Demarrer une session NON AUTHENTIFIEE si on donne son nom
@@ -2976,7 +2974,7 @@  discard block
 block discarded – undo
2976 2974
 	}
2977 2975
 
2978 2976
 	$h = (isset($_SERVER['PHP_AUTH_USER']) and !$GLOBALS['ignore_auth_http']);
2979
-	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'] . '_session'])) {
2977
+	if ($h or isset($_COOKIE['spip_session']) or isset($_COOKIE[$GLOBALS['cookie_prefix'].'_session'])) {
2980 2978
 
2981 2979
 		$session = charger_fonction('session', 'inc');
2982 2980
 		if ($session()) {
@@ -3056,7 +3054,7 @@  discard block
 block discarded – undo
3056 3054
 		$s = pipeline('definir_session',
3057 3055
 			$GLOBALS['visiteur_session']
3058 3056
 				? serialize($GLOBALS['visiteur_session'])
3059
-				. '_' . @$_COOKIE['spip_session']
3057
+				. '_'.@$_COOKIE['spip_session']
3060 3058
 				: ''
3061 3059
 		);
3062 3060
 		$session = $s ? substr(md5($s), 0, 8) : '';
@@ -3201,12 +3199,12 @@  discard block
 block discarded – undo
3201 3199
 	$GLOBALS['_INC_PUBLIC']++;
3202 3200
 
3203 3201
 	// fix #4235
3204
-	$cache_utilise_session_appelant	= (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3202
+	$cache_utilise_session_appelant = (isset($GLOBALS['cache_utilise_session']) ? $GLOBALS['cache_utilise_session'] : null);
3205 3203
 
3206 3204
 
3207 3205
 	foreach (is_array($fond) ? $fond : array($fond) as $f) {
3208 3206
 		
3209
-		unset($GLOBALS['cache_utilise_session']);	// fix #4235
3207
+		unset($GLOBALS['cache_utilise_session']); // fix #4235
3210 3208
 
3211 3209
 		$page = evaluer_fond($f, $contexte, $connect);
3212 3210
 		if ($page === '') {
@@ -3245,7 +3243,7 @@  discard block
 block discarded – undo
3245 3243
 		}
3246 3244
 		
3247 3245
 		// contamination de la session appelante, pour les inclusions statiques
3248
-		if (isset($page['invalideurs']['session'])){
3246
+		if (isset($page['invalideurs']['session'])) {
3249 3247
 			$cache_utilise_session_appelant = $page['invalideurs']['session'];
3250 3248
 		}
3251 3249
 	}
@@ -3291,7 +3289,7 @@  discard block
 block discarded – undo
3291 3289
  * @return array|string
3292 3290
  */
3293 3291
 function trouver_fond($nom, $dir = '', $pathinfo = false) {
3294
-	$f = find_in_path($nom . '.' . _EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/') . '/' : '');
3292
+	$f = find_in_path($nom.'.'._EXTENSION_SQUELETTES, $dir ? rtrim($dir, '/').'/' : '');
3295 3293
 	if (!$pathinfo) {
3296 3294
 		return $f;
3297 3295
 	}
@@ -3531,7 +3529,7 @@  discard block
 block discarded – undo
3531 3529
 
3532 3530
 			if (!is_array($params[0])) {
3533 3531
 				trigger_error(
3534
-					'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
3532
+					'array_column() expects parameter 1 to be array, '.gettype($params[0]).' given',
3535 3533
 					E_USER_WARNING
3536 3534
 				);
3537 3535
 				return null;
Please login to merge, or discard this patch.
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1392,8 +1392,7 @@  discard block
 block discarded – undo
1392 1392
 		and $f = find_in_theme("$file_svg_generique")) {
1393 1393
 		if ($fsize = substr($f,0,-6) . $m[1] . ".svg" and file_exists($fsize)) {
1394 1394
 			return $themefiles["$subdir$file"] = $fsize;
1395
-		}
1396
-		else {
1395
+		} else {
1397 1396
 			return $themefiles["$subdir$file"] = "$f?".$m[1]."px";
1398 1397
 		}
1399 1398
 	}
@@ -2333,12 +2332,13 @@  discard block
 block discarded – undo
2333 2332
 		define('_DIR_CHMOD', $pi);
2334 2333
 	}
2335 2334
 
2336
-	if (!isset($GLOBALS['test_dirs']))
2337
-		// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2335
+	if (!isset($GLOBALS['test_dirs'])) {
2336
+			// Pas $pi car il est bon de le mettre hors ecriture apres intstall
2338 2337
 		// il sera rajoute automatiquement si besoin a l'etape 2 de l'install
2339 2338
 	{
2340 2339
 		$GLOBALS['test_dirs'] = array($pa, $ti, $ta);
2341 2340
 	}
2341
+	}
2342 2342
 
2343 2343
 	// Declaration des fichiers
2344 2344
 
@@ -3415,8 +3415,7 @@  discard block
 block discarded – undo
3415 3415
 			  and $h = svg_dimension_to_pixels($attrs['height'])) {
3416 3416
 				$width = $w;
3417 3417
 				$height = $h;
3418
-			}
3419
-			elseif (isset($attrs['viewBox'])) {
3418
+			} elseif (isset($attrs['viewBox'])) {
3420 3419
 				$viewbox = trim($attrs['viewBox']);
3421 3420
 				$viewbox = preg_replace(",\s+,", " ", $viewbox);
3422 3421
 				$viewbox = explode(" ", $viewbox);
Please login to merge, or discard this patch.
ecrire/inc/filtres.php 3 patches
Indentation   +2016 added lines, -2016 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 ($svn_revision = version_svn_courante(_DIR_RACINE)) {
162
-		$version .= ($svn_revision < 0 ? ' SVN' : '') . ' [' . abs($svn_revision) . ']';
163
-	}
160
+    $version = $GLOBALS['spip_version_affichee'];
161
+    if ($svn_revision = version_svn_courante(_DIR_RACINE)) {
162
+        $version .= ($svn_revision < 0 ? ' SVN' : '') . ' [' . abs($svn_revision) . ']';
163
+    }
164 164
 
165
-	return $version;
165
+    return $version;
166 166
 }
167 167
 
168 168
 
@@ -181,43 +181,43 @@  discard block
 block discarded – undo
181 181
  *
182 182
  **/
183 183
 function version_svn_courante($dir) {
184
-	if (!$dir) {
185
-		$dir = '.';
186
-	}
187
-
188
-	// version installee par paquet ZIP
189
-	if (lire_fichier($dir . '/svn.revision', $c)
190
-		and preg_match(',Revision: (\d+),', $c, $d)
191
-	) {
192
-		return intval($d[1]);
193
-	}
194
-
195
-	// version installee par SVN
196
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
197
-		$db = new SQLite3($dir . '/.svn/wc.db');
198
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
199
-		if ($result) {
200
-			$row = $result->fetchArray();
201
-			if ($row['changed_revision'] != "") {
202
-				return -$row['changed_revision'];
203
-			}
204
-		}
205
-	} else if (lire_fichier($dir . '/.svn/entries', $c)
206
-		and (
207
-			(preg_match_all(
208
-					',committed-rev="([0-9]+)",', $c, $r1, PREG_PATTERN_ORDER)
209
-				and $v = max($r1[1])
210
-			)
211
-			or
212
-			(preg_match(',^\d.*dir[\r\n]+(\d+),ms', $c, $r1) # svn >= 1.4
213
-				and $v = $r1[1]
214
-			))
215
-	) {
216
-		return -$v;
217
-	}
218
-
219
-	// Bug ou paquet fait main
220
-	return 0;
184
+    if (!$dir) {
185
+        $dir = '.';
186
+    }
187
+
188
+    // version installee par paquet ZIP
189
+    if (lire_fichier($dir . '/svn.revision', $c)
190
+        and preg_match(',Revision: (\d+),', $c, $d)
191
+    ) {
192
+        return intval($d[1]);
193
+    }
194
+
195
+    // version installee par SVN
196
+    if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
197
+        $db = new SQLite3($dir . '/.svn/wc.db');
198
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
199
+        if ($result) {
200
+            $row = $result->fetchArray();
201
+            if ($row['changed_revision'] != "") {
202
+                return -$row['changed_revision'];
203
+            }
204
+        }
205
+    } else if (lire_fichier($dir . '/.svn/entries', $c)
206
+        and (
207
+            (preg_match_all(
208
+                    ',committed-rev="([0-9]+)",', $c, $r1, PREG_PATTERN_ORDER)
209
+                and $v = max($r1[1])
210
+            )
211
+            or
212
+            (preg_match(',^\d.*dir[\r\n]+(\d+),ms', $c, $r1) # svn >= 1.4
213
+                and $v = $r1[1]
214
+            ))
215
+    ) {
216
+        return -$v;
217
+    }
218
+
219
+    // Bug ou paquet fait main
220
+    return 0;
221 221
 }
222 222
 
223 223
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
  *     Code HTML retourné par le filtre
262 262
  **/
263 263
 function filtrer($filtre) {
264
-	$tous = func_get_args();
265
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
266
-		return image_filtrer($tous);
267
-	} elseif ($f = chercher_filtre($filtre)) {
268
-		array_shift($tous);
269
-		return call_user_func_array($f, $tous);
270
-	} else {
271
-		// le filtre n'existe pas, on provoque une erreur
272
-		$msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
273
-		erreur_squelette($msg);
274
-		return '';
275
-	}
264
+    $tous = func_get_args();
265
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
266
+        return image_filtrer($tous);
267
+    } elseif ($f = chercher_filtre($filtre)) {
268
+        array_shift($tous);
269
+        return call_user_func_array($f, $tous);
270
+    } else {
271
+        // le filtre n'existe pas, on provoque une erreur
272
+        $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
273
+        erreur_squelette($msg);
274
+        return '';
275
+    }
276 276
 }
277 277
 
278 278
 /**
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
290 290
  */
291 291
 function trouver_filtre_matrice($filtre) {
292
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
293
-		find_in_path($f, '', true);
294
-		$GLOBALS['spip_matrice'][$filtre] = true;
295
-	}
296
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
292
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
293
+        find_in_path($f, '', true);
294
+        $GLOBALS['spip_matrice'][$filtre] = true;
295
+    }
296
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
297 297
 }
298 298
 
299 299
 
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
  * @return mixed
322 322
  */
323 323
 function filtre_set(&$Pile, $val, $key, $continue = null) {
324
-	$Pile['vars'][$key] = $val;
325
-	return $continue ? $val : '';
324
+    $Pile['vars'][$key] = $val;
325
+    return $continue ? $val : '';
326 326
 }
327 327
 
328 328
 /**
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
349 349
  */
350 350
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
351
-	$Pile[0][$key] = $val;
352
-	return $continue ? $val : '';
351
+    $Pile[0][$key] = $val;
352
+    return $continue ? $val : '';
353 353
 }
354 354
 
355 355
 /**
@@ -371,18 +371,18 @@  discard block
 block discarded – undo
371 371
  * @return mixed Retourne la valeur (sans la modifier).
372 372
  */
373 373
 function filtre_debug($val, $key = null) {
374
-	$debug = (
375
-		is_null($key) ? '' : (var_export($key, true) . " = ")
376
-		) . var_export($val, true);
374
+    $debug = (
375
+        is_null($key) ? '' : (var_export($key, true) . " = ")
376
+        ) . var_export($val, true);
377 377
 
378
-	include_spip('inc/autoriser');
379
-	if (autoriser('webmestre')) {
380
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
381
-	}
378
+    include_spip('inc/autoriser');
379
+    if (autoriser('webmestre')) {
380
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
381
+    }
382 382
 
383
-	spip_log($debug, 'debug');
383
+    spip_log($debug, 'debug');
384 384
 
385
-	return $val;
385
+    return $val;
386 386
 }
387 387
 
388 388
 
@@ -410,71 +410,71 @@  discard block
 block discarded – undo
410 410
  *     Texte qui a reçu les filtres
411 411
  **/
412 412
 function image_filtrer($args) {
413
-	$filtre = array_shift($args); # enlever $filtre
414
-	$texte = array_shift($args);
415
-	if (!strlen($texte)) {
416
-		return;
417
-	}
418
-	find_in_path('filtres_images_mini.php', 'inc/', true);
419
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
420
-	// Cas du nom de fichier local
421
-	if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
422
-		and !preg_match(',^/|[<>]|\s,S', $texte)
423
-		and (
424
-			file_exists(preg_replace(',[?].*$,', '', $texte))
425
-			or tester_url_absolue($texte)
426
-		)
427
-	) {
428
-		array_unshift($args, "<img src='$texte' />");
429
-		$res = call_user_func_array($filtre, $args);
430
-		statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
431
-		return $res;
432
-	}
433
-
434
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
435
-	if (preg_match_all(
436
-		',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
437
-		$texte, $tags, PREG_SET_ORDER)) {
438
-		foreach ($tags as $tag) {
439
-			$class = extraire_attribut($tag[3], 'class');
440
-			if (!$class or
441
-				(strpos($class, 'filtre_inactif') === false
442
-					// compat historique a virer en 3.2
443
-					and strpos($class, 'no_image_filtrer') === false)
444
-			) {
445
-				array_unshift($args, $tag[3]);
446
-				if ($reduit = call_user_func_array($filtre, $args)) {
447
-					// En cas de span spip_documents, modifier le style=...width:
448
-					if ($tag[1]) {
449
-						$w = extraire_attribut($reduit, 'width');
450
-						if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
451
-							$w = $regs[1];
452
-						}
453
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
454
-							$style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
455
-							$replace = inserer_attribut($tag[1], 'style', $style);
456
-							$texte = str_replace($tag[1], $replace, $texte);
457
-						}
458
-					}
459
-					// traiter aussi un eventuel mouseover
460
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
461
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
462
-							$srcover = $match[1];
463
-							array_shift($args);
464
-							array_unshift($args, "<img src='" . $match[1] . "' />");
465
-							$srcover_filter = call_user_func_array($filtre, $args);
466
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
467
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
468
-						}
469
-					}
470
-					$texte = str_replace($tag[3], $reduit, $texte);
471
-				}
472
-				array_shift($args);
473
-			}
474
-		}
475
-	}
476
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
477
-	return $texte;
413
+    $filtre = array_shift($args); # enlever $filtre
414
+    $texte = array_shift($args);
415
+    if (!strlen($texte)) {
416
+        return;
417
+    }
418
+    find_in_path('filtres_images_mini.php', 'inc/', true);
419
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
420
+    // Cas du nom de fichier local
421
+    if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
422
+        and !preg_match(',^/|[<>]|\s,S', $texte)
423
+        and (
424
+            file_exists(preg_replace(',[?].*$,', '', $texte))
425
+            or tester_url_absolue($texte)
426
+        )
427
+    ) {
428
+        array_unshift($args, "<img src='$texte' />");
429
+        $res = call_user_func_array($filtre, $args);
430
+        statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
431
+        return $res;
432
+    }
433
+
434
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
435
+    if (preg_match_all(
436
+        ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
437
+        $texte, $tags, PREG_SET_ORDER)) {
438
+        foreach ($tags as $tag) {
439
+            $class = extraire_attribut($tag[3], 'class');
440
+            if (!$class or
441
+                (strpos($class, 'filtre_inactif') === false
442
+                    // compat historique a virer en 3.2
443
+                    and strpos($class, 'no_image_filtrer') === false)
444
+            ) {
445
+                array_unshift($args, $tag[3]);
446
+                if ($reduit = call_user_func_array($filtre, $args)) {
447
+                    // En cas de span spip_documents, modifier le style=...width:
448
+                    if ($tag[1]) {
449
+                        $w = extraire_attribut($reduit, 'width');
450
+                        if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
451
+                            $w = $regs[1];
452
+                        }
453
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
454
+                            $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
455
+                            $replace = inserer_attribut($tag[1], 'style', $style);
456
+                            $texte = str_replace($tag[1], $replace, $texte);
457
+                        }
458
+                    }
459
+                    // traiter aussi un eventuel mouseover
460
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
461
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
462
+                            $srcover = $match[1];
463
+                            array_shift($args);
464
+                            array_unshift($args, "<img src='" . $match[1] . "' />");
465
+                            $srcover_filter = call_user_func_array($filtre, $args);
466
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
467
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
468
+                        }
469
+                    }
470
+                    $texte = str_replace($tag[3], $reduit, $texte);
471
+                }
472
+                array_shift($args);
473
+            }
474
+        }
475
+    }
476
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
477
+    return $texte;
478 478
 }
479 479
 
480 480
 /**
@@ -489,65 +489,65 @@  discard block
 block discarded – undo
489 489
  **/
490 490
 function taille_image($img) {
491 491
 
492
-	static $largeur_img = array(), $hauteur_img = array();
493
-	$srcWidth = 0;
494
-	$srcHeight = 0;
495
-
496
-	$src = extraire_attribut($img, 'src');
497
-
498
-	if (!$src) {
499
-		$src = $img;
500
-	} else {
501
-		$srcWidth = extraire_attribut($img, 'width');
502
-		$srcHeight = extraire_attribut($img, 'height');
503
-	}
504
-
505
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
506
-	// la copie locale a toutes les chances d'etre la ou de resservir
507
-	if (tester_url_absolue($src)) {
508
-		include_spip('inc/distant');
509
-		$fichier = copie_locale($src);
510
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
511
-	}
512
-	if (($p = strpos($src, '?')) !== false) {
513
-		$src = substr($src, 0, $p);
514
-	}
515
-
516
-	$srcsize = false;
517
-	if (isset($largeur_img[$src])) {
518
-		$srcWidth = $largeur_img[$src];
519
-	}
520
-	if (isset($hauteur_img[$src])) {
521
-		$srcHeight = $hauteur_img[$src];
522
-	}
523
-	if (!$srcWidth or !$srcHeight) {
524
-
525
-		if (file_exists($src)
526
-			and $srcsize = spip_getimagesize($src)
527
-		) {
528
-			if (!$srcWidth) {
529
-				$largeur_img[$src] = $srcWidth = $srcsize[0];
530
-			}
531
-			if (!$srcHeight) {
532
-				$hauteur_img[$src] = $srcHeight = $srcsize[1];
533
-			}
534
-		}
535
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
536
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
537
-		elseif (@file_exists($f = "$src.src")
538
-			and lire_fichier($f, $valeurs)
539
-			and $valeurs = unserialize($valeurs)
540
-		) {
541
-			if (!$srcWidth) {
542
-				$largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
543
-			}
544
-			if (!$srcHeight) {
545
-				$hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
546
-			}
547
-		}
548
-	}
549
-
550
-	return array($srcHeight, $srcWidth);
492
+    static $largeur_img = array(), $hauteur_img = array();
493
+    $srcWidth = 0;
494
+    $srcHeight = 0;
495
+
496
+    $src = extraire_attribut($img, 'src');
497
+
498
+    if (!$src) {
499
+        $src = $img;
500
+    } else {
501
+        $srcWidth = extraire_attribut($img, 'width');
502
+        $srcHeight = extraire_attribut($img, 'height');
503
+    }
504
+
505
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
506
+    // la copie locale a toutes les chances d'etre la ou de resservir
507
+    if (tester_url_absolue($src)) {
508
+        include_spip('inc/distant');
509
+        $fichier = copie_locale($src);
510
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
511
+    }
512
+    if (($p = strpos($src, '?')) !== false) {
513
+        $src = substr($src, 0, $p);
514
+    }
515
+
516
+    $srcsize = false;
517
+    if (isset($largeur_img[$src])) {
518
+        $srcWidth = $largeur_img[$src];
519
+    }
520
+    if (isset($hauteur_img[$src])) {
521
+        $srcHeight = $hauteur_img[$src];
522
+    }
523
+    if (!$srcWidth or !$srcHeight) {
524
+
525
+        if (file_exists($src)
526
+            and $srcsize = spip_getimagesize($src)
527
+        ) {
528
+            if (!$srcWidth) {
529
+                $largeur_img[$src] = $srcWidth = $srcsize[0];
530
+            }
531
+            if (!$srcHeight) {
532
+                $hauteur_img[$src] = $srcHeight = $srcsize[1];
533
+            }
534
+        }
535
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
536
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
537
+        elseif (@file_exists($f = "$src.src")
538
+            and lire_fichier($f, $valeurs)
539
+            and $valeurs = unserialize($valeurs)
540
+        ) {
541
+            if (!$srcWidth) {
542
+                $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
543
+            }
544
+            if (!$srcHeight) {
545
+                $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
546
+            }
547
+        }
548
+    }
549
+
550
+    return array($srcHeight, $srcWidth);
551 551
 }
552 552
 
553 553
 
@@ -565,12 +565,12 @@  discard block
 block discarded – undo
565 565
  *     Largeur en pixels, NULL ou 0 si aucune image.
566 566
  **/
567 567
 function largeur($img) {
568
-	if (!$img) {
569
-		return;
570
-	}
571
-	list($h, $l) = taille_image($img);
568
+    if (!$img) {
569
+        return;
570
+    }
571
+    list($h, $l) = taille_image($img);
572 572
 
573
-	return $l;
573
+    return $l;
574 574
 }
575 575
 
576 576
 /**
@@ -587,12 +587,12 @@  discard block
 block discarded – undo
587 587
  *     Hauteur en pixels, NULL ou 0 si aucune image.
588 588
  **/
589 589
 function hauteur($img) {
590
-	if (!$img) {
591
-		return;
592
-	}
593
-	list($h, $l) = taille_image($img);
590
+    if (!$img) {
591
+        return;
592
+    }
593
+    list($h, $l) = taille_image($img);
594 594
 
595
-	return $h;
595
+    return $h;
596 596
 }
597 597
 
598 598
 
@@ -612,11 +612,11 @@  discard block
 block discarded – undo
612 612
  * @return string
613 613
  **/
614 614
 function corriger_entites_html($texte) {
615
-	if (strpos($texte, '&amp;') === false) {
616
-		return $texte;
617
-	}
615
+    if (strpos($texte, '&amp;') === false) {
616
+        return $texte;
617
+    }
618 618
 
619
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
619
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
620 620
 }
621 621
 
622 622
 /**
@@ -631,11 +631,11 @@  discard block
 block discarded – undo
631 631
  * @return string
632 632
  **/
633 633
 function corriger_toutes_entites_html($texte) {
634
-	if (strpos($texte, '&amp;') === false) {
635
-		return $texte;
636
-	}
634
+    if (strpos($texte, '&amp;') === false) {
635
+        return $texte;
636
+    }
637 637
 
638
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
638
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
639 639
 }
640 640
 
641 641
 /**
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
  * @return string
646 646
  **/
647 647
 function proteger_amp($texte) {
648
-	return str_replace('&', '&amp;', $texte);
648
+    return str_replace('&', '&amp;', $texte);
649 649
 }
650 650
 
651 651
 
@@ -676,20 +676,20 @@  discard block
 block discarded – undo
676 676
  * @return mixed|string
677 677
  */
678 678
 function entites_html($texte, $tout = false, $quote = true) {
679
-	if (!is_string($texte) or !$texte
680
-		or strpbrk($texte, "&\"'<>") == false
681
-	) {
682
-		return $texte;
683
-	}
684
-	include_spip('inc/texte');
685
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
686
-	$flags |= ENT_HTML401;
687
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
688
-	if ($tout) {
689
-		return corriger_toutes_entites_html($texte);
690
-	} else {
691
-		return corriger_entites_html($texte);
692
-	}
679
+    if (!is_string($texte) or !$texte
680
+        or strpbrk($texte, "&\"'<>") == false
681
+    ) {
682
+        return $texte;
683
+    }
684
+    include_spip('inc/texte');
685
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
686
+    $flags |= ENT_HTML401;
687
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
688
+    if ($tout) {
689
+        return corriger_toutes_entites_html($texte);
690
+    } else {
691
+        return corriger_entites_html($texte);
692
+    }
693 693
 }
694 694
 
695 695
 /**
@@ -708,37 +708,37 @@  discard block
 block discarded – undo
708 708
  *     Texte converti
709 709
  **/
710 710
 function filtrer_entites($texte) {
711
-	if (strpos($texte, '&') === false) {
712
-		return $texte;
713
-	}
714
-	// filtrer
715
-	$texte = html2unicode($texte);
716
-	// remettre le tout dans le charset cible
717
-	$texte = unicode2charset($texte);
718
-	// cas particulier des " et ' qu'il faut filtrer aussi
719
-	// (on le faisait deja avec un &quot;)
720
-	if (strpos($texte, "&#") !== false) {
721
-		$texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
722
-	}
711
+    if (strpos($texte, '&') === false) {
712
+        return $texte;
713
+    }
714
+    // filtrer
715
+    $texte = html2unicode($texte);
716
+    // remettre le tout dans le charset cible
717
+    $texte = unicode2charset($texte);
718
+    // cas particulier des " et ' qu'il faut filtrer aussi
719
+    // (on le faisait deja avec un &quot;)
720
+    if (strpos($texte, "&#") !== false) {
721
+        $texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
722
+    }
723 723
 
724
-	return $texte;
724
+    return $texte;
725 725
 }
726 726
 
727 727
 
728 728
 if (!function_exists('filtre_filtrer_entites_dist')) {
729
-	/**
730
-	 * Version sécurisée de filtrer_entites
731
-	 * 
732
-	 * @uses interdire_scripts()
733
-	 * @uses filtrer_entites()
734
-	 * 
735
-	 * @param string $t
736
-	 * @return string
737
-	 */
738
-	function filtre_filtrer_entites_dist($t) {
739
-		include_spip('inc/texte');
740
-		return interdire_scripts(filtrer_entites($t));
741
-	}
729
+    /**
730
+     * Version sécurisée de filtrer_entites
731
+     * 
732
+     * @uses interdire_scripts()
733
+     * @uses filtrer_entites()
734
+     * 
735
+     * @param string $t
736
+     * @return string
737
+     */
738
+    function filtre_filtrer_entites_dist($t) {
739
+        include_spip('inc/texte');
740
+        return interdire_scripts(filtrer_entites($t));
741
+    }
742 742
 }
743 743
 
744 744
 
@@ -753,18 +753,18 @@  discard block
 block discarded – undo
753 753
  * @return string|array
754 754
  **/
755 755
 function supprimer_caracteres_illegaux($texte) {
756
-	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";
757
-	static $to = null;
756
+    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";
757
+    static $to = null;
758 758
 
759
-	if (is_array($texte)) {
760
-		return array_map('supprimer_caracteres_illegaux', $texte);
761
-	}
759
+    if (is_array($texte)) {
760
+        return array_map('supprimer_caracteres_illegaux', $texte);
761
+    }
762 762
 
763
-	if (!$to) {
764
-		$to = str_repeat('-', strlen($from));
765
-	}
763
+    if (!$to) {
764
+        $to = str_repeat('-', strlen($from));
765
+    }
766 766
 
767
-	return strtr($texte, $from, $to);
767
+    return strtr($texte, $from, $to);
768 768
 }
769 769
 
770 770
 /**
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
  * @return string|array
777 777
  **/
778 778
 function corriger_caracteres($texte) {
779
-	$texte = corriger_caracteres_windows($texte);
780
-	$texte = supprimer_caracteres_illegaux($texte);
779
+    $texte = corriger_caracteres_windows($texte);
780
+    $texte = supprimer_caracteres_illegaux($texte);
781 781
 
782
-	return $texte;
782
+    return $texte;
783 783
 }
784 784
 
785 785
 /**
@@ -797,40 +797,40 @@  discard block
 block discarded – undo
797 797
  */
798 798
 function texte_backend($texte) {
799 799
 
800
-	static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
800
+    static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
801 801
 
802
-	// si on a des liens ou des images, les passer en absolu
803
-	$texte = liens_absolus($texte);
802
+    // si on a des liens ou des images, les passer en absolu
803
+    $texte = liens_absolus($texte);
804 804
 
805
-	// echapper les tags &gt; &lt;
806
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
805
+    // echapper les tags &gt; &lt;
806
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
807 807
 
808
-	// importer les &eacute;
809
-	$texte = filtrer_entites($texte);
808
+    // importer les &eacute;
809
+    $texte = filtrer_entites($texte);
810 810
 
811
-	// " -> &quot; et tout ce genre de choses
812
-	$u = $GLOBALS['meta']['pcre_u'];
813
-	$texte = str_replace("&nbsp;", " ", $texte);
814
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
815
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
816
-	$texte = entites_html($texte, false, false);
817
-	// mais bien echapper les double quotes !
818
-	$texte = str_replace('"', '&#034;', $texte);
811
+    // " -> &quot; et tout ce genre de choses
812
+    $u = $GLOBALS['meta']['pcre_u'];
813
+    $texte = str_replace("&nbsp;", " ", $texte);
814
+    $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
815
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
816
+    $texte = entites_html($texte, false, false);
817
+    // mais bien echapper les double quotes !
818
+    $texte = str_replace('"', '&#034;', $texte);
819 819
 
820
-	// verifier le charset
821
-	$texte = charset2unicode($texte);
820
+    // verifier le charset
821
+    $texte = charset2unicode($texte);
822 822
 
823
-	// Caracteres problematiques en iso-latin 1
824
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
825
-		$texte = str_replace(chr(156), '&#156;', $texte);
826
-		$texte = str_replace(chr(140), '&#140;', $texte);
827
-		$texte = str_replace(chr(159), '&#159;', $texte);
828
-	}
823
+    // Caracteres problematiques en iso-latin 1
824
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
825
+        $texte = str_replace(chr(156), '&#156;', $texte);
826
+        $texte = str_replace(chr(140), '&#140;', $texte);
827
+        $texte = str_replace(chr(159), '&#159;', $texte);
828
+    }
829 829
 
830
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
831
-	// et le caractere apostrophe alourdit les squelettes avec PHP
832
-	// ==> on les remplace par l'entite HTML
833
-	return str_replace($apostrophe, "'", $texte);
830
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
831
+    // et le caractere apostrophe alourdit les squelettes avec PHP
832
+    // ==> on les remplace par l'entite HTML
833
+    return str_replace($apostrophe, "'", $texte);
834 834
 }
835 835
 
836 836
 /**
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
  *     Texte encodé et quote pour XML
848 848
  */
849 849
 function texte_backendq($texte) {
850
-	return addslashes(texte_backend($texte));
850
+    return addslashes(texte_backend($texte));
851 851
 }
852 852
 
853 853
 
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
  *     Numéro de titre, sinon chaîne vide
871 871
  **/
872 872
 function supprimer_numero($texte) {
873
-	return preg_replace(
874
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
875
-		"", $texte);
873
+    return preg_replace(
874
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
875
+        "", $texte);
876 876
 }
877 877
 
878 878
 /**
@@ -895,13 +895,13 @@  discard block
 block discarded – undo
895 895
  *     Numéro de titre, sinon chaîne vide
896 896
  **/
897 897
 function recuperer_numero($texte) {
898
-	if (preg_match(
899
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
900
-		$texte, $regs)) {
901
-		return strval($regs[1]);
902
-	} else {
903
-		return '';
904
-	}
898
+    if (preg_match(
899
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
900
+        $texte, $regs)) {
901
+        return strval($regs[1]);
902
+    } else {
903
+        return '';
904
+    }
905 905
 }
906 906
 
907 907
 /**
@@ -928,13 +928,13 @@  discard block
 block discarded – undo
928 928
  *     Texte converti
929 929
  **/
930 930
 function supprimer_tags($texte, $rempl = "") {
931
-	$texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
932
-	// ne pas oublier un < final non ferme car coupe
933
-	$texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
934
-	// mais qui peut aussi etre un simple signe plus petit que
935
-	$texte = str_replace('<', '&lt;', $texte);
931
+    $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
932
+    // ne pas oublier un < final non ferme car coupe
933
+    $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
934
+    // mais qui peut aussi etre un simple signe plus petit que
935
+    $texte = str_replace('<', '&lt;', $texte);
936 936
 
937
-	return $texte;
937
+    return $texte;
938 938
 }
939 939
 
940 940
 /**
@@ -957,9 +957,9 @@  discard block
 block discarded – undo
957 957
  *     Texte converti
958 958
  **/
959 959
 function echapper_tags($texte, $rempl = "") {
960
-	$texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
960
+    $texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
961 961
 
962
-	return $texte;
962
+    return $texte;
963 963
 }
964 964
 
965 965
 /**
@@ -980,18 +980,18 @@  discard block
 block discarded – undo
980 980
  *     Texte converti
981 981
  **/
982 982
 function textebrut($texte) {
983
-	$u = $GLOBALS['meta']['pcre_u'];
984
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
985
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
986
-	$texte = preg_replace("/^\n+/", "", $texte);
987
-	$texte = preg_replace("/\n+$/", "", $texte);
988
-	$texte = preg_replace("/\n +/", "\n", $texte);
989
-	$texte = supprimer_tags($texte);
990
-	$texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
991
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
992
-	$texte = str_replace("&#8217;", "'", $texte);
983
+    $u = $GLOBALS['meta']['pcre_u'];
984
+    $texte = preg_replace('/\s+/S' . $u, " ", $texte);
985
+    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
986
+    $texte = preg_replace("/^\n+/", "", $texte);
987
+    $texte = preg_replace("/\n+$/", "", $texte);
988
+    $texte = preg_replace("/\n +/", "\n", $texte);
989
+    $texte = supprimer_tags($texte);
990
+    $texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
991
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
992
+    $texte = str_replace("&#8217;", "'", $texte);
993 993
 
994
-	return $texte;
994
+    return $texte;
995 995
 }
996 996
 
997 997
 
@@ -1007,17 +1007,17 @@  discard block
 block discarded – undo
1007 1007
  *     Texte avec liens ouvrants
1008 1008
  **/
1009 1009
 function liens_ouvrants($texte) {
1010
-	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1011
-		$texte, $liens, PREG_PATTERN_ORDER)) {
1012
-		foreach ($liens[0] as $a) {
1013
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1014
-			$ablank = inserer_attribut($a, 'rel', $rel);
1015
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1016
-			$texte = str_replace($a, $ablank, $texte);
1017
-		}
1018
-	}
1010
+    if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1011
+        $texte, $liens, PREG_PATTERN_ORDER)) {
1012
+        foreach ($liens[0] as $a) {
1013
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1014
+            $ablank = inserer_attribut($a, 'rel', $rel);
1015
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1016
+            $texte = str_replace($a, $ablank, $texte);
1017
+        }
1018
+    }
1019 1019
 
1020
-	return $texte;
1020
+    return $texte;
1021 1021
 }
1022 1022
 
1023 1023
 /**
@@ -1027,22 +1027,22 @@  discard block
 block discarded – undo
1027 1027
  * @return string
1028 1028
  */
1029 1029
 function liens_nofollow($texte) {
1030
-	if (stripos($texte, "<a") === false) {
1031
-		return $texte;
1032
-	}
1030
+    if (stripos($texte, "<a") === false) {
1031
+        return $texte;
1032
+    }
1033 1033
 
1034
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1035
-		foreach ($regs[0] as $a) {
1036
-			$rel = extraire_attribut($a, "rel");
1037
-			if (strpos($rel, "nofollow") === false) {
1038
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1039
-				$anofollow = inserer_attribut($a, "rel", $rel);
1040
-				$texte = str_replace($a, $anofollow, $texte);
1041
-			}
1042
-		}
1043
-	}
1034
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1035
+        foreach ($regs[0] as $a) {
1036
+            $rel = extraire_attribut($a, "rel");
1037
+            if (strpos($rel, "nofollow") === false) {
1038
+                $rel = "nofollow" . ($rel ? " $rel" : "");
1039
+                $anofollow = inserer_attribut($a, "rel", $rel);
1040
+                $texte = str_replace($a, $anofollow, $texte);
1041
+            }
1042
+        }
1043
+    }
1044 1044
 
1045
-	return $texte;
1045
+    return $texte;
1046 1046
 }
1047 1047
 
1048 1048
 /**
@@ -1061,12 +1061,12 @@  discard block
 block discarded – undo
1061 1061
  *     Texte sans paraghaphes
1062 1062
  **/
1063 1063
 function PtoBR($texte) {
1064
-	$u = $GLOBALS['meta']['pcre_u'];
1065
-	$texte = preg_replace("@</p>@iS", "\n", $texte);
1066
-	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1067
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1064
+    $u = $GLOBALS['meta']['pcre_u'];
1065
+    $texte = preg_replace("@</p>@iS", "\n", $texte);
1066
+    $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1067
+    $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1068 1068
 
1069
-	return $texte;
1069
+    return $texte;
1070 1070
 }
1071 1071
 
1072 1072
 
@@ -1090,14 +1090,14 @@  discard block
 block discarded – undo
1090 1090
  * @return string Texte encadré du style CSS
1091 1091
  */
1092 1092
 function lignes_longues($texte) {
1093
-	if (!strlen(trim($texte))) {
1094
-		return $texte;
1095
-	}
1096
-	include_spip('inc/texte');
1097
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1098
-		'div' : 'span';
1093
+    if (!strlen(trim($texte))) {
1094
+        return $texte;
1095
+    }
1096
+    include_spip('inc/texte');
1097
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1098
+        'div' : 'span';
1099 1099
 
1100
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1100
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1101 1101
 }
1102 1102
 
1103 1103
 /**
@@ -1116,30 +1116,30 @@  discard block
 block discarded – undo
1116 1116
  * @return string Texte en majuscule
1117 1117
  */
1118 1118
 function majuscules($texte) {
1119
-	if (!strlen($texte)) {
1120
-		return '';
1121
-	}
1119
+    if (!strlen($texte)) {
1120
+        return '';
1121
+    }
1122 1122
 
1123
-	// Cas du turc
1124
-	if ($GLOBALS['spip_lang'] == 'tr') {
1125
-		# remplacer hors des tags et des entites
1126
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1127
-			foreach ($regs as $n => $match) {
1128
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1129
-			}
1130
-		}
1123
+    // Cas du turc
1124
+    if ($GLOBALS['spip_lang'] == 'tr') {
1125
+        # remplacer hors des tags et des entites
1126
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1127
+            foreach ($regs as $n => $match) {
1128
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1129
+            }
1130
+        }
1131 1131
 
1132
-		$texte = str_replace('i', '&#304;', $texte);
1132
+        $texte = str_replace('i', '&#304;', $texte);
1133 1133
 
1134
-		if ($regs) {
1135
-			foreach ($regs as $n => $match) {
1136
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1137
-			}
1138
-		}
1139
-	}
1134
+        if ($regs) {
1135
+            foreach ($regs as $n => $match) {
1136
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1137
+            }
1138
+        }
1139
+    }
1140 1140
 
1141
-	// Cas general
1142
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1141
+    // Cas general
1142
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1143 1143
 }
1144 1144
 
1145 1145
 /**
@@ -1157,29 +1157,29 @@  discard block
 block discarded – undo
1157 1157
  * @return string
1158 1158
  **/
1159 1159
 function taille_en_octets($taille) {
1160
-	if (!defined('_KILOBYTE')) {
1161
-		/**
1162
-		 * Définit le nombre d'octets dans un Kilobyte
1163
-		 *
1164
-		 * @var int
1165
-		 **/
1166
-		define('_KILOBYTE', 1024);
1167
-	}
1160
+    if (!defined('_KILOBYTE')) {
1161
+        /**
1162
+         * Définit le nombre d'octets dans un Kilobyte
1163
+         *
1164
+         * @var int
1165
+         **/
1166
+        define('_KILOBYTE', 1024);
1167
+    }
1168 1168
 
1169
-	if ($taille < 1) {
1170
-		return '';
1171
-	}
1172
-	if ($taille < _KILOBYTE) {
1173
-		$taille = _T('taille_octets', array('taille' => $taille));
1174
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1175
-		$taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1176
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1177
-		$taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1178
-	} else {
1179
-		$taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1180
-	}
1169
+    if ($taille < 1) {
1170
+        return '';
1171
+    }
1172
+    if ($taille < _KILOBYTE) {
1173
+        $taille = _T('taille_octets', array('taille' => $taille));
1174
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1175
+        $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1176
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1177
+        $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1178
+    } else {
1179
+        $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1180
+    }
1181 1181
 
1182
-	return $taille;
1182
+    return $taille;
1183 1183
 }
1184 1184
 
1185 1185
 
@@ -1201,15 +1201,15 @@  discard block
 block discarded – undo
1201 1201
  *     Texte prêt pour être utilisé en attribut HTML
1202 1202
  **/
1203 1203
 function attribut_html($texte, $textebrut = true) {
1204
-	$u = $GLOBALS['meta']['pcre_u'];
1205
-	if ($textebrut) {
1206
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1207
-	}
1208
-	$texte = texte_backend($texte);
1209
-	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1204
+    $u = $GLOBALS['meta']['pcre_u'];
1205
+    if ($textebrut) {
1206
+        $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1207
+    }
1208
+    $texte = texte_backend($texte);
1209
+    $texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1210 1210
 
1211
-	return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1212
-		$texte);
1211
+    return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1212
+        $texte);
1213 1213
 }
1214 1214
 
1215 1215
 
@@ -1229,12 +1229,12 @@  discard block
 block discarded – undo
1229 1229
  *     URL ou chaîne vide
1230 1230
  **/
1231 1231
 function vider_url($url, $entites = true) {
1232
-	# un message pour abs_url
1233
-	$GLOBALS['mode_abs_url'] = 'url';
1234
-	$url = trim($url);
1235
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1232
+    # un message pour abs_url
1233
+    $GLOBALS['mode_abs_url'] = 'url';
1234
+    $url = trim($url);
1235
+    $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1236 1236
 
1237
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1237
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1238 1238
 }
1239 1239
 
1240 1240
 
@@ -1249,10 +1249,10 @@  discard block
 block discarded – undo
1249 1249
  * @return string Adresse email maquillée
1250 1250
  **/
1251 1251
 function antispam($texte) {
1252
-	include_spip('inc/acces');
1253
-	$masque = creer_pass_aleatoire(3);
1252
+    include_spip('inc/acces');
1253
+    $masque = creer_pass_aleatoire(3);
1254 1254
 
1255
-	return preg_replace("/@/", " $masque ", $texte);
1255
+    return preg_replace("/@/", " $masque ", $texte);
1256 1256
 }
1257 1257
 
1258 1258
 /**
@@ -1284,12 +1284,12 @@  discard block
 block discarded – undo
1284 1284
  *     True si on a le droit d'accès, false sinon.
1285 1285
  **/
1286 1286
 function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') {
1287
-	include_spip('inc/acces');
1288
-	if ($op) {
1289
-		$dir .= " $op $args";
1290
-	}
1287
+    include_spip('inc/acces');
1288
+    if ($op) {
1289
+        $dir .= " $op $args";
1290
+    }
1291 1291
 
1292
-	return verifier_low_sec($id_auteur, $cle, $dir);
1292
+    return verifier_low_sec($id_auteur, $cle, $dir);
1293 1293
 }
1294 1294
 
1295 1295
 /**
@@ -1314,11 +1314,11 @@  discard block
 block discarded – undo
1314 1314
  *     Retourne $texte, sinon $sinon.
1315 1315
  **/
1316 1316
 function sinon($texte, $sinon = '') {
1317
-	if ($texte or (!is_array($texte) and strlen($texte))) {
1318
-		return $texte;
1319
-	} else {
1320
-		return $sinon;
1321
-	}
1317
+    if ($texte or (!is_array($texte) and strlen($texte))) {
1318
+        return $texte;
1319
+    } else {
1320
+        return $sinon;
1321
+    }
1322 1322
 }
1323 1323
 
1324 1324
 /**
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
  * @return mixed
1343 1343
  **/
1344 1344
 function choixsivide($a, $vide, $pasvide) {
1345
-	return $a ? $pasvide : $vide;
1345
+    return $a ? $pasvide : $vide;
1346 1346
 }
1347 1347
 
1348 1348
 /**
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
  * @return mixed
1367 1367
  **/
1368 1368
 function choixsiegal($a1, $a2, $v, $f) {
1369
-	return ($a1 == $a2) ? $v : $f;
1369
+    return ($a1 == $a2) ? $v : $f;
1370 1370
 }
1371 1371
 
1372 1372
 //
@@ -1385,13 +1385,13 @@  discard block
 block discarded – undo
1385 1385
  * @return string
1386 1386
  **/
1387 1387
 function filtrer_ical($texte) {
1388
-	#include_spip('inc/charsets');
1389
-	$texte = html2unicode($texte);
1390
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1391
-	$texte = preg_replace("/\n/", " ", $texte);
1392
-	$texte = preg_replace("/,/", "\,", $texte);
1388
+    #include_spip('inc/charsets');
1389
+    $texte = html2unicode($texte);
1390
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1391
+    $texte = preg_replace("/\n/", " ", $texte);
1392
+    $texte = preg_replace("/,/", "\,", $texte);
1393 1393
 
1394
-	return $texte;
1394
+    return $texte;
1395 1395
 }
1396 1396
 
1397 1397
 
@@ -1416,53 +1416,53 @@  discard block
 block discarded – undo
1416 1416
  * @return string
1417 1417
  **/
1418 1418
 function post_autobr($texte, $delim = "\n_ ") {
1419
-	if (!function_exists('echappe_html')) {
1420
-		include_spip('inc/texte_mini');
1421
-	}
1422
-	$texte = str_replace("\r\n", "\r", $texte);
1423
-	$texte = str_replace("\r", "\n", $texte);
1424
-
1425
-	if (preg_match(",\n+$,", $texte, $fin)) {
1426
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1427
-	} else {
1428
-		$fin = '';
1429
-	}
1430
-
1431
-	$texte = echappe_html($texte, '', true);
1432
-
1433
-	// echapper les modeles
1434
-	if (strpos($texte, "<") !== false) {
1435
-		include_spip('inc/lien');
1436
-		if (defined('_PREG_MODELE')) {
1437
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1438
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1439
-		}
1440
-	}
1441
-
1442
-	$debut = '';
1443
-	$suite = $texte;
1444
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1445
-		$debut .= substr($suite, 0, $t - 1);
1446
-		$suite = substr($suite, $t);
1447
-		$car = substr($suite, 0, 1);
1448
-		if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1449
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1450
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1451
-		) {
1452
-			$debut .= $delim;
1453
-		} else {
1454
-			$debut .= "\n";
1455
-		}
1456
-		if (preg_match(",^\n+,", $suite, $regs)) {
1457
-			$debut .= $regs[0];
1458
-			$suite = substr($suite, strlen($regs[0]));
1459
-		}
1460
-	}
1461
-	$texte = $debut . $suite;
1462
-
1463
-	$texte = echappe_retour($texte);
1464
-
1465
-	return $texte . $fin;
1419
+    if (!function_exists('echappe_html')) {
1420
+        include_spip('inc/texte_mini');
1421
+    }
1422
+    $texte = str_replace("\r\n", "\r", $texte);
1423
+    $texte = str_replace("\r", "\n", $texte);
1424
+
1425
+    if (preg_match(",\n+$,", $texte, $fin)) {
1426
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1427
+    } else {
1428
+        $fin = '';
1429
+    }
1430
+
1431
+    $texte = echappe_html($texte, '', true);
1432
+
1433
+    // echapper les modeles
1434
+    if (strpos($texte, "<") !== false) {
1435
+        include_spip('inc/lien');
1436
+        if (defined('_PREG_MODELE')) {
1437
+            $preg_modeles = "@" . _PREG_MODELE . "@imsS";
1438
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1439
+        }
1440
+    }
1441
+
1442
+    $debut = '';
1443
+    $suite = $texte;
1444
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1445
+        $debut .= substr($suite, 0, $t - 1);
1446
+        $suite = substr($suite, $t);
1447
+        $car = substr($suite, 0, 1);
1448
+        if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1449
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1450
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1451
+        ) {
1452
+            $debut .= $delim;
1453
+        } else {
1454
+            $debut .= "\n";
1455
+        }
1456
+        if (preg_match(",^\n+,", $suite, $regs)) {
1457
+            $debut .= $regs[0];
1458
+            $suite = substr($suite, strlen($regs[0]));
1459
+        }
1460
+    }
1461
+    $texte = $debut . $suite;
1462
+
1463
+    $texte = echappe_retour($texte);
1464
+
1465
+    return $texte . $fin;
1466 1466
 }
1467 1467
 
1468 1468
 
@@ -1503,46 +1503,46 @@  discard block
 block discarded – undo
1503 1503
  * @return string
1504 1504
  **/
1505 1505
 function extraire_idiome($letexte, $lang = null, $options = array()) {
1506
-	static $traduire = false;
1507
-	if ($letexte
1508
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1509
-	) {
1510
-		if (!$traduire) {
1511
-			$traduire = charger_fonction('traduire', 'inc');
1512
-			include_spip('inc/lang');
1513
-		}
1514
-		if (!$lang) {
1515
-			$lang = $GLOBALS['spip_lang'];
1516
-		}
1517
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1518
-		if (is_bool($options)) {
1519
-			$options = array('echappe_span' => $options);
1520
-		}
1521
-		if (!isset($options['echappe_span'])) {
1522
-			$options = array_merge($options, array('echappe_span' => false));
1523
-		}
1524
-
1525
-		foreach ($regs as $reg) {
1526
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1527
-			$desc = $traduire($cle, $lang, true);
1528
-			$l = $desc->langue;
1529
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1530
-			if (strlen($desc->texte)) {
1531
-				$trad = code_echappement($desc->texte, 'idiome', false);
1532
-				if ($l !== $lang) {
1533
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1534
-				}
1535
-				if (lang_dir($l) !== lang_dir($lang)) {
1536
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1537
-				}
1538
-				if (!$options['echappe_span']) {
1539
-					$trad = echappe_retour($trad, 'idiome');
1540
-				}
1541
-				$letexte = str_replace($reg[0], $trad, $letexte);
1542
-			}
1543
-		}
1544
-	}
1545
-	return $letexte;
1506
+    static $traduire = false;
1507
+    if ($letexte
1508
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1509
+    ) {
1510
+        if (!$traduire) {
1511
+            $traduire = charger_fonction('traduire', 'inc');
1512
+            include_spip('inc/lang');
1513
+        }
1514
+        if (!$lang) {
1515
+            $lang = $GLOBALS['spip_lang'];
1516
+        }
1517
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1518
+        if (is_bool($options)) {
1519
+            $options = array('echappe_span' => $options);
1520
+        }
1521
+        if (!isset($options['echappe_span'])) {
1522
+            $options = array_merge($options, array('echappe_span' => false));
1523
+        }
1524
+
1525
+        foreach ($regs as $reg) {
1526
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1527
+            $desc = $traduire($cle, $lang, true);
1528
+            $l = $desc->langue;
1529
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1530
+            if (strlen($desc->texte)) {
1531
+                $trad = code_echappement($desc->texte, 'idiome', false);
1532
+                if ($l !== $lang) {
1533
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1534
+                }
1535
+                if (lang_dir($l) !== lang_dir($lang)) {
1536
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1537
+                }
1538
+                if (!$options['echappe_span']) {
1539
+                    $trad = echappe_retour($trad, 'idiome');
1540
+                }
1541
+                $letexte = str_replace($reg[0], $trad, $letexte);
1542
+            }
1543
+        }
1544
+    }
1545
+    return $letexte;
1546 1546
 }
1547 1547
 
1548 1548
 /**
@@ -1594,64 +1594,64 @@  discard block
 block discarded – undo
1594 1594
  **/
1595 1595
 function extraire_multi($letexte, $lang = null, $options = array()) {
1596 1596
 
1597
-	if ($letexte
1598
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1599
-	) {
1600
-		if (!$lang) {
1601
-			$lang = $GLOBALS['spip_lang'];
1602
-		}
1603
-
1604
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1605
-		if (is_bool($options)) {
1606
-			$options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1607
-		}
1608
-		if (!isset($options['echappe_span'])) {
1609
-			$options = array_merge($options, array('echappe_span' => false));
1610
-		}
1611
-		if (!isset($options['lang_defaut'])) {
1612
-			$options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1613
-		}
1614
-
1615
-		include_spip('inc/lang');
1616
-		foreach ($regs as $reg) {
1617
-			// chercher la version de la langue courante
1618
-			$trads = extraire_trads($reg[1]);
1619
-			if ($l = approcher_langue($trads, $lang)) {
1620
-				$trad = $trads[$l];
1621
-			} else {
1622
-				if ($options['lang_defaut'] == 'aucune') {
1623
-					$trad = '';
1624
-				} else {
1625
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1626
-					// ou la premiere dispo
1627
-					// mais typographier le texte selon les regles de celle-ci
1628
-					// Attention aux blocs multi sur plusieurs lignes
1629
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1630
-						$l = key($trads);
1631
-					}
1632
-					$trad = $trads[$l];
1633
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1634
-					$trad = $typographie($trad);
1635
-					// Tester si on echappe en span ou en div
1636
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1637
-					include_spip('inc/texte');
1638
-					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1639
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1640
-					$trad = code_echappement($trad, 'multi', false, $mode);
1641
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1642
-					if (lang_dir($l) !== lang_dir($lang)) {
1643
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1644
-					}
1645
-					if (!$options['echappe_span']) {
1646
-						$trad = echappe_retour($trad, 'multi');
1647
-					}
1648
-				}
1649
-			}
1650
-			$letexte = str_replace($reg[0], $trad, $letexte);
1651
-		}
1652
-	}
1653
-
1654
-	return $letexte;
1597
+    if ($letexte
1598
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1599
+    ) {
1600
+        if (!$lang) {
1601
+            $lang = $GLOBALS['spip_lang'];
1602
+        }
1603
+
1604
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1605
+        if (is_bool($options)) {
1606
+            $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1607
+        }
1608
+        if (!isset($options['echappe_span'])) {
1609
+            $options = array_merge($options, array('echappe_span' => false));
1610
+        }
1611
+        if (!isset($options['lang_defaut'])) {
1612
+            $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1613
+        }
1614
+
1615
+        include_spip('inc/lang');
1616
+        foreach ($regs as $reg) {
1617
+            // chercher la version de la langue courante
1618
+            $trads = extraire_trads($reg[1]);
1619
+            if ($l = approcher_langue($trads, $lang)) {
1620
+                $trad = $trads[$l];
1621
+            } else {
1622
+                if ($options['lang_defaut'] == 'aucune') {
1623
+                    $trad = '';
1624
+                } else {
1625
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1626
+                    // ou la premiere dispo
1627
+                    // mais typographier le texte selon les regles de celle-ci
1628
+                    // Attention aux blocs multi sur plusieurs lignes
1629
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1630
+                        $l = key($trads);
1631
+                    }
1632
+                    $trad = $trads[$l];
1633
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1634
+                    $trad = $typographie($trad);
1635
+                    // Tester si on echappe en span ou en div
1636
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1637
+                    include_spip('inc/texte');
1638
+                    $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1639
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1640
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1641
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1642
+                    if (lang_dir($l) !== lang_dir($lang)) {
1643
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1644
+                    }
1645
+                    if (!$options['echappe_span']) {
1646
+                        $trad = echappe_retour($trad, 'multi');
1647
+                    }
1648
+                }
1649
+            }
1650
+            $letexte = str_replace($reg[0], $trad, $letexte);
1651
+        }
1652
+    }
1653
+
1654
+    return $letexte;
1655 1655
 }
1656 1656
 
1657 1657
 /**
@@ -1667,20 +1667,20 @@  discard block
 block discarded – undo
1667 1667
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1668 1668
  **/
1669 1669
 function extraire_trads($bloc) {
1670
-	$lang = '';
1670
+    $lang = '';
1671 1671
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1672 1672
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1673
-	while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1674
-		$texte = trim($regs[1]);
1675
-		if ($texte or $lang) {
1676
-			$trads[$lang] = $texte;
1677
-		}
1678
-		$bloc = substr($bloc, strlen($regs[0]));
1679
-		$lang = $regs[2];
1680
-	}
1681
-	$trads[$lang] = $bloc;
1673
+    while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1674
+        $texte = trim($regs[1]);
1675
+        if ($texte or $lang) {
1676
+            $trads[$lang] = $texte;
1677
+        }
1678
+        $bloc = substr($bloc, strlen($regs[0]));
1679
+        $lang = $regs[2];
1680
+    }
1681
+    $trads[$lang] = $bloc;
1682 1682
 
1683
-	return $trads;
1683
+    return $trads;
1684 1684
 }
1685 1685
 
1686 1686
 
@@ -1691,7 +1691,7 @@  discard block
 block discarded – undo
1691 1691
  * @return string L'initiale en majuscule
1692 1692
  */
1693 1693
 function filtre_initiale($nom) {
1694
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1694
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1695 1695
 }
1696 1696
 
1697 1697
 
@@ -1736,33 +1736,33 @@  discard block
 block discarded – undo
1736 1736
  *      - null (interne) : si on empile
1737 1737
  **/
1738 1738
 function unique($donnee, $famille = '', $cpt = false) {
1739
-	static $mem = array();
1740
-	// permettre de vider la pile et de la restaurer
1741
-	// pour le calcul de introduction...
1742
-	if ($famille == '_spip_raz_') {
1743
-		$tmp = $mem;
1744
-		$mem = array();
1745
-
1746
-		return $tmp;
1747
-	} elseif ($famille == '_spip_set_') {
1748
-		$mem = $donnee;
1749
-
1750
-		return;
1751
-	}
1752
-	// eviter une notice
1753
-	if (!isset($mem[$famille])) {
1754
-		$mem[$famille] = array();
1755
-	}
1756
-	if ($cpt) {
1757
-		return count($mem[$famille]);
1758
-	}
1759
-	// eviter une notice
1760
-	if (!isset($mem[$famille][$donnee])) {
1761
-		$mem[$famille][$donnee] = 0;
1762
-	}
1763
-	if (!($mem[$famille][$donnee]++)) {
1764
-		return $donnee;
1765
-	}
1739
+    static $mem = array();
1740
+    // permettre de vider la pile et de la restaurer
1741
+    // pour le calcul de introduction...
1742
+    if ($famille == '_spip_raz_') {
1743
+        $tmp = $mem;
1744
+        $mem = array();
1745
+
1746
+        return $tmp;
1747
+    } elseif ($famille == '_spip_set_') {
1748
+        $mem = $donnee;
1749
+
1750
+        return;
1751
+    }
1752
+    // eviter une notice
1753
+    if (!isset($mem[$famille])) {
1754
+        $mem[$famille] = array();
1755
+    }
1756
+    if ($cpt) {
1757
+        return count($mem[$famille]);
1758
+    }
1759
+    // eviter une notice
1760
+    if (!isset($mem[$famille][$donnee])) {
1761
+        $mem[$famille][$donnee] = 0;
1762
+    }
1763
+    if (!($mem[$famille][$donnee]++)) {
1764
+        return $donnee;
1765
+    }
1766 1766
 }
1767 1767
 
1768 1768
 
@@ -1790,18 +1790,18 @@  discard block
 block discarded – undo
1790 1790
  *     Une des valeurs en fonction du compteur.
1791 1791
  **/
1792 1792
 function alterner($i) {
1793
-	// recuperer les arguments (attention fonctions un peu space)
1794
-	$num = func_num_args();
1795
-	$args = func_get_args();
1793
+    // recuperer les arguments (attention fonctions un peu space)
1794
+    $num = func_num_args();
1795
+    $args = func_get_args();
1796 1796
 
1797
-	if ($num == 2 && is_array($args[1])) {
1798
-		$args = $args[1];
1799
-		array_unshift($args, '');
1800
-		$num = count($args);
1801
-	}
1797
+    if ($num == 2 && is_array($args[1])) {
1798
+        $args = $args[1];
1799
+        array_unshift($args, '');
1800
+        $num = count($args);
1801
+    }
1802 1802
 
1803
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1804
-	return $args[(intval($i) - 1) % ($num - 1) + 1];
1803
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1804
+    return $args[(intval($i) - 1) % ($num - 1) + 1];
1805 1805
 }
1806 1806
 
1807 1807
 
@@ -1826,46 +1826,46 @@  discard block
 block discarded – undo
1826 1826
  *     - Tableau complet (si 2e argument)
1827 1827
  **/
1828 1828
 function extraire_attribut($balise, $attribut, $complet = false) {
1829
-	if (is_array($balise)) {
1830
-		array_walk(
1831
-			$balise,
1832
-			function(&$a, $key, $t){
1833
-				$a = extraire_attribut($a, $t);
1834
-			},
1835
-			$attribut
1836
-		);
1837
-
1838
-		return $balise;
1839
-	}
1840
-	if (preg_match(
1841
-		',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1842
-		. $attribut
1843
-		. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1844
-
1845
-		$balise, $r)) {
1846
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1847
-			$r[4] = substr($r[3], 1, -1);
1848
-			$r[3] = $r[3][0];
1849
-		} elseif ($r[3] !== '') {
1850
-			$r[4] = $r[3];
1851
-			$r[3] = '';
1852
-		} else {
1853
-			$r[4] = trim($r[2]);
1854
-		}
1855
-		$att = $r[4];
1856
-		if (strpos($att, "&#") !== false) {
1857
-			$att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1858
-		}
1859
-		$att = filtrer_entites($att);
1860
-	} else {
1861
-		$att = null;
1862
-	}
1863
-
1864
-	if ($complet) {
1865
-		return array($att, $r);
1866
-	} else {
1867
-		return $att;
1868
-	}
1829
+    if (is_array($balise)) {
1830
+        array_walk(
1831
+            $balise,
1832
+            function(&$a, $key, $t){
1833
+                $a = extraire_attribut($a, $t);
1834
+            },
1835
+            $attribut
1836
+        );
1837
+
1838
+        return $balise;
1839
+    }
1840
+    if (preg_match(
1841
+        ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1842
+        . $attribut
1843
+        . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1844
+
1845
+        $balise, $r)) {
1846
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1847
+            $r[4] = substr($r[3], 1, -1);
1848
+            $r[3] = $r[3][0];
1849
+        } elseif ($r[3] !== '') {
1850
+            $r[4] = $r[3];
1851
+            $r[3] = '';
1852
+        } else {
1853
+            $r[4] = trim($r[2]);
1854
+        }
1855
+        $att = $r[4];
1856
+        if (strpos($att, "&#") !== false) {
1857
+            $att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1858
+        }
1859
+        $att = filtrer_entites($att);
1860
+    } else {
1861
+        $att = null;
1862
+    }
1863
+
1864
+    if ($complet) {
1865
+        return array($att, $r);
1866
+    } else {
1867
+        return $att;
1868
+    }
1869 1869
 }
1870 1870
 
1871 1871
 /**
@@ -1897,37 +1897,37 @@  discard block
 block discarded – undo
1897 1897
  *     Code html modifié
1898 1898
  **/
1899 1899
 function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) {
1900
-	// preparer l'attribut
1901
-	// supprimer les &nbsp; etc mais pas les balises html
1902
-	// qui ont un sens dans un attribut value d'un input
1903
-	if ($proteger) {
1904
-		$val = attribut_html($val, false);
1905
-	}
1906
-
1907
-	// echapper les ' pour eviter tout bug
1908
-	$val = str_replace("'", "&#039;", $val);
1909
-	if ($vider and strlen($val) == 0) {
1910
-		$insert = '';
1911
-	} else {
1912
-		$insert = " $attribut='$val'";
1913
-	}
1914
-
1915
-	list($old, $r) = extraire_attribut($balise, $attribut, true);
1916
-
1917
-	if ($old !== null) {
1918
-		// Remplacer l'ancien attribut du meme nom
1919
-		$balise = $r[1] . $insert . $r[5];
1920
-	} else {
1921
-		// preferer une balise " />" (comme <img />)
1922
-		if (preg_match(',/>,', $balise)) {
1923
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1924
-		} // sinon une balise <a ...> ... </a>
1925
-		else {
1926
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1927
-		}
1928
-	}
1929
-
1930
-	return $balise;
1900
+    // preparer l'attribut
1901
+    // supprimer les &nbsp; etc mais pas les balises html
1902
+    // qui ont un sens dans un attribut value d'un input
1903
+    if ($proteger) {
1904
+        $val = attribut_html($val, false);
1905
+    }
1906
+
1907
+    // echapper les ' pour eviter tout bug
1908
+    $val = str_replace("'", "&#039;", $val);
1909
+    if ($vider and strlen($val) == 0) {
1910
+        $insert = '';
1911
+    } else {
1912
+        $insert = " $attribut='$val'";
1913
+    }
1914
+
1915
+    list($old, $r) = extraire_attribut($balise, $attribut, true);
1916
+
1917
+    if ($old !== null) {
1918
+        // Remplacer l'ancien attribut du meme nom
1919
+        $balise = $r[1] . $insert . $r[5];
1920
+    } else {
1921
+        // preferer une balise " />" (comme <img />)
1922
+        if (preg_match(',/>,', $balise)) {
1923
+            $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1924
+        } // sinon une balise <a ...> ... </a>
1925
+        else {
1926
+            $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1927
+        }
1928
+    }
1929
+
1930
+    return $balise;
1931 1931
 }
1932 1932
 
1933 1933
 /**
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
  * @return string Code HTML sans l'attribut
1946 1946
  **/
1947 1947
 function vider_attribut($balise, $attribut) {
1948
-	return inserer_attribut($balise, $attribut, '', false, true);
1948
+    return inserer_attribut($balise, $attribut, '', false, true);
1949 1949
 }
1950 1950
 
1951 1951
 
@@ -1957,9 +1957,9 @@  discard block
 block discarded – undo
1957 1957
  * @return string
1958 1958
  */
1959 1959
 function tester_config($id, $mode = '') {
1960
-	include_spip('action/inscrire_auteur');
1960
+    include_spip('action/inscrire_auteur');
1961 1961
 
1962
-	return tester_statut_inscription($mode, $id);
1962
+    return tester_statut_inscription($mode, $id);
1963 1963
 }
1964 1964
 
1965 1965
 //
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
  * @return int $a+$b
1985 1985
  **/
1986 1986
 function plus($a, $b) {
1987
-	return $a + $b;
1987
+    return $a + $b;
1988 1988
 }
1989 1989
 function strplus($a, $b) {return strize('plus', $a, $b);}
1990 1990
 /**
@@ -2003,7 +2003,7 @@  discard block
 block discarded – undo
2003 2003
  * @return int $a-$b
2004 2004
  **/
2005 2005
 function moins($a, $b) {
2006
-	return $a - $b;
2006
+    return $a - $b;
2007 2007
 }
2008 2008
 function strmoins($a, $b) {return strize('moins', $a, $b);}
2009 2009
 
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
  * @return int $a*$b
2025 2025
  **/
2026 2026
 function mult($a, $b) {
2027
-	return $a * $b;
2027
+    return $a * $b;
2028 2028
 }
2029 2029
 function strmult($a, $b) {return strize('mult', $a, $b);}
2030 2030
 
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
  * @return int $a/$b (ou 0 si $b est nul)
2046 2046
  **/
2047 2047
 function div($a, $b) {
2048
-	return $b ? $a / $b : 0;
2048
+    return $b ? $a / $b : 0;
2049 2049
 }
2050 2050
 function strdiv($a, $b) {return strize('div', $a, $b);}
2051 2051
 
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
  * @return int ($nb % $mod) + $add
2068 2068
  **/
2069 2069
 function modulo($nb, $mod, $add = 0) {
2070
-	return ($mod ? $nb % $mod : 0) + $add;
2070
+    return ($mod ? $nb % $mod : 0) + $add;
2071 2071
 }
2072 2072
 
2073 2073
 
@@ -2082,24 +2082,24 @@  discard block
 block discarded – undo
2082 2082
  *      - true sinon
2083 2083
  **/
2084 2084
 function nom_acceptable($nom) {
2085
-	if (!is_string($nom)) {
2086
-		return false;
2087
-	}
2088
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2089
-		define('_TAGS_NOM_AUTEUR', '');
2090
-	}
2091
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2092
-	foreach ($tags_acceptes as $tag) {
2093
-		if (strlen($tag)) {
2094
-			$remp1[] = '<' . trim($tag) . '>';
2095
-			$remp1[] = '</' . trim($tag) . '>';
2096
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2097
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2098
-		}
2099
-	}
2100
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2085
+    if (!is_string($nom)) {
2086
+        return false;
2087
+    }
2088
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2089
+        define('_TAGS_NOM_AUTEUR', '');
2090
+    }
2091
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2092
+    foreach ($tags_acceptes as $tag) {
2093
+        if (strlen($tag)) {
2094
+            $remp1[] = '<' . trim($tag) . '>';
2095
+            $remp1[] = '</' . trim($tag) . '>';
2096
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2097
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2098
+        }
2099
+    }
2100
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2101 2101
 
2102
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2102
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2103 2103
 }
2104 2104
 
2105 2105
 
@@ -2113,29 +2113,29 @@  discard block
 block discarded – undo
2113 2113
  *      - la normalisation de la dernière adresse donnée sinon
2114 2114
  **/
2115 2115
 function email_valide($adresses) {
2116
-	// eviter d'injecter n'importe quoi dans preg_match
2117
-	if (!is_string($adresses)) {
2118
-		return false;
2119
-	}
2116
+    // eviter d'injecter n'importe quoi dans preg_match
2117
+    if (!is_string($adresses)) {
2118
+        return false;
2119
+    }
2120 2120
 
2121
-	// Si c'est un spammeur autant arreter tout de suite
2122
-	if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2123
-		spip_log("Tentative d'injection de mail : $adresses");
2121
+    // Si c'est un spammeur autant arreter tout de suite
2122
+    if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2123
+        spip_log("Tentative d'injection de mail : $adresses");
2124 2124
 
2125
-		return false;
2126
-	}
2125
+        return false;
2126
+    }
2127 2127
 
2128
-	foreach (explode(',', $adresses) as $v) {
2129
-		// nettoyer certains formats
2130
-		// "Marie Toto <[email protected]>"
2131
-		$adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2132
-		// RFC 822
2133
-		if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2134
-			return false;
2135
-		}
2136
-	}
2128
+    foreach (explode(',', $adresses) as $v) {
2129
+        // nettoyer certains formats
2130
+        // "Marie Toto <[email protected]>"
2131
+        $adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2132
+        // RFC 822
2133
+        if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2134
+            return false;
2135
+        }
2136
+    }
2137 2137
 
2138
-	return $adresse;
2138
+    return $adresse;
2139 2139
 }
2140 2140
 
2141 2141
 /**
@@ -2149,20 +2149,20 @@  discard block
 block discarded – undo
2149 2149
  * @return string Texte
2150 2150
  **/
2151 2151
 function afficher_enclosures($tags) {
2152
-	$s = array();
2153
-	foreach (extraire_balises($tags, 'a') as $tag) {
2154
-		if (extraire_attribut($tag, 'rel') == 'enclosure'
2155
-			and $t = extraire_attribut($tag, 'href')
2156
-		) {
2157
-			$s[] = preg_replace(',>[^<]+</a>,S',
2158
-				'>'
2159
-				. http_img_pack('attachment-16.png', $t,
2160
-					'title="' . attribut_html($t) . '"')
2161
-				. '</a>', $tag);
2162
-		}
2163
-	}
2152
+    $s = array();
2153
+    foreach (extraire_balises($tags, 'a') as $tag) {
2154
+        if (extraire_attribut($tag, 'rel') == 'enclosure'
2155
+            and $t = extraire_attribut($tag, 'href')
2156
+        ) {
2157
+            $s[] = preg_replace(',>[^<]+</a>,S',
2158
+                '>'
2159
+                . http_img_pack('attachment-16.png', $t,
2160
+                    'title="' . attribut_html($t) . '"')
2161
+                . '</a>', $tag);
2162
+        }
2163
+    }
2164 2164
 
2165
-	return join('&nbsp;', $s);
2165
+    return join('&nbsp;', $s);
2166 2166
 }
2167 2167
 
2168 2168
 /**
@@ -2177,15 +2177,15 @@  discard block
 block discarded – undo
2177 2177
  * @return string Liens trouvés
2178 2178
  **/
2179 2179
 function afficher_tags($tags, $rels = 'tag,directory') {
2180
-	$s = array();
2181
-	foreach (extraire_balises($tags, 'a') as $tag) {
2182
-		$rel = extraire_attribut($tag, 'rel');
2183
-		if (strstr(",$rels,", ",$rel,")) {
2184
-			$s[] = $tag;
2185
-		}
2186
-	}
2180
+    $s = array();
2181
+    foreach (extraire_balises($tags, 'a') as $tag) {
2182
+        $rel = extraire_attribut($tag, 'rel');
2183
+        if (strstr(",$rels,", ",$rel,")) {
2184
+            $s[] = $tag;
2185
+        }
2186
+    }
2187 2187
 
2188
-	return join(', ', $s);
2188
+    return join(', ', $s);
2189 2189
 }
2190 2190
 
2191 2191
 
@@ -2207,21 +2207,21 @@  discard block
 block discarded – undo
2207 2207
  * @return string Tag HTML `<a>` avec microformat.
2208 2208
  **/
2209 2209
 function enclosure2microformat($e) {
2210
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2211
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2212
-	}
2213
-	$type = extraire_attribut($e, 'type');
2214
-	if (!$length = extraire_attribut($e, 'length')) {
2215
-		# <media:content : longeur dans fileSize. On tente.
2216
-		$length = extraire_attribut($e, 'fileSize');
2217
-	}
2218
-	$fichier = basename($url);
2210
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2211
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2212
+    }
2213
+    $type = extraire_attribut($e, 'type');
2214
+    if (!$length = extraire_attribut($e, 'length')) {
2215
+        # <media:content : longeur dans fileSize. On tente.
2216
+        $length = extraire_attribut($e, 'fileSize');
2217
+    }
2218
+    $fichier = basename($url);
2219 2219
 
2220
-	return '<a rel="enclosure"'
2221
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2222
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2223
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2224
-	. '>' . $fichier . '</a>';
2220
+    return '<a rel="enclosure"'
2221
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2222
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2223
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2224
+    . '>' . $fichier . '</a>';
2225 2225
 }
2226 2226
 
2227 2227
 /**
@@ -2239,24 +2239,24 @@  discard block
 block discarded – undo
2239 2239
  * @return string Tags RSS `<enclosure>`.
2240 2240
  **/
2241 2241
 function microformat2enclosure($tags) {
2242
-	$enclosures = array();
2243
-	foreach (extraire_balises($tags, 'a') as $e) {
2244
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2245
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2246
-			$type = extraire_attribut($e, 'type');
2247
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2248
-				$length = intval(extraire_attribut($e, 'length'));
2249
-			} # vieux data
2250
-			$fichier = basename($url);
2251
-			$enclosures[] = '<enclosure'
2252
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2253
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2254
-				. ($length ? ' length="' . $length . '"' : '')
2255
-				. ' />';
2256
-		}
2257
-	}
2242
+    $enclosures = array();
2243
+    foreach (extraire_balises($tags, 'a') as $e) {
2244
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2245
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2246
+            $type = extraire_attribut($e, 'type');
2247
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2248
+                $length = intval(extraire_attribut($e, 'length'));
2249
+            } # vieux data
2250
+            $fichier = basename($url);
2251
+            $enclosures[] = '<enclosure'
2252
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2253
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2254
+                . ($length ? ' length="' . $length . '"' : '')
2255
+                . ' />';
2256
+        }
2257
+    }
2258 2258
 
2259
-	return join("\n", $enclosures);
2259
+    return join("\n", $enclosures);
2260 2260
 }
2261 2261
 
2262 2262
 
@@ -2272,16 +2272,16 @@  discard block
 block discarded – undo
2272 2272
  * @return string Tags RSS Atom `<dc:subject>`.
2273 2273
  **/
2274 2274
 function tags2dcsubject($tags) {
2275
-	$subjects = '';
2276
-	foreach (extraire_balises($tags, 'a') as $e) {
2277
-		if (extraire_attribut($e, rel) == 'tag') {
2278
-			$subjects .= '<dc:subject>'
2279
-				. texte_backend(textebrut($e))
2280
-				. '</dc:subject>' . "\n";
2281
-		}
2282
-	}
2275
+    $subjects = '';
2276
+    foreach (extraire_balises($tags, 'a') as $e) {
2277
+        if (extraire_attribut($e, rel) == 'tag') {
2278
+            $subjects .= '<dc:subject>'
2279
+                . texte_backend(textebrut($e))
2280
+                . '</dc:subject>' . "\n";
2281
+        }
2282
+    }
2283 2283
 
2284
-	return $subjects;
2284
+    return $subjects;
2285 2285
 }
2286 2286
 
2287 2287
 /**
@@ -2310,23 +2310,23 @@  discard block
 block discarded – undo
2310 2310
  *     - Tableau de résultats, si tableau en entrée.
2311 2311
  **/
2312 2312
 function extraire_balise($texte, $tag = 'a') {
2313
-	if (is_array($texte)) {
2314
-		array_walk(
2315
-			$texte,
2316
-			function(&$a, $key, $t){
2317
-				$a = extraire_balise($a, $t);
2318
-			},
2319
-			$tag
2320
-		);
2313
+    if (is_array($texte)) {
2314
+        array_walk(
2315
+            $texte,
2316
+            function(&$a, $key, $t){
2317
+                $a = extraire_balise($a, $t);
2318
+            },
2319
+            $tag
2320
+        );
2321 2321
 
2322
-		return $texte;
2323
-	}
2322
+        return $texte;
2323
+    }
2324 2324
 
2325
-	if (preg_match(
2326
-		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2327
-		$texte, $regs)) {
2328
-		return $regs[0];
2329
-	}
2325
+    if (preg_match(
2326
+        ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2327
+        $texte, $regs)) {
2328
+        return $regs[0];
2329
+    }
2330 2330
 }
2331 2331
 
2332 2332
 /**
@@ -2354,25 +2354,25 @@  discard block
 block discarded – undo
2354 2354
  *     - Tableau de résultats, si tableau en entrée.
2355 2355
  **/
2356 2356
 function extraire_balises($texte, $tag = 'a') {
2357
-	if (is_array($texte)) {
2358
-		array_walk(
2359
-			$texte,
2360
-			function(&$a, $key, $t){
2361
-				$a = extraire_balises($a, $t);
2362
-			},
2363
-			$tag
2364
-		);
2357
+    if (is_array($texte)) {
2358
+        array_walk(
2359
+            $texte,
2360
+            function(&$a, $key, $t){
2361
+                $a = extraire_balises($a, $t);
2362
+            },
2363
+            $tag
2364
+        );
2365 2365
 
2366
-		return $texte;
2367
-	}
2366
+        return $texte;
2367
+    }
2368 2368
 
2369
-	if (preg_match_all(
2370
-		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2371
-		$texte, $regs, PREG_PATTERN_ORDER)) {
2372
-		return $regs[0];
2373
-	} else {
2374
-		return array();
2375
-	}
2369
+    if (preg_match_all(
2370
+        ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2371
+        $texte, $regs, PREG_PATTERN_ORDER)) {
2372
+        return $regs[0];
2373
+    } else {
2374
+        return array();
2375
+    }
2376 2376
 }
2377 2377
 
2378 2378
 /**
@@ -2401,11 +2401,11 @@  discard block
 block discarded – undo
2401 2401
  *     - `$def` si on n'a pas transmis de tableau
2402 2402
  **/
2403 2403
 function in_any($val, $vals, $def = '') {
2404
-	if (!is_array($vals) and $v = unserialize($vals)) {
2405
-		$vals = $v;
2406
-	}
2404
+    if (!is_array($vals) and $v = unserialize($vals)) {
2405
+        $vals = $v;
2406
+    }
2407 2407
 
2408
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2408
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2409 2409
 }
2410 2410
 
2411 2411
 
@@ -2426,12 +2426,12 @@  discard block
 block discarded – undo
2426 2426
  *     Résultat du calcul
2427 2427
  **/
2428 2428
 function valeur_numerique($expr) {
2429
-	$a = 0;
2430
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2431
-		eval("\$a = $expr;");
2432
-	}
2429
+    $a = 0;
2430
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2431
+        eval("\$a = $expr;");
2432
+    }
2433 2433
 
2434
-	return intval($a);
2434
+    return intval($a);
2435 2435
 }
2436 2436
 
2437 2437
 /**
@@ -2450,7 +2450,7 @@  discard block
 block discarded – undo
2450 2450
  *      Retourne `$a*$b/$c`
2451 2451
  **/
2452 2452
 function regledetrois($a, $b, $c) {
2453
-	return round($a * $b / $c);
2453
+    return round($a * $b / $c);
2454 2454
 }
2455 2455
 
2456 2456
 
@@ -2474,76 +2474,76 @@  discard block
 block discarded – undo
2474 2474
  **/
2475 2475
 function form_hidden($action) {
2476 2476
 
2477
-	$contexte = array();
2478
-	include_spip('inc/urls');
2479
-	if ($p = urls_decoder_url($action, '')
2480
-		and reset($p)
2481
-	) {
2482
-		$fond = array_shift($p);
2483
-		if ($fond != '404') {
2484
-			$contexte = array_shift($p);
2485
-			$contexte['page'] = $fond;
2486
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2487
-		}
2488
-	}
2489
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2490
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2491
-		unset($contexte['type']);
2492
-	}
2493
-	if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2494
-		unset($contexte['type-page']);
2495
-	}
2496
-
2497
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2498
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2499
-	$values = array();
2500
-
2501
-	// d'abord avec celles de l'url
2502
-	if (false !== ($p = strpos($action, '?'))) {
2503
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2504
-			$c = explode('=', $c, 2);
2505
-			$var = array_shift($c);
2506
-			$val = array_shift($c);
2507
-			if ($var) {
2508
-				$val = rawurldecode($val);
2509
-				$var = rawurldecode($var); // decoder les [] eventuels
2510
-				if (preg_match(',\[\]$,S', $var)) {
2511
-					$values[] = array($var, $val);
2512
-				} else {
2513
-					if (!isset($values[$var])) {
2514
-						$values[$var] = array($var, $val);
2515
-					}
2516
-				}
2517
-			}
2518
-		}
2519
-	}
2520
-
2521
-	// ensuite avec celles du contexte, sans doublonner !
2522
-	foreach ($contexte as $var => $val) {
2523
-		if (preg_match(',\[\]$,S', $var)) {
2524
-			$values[] = array($var, $val);
2525
-		} else {
2526
-			if (!isset($values[$var])) {
2527
-				$values[$var] = array($var, $val);
2528
-			}
2529
-		}
2530
-	}
2531
-
2532
-	// puis on rassemble le tout
2533
-	$hidden = array();
2534
-	foreach ($values as $value) {
2535
-		list($var, $val) = $value;
2536
-		$hidden[] = '<input name="'
2537
-			. entites_html($var)
2538
-			. '"'
2539
-			. (is_null($val)
2540
-				? ''
2541
-				: ' value="' . entites_html($val) . '"'
2542
-			)
2543
-			. ' type="hidden"' . "\n/>";
2544
-	}
2545
-
2546
-	return join("", $hidden);
2477
+    $contexte = array();
2478
+    include_spip('inc/urls');
2479
+    if ($p = urls_decoder_url($action, '')
2480
+        and reset($p)
2481
+    ) {
2482
+        $fond = array_shift($p);
2483
+        if ($fond != '404') {
2484
+            $contexte = array_shift($p);
2485
+            $contexte['page'] = $fond;
2486
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2487
+        }
2488
+    }
2489
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2490
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2491
+        unset($contexte['type']);
2492
+    }
2493
+    if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2494
+        unset($contexte['type-page']);
2495
+    }
2496
+
2497
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2498
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2499
+    $values = array();
2500
+
2501
+    // d'abord avec celles de l'url
2502
+    if (false !== ($p = strpos($action, '?'))) {
2503
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2504
+            $c = explode('=', $c, 2);
2505
+            $var = array_shift($c);
2506
+            $val = array_shift($c);
2507
+            if ($var) {
2508
+                $val = rawurldecode($val);
2509
+                $var = rawurldecode($var); // decoder les [] eventuels
2510
+                if (preg_match(',\[\]$,S', $var)) {
2511
+                    $values[] = array($var, $val);
2512
+                } else {
2513
+                    if (!isset($values[$var])) {
2514
+                        $values[$var] = array($var, $val);
2515
+                    }
2516
+                }
2517
+            }
2518
+        }
2519
+    }
2520
+
2521
+    // ensuite avec celles du contexte, sans doublonner !
2522
+    foreach ($contexte as $var => $val) {
2523
+        if (preg_match(',\[\]$,S', $var)) {
2524
+            $values[] = array($var, $val);
2525
+        } else {
2526
+            if (!isset($values[$var])) {
2527
+                $values[$var] = array($var, $val);
2528
+            }
2529
+        }
2530
+    }
2531
+
2532
+    // puis on rassemble le tout
2533
+    $hidden = array();
2534
+    foreach ($values as $value) {
2535
+        list($var, $val) = $value;
2536
+        $hidden[] = '<input name="'
2537
+            . entites_html($var)
2538
+            . '"'
2539
+            . (is_null($val)
2540
+                ? ''
2541
+                : ' value="' . entites_html($val) . '"'
2542
+            )
2543
+            . ' type="hidden"' . "\n/>";
2544
+    }
2545
+
2546
+    return join("", $hidden);
2547 2547
 }
2548 2548
 
2549 2549
 /**
@@ -2561,15 +2561,15 @@  discard block
 block discarded – undo
2561 2561
  *     Liste (première page, dernière page).
2562 2562
  **/
2563 2563
 function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) {
2564
-	if ($max <= 0 or $max >= $nombre) {
2565
-		return array(1, $nombre);
2566
-	}
2564
+    if ($max <= 0 or $max >= $nombre) {
2565
+        return array(1, $nombre);
2566
+    }
2567 2567
 
2568
-	$premiere = max(1, $courante - floor(($max - 1) / 2));
2569
-	$derniere = min($nombre, $premiere + $max - 2);
2570
-	$premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2568
+    $premiere = max(1, $courante - floor(($max - 1) / 2));
2569
+    $derniere = min($nombre, $premiere + $max - 2);
2570
+    $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2571 2571
 
2572
-	return array($premiere, $derniere);
2572
+    return array($premiere, $derniere);
2573 2573
 }
2574 2574
 
2575 2575
 
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
  *    - la première valeur du tableau sinon.
2592 2592
  **/
2593 2593
 function filtre_reset($array) {
2594
-	return !is_array($array) ? null : reset($array);
2594
+    return !is_array($array) ? null : reset($array);
2595 2595
 }
2596 2596
 
2597 2597
 /**
@@ -2612,7 +2612,7 @@  discard block
 block discarded – undo
2612 2612
  *    - la dernière valeur du tableau sinon.
2613 2613
  **/
2614 2614
 function filtre_end($array) {
2615
-	return !is_array($array) ? null : end($array);
2615
+    return !is_array($array) ? null : end($array);
2616 2616
 }
2617 2617
 
2618 2618
 /**
@@ -2632,11 +2632,11 @@  discard block
 block discarded – undo
2632 2632
  *
2633 2633
  **/
2634 2634
 function filtre_push($array, $val) {
2635
-	if (!is_array($array) or !array_push($array, $val)) {
2636
-		return '';
2637
-	}
2635
+    if (!is_array($array) or !array_push($array, $val)) {
2636
+        return '';
2637
+    }
2638 2638
 
2639
-	return $array;
2639
+    return $array;
2640 2640
 }
2641 2641
 
2642 2642
 /**
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2656 2656
  **/
2657 2657
 function filtre_find($array, $val) {
2658
-	return (is_array($array) and in_array($val, $array));
2658
+    return (is_array($array) and in_array($val, $array));
2659 2659
 }
2660 2660
 
2661 2661
 
@@ -2690,58 +2690,58 @@  discard block
 block discarded – undo
2690 2690
  *     Code HTML de la pagination
2691 2691
  **/
2692 2692
 function filtre_pagination_dist(
2693
-	$total,
2694
-	$nom,
2695
-	$position,
2696
-	$pas,
2697
-	$liste = true,
2698
-	$modele = '',
2699
-	$connect = '',
2700
-	$env = array()
2693
+    $total,
2694
+    $nom,
2695
+    $position,
2696
+    $pas,
2697
+    $liste = true,
2698
+    $modele = '',
2699
+    $connect = '',
2700
+    $env = array()
2701 2701
 ) {
2702
-	static $ancres = array();
2703
-	if ($pas < 1) {
2704
-		return '';
2705
-	}
2706
-	$ancre = 'pagination' . $nom; // #pagination_articles
2707
-	$debut = 'debut' . $nom; // 'debut_articles'
2708
-
2709
-	// n'afficher l'ancre qu'une fois
2710
-	if (!isset($ancres[$ancre])) {
2711
-		$bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2712
-	} else {
2713
-		$bloc_ancre = '';
2714
-	}
2715
-	// liste = false : on ne veut que l'ancre
2716
-	if (!$liste) {
2717
-		return $ancres[$ancre];
2718
-	}
2719
-
2720
-	$pagination = array(
2721
-		'debut' => $debut,
2722
-		'url' => parametre_url(self(), 'fragment', ''), // nettoyer l'id ahah eventuel
2723
-		'total' => $total,
2724
-		'position' => intval($position),
2725
-		'pas' => $pas,
2726
-		'nombre_pages' => floor(($total - 1) / $pas) + 1,
2727
-		'page_courante' => floor(intval($position) / $pas) + 1,
2728
-		'ancre' => $ancre,
2729
-		'bloc_ancre' => $bloc_ancre
2730
-	);
2731
-	if (is_array($env)) {
2732
-		$pagination = array_merge($env, $pagination);
2733
-	}
2734
-
2735
-	// Pas de pagination
2736
-	if ($pagination['nombre_pages'] <= 1) {
2737
-		return '';
2738
-	}
2739
-
2740
-	if ($modele) {
2741
-		$modele = '_' . $modele;
2742
-	}
2743
-
2744
-	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
2702
+    static $ancres = array();
2703
+    if ($pas < 1) {
2704
+        return '';
2705
+    }
2706
+    $ancre = 'pagination' . $nom; // #pagination_articles
2707
+    $debut = 'debut' . $nom; // 'debut_articles'
2708
+
2709
+    // n'afficher l'ancre qu'une fois
2710
+    if (!isset($ancres[$ancre])) {
2711
+        $bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2712
+    } else {
2713
+        $bloc_ancre = '';
2714
+    }
2715
+    // liste = false : on ne veut que l'ancre
2716
+    if (!$liste) {
2717
+        return $ancres[$ancre];
2718
+    }
2719
+
2720
+    $pagination = array(
2721
+        'debut' => $debut,
2722
+        'url' => parametre_url(self(), 'fragment', ''), // nettoyer l'id ahah eventuel
2723
+        'total' => $total,
2724
+        'position' => intval($position),
2725
+        'pas' => $pas,
2726
+        'nombre_pages' => floor(($total - 1) / $pas) + 1,
2727
+        'page_courante' => floor(intval($position) / $pas) + 1,
2728
+        'ancre' => $ancre,
2729
+        'bloc_ancre' => $bloc_ancre
2730
+    );
2731
+    if (is_array($env)) {
2732
+        $pagination = array_merge($env, $pagination);
2733
+    }
2734
+
2735
+    // Pas de pagination
2736
+    if ($pagination['nombre_pages'] <= 1) {
2737
+        return '';
2738
+    }
2739
+
2740
+    if ($modele) {
2741
+        $modele = '_' . $modele;
2742
+    }
2743
+
2744
+    return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
2745 2745
 }
2746 2746
 
2747 2747
 
@@ -2758,15 +2758,15 @@  discard block
 block discarded – undo
2758 2758
  *     Contenu avec urls en absolus
2759 2759
  **/
2760 2760
 function urls_absolues_css($contenu, $source) {
2761
-	$path = suivre_lien(url_absolue($source), './');
2761
+    $path = suivre_lien(url_absolue($source), './');
2762 2762
 
2763
-	return preg_replace_callback(
2764
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2765
-		function($x) use ($path) {
2766
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2767
-		},
2768
-		$contenu
2769
-	);
2763
+    return preg_replace_callback(
2764
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2765
+        function($x) use ($path) {
2766
+            return "url('" . suivre_lien($path, $x[1]) . "')";
2767
+        },
2768
+        $contenu
2769
+    );
2770 2770
 }
2771 2771
 
2772 2772
 
@@ -2795,118 +2795,118 @@  discard block
 block discarded – undo
2795 2795
  *     Chemin du fichier CSS inversé
2796 2796
  **/
2797 2797
 function direction_css($css, $voulue = '') {
2798
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2799
-		return $css;
2800
-	}
2801
-
2802
-	// si on a precise le sens voulu en argument, le prendre en compte
2803
-	if ($voulue = strtolower($voulue)) {
2804
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2805
-			$voulue = lang_dir($voulue);
2806
-		}
2807
-	} else {
2808
-		$voulue = lang_dir();
2809
-	}
2810
-
2811
-	$r = count($r) > 1;
2812
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2813
-	$dir = $r ? 'rtl' : 'ltr';
2814
-	$ndir = $r ? 'ltr' : 'rtl';
2815
-
2816
-	if ($voulue == $dir) {
2817
-		return $css;
2818
-	}
2819
-
2820
-	if (
2821
-		// url absolue
2822
-		preg_match(",^https?:,i", $css)
2823
-		// ou qui contient un ?
2824
-		or (($p = strpos($css, '?')) !== false)
2825
-	) {
2826
-		$distant = true;
2827
-		$cssf = parse_url($css);
2828
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2829
-		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2830
-	} else {
2831
-		$distant = false;
2832
-		$cssf = $css;
2833
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2834
-		//propose (rien a faire dans ce cas)
2835
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2836
-		if (@file_exists($f)) {
2837
-			return $f;
2838
-		}
2839
-	}
2840
-
2841
-	// 2.
2842
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2843
-	$f = $dir_var
2844
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2845
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2846
-
2847
-	// la css peut etre distante (url absolue !)
2848
-	if ($distant) {
2849
-		include_spip('inc/distant');
2850
-		$res = recuperer_url($css);
2851
-		if (!$res or !$contenu = $res['page']) {
2852
-			return $css;
2853
-		}
2854
-	} else {
2855
-		if ((@filemtime($f) > @filemtime($css))
2856
-			and (_VAR_MODE != 'recalcul')
2857
-		) {
2858
-			return $f;
2859
-		}
2860
-		if (!lire_fichier($css, $contenu)) {
2861
-			return $css;
2862
-		}
2863
-	}
2864
-
2865
-
2866
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2867
-	include_spip("lib/csstidy/class.csstidy");
2868
-	$parser = new csstidy();
2869
-	$parser->set_cfg('optimise_shorthands', 0);
2870
-	$parser->set_cfg('reverse_left_and_right', true);
2871
-	$parser->parse($contenu);
2872
-
2873
-	$contenu = $parser->print->plain();
2874
-
2875
-
2876
-	// reperer les @import auxquels il faut propager le direction_css
2877
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2878
-	$src = array();
2879
-	$src_direction_css = array();
2880
-	$src_faux_abs = array();
2881
-	$d = dirname($css);
2882
-	foreach ($regs[1] as $k => $import_css) {
2883
-		$css_direction = direction_css("$d/$import_css", $voulue);
2884
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2885
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2886
-			$css_direction = substr($css_direction, strlen($d) + 1);
2887
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2888
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2889
-			$css_direction = substr($css_direction, strlen($dir_var));
2890
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2891
-			$css_direction = "/@@@@@@/" . $css_direction;
2892
-		}
2893
-		$src[] = $regs[0][$k];
2894
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2895
-	}
2896
-	$contenu = str_replace($src, $src_direction_css, $contenu);
2897
-
2898
-	$contenu = urls_absolues_css($contenu, $css);
2899
-
2900
-	// virer les fausses url absolues que l'on a mis dans les import
2901
-	if (count($src_faux_abs)) {
2902
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2903
-	}
2904
-
2905
-	if (!ecrire_fichier($f, $contenu)) {
2906
-		return $css;
2907
-	}
2908
-
2909
-	return $f;
2798
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2799
+        return $css;
2800
+    }
2801
+
2802
+    // si on a precise le sens voulu en argument, le prendre en compte
2803
+    if ($voulue = strtolower($voulue)) {
2804
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2805
+            $voulue = lang_dir($voulue);
2806
+        }
2807
+    } else {
2808
+        $voulue = lang_dir();
2809
+    }
2810
+
2811
+    $r = count($r) > 1;
2812
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2813
+    $dir = $r ? 'rtl' : 'ltr';
2814
+    $ndir = $r ? 'ltr' : 'rtl';
2815
+
2816
+    if ($voulue == $dir) {
2817
+        return $css;
2818
+    }
2819
+
2820
+    if (
2821
+        // url absolue
2822
+        preg_match(",^https?:,i", $css)
2823
+        // ou qui contient un ?
2824
+        or (($p = strpos($css, '?')) !== false)
2825
+    ) {
2826
+        $distant = true;
2827
+        $cssf = parse_url($css);
2828
+        $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2829
+        $cssf = preg_replace(',[?:&=],', "_", $cssf);
2830
+    } else {
2831
+        $distant = false;
2832
+        $cssf = $css;
2833
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2834
+        //propose (rien a faire dans ce cas)
2835
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2836
+        if (@file_exists($f)) {
2837
+            return $f;
2838
+        }
2839
+    }
2840
+
2841
+    // 2.
2842
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2843
+    $f = $dir_var
2844
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2845
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2846
+
2847
+    // la css peut etre distante (url absolue !)
2848
+    if ($distant) {
2849
+        include_spip('inc/distant');
2850
+        $res = recuperer_url($css);
2851
+        if (!$res or !$contenu = $res['page']) {
2852
+            return $css;
2853
+        }
2854
+    } else {
2855
+        if ((@filemtime($f) > @filemtime($css))
2856
+            and (_VAR_MODE != 'recalcul')
2857
+        ) {
2858
+            return $f;
2859
+        }
2860
+        if (!lire_fichier($css, $contenu)) {
2861
+            return $css;
2862
+        }
2863
+    }
2864
+
2865
+
2866
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2867
+    include_spip("lib/csstidy/class.csstidy");
2868
+    $parser = new csstidy();
2869
+    $parser->set_cfg('optimise_shorthands', 0);
2870
+    $parser->set_cfg('reverse_left_and_right', true);
2871
+    $parser->parse($contenu);
2872
+
2873
+    $contenu = $parser->print->plain();
2874
+
2875
+
2876
+    // reperer les @import auxquels il faut propager le direction_css
2877
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2878
+    $src = array();
2879
+    $src_direction_css = array();
2880
+    $src_faux_abs = array();
2881
+    $d = dirname($css);
2882
+    foreach ($regs[1] as $k => $import_css) {
2883
+        $css_direction = direction_css("$d/$import_css", $voulue);
2884
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2885
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2886
+            $css_direction = substr($css_direction, strlen($d) + 1);
2887
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2888
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2889
+            $css_direction = substr($css_direction, strlen($dir_var));
2890
+            $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2891
+            $css_direction = "/@@@@@@/" . $css_direction;
2892
+        }
2893
+        $src[] = $regs[0][$k];
2894
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2895
+    }
2896
+    $contenu = str_replace($src, $src_direction_css, $contenu);
2897
+
2898
+    $contenu = urls_absolues_css($contenu, $css);
2899
+
2900
+    // virer les fausses url absolues que l'on a mis dans les import
2901
+    if (count($src_faux_abs)) {
2902
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2903
+    }
2904
+
2905
+    if (!ecrire_fichier($f, $contenu)) {
2906
+        return $css;
2907
+    }
2908
+
2909
+    return $f;
2910 2910
 }
2911 2911
 
2912 2912
 
@@ -2929,43 +2929,43 @@  discard block
 block discarded – undo
2929 2929
  *     - Chemin ou URL du fichier CSS source sinon.
2930 2930
  **/
2931 2931
 function url_absolue_css($css) {
2932
-	if (!preg_match(',\.css$,i', $css, $r)) {
2933
-		return $css;
2934
-	}
2932
+    if (!preg_match(',\.css$,i', $css, $r)) {
2933
+        return $css;
2934
+    }
2935 2935
 
2936
-	$url_absolue_css = url_absolue($css);
2936
+    $url_absolue_css = url_absolue($css);
2937 2937
 
2938
-	$f = basename($css, '.css');
2939
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2940
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2941
-		. '.css';
2938
+    $f = basename($css, '.css');
2939
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
2940
+        . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2941
+        . '.css';
2942 2942
 
2943
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
2944
-		return $f;
2945
-	}
2943
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
2944
+        return $f;
2945
+    }
2946 2946
 
2947
-	if ($url_absolue_css == $css) {
2948
-		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
2949
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2950
-		) {
2951
-			include_spip('inc/distant');
2952
-			if (!$contenu = recuperer_page($css)) {
2953
-				return $css;
2954
-			}
2955
-		}
2956
-	} elseif (!lire_fichier($css, $contenu)) {
2957
-		return $css;
2958
-	}
2947
+    if ($url_absolue_css == $css) {
2948
+        if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
2949
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2950
+        ) {
2951
+            include_spip('inc/distant');
2952
+            if (!$contenu = recuperer_page($css)) {
2953
+                return $css;
2954
+            }
2955
+        }
2956
+    } elseif (!lire_fichier($css, $contenu)) {
2957
+        return $css;
2958
+    }
2959 2959
 
2960
-	// passer les url relatives a la css d'origine en url absolues
2961
-	$contenu = urls_absolues_css($contenu, $css);
2960
+    // passer les url relatives a la css d'origine en url absolues
2961
+    $contenu = urls_absolues_css($contenu, $css);
2962 2962
 
2963
-	// ecrire la css
2964
-	if (!ecrire_fichier($f, $contenu)) {
2965
-		return $css;
2966
-	}
2963
+    // ecrire la css
2964
+    if (!ecrire_fichier($f, $contenu)) {
2965
+        return $css;
2966
+    }
2967 2967
 
2968
-	return $f;
2968
+    return $f;
2969 2969
 }
2970 2970
 
2971 2971
 
@@ -2999,24 +2999,24 @@  discard block
 block discarded – undo
2999 2999
  *     Valeur trouvée ou valeur par défaut.
3000 3000
  **/
3001 3001
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3002
-	foreach (explode('/', $cle) as $k) {
3002
+    foreach (explode('/', $cle) as $k) {
3003 3003
 
3004
-		$table = is_string($table) ? @unserialize($table) : $table;
3004
+        $table = is_string($table) ? @unserialize($table) : $table;
3005 3005
 
3006
-		if (is_object($table)) {
3007
-			$table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3008
-		} elseif (is_array($table)) {
3009
-			if ($conserver_null) {
3010
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3011
-			} else {
3012
-				$table = isset($table[$k]) ? $table[$k] : $defaut;
3013
-			}
3014
-		} else {
3015
-			$table = $defaut;
3016
-		}
3017
-	}
3006
+        if (is_object($table)) {
3007
+            $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
3008
+        } elseif (is_array($table)) {
3009
+            if ($conserver_null) {
3010
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3011
+            } else {
3012
+                $table = isset($table[$k]) ? $table[$k] : $defaut;
3013
+            }
3014
+        } else {
3015
+            $table = $defaut;
3016
+        }
3017
+    }
3018 3018
 
3019
-	return $table;
3019
+    return $table;
3020 3020
 }
3021 3021
 
3022 3022
 /**
@@ -3049,22 +3049,22 @@  discard block
 block discarded – undo
3049 3049
  *     - string : expression trouvée.
3050 3050
  **/
3051 3051
 function match($texte, $expression, $modif = "UimsS", $capte = 0) {
3052
-	if (intval($modif) and $capte == 0) {
3053
-		$capte = $modif;
3054
-		$modif = "UimsS";
3055
-	}
3056
-	$expression = str_replace("\/", "/", $expression);
3057
-	$expression = str_replace("/", "\/", $expression);
3052
+    if (intval($modif) and $capte == 0) {
3053
+        $capte = $modif;
3054
+        $modif = "UimsS";
3055
+    }
3056
+    $expression = str_replace("\/", "/", $expression);
3057
+    $expression = str_replace("/", "\/", $expression);
3058 3058
 
3059
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3060
-		if (isset($r[$capte])) {
3061
-			return $r[$capte];
3062
-		} else {
3063
-			return true;
3064
-		}
3065
-	}
3059
+    if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3060
+        if (isset($r[$capte])) {
3061
+            return $r[$capte];
3062
+        } else {
3063
+            return true;
3064
+        }
3065
+    }
3066 3066
 
3067
-	return false;
3067
+    return false;
3068 3068
 }
3069 3069
 
3070 3070
 
@@ -3091,10 +3091,10 @@  discard block
 block discarded – undo
3091 3091
  *     Texte
3092 3092
  **/
3093 3093
 function replace($texte, $expression, $replace = '', $modif = "UimsS") {
3094
-	$expression = str_replace("\/", "/", $expression);
3095
-	$expression = str_replace("/", "\/", $expression);
3094
+    $expression = str_replace("\/", "/", $expression);
3095
+    $expression = str_replace("/", "\/", $expression);
3096 3096
 
3097
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3097
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3098 3098
 }
3099 3099
 
3100 3100
 
@@ -3112,21 +3112,21 @@  discard block
 block discarded – undo
3112 3112
  **/
3113 3113
 function traiter_doublons_documents(&$doublons, $letexte) {
3114 3114
 
3115
-	// Verifier dans le texte & les notes (pas beau, helas)
3116
-	$t = $letexte . $GLOBALS['les_notes'];
3115
+    // Verifier dans le texte & les notes (pas beau, helas)
3116
+    $t = $letexte . $GLOBALS['les_notes'];
3117 3117
 
3118
-	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3119
-		and preg_match_all(
3120
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3121
-			$t, $matches, PREG_PATTERN_ORDER)
3122
-	) {
3123
-		if (!isset($doublons['documents'])) {
3124
-			$doublons['documents'] = "";
3125
-		}
3126
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3127
-	}
3118
+    if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3119
+        and preg_match_all(
3120
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3121
+            $t, $matches, PREG_PATTERN_ORDER)
3122
+    ) {
3123
+        if (!isset($doublons['documents'])) {
3124
+            $doublons['documents'] = "";
3125
+        }
3126
+        $doublons['documents'] .= "," . join(',', $matches[1]);
3127
+    }
3128 3128
 
3129
-	return $letexte;
3129
+    return $letexte;
3130 3130
 }
3131 3131
 
3132 3132
 /**
@@ -3140,7 +3140,7 @@  discard block
 block discarded – undo
3140 3140
  * @return string Chaîne vide
3141 3141
  **/
3142 3142
 function vide($texte) {
3143
-	return "";
3143
+    return "";
3144 3144
 }
3145 3145
 
3146 3146
 //
@@ -3169,23 +3169,23 @@  discard block
 block discarded – undo
3169 3169
  *      Code HTML résultant
3170 3170
  **/
3171 3171
 function env_to_params($env, $ignore_params = array()) {
3172
-	$ignore_params = array_merge(
3173
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3174
-		$ignore_params
3175
-	);
3176
-	if (!is_array($env)) {
3177
-		$env = unserialize($env);
3178
-	}
3179
-	$texte = "";
3180
-	if ($env) {
3181
-		foreach ($env as $i => $j) {
3182
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3183
-				$texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />";
3184
-			}
3185
-		}
3186
-	}
3187
-
3188
-	return $texte;
3172
+    $ignore_params = array_merge(
3173
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3174
+        $ignore_params
3175
+    );
3176
+    if (!is_array($env)) {
3177
+        $env = unserialize($env);
3178
+    }
3179
+    $texte = "";
3180
+    if ($env) {
3181
+        foreach ($env as $i => $j) {
3182
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3183
+                $texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />";
3184
+            }
3185
+        }
3186
+    }
3187
+
3188
+    return $texte;
3189 3189
 }
3190 3190
 
3191 3191
 /**
@@ -3208,23 +3208,23 @@  discard block
 block discarded – undo
3208 3208
  *      Code HTML résultant
3209 3209
  **/
3210 3210
 function env_to_attributs($env, $ignore_params = array()) {
3211
-	$ignore_params = array_merge(
3212
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3213
-		$ignore_params
3214
-	);
3215
-	if (!is_array($env)) {
3216
-		$env = unserialize($env);
3217
-	}
3218
-	$texte = "";
3219
-	if ($env) {
3220
-		foreach ($env as $i => $j) {
3221
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3222
-				$texte .= $i . "='" . $j . "' ";
3223
-			}
3224
-		}
3225
-	}
3211
+    $ignore_params = array_merge(
3212
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3213
+        $ignore_params
3214
+    );
3215
+    if (!is_array($env)) {
3216
+        $env = unserialize($env);
3217
+    }
3218
+    $texte = "";
3219
+    if ($env) {
3220
+        foreach ($env as $i => $j) {
3221
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3222
+                $texte .= $i . "='" . $j . "' ";
3223
+            }
3224
+        }
3225
+    }
3226 3226
 
3227
-	return $texte;
3227
+    return $texte;
3228 3228
 }
3229 3229
 
3230 3230
 
@@ -3241,9 +3241,9 @@  discard block
 block discarded – undo
3241 3241
  * @return string Chaînes concaténés
3242 3242
  **/
3243 3243
 function concat() {
3244
-	$args = func_get_args();
3244
+    $args = func_get_args();
3245 3245
 
3246
-	return join('', $args);
3246
+    return join('', $args);
3247 3247
 }
3248 3248
 
3249 3249
 
@@ -3263,23 +3263,23 @@  discard block
 block discarded – undo
3263 3263
  *     Contenu du ou des fichiers, concaténé
3264 3264
  **/
3265 3265
 function charge_scripts($files, $script = true) {
3266
-	$flux = "";
3267
-	foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3268
-		if (!is_string($file)) {
3269
-			continue;
3270
-		}
3271
-		if ($script) {
3272
-			$file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3273
-		}
3274
-		if ($file) {
3275
-			$path = find_in_path($file);
3276
-			if ($path) {
3277
-				$flux .= spip_file_get_contents($path);
3278
-			}
3279
-		}
3280
-	}
3266
+    $flux = "";
3267
+    foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3268
+        if (!is_string($file)) {
3269
+            continue;
3270
+        }
3271
+        if ($script) {
3272
+            $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3273
+        }
3274
+        if ($file) {
3275
+            $path = find_in_path($file);
3276
+            if ($path) {
3277
+                $flux .= spip_file_get_contents($path);
3278
+            }
3279
+        }
3280
+    }
3281 3281
 
3282
-	return $flux;
3282
+    return $flux;
3283 3283
 }
3284 3284
 
3285 3285
 
@@ -3301,55 +3301,55 @@  discard block
 block discarded – undo
3301 3301
  */
3302 3302
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) {
3303 3303
 
3304
-	$img_file = $img;
3305
-	if ($p = strpos($img_file, '?')) {
3306
-		$img_file = substr($img_file,0, $p);
3307
-	}
3308
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3309
-		$img_file = chemin_image($img);
3310
-	}
3311
-	else {
3312
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3313
-			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3314
-			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3315
-			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3316
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3317
-			  and file_exists($variante_svg_generique)) {
3318
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3319
-					$img_file = $variante_svg_size;
3320
-				}
3321
-				else {
3322
-					$img_file = $variante_svg_generique;
3323
-				}
3324
-			}
3325
-		}
3326
-	}
3327
-	if (stripos($atts, 'width') === false) {
3328
-		// utiliser directement l'info de taille presente dans le nom
3329
-		if ((!isset($options['utiliser_suffixe_size'])
3330
-				or $options['utiliser_suffixe_size'] == true
3331
-			  or strpos($img_file, '-xx.svg') !== false)
3332
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3333
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3334
-		) {
3335
-			$largeur = $hauteur = intval($regs[1]);
3336
-		} else {
3337
-			$taille = taille_image($img_file);
3338
-			list($hauteur, $largeur) = $taille;
3339
-			if (!$hauteur or !$largeur) {
3340
-				return "";
3341
-			}
3342
-		}
3343
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3344
-	}
3345
-
3346
-	if (file_exists($img_file)) {
3347
-		$img_file = timestamp($img_file);
3348
-	}
3349
-	return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'"
3350
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3351
-	. " " . ltrim($atts)
3352
-	. " />";
3304
+    $img_file = $img;
3305
+    if ($p = strpos($img_file, '?')) {
3306
+        $img_file = substr($img_file,0, $p);
3307
+    }
3308
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3309
+        $img_file = chemin_image($img);
3310
+    }
3311
+    else {
3312
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3313
+            // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3314
+            // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3315
+            if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3316
+              and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3317
+              and file_exists($variante_svg_generique)) {
3318
+                if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3319
+                    $img_file = $variante_svg_size;
3320
+                }
3321
+                else {
3322
+                    $img_file = $variante_svg_generique;
3323
+                }
3324
+            }
3325
+        }
3326
+    }
3327
+    if (stripos($atts, 'width') === false) {
3328
+        // utiliser directement l'info de taille presente dans le nom
3329
+        if ((!isset($options['utiliser_suffixe_size'])
3330
+                or $options['utiliser_suffixe_size'] == true
3331
+              or strpos($img_file, '-xx.svg') !== false)
3332
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3333
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3334
+        ) {
3335
+            $largeur = $hauteur = intval($regs[1]);
3336
+        } else {
3337
+            $taille = taille_image($img_file);
3338
+            list($hauteur, $largeur) = $taille;
3339
+            if (!$hauteur or !$largeur) {
3340
+                return "";
3341
+            }
3342
+        }
3343
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3344
+    }
3345
+
3346
+    if (file_exists($img_file)) {
3347
+        $img_file = timestamp($img_file);
3348
+    }
3349
+    return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'"
3350
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3351
+    . " " . ltrim($atts)
3352
+    . " />";
3353 3353
 }
3354 3354
 
3355 3355
 /**
@@ -3361,13 +3361,13 @@  discard block
 block discarded – undo
3361 3361
  * @return string
3362 3362
  */
3363 3363
 function http_style_background($img, $att = '', $size=null) {
3364
-	if ($size and is_numeric($size)){
3365
-		$size = trim($size) . "px";
3366
-	}
3367
-	return " style='background" .
3368
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3369
-		. ($size ? "background-size:{$size};" : '')
3370
-		. "'";
3364
+    if ($size and is_numeric($size)){
3365
+        $size = trim($size) . "px";
3366
+    }
3367
+    return " style='background" .
3368
+        ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3369
+        . ($size ? "background-size:{$size};" : '')
3370
+        . "'";
3371 3371
 }
3372 3372
 
3373 3373
 /**
@@ -3383,17 +3383,17 @@  discard block
 block discarded – undo
3383 3383
  *     Code HTML de la balise IMG
3384 3384
  */
3385 3385
 function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3386
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3387
-	// ecriture courte : on donne le width en 2e arg
3388
-	if (empty($width) and is_numeric($alt)) {
3389
-		$width = $alt;
3390
-		$alt = '';
3391
-	}
3392
-	if ($width) {
3393
-		$atts .= " width='{$width}'";
3394
-	}
3395
-	return http_img_pack($img, $alt, $atts, '',
3396
-		array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3386
+    $atts = $class ? " class='" . attribut_html($class) . "'" : '';
3387
+    // ecriture courte : on donne le width en 2e arg
3388
+    if (empty($width) and is_numeric($alt)) {
3389
+        $width = $alt;
3390
+        $alt = '';
3391
+    }
3392
+    if ($width) {
3393
+        $atts .= " width='{$width}'";
3394
+    }
3395
+    return http_img_pack($img, $alt, $atts, '',
3396
+        array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3397 3397
 }
3398 3398
 
3399 3399
 
@@ -3409,34 +3409,34 @@  discard block
 block discarded – undo
3409 3409
  * @return string
3410 3410
  */
3411 3411
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3412
-	if (!$file = find_in_path($img)
3413
-	  or !$svg = file_get_contents($file)) {
3414
-		return '';
3415
-	}
3416
-
3417
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3418
-		return '';
3419
-	}
3420
-	$balise_svg = $match[0];
3421
-	$balise_svg_source = $balise_svg;
3422
-	// IE est toujours mon ami
3423
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3424
-	if ($class) {
3425
-		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3426
-	}
3427
-	if ($alt){
3428
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3429
-		$id = "img-svg-title-" . substr(md5("$file:$svg:$alt"),0,4);
3430
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3431
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3432
-		$balise_svg .= $title;
3433
-	}
3434
-	else {
3435
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3436
-	}
3437
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3438
-
3439
-	return $svg;
3412
+    if (!$file = find_in_path($img)
3413
+      or !$svg = file_get_contents($file)) {
3414
+        return '';
3415
+    }
3416
+
3417
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3418
+        return '';
3419
+    }
3420
+    $balise_svg = $match[0];
3421
+    $balise_svg_source = $balise_svg;
3422
+    // IE est toujours mon ami
3423
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3424
+    if ($class) {
3425
+        $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3426
+    }
3427
+    if ($alt){
3428
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3429
+        $id = "img-svg-title-" . substr(md5("$file:$svg:$alt"),0,4);
3430
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3431
+        $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3432
+        $balise_svg .= $title;
3433
+    }
3434
+    else {
3435
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3436
+    }
3437
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3438
+
3439
+    return $svg;
3440 3440
 }
3441 3441
 
3442 3442
 
@@ -3459,17 +3459,17 @@  discard block
 block discarded – undo
3459 3459
  *     Code HTML résultant
3460 3460
  **/
3461 3461
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3462
-	$texte = '';
3463
-	if (is_array($tableau)) {
3464
-		foreach ($tableau as $k => $v) {
3465
-			$res = recuperer_fond('modeles/' . $modele,
3466
-				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3467
-			);
3468
-			$texte .= $res;
3469
-		}
3470
-	}
3462
+    $texte = '';
3463
+    if (is_array($tableau)) {
3464
+        foreach ($tableau as $k => $v) {
3465
+            $res = recuperer_fond('modeles/' . $modele,
3466
+                array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3467
+            );
3468
+            $texte .= $res;
3469
+        }
3470
+    }
3471 3471
 
3472
-	return $texte;
3472
+    return $texte;
3473 3473
 }
3474 3474
 
3475 3475
 
@@ -3494,37 +3494,37 @@  discard block
 block discarded – undo
3494 3494
  *         - tout : retourne toutes les informations du plugin actif
3495 3495
  **/
3496 3496
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3497
-	include_spip('inc/plugin');
3498
-	$plugin = strtoupper($plugin);
3499
-	$plugins_actifs = liste_plugin_actifs();
3500
-
3501
-	if (!$plugin) {
3502
-		return serialize(array_keys($plugins_actifs));
3503
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3504
-		return '';
3505
-	} elseif (($type_info == 'est_actif') and !$reload) {
3506
-		return $plugins_actifs[$plugin] ? 1 : 0;
3507
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3508
-		return $plugins_actifs[$plugin][$type_info];
3509
-	} else {
3510
-		$get_infos = charger_fonction('get_infos', 'plugins');
3511
-		// On prend en compte les extensions
3512
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3513
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3514
-		} else {
3515
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3516
-		}
3517
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3518
-			return '';
3519
-		}
3520
-		if ($type_info == 'tout') {
3521
-			return $infos;
3522
-		} elseif ($type_info == 'est_actif') {
3523
-			return $infos ? 1 : 0;
3524
-		} else {
3525
-			return strval($infos[$type_info]);
3526
-		}
3527
-	}
3497
+    include_spip('inc/plugin');
3498
+    $plugin = strtoupper($plugin);
3499
+    $plugins_actifs = liste_plugin_actifs();
3500
+
3501
+    if (!$plugin) {
3502
+        return serialize(array_keys($plugins_actifs));
3503
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3504
+        return '';
3505
+    } elseif (($type_info == 'est_actif') and !$reload) {
3506
+        return $plugins_actifs[$plugin] ? 1 : 0;
3507
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3508
+        return $plugins_actifs[$plugin][$type_info];
3509
+    } else {
3510
+        $get_infos = charger_fonction('get_infos', 'plugins');
3511
+        // On prend en compte les extensions
3512
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3513
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3514
+        } else {
3515
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3516
+        }
3517
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3518
+            return '';
3519
+        }
3520
+        if ($type_info == 'tout') {
3521
+            return $infos;
3522
+        } elseif ($type_info == 'est_actif') {
3523
+            return $infos ? 1 : 0;
3524
+        } else {
3525
+            return strval($infos[$type_info]);
3526
+        }
3527
+    }
3528 3528
 }
3529 3529
 
3530 3530
 
@@ -3551,9 +3551,9 @@  discard block
 block discarded – undo
3551 3551
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3552 3552
  */
3553 3553
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3554
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3554
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3555 3555
 
3556
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3556
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3557 3557
 }
3558 3558
 
3559 3559
 
@@ -3583,13 +3583,13 @@  discard block
 block discarded – undo
3583 3583
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3584 3584
  */
3585 3585
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3586
-	static $puce_statut = null;
3587
-	if (!$puce_statut) {
3588
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3589
-	}
3586
+    static $puce_statut = null;
3587
+    if (!$puce_statut) {
3588
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3589
+    }
3590 3590
 
3591
-	return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3592
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3591
+    return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3592
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3593 3593
 }
3594 3594
 
3595 3595
 
@@ -3616,88 +3616,88 @@  discard block
 block discarded – undo
3616 3616
  *   hash du contexte
3617 3617
  */
3618 3618
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3619
-	if (is_string($c)
3620
-		and @unserialize($c) !== false
3621
-	) {
3622
-		$c = unserialize($c);
3623
-	}
3624
-
3625
-	// supprimer les parametres debut_x
3626
-	// pour que la pagination ajax ne soit pas plantee
3627
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3628
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3629
-	if (is_array($c)) {
3630
-		foreach ($c as $k => $v) {
3631
-			if (strpos($k, 'debut_') === 0) {
3632
-				unset($c[$k]);
3633
-			}
3634
-		}
3635
-	}
3636
-
3637
-	if (!function_exists('calculer_cle_action')) {
3638
-		include_spip("inc/securiser_action");
3639
-	}
3640
-
3641
-	$c = serialize($c);
3642
-	$cle = calculer_cle_action($form . $c);
3643
-	$c = "$cle:$c";
3644
-
3645
-	// on ne stocke pas les contextes dans des fichiers caches
3646
-	// par defaut, sauf si cette configuration a ete forcee
3647
-	// OU que la longueur de l''argument generee est plus long
3648
-	// que ce que telere Suhosin.
3649
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3650
-	if (!$cache_contextes_ajax) {
3651
-		$env = $c;
3652
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3653
-			$env = gzdeflate($env);
3654
-			// http://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3655
-			if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3656
-				$cache_contextes_ajax = true;
3657
-				spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3658
-			}
3659
-		}
3660
-		$env = _xor($env);
3661
-		$env = base64_encode($env);
3662
-		// tester Suhosin et la valeur maximale des variables en GET...
3663
-		if ($max_len = @ini_get('suhosin.get.max_value_length')
3664
-			and $max_len < ($len = strlen($env))
3665
-		) {
3666
-			$cache_contextes_ajax = true;
3667
-			spip_log("Contextes AJAX forces en fichiers !"
3668
-				. " Cela arrive lorsque la valeur du contexte"
3669
-				. " depasse la longueur maximale autorisee par Suhosin"
3670
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3671
-				. " Vous devriez modifier les parametres de Suhosin"
3672
-				. " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3673
-		}
3674
-	}
3675
-
3676
-	if ($cache_contextes_ajax) {
3677
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3678
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3679
-		$md5 = md5($c);
3680
-		ecrire_fichier("$dir/c$md5", $c);
3681
-		$env = $md5;
3682
-	}
3683
-
3684
-	if ($emboite === null) {
3685
-		return $env;
3686
-	}
3687
-	if (!trim($emboite)) {
3688
-		return "";
3689
-	}
3690
-	// toujours encoder l'url source dans le bloc ajax
3691
-	$r = self();
3692
-	$r = ' data-origin="' . $r . '"';
3693
-	$class = 'ajaxbloc';
3694
-	if ($ajaxid and is_string($ajaxid)) {
3695
-		// ajaxid est normalement conforme a un nom de classe css
3696
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3697
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3698
-	}
3699
-
3700
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3619
+    if (is_string($c)
3620
+        and @unserialize($c) !== false
3621
+    ) {
3622
+        $c = unserialize($c);
3623
+    }
3624
+
3625
+    // supprimer les parametres debut_x
3626
+    // pour que la pagination ajax ne soit pas plantee
3627
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3628
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3629
+    if (is_array($c)) {
3630
+        foreach ($c as $k => $v) {
3631
+            if (strpos($k, 'debut_') === 0) {
3632
+                unset($c[$k]);
3633
+            }
3634
+        }
3635
+    }
3636
+
3637
+    if (!function_exists('calculer_cle_action')) {
3638
+        include_spip("inc/securiser_action");
3639
+    }
3640
+
3641
+    $c = serialize($c);
3642
+    $cle = calculer_cle_action($form . $c);
3643
+    $c = "$cle:$c";
3644
+
3645
+    // on ne stocke pas les contextes dans des fichiers caches
3646
+    // par defaut, sauf si cette configuration a ete forcee
3647
+    // OU que la longueur de l''argument generee est plus long
3648
+    // que ce que telere Suhosin.
3649
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3650
+    if (!$cache_contextes_ajax) {
3651
+        $env = $c;
3652
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3653
+            $env = gzdeflate($env);
3654
+            // http://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3655
+            if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3656
+                $cache_contextes_ajax = true;
3657
+                spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3658
+            }
3659
+        }
3660
+        $env = _xor($env);
3661
+        $env = base64_encode($env);
3662
+        // tester Suhosin et la valeur maximale des variables en GET...
3663
+        if ($max_len = @ini_get('suhosin.get.max_value_length')
3664
+            and $max_len < ($len = strlen($env))
3665
+        ) {
3666
+            $cache_contextes_ajax = true;
3667
+            spip_log("Contextes AJAX forces en fichiers !"
3668
+                . " Cela arrive lorsque la valeur du contexte"
3669
+                . " depasse la longueur maximale autorisee par Suhosin"
3670
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3671
+                . " Vous devriez modifier les parametres de Suhosin"
3672
+                . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3673
+        }
3674
+    }
3675
+
3676
+    if ($cache_contextes_ajax) {
3677
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3678
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3679
+        $md5 = md5($c);
3680
+        ecrire_fichier("$dir/c$md5", $c);
3681
+        $env = $md5;
3682
+    }
3683
+
3684
+    if ($emboite === null) {
3685
+        return $env;
3686
+    }
3687
+    if (!trim($emboite)) {
3688
+        return "";
3689
+    }
3690
+    // toujours encoder l'url source dans le bloc ajax
3691
+    $r = self();
3692
+    $r = ' data-origin="' . $r . '"';
3693
+    $class = 'ajaxbloc';
3694
+    if ($ajaxid and is_string($ajaxid)) {
3695
+        // ajaxid est normalement conforme a un nom de classe css
3696
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3697
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3698
+    }
3699
+
3700
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3701 3701
 }
3702 3702
 
3703 3703
 /**
@@ -3717,36 +3717,36 @@  discard block
 block discarded – undo
3717 3717
  *   - false : erreur de décodage
3718 3718
  */
3719 3719
 function decoder_contexte_ajax($c, $form = '') {
3720
-	if (!function_exists('calculer_cle_action')) {
3721
-		include_spip("inc/securiser_action");
3722
-	}
3723
-	if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3724
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3725
-		and lire_fichier("$dir/c$c", $contexte)
3726
-	) {
3727
-		$c = $contexte;
3728
-	} else {
3729
-		$c = @base64_decode($c);
3730
-		$c = _xor($c);
3731
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3732
-			$c = @gzinflate($c);
3733
-		}
3734
-	}
3735
-
3736
-	// extraire la signature en debut de contexte
3737
-	// et la verifier avant de deserializer
3738
-	// format : signature:donneesserializees
3739
-	if ($p = strpos($c,":")){
3740
-		$cle = substr($c,0,$p);
3741
-		$c = substr($c,$p+1);
3742
-
3743
-		if ($cle == calculer_cle_action($form . $c)) {
3744
-			$env = @unserialize($c);
3745
-			return $env;
3746
-		}
3747
-	}
3748
-
3749
-	return false;
3720
+    if (!function_exists('calculer_cle_action')) {
3721
+        include_spip("inc/securiser_action");
3722
+    }
3723
+    if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3724
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3725
+        and lire_fichier("$dir/c$c", $contexte)
3726
+    ) {
3727
+        $c = $contexte;
3728
+    } else {
3729
+        $c = @base64_decode($c);
3730
+        $c = _xor($c);
3731
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3732
+            $c = @gzinflate($c);
3733
+        }
3734
+    }
3735
+
3736
+    // extraire la signature en debut de contexte
3737
+    // et la verifier avant de deserializer
3738
+    // format : signature:donneesserializees
3739
+    if ($p = strpos($c,":")){
3740
+        $cle = substr($c,0,$p);
3741
+        $c = substr($c,$p+1);
3742
+
3743
+        if ($cle == calculer_cle_action($form . $c)) {
3744
+            $env = @unserialize($c);
3745
+            return $env;
3746
+        }
3747
+    }
3748
+
3749
+    return false;
3750 3750
 }
3751 3751
 
3752 3752
 
@@ -3764,20 +3764,20 @@  discard block
 block discarded – undo
3764 3764
  *    Message décrypté ou encrypté
3765 3765
  **/
3766 3766
 function _xor($message, $key = null) {
3767
-	if (is_null($key)) {
3768
-		if (!function_exists('calculer_cle_action')) {
3769
-			include_spip("inc/securiser_action");
3770
-		}
3771
-		$key = pack("H*", calculer_cle_action('_xor'));
3772
-	}
3767
+    if (is_null($key)) {
3768
+        if (!function_exists('calculer_cle_action')) {
3769
+            include_spip("inc/securiser_action");
3770
+        }
3771
+        $key = pack("H*", calculer_cle_action('_xor'));
3772
+    }
3773 3773
 
3774
-	$keylen = strlen($key);
3775
-	$messagelen = strlen($message);
3776
-	for ($i = 0; $i < $messagelen; $i++) {
3777
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3778
-	}
3774
+    $keylen = strlen($key);
3775
+    $messagelen = strlen($message);
3776
+    for ($i = 0; $i < $messagelen; $i++) {
3777
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3778
+    }
3779 3779
 
3780
-	return $message;
3780
+    return $message;
3781 3781
 }
3782 3782
 
3783 3783
 /**
@@ -3835,22 +3835,22 @@  discard block
 block discarded – undo
3835 3835
  *   Code HTML
3836 3836
  */
3837 3837
 function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') {
3838
-	if ($on) {
3839
-		$bal = "strong";
3840
-		$att = "class='on'";
3841
-	} else {
3842
-		$bal = 'a';
3843
-		$att = "href='$url'"
3844
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3845
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3846
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3847
-			. $evt;
3848
-	}
3849
-	if ($libelle === null) {
3850
-		$libelle = $url;
3851
-	}
3838
+    if ($on) {
3839
+        $bal = "strong";
3840
+        $att = "class='on'";
3841
+    } else {
3842
+        $bal = 'a';
3843
+        $att = "href='$url'"
3844
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
3845
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
3846
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3847
+            . $evt;
3848
+    }
3849
+    if ($libelle === null) {
3850
+        $libelle = $url;
3851
+    }
3852 3852
 
3853
-	return "<$bal $att>$libelle</$bal>";
3853
+    return "<$bal $att>$libelle</$bal>";
3854 3854
 }
3855 3855
 
3856 3856
 
@@ -3867,18 +3867,18 @@  discard block
 block discarded – undo
3867 3867
  * @return string : la chaine de langue finale en utilisant la fonction _T()
3868 3868
  */
3869 3869
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) {
3870
-	if (!$nb = intval($nb)) {
3871
-		return "";
3872
-	}
3873
-	if (!is_array($vars)) {
3874
-		return "";
3875
-	}
3876
-	$vars[$var] = $nb;
3877
-	if ($nb > 1) {
3878
-		return _T($chaine_plusieurs, $vars);
3879
-	} else {
3880
-		return _T($chaine_un, $vars);
3881
-	}
3870
+    if (!$nb = intval($nb)) {
3871
+        return "";
3872
+    }
3873
+    if (!is_array($vars)) {
3874
+        return "";
3875
+    }
3876
+    $vars[$var] = $nb;
3877
+    if ($nb > 1) {
3878
+        return _T($chaine_plusieurs, $vars);
3879
+    } else {
3880
+        return _T($chaine_un, $vars);
3881
+    }
3882 3882
 }
3883 3883
 
3884 3884
 
@@ -3903,56 +3903,56 @@  discard block
 block discarded – undo
3903 3903
  * @return string
3904 3904
  */
3905 3905
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
3906
-	if (in_array($fonction, array("del", "supprimer.gif"))) {
3907
-		$class .= ' danger';
3908
-	} elseif ($fonction == "rien.gif") {
3909
-		$fonction = "";
3910
-	} elseif ($fonction == "delsafe") {
3911
-		$fonction = "del";
3912
-	}
3913
-
3914
-	$fond_origine = $fond;
3915
-	// remappage des icone : article-24.png+new => article-new-24.png
3916
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
3917
-		list($fond, $fonction) = $icone_renommer($fond, $fonction);
3918
-	}
3919
-
3920
-	// ajouter le type d'objet dans la class de l'icone
3921
-	$class .= " " . substr(basename($fond), 0, -4);
3922
-
3923
-	$alt = attribut_html($texte);
3924
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
3925
-
3926
-	$ajax = "";
3927
-	if (strpos($class, "ajax") !== false) {
3928
-		$ajax = "ajax";
3929
-		if (strpos($class, "preload") !== false) {
3930
-			$ajax .= " preload";
3931
-		}
3932
-		if (strpos($class, "nocache") !== false) {
3933
-			$ajax .= " nocache";
3934
-		}
3935
-		$ajax = " class='$ajax'";
3936
-	}
3937
-
3938
-	$size = 24;
3939
-	if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
3940
-	  or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
3941
-		$size = $match[1];
3942
-	}
3943
-
3944
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
3945
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
3946
-
3947
-	if ($type == 'lien') {
3948
-		return "<span class='icone s$size $class'>"
3949
-		. "<a href='$lien'$title$ajax$javascript>"
3950
-		. $icone
3951
-		. "<b>$texte</b>"
3952
-		. "</a></span>\n";
3953
-	} else {
3954
-		return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
3955
-	}
3906
+    if (in_array($fonction, array("del", "supprimer.gif"))) {
3907
+        $class .= ' danger';
3908
+    } elseif ($fonction == "rien.gif") {
3909
+        $fonction = "";
3910
+    } elseif ($fonction == "delsafe") {
3911
+        $fonction = "del";
3912
+    }
3913
+
3914
+    $fond_origine = $fond;
3915
+    // remappage des icone : article-24.png+new => article-new-24.png
3916
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
3917
+        list($fond, $fonction) = $icone_renommer($fond, $fonction);
3918
+    }
3919
+
3920
+    // ajouter le type d'objet dans la class de l'icone
3921
+    $class .= " " . substr(basename($fond), 0, -4);
3922
+
3923
+    $alt = attribut_html($texte);
3924
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
3925
+
3926
+    $ajax = "";
3927
+    if (strpos($class, "ajax") !== false) {
3928
+        $ajax = "ajax";
3929
+        if (strpos($class, "preload") !== false) {
3930
+            $ajax .= " preload";
3931
+        }
3932
+        if (strpos($class, "nocache") !== false) {
3933
+            $ajax .= " nocache";
3934
+        }
3935
+        $ajax = " class='$ajax'";
3936
+    }
3937
+
3938
+    $size = 24;
3939
+    if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
3940
+      or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
3941
+        $size = $match[1];
3942
+    }
3943
+
3944
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
3945
+    $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
3946
+
3947
+    if ($type == 'lien') {
3948
+        return "<span class='icone s$size $class'>"
3949
+        . "<a href='$lien'$title$ajax$javascript>"
3950
+        . $icone
3951
+        . "<b>$texte</b>"
3952
+        . "</a></span>\n";
3953
+    } else {
3954
+        return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
3955
+    }
3956 3956
 }
3957 3957
 
3958 3958
 /**
@@ -3976,7 +3976,7 @@  discard block
 block discarded – undo
3976 3976
  *     Code HTML du lien
3977 3977
  **/
3978 3978
 function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
3979
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
3979
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
3980 3980
 }
3981 3981
 
3982 3982
 /**
@@ -4011,7 +4011,7 @@  discard block
 block discarded – undo
4011 4011
  *     Code HTML du lien
4012 4012
  **/
4013 4013
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4014
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4014
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4015 4015
 }
4016 4016
 
4017 4017
 /**
@@ -4056,7 +4056,7 @@  discard block
 block discarded – undo
4056 4056
  *     Code HTML du lien
4057 4057
  **/
4058 4058
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4059
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4059
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4060 4060
 }
4061 4061
 
4062 4062
 /**
@@ -4087,7 +4087,7 @@  discard block
 block discarded – undo
4087 4087
  *     Code HTML du lien
4088 4088
  **/
4089 4089
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") {
4090
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4090
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4091 4091
 }
4092 4092
 
4093 4093
 /**
@@ -4117,7 +4117,7 @@  discard block
 block discarded – undo
4117 4117
  *     Code HTML du lien
4118 4118
  */
4119 4119
 function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") {
4120
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4120
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4121 4121
 }
4122 4122
 
4123 4123
 
@@ -4165,26 +4165,26 @@  discard block
 block discarded – undo
4165 4165
  * @return string Code CSS
4166 4166
  */
4167 4167
 function bando_images_background() {
4168
-	include_spip('inc/bandeau');
4169
-	// recuperer tous les boutons et leurs images
4170
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4168
+    include_spip('inc/bandeau');
4169
+    // recuperer tous les boutons et leurs images
4170
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4171 4171
 
4172
-	$res = "";
4173
-	foreach ($boutons as $page => $detail) {
4174
-		if ($detail->icone and strlen(trim($detail->icone))) {
4175
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4176
-		}
4177
-		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4178
-		if (is_array($detail->sousmenu)) {
4179
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4180
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4181
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4182
-				}
4183
-			}
4184
-		}
4185
-	}
4172
+    $res = "";
4173
+    foreach ($boutons as $page => $detail) {
4174
+        if ($detail->icone and strlen(trim($detail->icone))) {
4175
+            $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4176
+        }
4177
+        $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4178
+        if (is_array($detail->sousmenu)) {
4179
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4180
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4181
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4182
+                }
4183
+            }
4184
+        }
4185
+    }
4186 4186
 
4187
-	return $res;
4187
+    return $res;
4188 4188
 }
4189 4189
 
4190 4190
 /**
@@ -4203,19 +4203,19 @@  discard block
 block discarded – undo
4203 4203
  * @return string
4204 4204
  */
4205 4205
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4206
-	if ($confirm) {
4207
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4208
-		if ($callback) {
4209
-			$callback = "$confirm?($callback):false";
4210
-		} else {
4211
-			$callback = $confirm;
4212
-		}
4213
-	}
4214
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4215
-	$title = $title ? " title='$title'" : "";
4206
+    if ($confirm) {
4207
+        $confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4208
+        if ($callback) {
4209
+            $callback = "$confirm?($callback):false";
4210
+        } else {
4211
+            $callback = $confirm;
4212
+        }
4213
+    }
4214
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4215
+    $title = $title ? " title='$title'" : "";
4216 4216
 
4217
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4218
-	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4217
+    return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4218
+    . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4219 4219
 }
4220 4220
 
4221 4221
 
@@ -4227,7 +4227,7 @@  discard block
 block discarded – undo
4227 4227
  * @return string
4228 4228
  */
4229 4229
 function tri_protege_champ($t) {
4230
-	return preg_replace(',[^\s\w.+],', '', $t);
4230
+    return preg_replace(',[^\s\w.+],', '', $t);
4231 4231
 }
4232 4232
 
4233 4233
 /**
@@ -4240,34 +4240,34 @@  discard block
 block discarded – undo
4240 4240
  * @return string
4241 4241
  */
4242 4242
 function tri_champ_order($t, $from = null) {
4243
-	if (strncmp($t, 'multi ', 6) == 0) {
4244
-		return "multi";
4245
-	}
4246
-
4247
-	$champ = $t;
4248
-
4249
-	if (strncmp($t, 'num ', 4) == 0) {
4250
-		$champ = substr($t, 4);
4251
-	}
4252
-	// enlever les autres espaces non evacues par tri_protege_champ
4253
-	$champ = preg_replace(',\s,', '', $champ);
4254
-
4255
-	if (is_array($from)) {
4256
-		$trouver_table = charger_fonction('trouver_table', 'base');
4257
-		foreach ($from as $idt => $table_sql) {
4258
-			if ($desc = $trouver_table($table_sql)
4259
-				and isset($desc['field'][$champ])
4260
-			) {
4261
-				$champ = "$idt.$champ";
4262
-				break;
4263
-			}
4264
-		}
4265
-	}
4266
-	if (strncmp($t, 'num ', 4) == 0) {
4267
-		return "0+$champ";
4268
-	} else {
4269
-		return $champ;
4270
-	}
4243
+    if (strncmp($t, 'multi ', 6) == 0) {
4244
+        return "multi";
4245
+    }
4246
+
4247
+    $champ = $t;
4248
+
4249
+    if (strncmp($t, 'num ', 4) == 0) {
4250
+        $champ = substr($t, 4);
4251
+    }
4252
+    // enlever les autres espaces non evacues par tri_protege_champ
4253
+    $champ = preg_replace(',\s,', '', $champ);
4254
+
4255
+    if (is_array($from)) {
4256
+        $trouver_table = charger_fonction('trouver_table', 'base');
4257
+        foreach ($from as $idt => $table_sql) {
4258
+            if ($desc = $trouver_table($table_sql)
4259
+                and isset($desc['field'][$champ])
4260
+            ) {
4261
+                $champ = "$idt.$champ";
4262
+                break;
4263
+            }
4264
+        }
4265
+    }
4266
+    if (strncmp($t, 'num ', 4) == 0) {
4267
+        return "0+$champ";
4268
+    } else {
4269
+        return $champ;
4270
+    }
4271 4271
 }
4272 4272
 
4273 4273
 /**
@@ -4281,18 +4281,18 @@  discard block
 block discarded – undo
4281 4281
  * @return string
4282 4282
  */
4283 4283
 function tri_champ_select($t) {
4284
-	if (strncmp($t, 'multi ', 6) == 0) {
4285
-		$t = substr($t, 6);
4286
-		$t = preg_replace(',\s,', '', $t);
4287
-		$t = sql_multi($t, $GLOBALS['spip_lang']);
4284
+    if (strncmp($t, 'multi ', 6) == 0) {
4285
+        $t = substr($t, 6);
4286
+        $t = preg_replace(',\s,', '', $t);
4287
+        $t = sql_multi($t, $GLOBALS['spip_lang']);
4288 4288
 
4289
-		return $t;
4290
-	}
4291
-	if (trim($t) == 'hasard') {
4292
-		return 'rand() AS hasard';
4293
-	}
4289
+        return $t;
4290
+    }
4291
+    if (trim($t) == 'hasard') {
4292
+        return 'rand() AS hasard';
4293
+    }
4294 4294
 
4295
-	return "''";
4295
+    return "''";
4296 4296
 }
4297 4297
 
4298 4298
 
@@ -4314,78 +4314,78 @@  discard block
 block discarded – undo
4314 4314
  * @return string
4315 4315
  */
4316 4316
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") {
4317
-	static $trouver_table = null;
4318
-	static $objets;
4319
-
4320
-	// On verifie qu'on a tout ce qu'il faut
4321
-	$id_objet = intval($id_objet);
4322
-	if (!($id_objet and $type_objet and $info)) {
4323
-		return '';
4324
-	}
4325
-
4326
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4327
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4328
-		return '';
4329
-	}
4330
-
4331
-	// Si on demande l'url, on retourne direct la fonction
4332
-	if ($info == 'url') {
4333
-		return generer_url_entite($id_objet, $type_objet);
4334
-	}
4335
-
4336
-	// Sinon on va tout chercher dans la table et on garde en memoire
4337
-	$demande_titre = ($info == 'titre');
4338
-
4339
-	// 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
4340
-	if (!isset($objets[$type_objet][$id_objet])
4341
-		or
4342
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4343
-	) {
4344
-		if (!$trouver_table) {
4345
-			$trouver_table = charger_fonction('trouver_table', 'base');
4346
-		}
4347
-		$desc = $trouver_table(table_objet_sql($type_objet));
4348
-		if (!$desc) {
4349
-			return $objets[$type_objet] = false;
4350
-		}
4351
-
4352
-		// Si on demande le titre, on le gere en interne
4353
-		$champ_titre = "";
4354
-		if ($demande_titre) {
4355
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4356
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4357
-		}
4358
-		include_spip('base/abstract_sql');
4359
-		include_spip('base/connect_sql');
4360
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4361
-			'*' . $champ_titre,
4362
-			$desc['table_sql'],
4363
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4364
-		);
4365
-	}
4366
-
4367
-	// Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4368
-	if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4369
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4370
-	} // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4371
-	else {
4372
-		if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4373
-			$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4374
-		} // Sinon on prend directement le champ SQL tel quel
4375
-		else {
4376
-			$info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4377
-		}
4378
-	}
4379
-
4380
-	// On va ensuite appliquer les traitements automatiques si besoin
4381
-	if (!$etoile) {
4382
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4383
-		// mais ce fonctionnement est a ameliorer !
4384
-		$info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4385
-			array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4386
-	}
4387
-
4388
-	return $info_generee;
4317
+    static $trouver_table = null;
4318
+    static $objets;
4319
+
4320
+    // On verifie qu'on a tout ce qu'il faut
4321
+    $id_objet = intval($id_objet);
4322
+    if (!($id_objet and $type_objet and $info)) {
4323
+        return '';
4324
+    }
4325
+
4326
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4327
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4328
+        return '';
4329
+    }
4330
+
4331
+    // Si on demande l'url, on retourne direct la fonction
4332
+    if ($info == 'url') {
4333
+        return generer_url_entite($id_objet, $type_objet);
4334
+    }
4335
+
4336
+    // Sinon on va tout chercher dans la table et on garde en memoire
4337
+    $demande_titre = ($info == 'titre');
4338
+
4339
+    // 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
4340
+    if (!isset($objets[$type_objet][$id_objet])
4341
+        or
4342
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4343
+    ) {
4344
+        if (!$trouver_table) {
4345
+            $trouver_table = charger_fonction('trouver_table', 'base');
4346
+        }
4347
+        $desc = $trouver_table(table_objet_sql($type_objet));
4348
+        if (!$desc) {
4349
+            return $objets[$type_objet] = false;
4350
+        }
4351
+
4352
+        // Si on demande le titre, on le gere en interne
4353
+        $champ_titre = "";
4354
+        if ($demande_titre) {
4355
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4356
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4357
+        }
4358
+        include_spip('base/abstract_sql');
4359
+        include_spip('base/connect_sql');
4360
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4361
+            '*' . $champ_titre,
4362
+            $desc['table_sql'],
4363
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4364
+        );
4365
+    }
4366
+
4367
+    // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4368
+    if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4369
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4370
+    } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4371
+    else {
4372
+        if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4373
+            $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4374
+        } // Sinon on prend directement le champ SQL tel quel
4375
+        else {
4376
+            $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4377
+        }
4378
+    }
4379
+
4380
+    // On va ensuite appliquer les traitements automatiques si besoin
4381
+    if (!$etoile) {
4382
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4383
+        // mais ce fonctionnement est a ameliorer !
4384
+        $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4385
+            array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4386
+    }
4387
+
4388
+    return $info_generee;
4389 4389
 }
4390 4390
 
4391 4391
 /**
@@ -4399,44 +4399,44 @@  discard block
 block discarded – undo
4399 4399
  * @return string
4400 4400
  */
4401 4401
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') {
4402
-	if (!$champ) {
4403
-		return $texte;
4404
-	}
4402
+    if (!$champ) {
4403
+        return $texte;
4404
+    }
4405 4405
 	
4406
-	// On charge toujours les filtres de texte car la majorité des traitements les utilisent
4407
-	// et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4408
-	include_spip('inc/texte');
4406
+    // On charge toujours les filtres de texte car la majorité des traitements les utilisent
4407
+    // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4408
+    include_spip('inc/texte');
4409 4409
 	
4410
-	$champ = strtoupper($champ);
4411
-	$traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4412
-	if (!$traitements or !is_array($traitements)) {
4413
-		return $texte;
4414
-	}
4410
+    $champ = strtoupper($champ);
4411
+    $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4412
+    if (!$traitements or !is_array($traitements)) {
4413
+        return $texte;
4414
+    }
4415 4415
 
4416
-	$traitement = '';
4417
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4418
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4419
-		$table_objet = table_objet($table_objet);
4420
-		if (isset($traitements[$table_objet])) {
4421
-			$traitement = $traitements[$table_objet];
4422
-		}
4423
-	}
4424
-	if (!$traitement and isset($traitements[0])) {
4425
-		$traitement = $traitements[0];
4426
-	}
4427
-	// (sinon prendre le premier de la liste par defaut ?)
4416
+    $traitement = '';
4417
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4418
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4419
+        $table_objet = table_objet($table_objet);
4420
+        if (isset($traitements[$table_objet])) {
4421
+            $traitement = $traitements[$table_objet];
4422
+        }
4423
+    }
4424
+    if (!$traitement and isset($traitements[0])) {
4425
+        $traitement = $traitements[0];
4426
+    }
4427
+    // (sinon prendre le premier de la liste par defaut ?)
4428 4428
 
4429
-	if (!$traitement) {
4430
-		return $texte;
4431
-	}
4429
+    if (!$traitement) {
4430
+        return $texte;
4431
+    }
4432 4432
 
4433
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4433
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4434 4434
 
4435
-	// Fournir $connect et $Pile[0] au traitement si besoin
4436
-	$Pile = array(0 => $env);
4437
-	eval("\$texte = $traitement;");
4435
+    // Fournir $connect et $Pile[0] au traitement si besoin
4436
+    $Pile = array(0 => $env);
4437
+    eval("\$texte = $traitement;");
4438 4438
 
4439
-	return $texte;
4439
+    return $texte;
4440 4440
 }
4441 4441
 
4442 4442
 
@@ -4450,21 +4450,21 @@  discard block
 block discarded – undo
4450 4450
  * @return string
4451 4451
  */
4452 4452
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4453
-	include_spip('inc/liens');
4454
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4455
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4456
-	// le raccourcis n'est plus valide
4457
-	$titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4458
-	// on essaye avec generer_info_entite ?
4459
-	if (!strlen($titre) and !$connect) {
4460
-		$titre = generer_info_entite($id_objet, $objet, 'titre');
4461
-	}
4462
-	if (!strlen($titre)) {
4463
-		$titre = _T('info_sans_titre');
4464
-	}
4465
-	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4453
+    include_spip('inc/liens');
4454
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4455
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4456
+    // le raccourcis n'est plus valide
4457
+    $titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4458
+    // on essaye avec generer_info_entite ?
4459
+    if (!strlen($titre) and !$connect) {
4460
+        $titre = generer_info_entite($id_objet, $objet, 'titre');
4461
+    }
4462
+    if (!strlen($titre)) {
4463
+        $titre = _T('info_sans_titre');
4464
+    }
4465
+    $url = generer_url_entite($id_objet, $objet, '', '', $connect);
4466 4466
 
4467
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4467
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4468 4468
 }
4469 4469
 
4470 4470
 
@@ -4481,15 +4481,15 @@  discard block
 block discarded – undo
4481 4481
  * @return string
4482 4482
  */
4483 4483
 function wrap($texte, $wrap) {
4484
-	$balises = extraire_balises($wrap);
4485
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4486
-		$texte = $wrap . $texte;
4487
-		$regs = array_reverse($regs[1]);
4488
-		$wrap = "</" . implode("></", $regs) . ">";
4489
-		$texte = $texte . $wrap;
4490
-	}
4484
+    $balises = extraire_balises($wrap);
4485
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4486
+        $texte = $wrap . $texte;
4487
+        $regs = array_reverse($regs[1]);
4488
+        $wrap = "</" . implode("></", $regs) . ">";
4489
+        $texte = $texte . $wrap;
4490
+    }
4491 4491
 
4492
-	return $texte;
4492
+    return $texte;
4493 4493
 }
4494 4494
 
4495 4495
 
@@ -4509,43 +4509,43 @@  discard block
 block discarded – undo
4509 4509
  * @return array|mixed|string
4510 4510
  */
4511 4511
 function filtre_print_dist($u, $join = "<br />", $indent = 0) {
4512
-	if (is_string($u)) {
4513
-		$u = typo($u);
4512
+    if (is_string($u)) {
4513
+        $u = typo($u);
4514 4514
 
4515
-		return $u;
4516
-	}
4515
+        return $u;
4516
+    }
4517 4517
 
4518
-	// caster $u en array si besoin
4519
-	if (is_object($u)) {
4520
-		$u = (array)$u;
4521
-	}
4518
+    // caster $u en array si besoin
4519
+    if (is_object($u)) {
4520
+        $u = (array)$u;
4521
+    }
4522 4522
 
4523
-	if (is_array($u)) {
4524
-		$out = "";
4525
-		// toutes les cles sont numeriques ?
4526
-		// et aucun enfant n'est un tableau
4527
-		// liste simple separee par des virgules
4528
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4529
-		$array_values = array_map('is_array', $u);
4530
-		$object_values = array_map('is_object', $u);
4531
-		if (array_sum($numeric_keys) == count($numeric_keys)
4532
-			and !array_sum($array_values)
4533
-			and !array_sum($object_values)
4534
-		) {
4535
-			return join(", ", array_map('filtre_print_dist', $u));
4536
-		}
4523
+    if (is_array($u)) {
4524
+        $out = "";
4525
+        // toutes les cles sont numeriques ?
4526
+        // et aucun enfant n'est un tableau
4527
+        // liste simple separee par des virgules
4528
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4529
+        $array_values = array_map('is_array', $u);
4530
+        $object_values = array_map('is_object', $u);
4531
+        if (array_sum($numeric_keys) == count($numeric_keys)
4532
+            and !array_sum($array_values)
4533
+            and !array_sum($object_values)
4534
+        ) {
4535
+            return join(", ", array_map('filtre_print_dist', $u));
4536
+        }
4537 4537
 
4538
-		// sinon on passe a la ligne et on indente
4539
-		$i_str = str_pad("", $indent, " ");
4540
-		foreach ($u as $k => $v) {
4541
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4542
-		}
4538
+        // sinon on passe a la ligne et on indente
4539
+        $i_str = str_pad("", $indent, " ");
4540
+        foreach ($u as $k => $v) {
4541
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4542
+        }
4543 4543
 
4544
-		return $out;
4545
-	}
4544
+        return $out;
4545
+    }
4546 4546
 
4547
-	// on sait pas quoi faire...
4548
-	return $u;
4547
+    // on sait pas quoi faire...
4548
+    return $u;
4549 4549
 }
4550 4550
 
4551 4551
 
@@ -4558,10 +4558,10 @@  discard block
 block discarded – undo
4558 4558
  * @return string
4559 4559
  */
4560 4560
 function objet_info($objet, $info) {
4561
-	$table = table_objet_sql($objet);
4562
-	$infos = lister_tables_objets_sql($table);
4561
+    $table = table_objet_sql($objet);
4562
+    $infos = lister_tables_objets_sql($table);
4563 4563
 
4564
-	return (isset($infos[$info]) ? $infos[$info] : '');
4564
+    return (isset($infos[$info]) ? $infos[$info] : '');
4565 4565
 }
4566 4566
 
4567 4567
 /**
@@ -4576,11 +4576,11 @@  discard block
 block discarded – undo
4576 4576
  *     Texte traduit du comptage, tel que '3 articles'
4577 4577
  */
4578 4578
 function objet_afficher_nb($nb, $objet) {
4579
-	if (!$nb) {
4580
-		return _T(objet_info($objet, 'info_aucun_objet'));
4581
-	} else {
4582
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4583
-	}
4579
+    if (!$nb) {
4580
+        return _T(objet_info($objet, 'info_aucun_objet'));
4581
+    } else {
4582
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4583
+    }
4584 4584
 }
4585 4585
 
4586 4586
 /**
@@ -4592,11 +4592,11 @@  discard block
 block discarded – undo
4592 4592
  * @return string
4593 4593
  */
4594 4594
 function objet_icone($objet, $taille = 24, $class='') {
4595
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4596
-	$icone = chemin_image($icone);
4597
-	$balise_img = charger_filtre('balise_img');
4595
+    $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4596
+    $icone = chemin_image($icone);
4597
+    $balise_img = charger_filtre('balise_img');
4598 4598
 
4599
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4599
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4600 4600
 }
4601 4601
 
4602 4602
 /**
@@ -4617,12 +4617,12 @@  discard block
 block discarded – undo
4617 4617
  * @return string
4618 4618
  */
4619 4619
 function objet_T($objet, $chaine, $args = array(), $options = array()){
4620
-	$chaine = explode(':',$chaine);
4621
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4622
-		return $t;
4623
-	}
4624
-	$chaine = implode(':',$chaine);
4625
-	return _T($chaine, $args, $options);
4620
+    $chaine = explode(':',$chaine);
4621
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4622
+        return $t;
4623
+    }
4624
+    $chaine = implode(':',$chaine);
4625
+    return _T($chaine, $args, $options);
4626 4626
 }
4627 4627
 
4628 4628
 /**
@@ -4636,17 +4636,17 @@  discard block
 block discarded – undo
4636 4636
  * @return string      Code HTML
4637 4637
  */
4638 4638
 function insert_head_css_conditionnel($flux) {
4639
-	if (strpos($flux, '<!-- insert_head_css -->') === false
4640
-		and $p = strpos($flux, '<!-- insert_head -->')
4641
-	) {
4642
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4643
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4644
-			$p = $p1;
4645
-		}
4646
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4647
-	}
4639
+    if (strpos($flux, '<!-- insert_head_css -->') === false
4640
+        and $p = strpos($flux, '<!-- insert_head -->')
4641
+    ) {
4642
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4643
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4644
+            $p = $p1;
4645
+        }
4646
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4647
+    }
4648 4648
 
4649
-	return $flux;
4649
+    return $flux;
4650 4650
 }
4651 4651
 
4652 4652
 /**
@@ -4667,66 +4667,66 @@  discard block
 block discarded – undo
4667 4667
  * @return string
4668 4668
  */
4669 4669
 function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') {
4670
-	if (isset($contexte['format'])) {
4671
-		$extension = $contexte['format'];
4672
-		unset($contexte['format']);
4673
-	} else {
4674
-		$extension = "html";
4675
-		if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4676
-			$extension = $m[1];
4677
-		}
4678
-	}
4679
-	// recuperer le contenu produit par le squelette
4680
-	$options['raw'] = true;
4681
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4682
-
4683
-	// calculer le nom de la css
4684
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4685
-	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4686
-	$contexte_implicite = calculer_contexte_implicite();
4687
-	$filename = $dir_var . $extension . "dyn-$nom_safe-"
4688
-		. substr(md5($fond . serialize($contexte_implicite) . serialize($contexte) . $connect), 0, 8)
4689
-		. ".$extension";
4690
-
4691
-	// mettre a jour le fichier si il n'existe pas
4692
-	// ou trop ancien
4693
-	// le dernier fichier produit est toujours suffixe par .last
4694
-	// et recopie sur le fichier cible uniquement si il change
4695
-	if (!file_exists($filename)
4696
-		or !file_exists($filename . ".last")
4697
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4698
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4699
-	) {
4700
-		$contenu = $cache['texte'];
4701
-		// passer les urls en absolu si c'est une css
4702
-		if ($extension == "css") {
4703
-			$contenu = urls_absolues_css($contenu,
4704
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4705
-		}
4706
-
4707
-		$comment = '';
4708
-		// ne pas insérer de commentaire si c'est du json
4709
-		if ($extension != "json") {
4710
-			$comment = "/* #PRODUIRE{fond=$fond";
4711
-			foreach ($contexte as $k => $v) {
4712
-				$comment .= ",$k=$v";
4713
-			}
4714
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4715
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4716
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4717
-		}
4718
-		// et ecrire le fichier
4719
-		ecrire_fichier($filename . ".last", $comment . $contenu);
4720
-		// regarder si on recopie
4721
-		if (!file_exists($filename)
4722
-			or md5_file($filename) !== md5_file($filename . ".last")
4723
-		) {
4724
-			@copy($filename . ".last", $filename);
4725
-			clearstatcache(true, $filename); // eviter que PHP ne reserve le vieux timestamp
4726
-		}
4727
-	}
4728
-
4729
-	return timestamp($filename);
4670
+    if (isset($contexte['format'])) {
4671
+        $extension = $contexte['format'];
4672
+        unset($contexte['format']);
4673
+    } else {
4674
+        $extension = "html";
4675
+        if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4676
+            $extension = $m[1];
4677
+        }
4678
+    }
4679
+    // recuperer le contenu produit par le squelette
4680
+    $options['raw'] = true;
4681
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4682
+
4683
+    // calculer le nom de la css
4684
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4685
+    $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4686
+    $contexte_implicite = calculer_contexte_implicite();
4687
+    $filename = $dir_var . $extension . "dyn-$nom_safe-"
4688
+        . substr(md5($fond . serialize($contexte_implicite) . serialize($contexte) . $connect), 0, 8)
4689
+        . ".$extension";
4690
+
4691
+    // mettre a jour le fichier si il n'existe pas
4692
+    // ou trop ancien
4693
+    // le dernier fichier produit est toujours suffixe par .last
4694
+    // et recopie sur le fichier cible uniquement si il change
4695
+    if (!file_exists($filename)
4696
+        or !file_exists($filename . ".last")
4697
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4698
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4699
+    ) {
4700
+        $contenu = $cache['texte'];
4701
+        // passer les urls en absolu si c'est une css
4702
+        if ($extension == "css") {
4703
+            $contenu = urls_absolues_css($contenu,
4704
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4705
+        }
4706
+
4707
+        $comment = '';
4708
+        // ne pas insérer de commentaire si c'est du json
4709
+        if ($extension != "json") {
4710
+            $comment = "/* #PRODUIRE{fond=$fond";
4711
+            foreach ($contexte as $k => $v) {
4712
+                $comment .= ",$k=$v";
4713
+            }
4714
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4715
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4716
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
4717
+        }
4718
+        // et ecrire le fichier
4719
+        ecrire_fichier($filename . ".last", $comment . $contenu);
4720
+        // regarder si on recopie
4721
+        if (!file_exists($filename)
4722
+            or md5_file($filename) !== md5_file($filename . ".last")
4723
+        ) {
4724
+            @copy($filename . ".last", $filename);
4725
+            clearstatcache(true, $filename); // eviter que PHP ne reserve le vieux timestamp
4726
+        }
4727
+    }
4728
+
4729
+    return timestamp($filename);
4730 4730
 }
4731 4731
 
4732 4732
 /**
@@ -4739,14 +4739,14 @@  discard block
 block discarded – undo
4739 4739
  *    $fichier auquel on a ajouté le timestamp
4740 4740
  */
4741 4741
 function timestamp($fichier) {
4742
-	if (!$fichier
4743
-		or !file_exists($fichier)
4744
-		or !$m = filemtime($fichier)
4745
-	) {
4746
-		return $fichier;
4747
-	}
4742
+    if (!$fichier
4743
+        or !file_exists($fichier)
4744
+        or !$m = filemtime($fichier)
4745
+    ) {
4746
+        return $fichier;
4747
+    }
4748 4748
 
4749
-	return "$fichier?$m";
4749
+    return "$fichier?$m";
4750 4750
 }
4751 4751
 
4752 4752
 /**
@@ -4756,11 +4756,11 @@  discard block
 block discarded – undo
4756 4756
  * @return string
4757 4757
  */
4758 4758
 function supprimer_timestamp($url) {
4759
-	if (strpos($url, "?") === false) {
4760
-		return $url;
4761
-	}
4759
+    if (strpos($url, "?") === false) {
4760
+        return $url;
4761
+    }
4762 4762
 
4763
-	return preg_replace(",\?[[:digit:]]+$,", "", $url);
4763
+    return preg_replace(",\?[[:digit:]]+$,", "", $url);
4764 4764
 }
4765 4765
 
4766 4766
 /**
@@ -4775,9 +4775,9 @@  discard block
 block discarded – undo
4775 4775
  * @return string
4776 4776
  */
4777 4777
 function filtre_nettoyer_titre_email_dist($titre) {
4778
-	include_spip('inc/envoyer_mail');
4778
+    include_spip('inc/envoyer_mail');
4779 4779
 
4780
-	return nettoyer_titre_email($titre);
4780
+    return nettoyer_titre_email($titre);
4781 4781
 }
4782 4782
 
4783 4783
 /**
@@ -4799,19 +4799,19 @@  discard block
 block discarded – undo
4799 4799
  * @return string
4800 4800
  */
4801 4801
 function filtre_chercher_rubrique_dist(
4802
-	$titre,
4803
-	$id_objet,
4804
-	$id_parent,
4805
-	$objet,
4806
-	$id_secteur,
4807
-	$restreint,
4808
-	$actionable = false,
4809
-	$retour_sans_cadre = false
4802
+    $titre,
4803
+    $id_objet,
4804
+    $id_parent,
4805
+    $objet,
4806
+    $id_secteur,
4807
+    $restreint,
4808
+    $actionable = false,
4809
+    $retour_sans_cadre = false
4810 4810
 ) {
4811
-	include_spip('inc/filtres_ecrire');
4811
+    include_spip('inc/filtres_ecrire');
4812 4812
 
4813
-	return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4814
-		$retour_sans_cadre);
4813
+    return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4814
+        $retour_sans_cadre);
4815 4815
 }
4816 4816
 
4817 4817
 /**
@@ -4840,56 +4840,56 @@  discard block
 block discarded – undo
4840 4840
  *     Chaîne vide si l'accès est autorisé
4841 4841
  */
4842 4842
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
4843
-	if ($ok) {
4844
-		return '';
4845
-	}
4846
-
4847
-	// Vider tous les tampons
4848
-	$level = @ob_get_level();
4849
-	while ($level--) {
4850
-		@ob_end_clean();
4851
-	}
4852
-
4853
-	include_spip('inc/headers');
4854
-
4855
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4856
-	if ($url) {
4857
-		redirige_par_entete($url, '', $statut);
4858
-	}
4859
-
4860
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
4861
-	if (!is_numeric($statut) and is_null($message)) {
4862
-		$message = $statut;
4863
-		$statut = 0;
4864
-	}
4865
-	if (!$message) {
4866
-		$message = '';
4867
-	}
4868
-	$statut = intval($statut);
4869
-
4870
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4871
-	if (test_espace_prive()) {
4872
-		if (!$statut or !in_array($statut, array(404, 403))) {
4873
-			$statut = 403;
4874
-		}
4875
-		http_status(403);
4876
-		$echec = charger_fonction('403', 'exec');
4877
-		$echec($message);
4878
-	} else {
4879
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4880
-		if (!$statut) {
4881
-			$statut = 404;
4882
-		}
4883
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
4884
-		http_status($statut);
4885
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4886
-		if ($statut >= 400) {
4887
-			echo recuperer_fond("$statut", array('erreur' => $message));
4888
-		}
4889
-	}
4890
-
4891
-
4892
-	exit;
4843
+    if ($ok) {
4844
+        return '';
4845
+    }
4846
+
4847
+    // Vider tous les tampons
4848
+    $level = @ob_get_level();
4849
+    while ($level--) {
4850
+        @ob_end_clean();
4851
+    }
4852
+
4853
+    include_spip('inc/headers');
4854
+
4855
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4856
+    if ($url) {
4857
+        redirige_par_entete($url, '', $statut);
4858
+    }
4859
+
4860
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
4861
+    if (!is_numeric($statut) and is_null($message)) {
4862
+        $message = $statut;
4863
+        $statut = 0;
4864
+    }
4865
+    if (!$message) {
4866
+        $message = '';
4867
+    }
4868
+    $statut = intval($statut);
4869
+
4870
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4871
+    if (test_espace_prive()) {
4872
+        if (!$statut or !in_array($statut, array(404, 403))) {
4873
+            $statut = 403;
4874
+        }
4875
+        http_status(403);
4876
+        $echec = charger_fonction('403', 'exec');
4877
+        $echec($message);
4878
+    } else {
4879
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4880
+        if (!$statut) {
4881
+            $statut = 404;
4882
+        }
4883
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
4884
+        http_status($statut);
4885
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4886
+        if ($statut >= 400) {
4887
+            echo recuperer_fond("$statut", array('erreur' => $message));
4888
+        }
4889
+    }
4890
+
4891
+
4892
+    exit;
4893 4893
 }
4894 4894
 
4895 4895
 /**
@@ -4900,9 +4900,9 @@  discard block
 block discarded – undo
4900 4900
  * @return string
4901 4901
  */
4902 4902
 function filtre_compacte_dist($source, $format = null) {
4903
-	if (function_exists('compacte')) {
4904
-		return compacte($source, $format);
4905
-	}
4903
+    if (function_exists('compacte')) {
4904
+        return compacte($source, $format);
4905
+    }
4906 4906
 
4907
-	return $source;
4907
+    return $source;
4908 4908
 }
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 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)) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 function spip_version() {
160 160
 	$version = $GLOBALS['spip_version_affichee'];
161 161
 	if ($svn_revision = version_svn_courante(_DIR_RACINE)) {
162
-		$version .= ($svn_revision < 0 ? ' SVN' : '') . ' [' . abs($svn_revision) . ']';
162
+		$version .= ($svn_revision < 0 ? ' SVN' : '').' ['.abs($svn_revision).']';
163 163
 	}
164 164
 
165 165
 	return $version;
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 	}
187 187
 
188 188
 	// version installee par paquet ZIP
189
-	if (lire_fichier($dir . '/svn.revision', $c)
189
+	if (lire_fichier($dir.'/svn.revision', $c)
190 190
 		and preg_match(',Revision: (\d+),', $c, $d)
191 191
 	) {
192 192
 		return intval($d[1]);
193 193
 	}
194 194
 
195 195
 	// version installee par SVN
196
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
197
-		$db = new SQLite3($dir . '/.svn/wc.db');
196
+	if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) {
197
+		$db = new SQLite3($dir.'/.svn/wc.db');
198 198
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
199 199
 		if ($result) {
200 200
 			$row = $result->fetchArray();
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				return -$row['changed_revision'];
203 203
 			}
204 204
 		}
205
-	} else if (lire_fichier($dir . '/.svn/entries', $c)
205
+	} else if (lire_fichier($dir.'/.svn/entries', $c)
206 206
 		and (
207 207
 			(preg_match_all(
208 208
 					',committed-rev="([0-9]+)",', $c, $r1, PREG_PATTERN_ORDER)
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 
223 223
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
224 224
 // et laisser passer les fonctions personnelles baptisees image_...
225
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
226
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
227
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
228
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
229
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
225
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
226
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
227
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
228
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
229
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
230 230
 
231 231
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
232 232
 $GLOBALS['spip_matrice']['couleur_foncer'] = 'inc/filtres_images_mini.php';
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
  */
373 373
 function filtre_debug($val, $key = null) {
374 374
 	$debug = (
375
-		is_null($key) ? '' : (var_export($key, true) . " = ")
376
-		) . var_export($val, true);
375
+		is_null($key) ? '' : (var_export($key, true)." = ")
376
+		).var_export($val, true);
377 377
 
378 378
 	include_spip('inc/autoriser');
379 379
 	if (autoriser('webmestre')) {
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
462 462
 							$srcover = $match[1];
463 463
 							array_shift($args);
464
-							array_unshift($args, "<img src='" . $match[1] . "' />");
464
+							array_unshift($args, "<img src='".$match[1]."' />");
465 465
 							$srcover_filter = call_user_func_array($filtre, $args);
466 466
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
467 467
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 	// " -> &quot; et tout ce genre de choses
812 812
 	$u = $GLOBALS['meta']['pcre_u'];
813 813
 	$texte = str_replace("&nbsp;", " ", $texte);
814
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
814
+	$texte = preg_replace('/\s{2,}/S'.$u, " ", $texte);
815 815
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
816 816
 	$texte = entites_html($texte, false, false);
817 817
 	// mais bien echapper les double quotes !
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
  **/
872 872
 function supprimer_numero($texte) {
873 873
 	return preg_replace(
874
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
874
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
875 875
 		"", $texte);
876 876
 }
877 877
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
  **/
897 897
 function recuperer_numero($texte) {
898 898
 	if (preg_match(
899
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
899
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
900 900
 		$texte, $regs)) {
901 901
 		return strval($regs[1]);
902 902
 	} else {
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
  **/
982 982
 function textebrut($texte) {
983 983
 	$u = $GLOBALS['meta']['pcre_u'];
984
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
985
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
984
+	$texte = preg_replace('/\s+/S'.$u, " ", $texte);
985
+	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
986 986
 	$texte = preg_replace("/^\n+/", "", $texte);
987 987
 	$texte = preg_replace("/\n+$/", "", $texte);
988 988
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1011 1011
 		$texte, $liens, PREG_PATTERN_ORDER)) {
1012 1012
 		foreach ($liens[0] as $a) {
1013
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1013
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1014 1014
 			$ablank = inserer_attribut($a, 'rel', $rel);
1015 1015
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1016 1016
 			$texte = str_replace($a, $ablank, $texte);
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		foreach ($regs[0] as $a) {
1036 1036
 			$rel = extraire_attribut($a, "rel");
1037 1037
 			if (strpos($rel, "nofollow") === false) {
1038
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1038
+				$rel = "nofollow".($rel ? " $rel" : "");
1039 1039
 				$anofollow = inserer_attribut($a, "rel", $rel);
1040 1040
 				$texte = str_replace($a, $anofollow, $texte);
1041 1041
 			}
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 	$u = $GLOBALS['meta']['pcre_u'];
1065 1065
 	$texte = preg_replace("@</p>@iS", "\n", $texte);
1066 1066
 	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1067
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1067
+	$texte = preg_replace("@^\s*<br />@S".$u, "", $texte);
1068 1068
 
1069 1069
 	return $texte;
1070 1070
 }
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 		return $texte;
1095 1095
 	}
1096 1096
 	include_spip('inc/texte');
1097
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1097
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1098 1098
 		'div' : 'span';
1099 1099
 
1100 1100
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
 function attribut_html($texte, $textebrut = true) {
1204 1204
 	$u = $GLOBALS['meta']['pcre_u'];
1205 1205
 	if ($textebrut) {
1206
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1206
+		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte));
1207 1207
 	}
1208 1208
 	$texte = texte_backend($texte);
1209 1209
 	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 	# un message pour abs_url
1233 1233
 	$GLOBALS['mode_abs_url'] = 'url';
1234 1234
 	$url = trim($url);
1235
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1235
+	$r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS';
1236 1236
 
1237 1237
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1238 1238
 }
@@ -1434,14 +1434,14 @@  discard block
 block discarded – undo
1434 1434
 	if (strpos($texte, "<") !== false) {
1435 1435
 		include_spip('inc/lien');
1436 1436
 		if (defined('_PREG_MODELE')) {
1437
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1437
+			$preg_modeles = "@"._PREG_MODELE."@imsS";
1438 1438
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1439 1439
 		}
1440 1440
 	}
1441 1441
 
1442 1442
 	$debut = '';
1443 1443
 	$suite = $texte;
1444
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1444
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1445 1445
 		$debut .= substr($suite, 0, $t - 1);
1446 1446
 		$suite = substr($suite, $t);
1447 1447
 		$car = substr($suite, 0, 1);
@@ -1458,11 +1458,11 @@  discard block
 block discarded – undo
1458 1458
 			$suite = substr($suite, strlen($regs[0]));
1459 1459
 		}
1460 1460
 	}
1461
-	$texte = $debut . $suite;
1461
+	$texte = $debut.$suite;
1462 1462
 
1463 1463
 	$texte = echappe_retour($texte);
1464 1464
 
1465
-	return $texte . $fin;
1465
+	return $texte.$fin;
1466 1466
 }
1467 1467
 
1468 1468
 
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 		}
1524 1524
 
1525 1525
 		foreach ($regs as $reg) {
1526
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1526
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1527 1527
 			$desc = $traduire($cle, $lang, true);
1528 1528
 			$l = $desc->langue;
1529 1529
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1637 1637
 					include_spip('inc/texte');
1638 1638
 					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1639
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1639
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1640 1640
 					$trad = code_echappement($trad, 'multi', false, $mode);
1641 1641
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1642 1642
 					if (lang_dir($l) !== lang_dir($lang)) {
@@ -1829,7 +1829,7 @@  discard block
 block discarded – undo
1829 1829
 	if (is_array($balise)) {
1830 1830
 		array_walk(
1831 1831
 			$balise,
1832
-			function(&$a, $key, $t){
1832
+			function(&$a, $key, $t) {
1833 1833
 				$a = extraire_attribut($a, $t);
1834 1834
 			},
1835 1835
 			$attribut
@@ -1916,14 +1916,14 @@  discard block
 block discarded – undo
1916 1916
 
1917 1917
 	if ($old !== null) {
1918 1918
 		// Remplacer l'ancien attribut du meme nom
1919
-		$balise = $r[1] . $insert . $r[5];
1919
+		$balise = $r[1].$insert.$r[5];
1920 1920
 	} else {
1921 1921
 		// preferer une balise " />" (comme <img />)
1922 1922
 		if (preg_match(',/>,', $balise)) {
1923
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1923
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
1924 1924
 		} // sinon une balise <a ...> ... </a>
1925 1925
 		else {
1926
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1926
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
1927 1927
 		}
1928 1928
 	}
1929 1929
 
@@ -1965,8 +1965,8 @@  discard block
 block discarded – undo
1965 1965
 //
1966 1966
 // Quelques fonctions de calcul arithmetique
1967 1967
 //
1968
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
1969
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
1968
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
1969
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
1970 1970
 
1971 1971
 /**
1972 1972
  * Additionne 2 nombres
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
 function plus($a, $b) {
1987 1987
 	return $a + $b;
1988 1988
 }
1989
-function strplus($a, $b) {return strize('plus', $a, $b);}
1989
+function strplus($a, $b) {return strize('plus', $a, $b); }
1990 1990
 /**
1991 1991
  * Soustrait 2 nombres
1992 1992
  *
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
 function moins($a, $b) {
2006 2006
 	return $a - $b;
2007 2007
 }
2008
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2008
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2009 2009
 
2010 2010
 /**
2011 2011
  * Multiplie 2 nombres
@@ -2026,7 +2026,7 @@  discard block
 block discarded – undo
2026 2026
 function mult($a, $b) {
2027 2027
 	return $a * $b;
2028 2028
 }
2029
-function strmult($a, $b) {return strize('mult', $a, $b);}
2029
+function strmult($a, $b) {return strize('mult', $a, $b); }
2030 2030
 
2031 2031
 /**
2032 2032
  * Divise 2 nombres
@@ -2047,7 +2047,7 @@  discard block
 block discarded – undo
2047 2047
 function div($a, $b) {
2048 2048
 	return $b ? $a / $b : 0;
2049 2049
 }
2050
-function strdiv($a, $b) {return strize('div', $a, $b);}
2050
+function strdiv($a, $b) {return strize('div', $a, $b); }
2051 2051
 
2052 2052
 /**
2053 2053
  * Retourne le modulo 2 nombres
@@ -2088,13 +2088,13 @@  discard block
 block discarded – undo
2088 2088
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2089 2089
 		define('_TAGS_NOM_AUTEUR', '');
2090 2090
 	}
2091
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2091
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2092 2092
 	foreach ($tags_acceptes as $tag) {
2093 2093
 		if (strlen($tag)) {
2094
-			$remp1[] = '<' . trim($tag) . '>';
2095
-			$remp1[] = '</' . trim($tag) . '>';
2096
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2097
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2094
+			$remp1[] = '<'.trim($tag).'>';
2095
+			$remp1[] = '</'.trim($tag).'>';
2096
+			$remp2[] = '\x60'.trim($tag).'\x61';
2097
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2098 2098
 		}
2099 2099
 	}
2100 2100
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2157,7 +2157,7 @@  discard block
 block discarded – undo
2157 2157
 			$s[] = preg_replace(',>[^<]+</a>,S',
2158 2158
 				'>'
2159 2159
 				. http_img_pack('attachment-16.png', $t,
2160
-					'title="' . attribut_html($t) . '"')
2160
+					'title="'.attribut_html($t).'"')
2161 2161
 				. '</a>', $tag);
2162 2162
 		}
2163 2163
 	}
@@ -2218,10 +2218,10 @@  discard block
 block discarded – undo
2218 2218
 	$fichier = basename($url);
2219 2219
 
2220 2220
 	return '<a rel="enclosure"'
2221
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2222
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2223
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2224
-	. '>' . $fichier . '</a>';
2221
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2222
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2223
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2224
+	. '>'.$fichier.'</a>';
2225 2225
 }
2226 2226
 
2227 2227
 /**
@@ -2249,9 +2249,9 @@  discard block
 block discarded – undo
2249 2249
 			} # vieux data
2250 2250
 			$fichier = basename($url);
2251 2251
 			$enclosures[] = '<enclosure'
2252
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2253
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2254
-				. ($length ? ' length="' . $length . '"' : '')
2252
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2253
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2254
+				. ($length ? ' length="'.$length.'"' : '')
2255 2255
 				. ' />';
2256 2256
 		}
2257 2257
 	}
@@ -2277,7 +2277,7 @@  discard block
 block discarded – undo
2277 2277
 		if (extraire_attribut($e, rel) == 'tag') {
2278 2278
 			$subjects .= '<dc:subject>'
2279 2279
 				. texte_backend(textebrut($e))
2280
-				. '</dc:subject>' . "\n";
2280
+				. '</dc:subject>'."\n";
2281 2281
 		}
2282 2282
 	}
2283 2283
 
@@ -2313,7 +2313,7 @@  discard block
 block discarded – undo
2313 2313
 	if (is_array($texte)) {
2314 2314
 		array_walk(
2315 2315
 			$texte,
2316
-			function(&$a, $key, $t){
2316
+			function(&$a, $key, $t) {
2317 2317
 				$a = extraire_balise($a, $t);
2318 2318
 			},
2319 2319
 			$tag
@@ -2357,7 +2357,7 @@  discard block
 block discarded – undo
2357 2357
 	if (is_array($texte)) {
2358 2358
 		array_walk(
2359 2359
 			$texte,
2360
-			function(&$a, $key, $t){
2360
+			function(&$a, $key, $t) {
2361 2361
 				$a = extraire_balises($a, $t);
2362 2362
 			},
2363 2363
 			$tag
@@ -2483,7 +2483,7 @@  discard block
 block discarded – undo
2483 2483
 		if ($fond != '404') {
2484 2484
 			$contexte = array_shift($p);
2485 2485
 			$contexte['page'] = $fond;
2486
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2486
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2487 2487
 		}
2488 2488
 	}
2489 2489
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2538,9 +2538,9 @@  discard block
 block discarded – undo
2538 2538
 			. '"'
2539 2539
 			. (is_null($val)
2540 2540
 				? ''
2541
-				: ' value="' . entites_html($val) . '"'
2541
+				: ' value="'.entites_html($val).'"'
2542 2542
 			)
2543
-			. ' type="hidden"' . "\n/>";
2543
+			. ' type="hidden"'."\n/>";
2544 2544
 	}
2545 2545
 
2546 2546
 	return join("", $hidden);
@@ -2703,12 +2703,12 @@  discard block
 block discarded – undo
2703 2703
 	if ($pas < 1) {
2704 2704
 		return '';
2705 2705
 	}
2706
-	$ancre = 'pagination' . $nom; // #pagination_articles
2707
-	$debut = 'debut' . $nom; // 'debut_articles'
2706
+	$ancre = 'pagination'.$nom; // #pagination_articles
2707
+	$debut = 'debut'.$nom; // 'debut_articles'
2708 2708
 
2709 2709
 	// n'afficher l'ancre qu'une fois
2710 2710
 	if (!isset($ancres[$ancre])) {
2711
-		$bloc_ancre = $ancres[$ancre] = "<a name='" . $ancre . "' id='" . $ancre . "'></a>";
2711
+		$bloc_ancre = $ancres[$ancre] = "<a name='".$ancre."' id='".$ancre."'></a>";
2712 2712
 	} else {
2713 2713
 		$bloc_ancre = '';
2714 2714
 	}
@@ -2738,7 +2738,7 @@  discard block
 block discarded – undo
2738 2738
 	}
2739 2739
 
2740 2740
 	if ($modele) {
2741
-		$modele = '_' . $modele;
2741
+		$modele = '_'.$modele;
2742 2742
 	}
2743 2743
 
2744 2744
 	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
@@ -2763,7 +2763,7 @@  discard block
 block discarded – undo
2763 2763
 	return preg_replace_callback(
2764 2764
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2765 2765
 		function($x) use ($path) {
2766
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2766
+			return "url('".suivre_lien($path, $x[1])."')";
2767 2767
 		},
2768 2768
 		$contenu
2769 2769
 	);
@@ -2825,14 +2825,14 @@  discard block
 block discarded – undo
2825 2825
 	) {
2826 2826
 		$distant = true;
2827 2827
 		$cssf = parse_url($css);
2828
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2828
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2829 2829
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2830 2830
 	} else {
2831 2831
 		$distant = false;
2832 2832
 		$cssf = $css;
2833 2833
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2834 2834
 		//propose (rien a faire dans ce cas)
2835
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2835
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2836 2836
 		if (@file_exists($f)) {
2837 2837
 			return $f;
2838 2838
 		}
@@ -2842,7 +2842,7 @@  discard block
 block discarded – undo
2842 2842
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2843 2843
 	$f = $dir_var
2844 2844
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2845
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2845
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2846 2846
 
2847 2847
 	// la css peut etre distante (url absolue !)
2848 2848
 	if ($distant) {
@@ -2887,8 +2887,8 @@  discard block
 block discarded – undo
2887 2887
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2888 2888
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2889 2889
 			$css_direction = substr($css_direction, strlen($dir_var));
2890
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2891
-			$css_direction = "/@@@@@@/" . $css_direction;
2890
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
2891
+			$css_direction = "/@@@@@@/".$css_direction;
2892 2892
 		}
2893 2893
 		$src[] = $regs[0][$k];
2894 2894
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -2937,7 +2937,7 @@  discard block
 block discarded – undo
2937 2937
 
2938 2938
 	$f = basename($css, '.css');
2939 2939
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2940
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2940
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
2941 2941
 		. '.css';
2942 2942
 
2943 2943
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -2946,7 +2946,7 @@  discard block
 block discarded – undo
2946 2946
 
2947 2947
 	if ($url_absolue_css == $css) {
2948 2948
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
2949
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2949
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
2950 2950
 		) {
2951 2951
 			include_spip('inc/distant');
2952 2952
 			if (!$contenu = recuperer_page($css)) {
@@ -3056,7 +3056,7 @@  discard block
 block discarded – undo
3056 3056
 	$expression = str_replace("\/", "/", $expression);
3057 3057
 	$expression = str_replace("/", "\/", $expression);
3058 3058
 
3059
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3059
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3060 3060
 		if (isset($r[$capte])) {
3061 3061
 			return $r[$capte];
3062 3062
 		} else {
@@ -3094,7 +3094,7 @@  discard block
 block discarded – undo
3094 3094
 	$expression = str_replace("\/", "/", $expression);
3095 3095
 	$expression = str_replace("/", "\/", $expression);
3096 3096
 
3097
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3097
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3098 3098
 }
3099 3099
 
3100 3100
 
@@ -3113,7 +3113,7 @@  discard block
 block discarded – undo
3113 3113
 function traiter_doublons_documents(&$doublons, $letexte) {
3114 3114
 
3115 3115
 	// Verifier dans le texte & les notes (pas beau, helas)
3116
-	$t = $letexte . $GLOBALS['les_notes'];
3116
+	$t = $letexte.$GLOBALS['les_notes'];
3117 3117
 
3118 3118
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3119 3119
 		and preg_match_all(
@@ -3123,7 +3123,7 @@  discard block
 block discarded – undo
3123 3123
 		if (!isset($doublons['documents'])) {
3124 3124
 			$doublons['documents'] = "";
3125 3125
 		}
3126
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3126
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3127 3127
 	}
3128 3128
 
3129 3129
 	return $letexte;
@@ -3180,7 +3180,7 @@  discard block
 block discarded – undo
3180 3180
 	if ($env) {
3181 3181
 		foreach ($env as $i => $j) {
3182 3182
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3183
-				$texte .= "<param name='" . $i . "'\n\tvalue='" . $j . "' />";
3183
+				$texte .= "<param name='".$i."'\n\tvalue='".$j."' />";
3184 3184
 			}
3185 3185
 		}
3186 3186
 	}
@@ -3219,7 +3219,7 @@  discard block
 block discarded – undo
3219 3219
 	if ($env) {
3220 3220
 		foreach ($env as $i => $j) {
3221 3221
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3222
-				$texte .= $i . "='" . $j . "' ";
3222
+				$texte .= $i."='".$j."' ";
3223 3223
 			}
3224 3224
 		}
3225 3225
 	}
@@ -3303,19 +3303,19 @@  discard block
 block discarded – undo
3303 3303
 
3304 3304
 	$img_file = $img;
3305 3305
 	if ($p = strpos($img_file, '?')) {
3306
-		$img_file = substr($img_file,0, $p);
3306
+		$img_file = substr($img_file, 0, $p);
3307 3307
 	}
3308 3308
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3309 3309
 		$img_file = chemin_image($img);
3310 3310
 	}
3311 3311
 	else {
3312
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3312
+		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3313 3313
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3314 3314
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3315 3315
 			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3316
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3316
+			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg"
3317 3317
 			  and file_exists($variante_svg_generique)) {
3318
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3318
+				if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) {
3319 3319
 					$img_file = $variante_svg_size;
3320 3320
 				}
3321 3321
 				else {
@@ -3340,15 +3340,15 @@  discard block
 block discarded – undo
3340 3340
 				return "";
3341 3341
 			}
3342 3342
 		}
3343
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3343
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3344 3344
 	}
3345 3345
 
3346 3346
 	if (file_exists($img_file)) {
3347 3347
 		$img_file = timestamp($img_file);
3348 3348
 	}
3349
-	return "<img src='$img_file' alt='" . attribut_html($alt ? $alt : $title) . "'"
3350
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3351
-	. " " . ltrim($atts)
3349
+	return "<img src='$img_file' alt='".attribut_html($alt ? $alt : $title)."'"
3350
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3351
+	. " ".ltrim($atts)
3352 3352
 	. " />";
3353 3353
 }
3354 3354
 
@@ -3360,12 +3360,12 @@  discard block
 block discarded – undo
3360 3360
  * @param string $size
3361 3361
  * @return string
3362 3362
  */
3363
-function http_style_background($img, $att = '', $size=null) {
3364
-	if ($size and is_numeric($size)){
3365
-		$size = trim($size) . "px";
3363
+function http_style_background($img, $att = '', $size = null) {
3364
+	if ($size and is_numeric($size)) {
3365
+		$size = trim($size)."px";
3366 3366
 	}
3367
-	return " style='background" .
3368
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3367
+	return " style='background".
3368
+		($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";"
3369 3369
 		. ($size ? "background-size:{$size};" : '')
3370 3370
 		. "'";
3371 3371
 }
@@ -3382,8 +3382,8 @@  discard block
 block discarded – undo
3382 3382
  * @return string
3383 3383
  *     Code HTML de la balise IMG
3384 3384
  */
3385
-function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3386
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3385
+function filtre_balise_img_dist($img, $alt = "", $class = "", $width = null) {
3386
+	$atts = $class ? " class='".attribut_html($class)."'" : '';
3387 3387
 	// ecriture courte : on donne le width en 2e arg
3388 3388
 	if (empty($width) and is_numeric($alt)) {
3389 3389
 		$width = $alt;
@@ -3424,11 +3424,11 @@  discard block
 block discarded – undo
3424 3424
 	if ($class) {
3425 3425
 		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3426 3426
 	}
3427
-	if ($alt){
3427
+	if ($alt) {
3428 3428
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3429
-		$id = "img-svg-title-" . substr(md5("$file:$svg:$alt"),0,4);
3429
+		$id = "img-svg-title-".substr(md5("$file:$svg:$alt"), 0, 4);
3430 3430
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3431
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3431
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3432 3432
 		$balise_svg .= $title;
3433 3433
 	}
3434 3434
 	else {
@@ -3462,7 +3462,7 @@  discard block
 block discarded – undo
3462 3462
 	$texte = '';
3463 3463
 	if (is_array($tableau)) {
3464 3464
 		foreach ($tableau as $k => $v) {
3465
-			$res = recuperer_fond('modeles/' . $modele,
3465
+			$res = recuperer_fond('modeles/'.$modele,
3466 3466
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3467 3467
 			);
3468 3468
 			$texte .= $res;
@@ -3639,7 +3639,7 @@  discard block
 block discarded – undo
3639 3639
 	}
3640 3640
 
3641 3641
 	$c = serialize($c);
3642
-	$cle = calculer_cle_action($form . $c);
3642
+	$cle = calculer_cle_action($form.$c);
3643 3643
 	$c = "$cle:$c";
3644 3644
 
3645 3645
 	// on ne stocke pas les contextes dans des fichiers caches
@@ -3689,15 +3689,15 @@  discard block
 block discarded – undo
3689 3689
 	}
3690 3690
 	// toujours encoder l'url source dans le bloc ajax
3691 3691
 	$r = self();
3692
-	$r = ' data-origin="' . $r . '"';
3692
+	$r = ' data-origin="'.$r.'"';
3693 3693
 	$class = 'ajaxbloc';
3694 3694
 	if ($ajaxid and is_string($ajaxid)) {
3695 3695
 		// ajaxid est normalement conforme a un nom de classe css
3696 3696
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3697
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3697
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3698 3698
 	}
3699 3699
 
3700
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3700
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3701 3701
 }
3702 3702
 
3703 3703
 /**
@@ -3736,11 +3736,11 @@  discard block
 block discarded – undo
3736 3736
 	// extraire la signature en debut de contexte
3737 3737
 	// et la verifier avant de deserializer
3738 3738
 	// format : signature:donneesserializees
3739
-	if ($p = strpos($c,":")){
3740
-		$cle = substr($c,0,$p);
3741
-		$c = substr($c,$p+1);
3739
+	if ($p = strpos($c, ":")) {
3740
+		$cle = substr($c, 0, $p);
3741
+		$c = substr($c, $p + 1);
3742 3742
 
3743
-		if ($cle == calculer_cle_action($form . $c)) {
3743
+		if ($cle == calculer_cle_action($form.$c)) {
3744 3744
 			$env = @unserialize($c);
3745 3745
 			return $env;
3746 3746
 		}
@@ -3841,9 +3841,9 @@  discard block
 block discarded – undo
3841 3841
 	} else {
3842 3842
 		$bal = 'a';
3843 3843
 		$att = "href='$url'"
3844
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3845
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3846
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3844
+			. ($title ? " title='".attribut_html($title)."'" : '')
3845
+			. ($class ? " class='".attribut_html($class)."'" : '')
3846
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
3847 3847
 			. $evt;
3848 3848
 	}
3849 3849
 	if ($libelle === null) {
@@ -3918,7 +3918,7 @@  discard block
 block discarded – undo
3918 3918
 	}
3919 3919
 
3920 3920
 	// ajouter le type d'objet dans la class de l'icone
3921
-	$class .= " " . substr(basename($fond), 0, -4);
3921
+	$class .= " ".substr(basename($fond), 0, -4);
3922 3922
 
3923 3923
 	$alt = attribut_html($texte);
3924 3924
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -3942,7 +3942,7 @@  discard block
 block discarded – undo
3942 3942
 	}
3943 3943
 
3944 3944
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
3945
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
3945
+	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "")."\">$icone</span>";
3946 3946
 
3947 3947
 	if ($type == 'lien') {
3948 3948
 		return "<span class='icone s$size $class'>"
@@ -4172,13 +4172,13 @@  discard block
 block discarded – undo
4172 4172
 	$res = "";
4173 4173
 	foreach ($boutons as $page => $detail) {
4174 4174
 		if ($detail->icone and strlen(trim($detail->icone))) {
4175
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4175
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4176 4176
 		}
4177 4177
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4178 4178
 		if (is_array($detail->sousmenu)) {
4179 4179
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4180 4180
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4181
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4181
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4182 4182
 				}
4183 4183
 			}
4184 4184
 		}
@@ -4204,17 +4204,17 @@  discard block
 block discarded – undo
4204 4204
  */
4205 4205
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4206 4206
 	if ($confirm) {
4207
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4207
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4208 4208
 		if ($callback) {
4209 4209
 			$callback = "$confirm?($callback):false";
4210 4210
 		} else {
4211 4211
 			$callback = $confirm;
4212 4212
 		}
4213 4213
 	}
4214
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4214
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4215 4215
 	$title = $title ? " title='$title'" : "";
4216 4216
 
4217
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4217
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4218 4218
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4219 4219
 }
4220 4220
 
@@ -4353,14 +4353,14 @@  discard block
 block discarded – undo
4353 4353
 		$champ_titre = "";
4354 4354
 		if ($demande_titre) {
4355 4355
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4356
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4356
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4357 4357
 		}
4358 4358
 		include_spip('base/abstract_sql');
4359 4359
 		include_spip('base/connect_sql');
4360 4360
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4361
-			'*' . $champ_titre,
4361
+			'*'.$champ_titre,
4362 4362
 			$desc['table_sql'],
4363
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4363
+			id_table_objet($type_objet).' = '.intval($id_objet)
4364 4364
 		);
4365 4365
 	}
4366 4366
 
@@ -4430,7 +4430,7 @@  discard block
 block discarded – undo
4430 4430
 		return $texte;
4431 4431
 	}
4432 4432
 
4433
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4433
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4434 4434
 
4435 4435
 	// Fournir $connect et $Pile[0] au traitement si besoin
4436 4436
 	$Pile = array(0 => $env);
@@ -4464,7 +4464,7 @@  discard block
 block discarded – undo
4464 4464
 	}
4465 4465
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4466 4466
 
4467
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4467
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4468 4468
 }
4469 4469
 
4470 4470
 
@@ -4483,10 +4483,10 @@  discard block
 block discarded – undo
4483 4483
 function wrap($texte, $wrap) {
4484 4484
 	$balises = extraire_balises($wrap);
4485 4485
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4486
-		$texte = $wrap . $texte;
4486
+		$texte = $wrap.$texte;
4487 4487
 		$regs = array_reverse($regs[1]);
4488
-		$wrap = "</" . implode("></", $regs) . ">";
4489
-		$texte = $texte . $wrap;
4488
+		$wrap = "</".implode("></", $regs).">";
4489
+		$texte = $texte.$wrap;
4490 4490
 	}
4491 4491
 
4492 4492
 	return $texte;
@@ -4517,7 +4517,7 @@  discard block
 block discarded – undo
4517 4517
 
4518 4518
 	// caster $u en array si besoin
4519 4519
 	if (is_object($u)) {
4520
-		$u = (array)$u;
4520
+		$u = (array) $u;
4521 4521
 	}
4522 4522
 
4523 4523
 	if (is_array($u)) {
@@ -4538,7 +4538,7 @@  discard block
 block discarded – undo
4538 4538
 		// sinon on passe a la ligne et on indente
4539 4539
 		$i_str = str_pad("", $indent, " ");
4540 4540
 		foreach ($u as $k => $v) {
4541
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4541
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4542 4542
 		}
4543 4543
 
4544 4544
 		return $out;
@@ -4591,8 +4591,8 @@  discard block
 block discarded – undo
4591 4591
  * @param string $class
4592 4592
  * @return string
4593 4593
  */
4594
-function objet_icone($objet, $taille = 24, $class='') {
4595
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4594
+function objet_icone($objet, $taille = 24, $class = '') {
4595
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4596 4596
 	$icone = chemin_image($icone);
4597 4597
 	$balise_img = charger_filtre('balise_img');
4598 4598
 
@@ -4616,12 +4616,12 @@  discard block
 block discarded – undo
4616 4616
  * @param array $options
4617 4617
  * @return string
4618 4618
  */
4619
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4620
-	$chaine = explode(':',$chaine);
4621
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4619
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4620
+	$chaine = explode(':', $chaine);
4621
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4622 4622
 		return $t;
4623 4623
 	}
4624
-	$chaine = implode(':',$chaine);
4624
+	$chaine = implode(':', $chaine);
4625 4625
 	return _T($chaine, $args, $options);
4626 4626
 }
4627 4627
 
@@ -4681,11 +4681,11 @@  discard block
 block discarded – undo
4681 4681
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4682 4682
 
4683 4683
 	// calculer le nom de la css
4684
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4684
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4685 4685
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4686 4686
 	$contexte_implicite = calculer_contexte_implicite();
4687
-	$filename = $dir_var . $extension . "dyn-$nom_safe-"
4688
-		. substr(md5($fond . serialize($contexte_implicite) . serialize($contexte) . $connect), 0, 8)
4687
+	$filename = $dir_var.$extension."dyn-$nom_safe-"
4688
+		. substr(md5($fond.serialize($contexte_implicite).serialize($contexte).$connect), 0, 8)
4689 4689
 		. ".$extension";
4690 4690
 
4691 4691
 	// mettre a jour le fichier si il n'existe pas
@@ -4693,8 +4693,8 @@  discard block
 block discarded – undo
4693 4693
 	// le dernier fichier produit est toujours suffixe par .last
4694 4694
 	// et recopie sur le fichier cible uniquement si il change
4695 4695
 	if (!file_exists($filename)
4696
-		or !file_exists($filename . ".last")
4697
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4696
+		or !file_exists($filename.".last")
4697
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4698 4698
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4699 4699
 	) {
4700 4700
 		$contenu = $cache['texte'];
@@ -4713,15 +4713,15 @@  discard block
 block discarded – undo
4713 4713
 			}
4714 4714
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4715 4715
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4716
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4716
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4717 4717
 		}
4718 4718
 		// et ecrire le fichier
4719
-		ecrire_fichier($filename . ".last", $comment . $contenu);
4719
+		ecrire_fichier($filename.".last", $comment.$contenu);
4720 4720
 		// regarder si on recopie
4721 4721
 		if (!file_exists($filename)
4722
-			or md5_file($filename) !== md5_file($filename . ".last")
4722
+			or md5_file($filename) !== md5_file($filename.".last")
4723 4723
 		) {
4724
-			@copy($filename . ".last", $filename);
4724
+			@copy($filename.".last", $filename);
4725 4725
 			clearstatcache(true, $filename); // eviter que PHP ne reserve le vieux timestamp
4726 4726
 		}
4727 4727
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3307,8 +3307,7 @@  discard block
 block discarded – undo
3307 3307
 	}
3308 3308
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3309 3309
 		$img_file = chemin_image($img);
3310
-	}
3311
-	else {
3310
+	} else {
3312 3311
 		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3313 3312
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3314 3313
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
@@ -3317,8 +3316,7 @@  discard block
 block discarded – undo
3317 3316
 			  and file_exists($variante_svg_generique)) {
3318 3317
 				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3319 3318
 					$img_file = $variante_svg_size;
3320
-				}
3321
-				else {
3319
+				} else {
3322 3320
 					$img_file = $variante_svg_generique;
3323 3321
 				}
3324 3322
 			}
@@ -3430,8 +3428,7 @@  discard block
 block discarded – undo
3430 3428
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3431 3429
 		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3432 3430
 		$balise_svg .= $title;
3433
-	}
3434
-	else {
3431
+	} else {
3435 3432
 		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3436 3433
 	}
3437 3434
 	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
Please login to merge, or discard this patch.