Completed
Push — master ( 449397...130c6f )
by cam
04:19
created
ecrire/public/fonctions.php 2 patches
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  **/
24 24
 
25 25
 if (!defined('_ECRIRE_INC_VERSION')) {
26
-	return;
26
+    return;
27 27
 }
28 28
 
29 29
 
@@ -52,75 +52,75 @@  discard block
 block discarded – undo
52 52
  *     Introduction calculée
53 53
  **/
54 54
 function filtre_introduction_dist($descriptif, $texte, $longueur, $connect, $suite = null) {
55
-	// Si un descriptif est envoye, on l'utilise directement
56
-	if (strlen($descriptif)) {
57
-		return appliquer_traitement_champ($descriptif, 'introduction', '', array(), $connect);
58
-	}
59
-
60
-	// De preference ce qui est marque <intro>...</intro>
61
-	$intro = '';
62
-	$texte = preg_replace(",(</?)intro>,i", "\\1intro>", $texte); // minuscules
63
-	while ($fin = strpos($texte, "</intro>")) {
64
-		$zone = substr($texte, 0, $fin);
65
-		$texte = substr($texte, $fin + strlen("</intro>"));
66
-		if ($deb = strpos($zone, "<intro>") or substr($zone, 0, 7) == "<intro>") {
67
-			$zone = substr($zone, $deb + 7);
68
-		}
69
-		$intro .= $zone;
70
-	}
71
-
72
-	// [12025] On ne *PEUT* pas couper simplement ici car c'est du texte brut,
73
-	// qui inclus raccourcis et modeles
74
-	// un simple <articlexx> peut etre ensuite transforme en 1000 lignes ...
75
-	// par ailleurs le nettoyage des raccourcis ne tient pas compte
76
-	// des surcharges et enrichissement de propre
77
-	// couper doit se faire apres propre
78
-	//$texte = nettoyer_raccourcis_typo($intro ? $intro : $texte, $connect);
79
-
80
-	// Cependant pour des questions de perfs on coupe quand meme, en prenant
81
-	// large et en se mefiant des tableaux #1323
82
-
83
-	if (strlen($intro)) {
84
-		$texte = $intro;
85
-	} else {
86
-		if (strpos("\n" . $texte, "\n|") === false
87
-			and strlen($texte) > 2.5 * $longueur
88
-		) {
89
-			if (strpos($texte, "<multi") !== false) {
90
-				$texte = extraire_multi($texte);
91
-			}
92
-			$texte = couper($texte, 2 * $longueur);
93
-		}
94
-	}
95
-
96
-	// ne pas tenir compte des notes
97
-	if ($notes = charger_fonction('notes', 'inc', true)) {
98
-		$notes('', 'empiler');
99
-	}
100
-	// Supprimer les modèles avant le propre afin d'éviter qu'ils n'ajoutent du texte indésirable
101
-	// dans l'introduction.
102
-	$texte = supprime_img($texte, '');
103
-	$texte = appliquer_traitement_champ($texte, 'introduction', '', array(), $connect);
104
-
105
-	if ($notes) {
106
-		$notes('', 'depiler');
107
-	}
108
-
109
-	if (is_null($suite) and defined('_INTRODUCTION_SUITE')) {
110
-		$suite = _INTRODUCTION_SUITE;
111
-	}
112
-	$texte = couper($texte, $longueur, $suite);
113
-	// comme on a coupe il faut repasser la typo (on a perdu les insecables)
114
-	$texte = typo($texte, true, $connect, array());
115
-
116
-	// et reparagrapher si necessaire (coherence avec le cas descriptif)
117
-	// une introduction a tojours un <p>
118
-	if ($GLOBALS['toujours_paragrapher']) // Fermer les paragraphes
119
-	{
120
-		$texte = paragrapher($texte, $GLOBALS['toujours_paragrapher']);
121
-	}
122
-
123
-	return $texte;
55
+    // Si un descriptif est envoye, on l'utilise directement
56
+    if (strlen($descriptif)) {
57
+        return appliquer_traitement_champ($descriptif, 'introduction', '', array(), $connect);
58
+    }
59
+
60
+    // De preference ce qui est marque <intro>...</intro>
61
+    $intro = '';
62
+    $texte = preg_replace(",(</?)intro>,i", "\\1intro>", $texte); // minuscules
63
+    while ($fin = strpos($texte, "</intro>")) {
64
+        $zone = substr($texte, 0, $fin);
65
+        $texte = substr($texte, $fin + strlen("</intro>"));
66
+        if ($deb = strpos($zone, "<intro>") or substr($zone, 0, 7) == "<intro>") {
67
+            $zone = substr($zone, $deb + 7);
68
+        }
69
+        $intro .= $zone;
70
+    }
71
+
72
+    // [12025] On ne *PEUT* pas couper simplement ici car c'est du texte brut,
73
+    // qui inclus raccourcis et modeles
74
+    // un simple <articlexx> peut etre ensuite transforme en 1000 lignes ...
75
+    // par ailleurs le nettoyage des raccourcis ne tient pas compte
76
+    // des surcharges et enrichissement de propre
77
+    // couper doit se faire apres propre
78
+    //$texte = nettoyer_raccourcis_typo($intro ? $intro : $texte, $connect);
79
+
80
+    // Cependant pour des questions de perfs on coupe quand meme, en prenant
81
+    // large et en se mefiant des tableaux #1323
82
+
83
+    if (strlen($intro)) {
84
+        $texte = $intro;
85
+    } else {
86
+        if (strpos("\n" . $texte, "\n|") === false
87
+            and strlen($texte) > 2.5 * $longueur
88
+        ) {
89
+            if (strpos($texte, "<multi") !== false) {
90
+                $texte = extraire_multi($texte);
91
+            }
92
+            $texte = couper($texte, 2 * $longueur);
93
+        }
94
+    }
95
+
96
+    // ne pas tenir compte des notes
97
+    if ($notes = charger_fonction('notes', 'inc', true)) {
98
+        $notes('', 'empiler');
99
+    }
100
+    // Supprimer les modèles avant le propre afin d'éviter qu'ils n'ajoutent du texte indésirable
101
+    // dans l'introduction.
102
+    $texte = supprime_img($texte, '');
103
+    $texte = appliquer_traitement_champ($texte, 'introduction', '', array(), $connect);
104
+
105
+    if ($notes) {
106
+        $notes('', 'depiler');
107
+    }
108
+
109
+    if (is_null($suite) and defined('_INTRODUCTION_SUITE')) {
110
+        $suite = _INTRODUCTION_SUITE;
111
+    }
112
+    $texte = couper($texte, $longueur, $suite);
113
+    // comme on a coupe il faut repasser la typo (on a perdu les insecables)
114
+    $texte = typo($texte, true, $connect, array());
115
+
116
+    // et reparagrapher si necessaire (coherence avec le cas descriptif)
117
+    // une introduction a tojours un <p>
118
+    if ($GLOBALS['toujours_paragrapher']) // Fermer les paragraphes
119
+    {
120
+        $texte = paragrapher($texte, $GLOBALS['toujours_paragrapher']);
121
+    }
122
+
123
+    return $texte;
124 124
 }
125 125
 
126 126
 
@@ -155,59 +155,59 @@  discard block
 block discarded – undo
155 155
  *     Code HTML de la pagination
156 156
  **/
157 157
 function filtre_pagination_dist(
158
-	$total,
159
-	$nom,
160
-	$position,
161
-	$pas,
162
-	$liste = true,
163
-	$modele = '',
164
-	$connect = '',
165
-	$env = array()
158
+    $total,
159
+    $nom,
160
+    $position,
161
+    $pas,
162
+    $liste = true,
163
+    $modele = '',
164
+    $connect = '',
165
+    $env = array()
166 166
 ) {
167
-	static $ancres = array();
168
-	if ($pas < 1) {
169
-		return '';
170
-	}
171
-	$ancre = 'pagination' . $nom; // #pagination_articles
172
-	$debut = 'debut' . $nom; // 'debut_articles'
173
-
174
-	// n'afficher l'ancre qu'une fois
175
-	if (!isset($ancres[$ancre])) {
176
-		$bloc_ancre = $ancres[$ancre] = "<a id='" . $ancre . "' class='pagination_ancre'></a>";
177
-	} else {
178
-		$bloc_ancre = '';
179
-	}
180
-	// liste = false : on ne veut que l'ancre
181
-	if (!$liste) {
182
-		return $ancres[$ancre];
183
-	}
184
-
185
-	$self = (empty($env['self']) ? self() : $env['self']);
186
-	$pagination = array(
187
-		'debut' => $debut,
188
-		'url' => parametre_url($self, 'fragment', ''), // nettoyer l'id ahah eventuel
189
-		'total' => $total,
190
-		'position' => intval($position),
191
-		'pas' => $pas,
192
-		'nombre_pages' => floor(($total - 1) / $pas) + 1,
193
-		'page_courante' => floor(intval($position) / $pas) + 1,
194
-		'ancre' => $ancre,
195
-		'bloc_ancre' => $bloc_ancre
196
-	);
197
-	if (is_array($env)) {
198
-		$pagination = array_merge($env, $pagination);
199
-	}
200
-
201
-	// Pas de pagination
202
-	if ($pagination['nombre_pages'] <= 1) {
203
-		return '';
204
-	}
205
-
206
-	if ($modele) {
207
-		$modele = '_' . $modele;
208
-	}
209
-
210
-	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
167
+    static $ancres = array();
168
+    if ($pas < 1) {
169
+        return '';
170
+    }
171
+    $ancre = 'pagination' . $nom; // #pagination_articles
172
+    $debut = 'debut' . $nom; // 'debut_articles'
173
+
174
+    // n'afficher l'ancre qu'une fois
175
+    if (!isset($ancres[$ancre])) {
176
+        $bloc_ancre = $ancres[$ancre] = "<a id='" . $ancre . "' class='pagination_ancre'></a>";
177
+    } else {
178
+        $bloc_ancre = '';
179
+    }
180
+    // liste = false : on ne veut que l'ancre
181
+    if (!$liste) {
182
+        return $ancres[$ancre];
183
+    }
184
+
185
+    $self = (empty($env['self']) ? self() : $env['self']);
186
+    $pagination = array(
187
+        'debut' => $debut,
188
+        'url' => parametre_url($self, 'fragment', ''), // nettoyer l'id ahah eventuel
189
+        'total' => $total,
190
+        'position' => intval($position),
191
+        'pas' => $pas,
192
+        'nombre_pages' => floor(($total - 1) / $pas) + 1,
193
+        'page_courante' => floor(intval($position) / $pas) + 1,
194
+        'ancre' => $ancre,
195
+        'bloc_ancre' => $bloc_ancre
196
+    );
197
+    if (is_array($env)) {
198
+        $pagination = array_merge($env, $pagination);
199
+    }
200
+
201
+    // Pas de pagination
202
+    if ($pagination['nombre_pages'] <= 1) {
203
+        return '';
204
+    }
205
+
206
+    if ($modele) {
207
+        $modele = '_' . $modele;
208
+    }
209
+
210
+    return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
211 211
 }
212 212
 
213 213
 
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
  **/
222 222
 function lister_objets_avec_logos($type) {
223 223
 
224
-	$objet = objet_type($type);
225
-	$ids = sql_allfetsel("L.id_objet", "spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document", "D.mode=".sql_quote('logoon')." AND L.objet=".sql_quote($objet));
226
-	if ($ids) {
227
-		$ids = array_column($ids, 'id_objet');
228
-		return implode(',', $ids);
229
-	}
230
-	else {
231
-		return "0";
232
-	}
224
+    $objet = objet_type($type);
225
+    $ids = sql_allfetsel("L.id_objet", "spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document", "D.mode=".sql_quote('logoon')." AND L.objet=".sql_quote($objet));
226
+    if ($ids) {
227
+        $ids = array_column($ids, 'id_objet');
228
+        return implode(',', $ids);
229
+    }
230
+    else {
231
+        return "0";
232
+    }
233 233
 }
234 234
 
235 235
 
@@ -245,14 +245,14 @@  discard block
 block discarded – undo
245 245
  *     Code HTML des notes
246 246
  **/
247 247
 function calculer_notes() {
248
-	$r = '';
249
-	if ($notes = charger_fonction('notes', 'inc', true)) {
250
-		$r = $notes(array());
251
-		$notes('', 'depiler');
252
-		$notes('', 'empiler');
253
-	}
254
-
255
-	return $r;
248
+    $r = '';
249
+    if ($notes = charger_fonction('notes', 'inc', true)) {
250
+        $r = $notes(array());
251
+        $notes('', 'depiler');
252
+        $notes('', 'empiler');
253
+    }
254
+
255
+    return $r;
256 256
 }
257 257
 
258 258
 
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
  * @return string
270 270
  */
271 271
 function retrouver_rang_lien($objet_source, $ids, $objet_lie, $idl, $objet_lien){
272
-	$res = lister_objets_liens($objet_source, $objet_lie, $idl, $objet_lien);
273
-	$res = array_column($res, 'rang_lien', $objet_source);
272
+    $res = lister_objets_liens($objet_source, $objet_lie, $idl, $objet_lien);
273
+    $res = array_column($res, 'rang_lien', $objet_source);
274 274
 
275
-	return (isset($res[$ids]) ? $res[$ids] : '');
275
+    return (isset($res[$ids]) ? $res[$ids] : '');
276 276
 }
277 277
 
278 278
 
@@ -289,19 +289,19 @@  discard block
 block discarded – undo
289 289
  * @private
290 290
  */
291 291
 function lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien) {
292
-	static $liens = array();
293
-	if (!isset($liens["$objet_source-$objet-$id_objet-$objet_lien"])) {
294
-		include_spip('action/editer_liens');
295
-		// quand $objet == $objet_lien == $objet_source on reste sur le cas par defaut de $objet_lien == $objet_source
296
-		if ($objet_lien == $objet and $objet_lien !== $objet_source) {
297
-			$res = objet_trouver_liens(array($objet => $id_objet), array($objet_source => '*'));
298
-		} else {
299
-			$res = objet_trouver_liens(array($objet_source => '*'), array($objet => $id_objet));
300
-		}
301
-
302
-		$liens["$objet_source-$objet-$id_objet-$objet_lien"] = $res;
303
-	}
304
-	return $liens["$objet_source-$objet-$id_objet-$objet_lien"];
292
+    static $liens = array();
293
+    if (!isset($liens["$objet_source-$objet-$id_objet-$objet_lien"])) {
294
+        include_spip('action/editer_liens');
295
+        // quand $objet == $objet_lien == $objet_source on reste sur le cas par defaut de $objet_lien == $objet_source
296
+        if ($objet_lien == $objet and $objet_lien !== $objet_source) {
297
+            $res = objet_trouver_liens(array($objet => $id_objet), array($objet_source => '*'));
298
+        } else {
299
+            $res = objet_trouver_liens(array($objet_source => '*'), array($objet => $id_objet));
300
+        }
301
+
302
+        $liens["$objet_source-$objet-$id_objet-$objet_lien"] = $res;
303
+    }
304
+    return $liens["$objet_source-$objet-$id_objet-$objet_lien"];
305 305
 }
306 306
 
307 307
 /**
@@ -315,23 +315,23 @@  discard block
 block discarded – undo
315 315
  * @return int|string
316 316
  */
317 317
 function calculer_rang_smart($titre, $objet_source, $id, $env) {
318
-	// Cas du #RANG utilisé dans #FORMULAIRE_EDITER_LIENS -> attraper le rang du lien
319
-	// permet de voir le rang du lien si il y en a un en base, meme avant un squelette xxxx-lies.html ne gerant pas les liens
320
-	if (isset($env['form']) and $env['form']
321
-		and isset($env['_objet_lien']) and $env['_objet_lien']
322
-		and (function_exists('lien_triables') or include_spip('action/editer_liens'))
323
-		and $r = objet_associable($env['_objet_lien'])
324
-		and list($p, $table_lien) = $r
325
-	  and lien_triables($table_lien)
326
-	  and isset($env['objet']) and $env['objet']
327
-		and isset($env['id_objet']) and $env['id_objet']
328
-		and $objet_source
329
-		and $id = intval($id)
330
-	) {
331
-		$rang = retrouver_rang_lien($objet_source, $id, $env['objet'], $env['id_objet'], $env['_objet_lien']);
332
-		return ($rang ? $rang : '');
333
-	}
334
-	return recuperer_numero($titre);
318
+    // Cas du #RANG utilisé dans #FORMULAIRE_EDITER_LIENS -> attraper le rang du lien
319
+    // permet de voir le rang du lien si il y en a un en base, meme avant un squelette xxxx-lies.html ne gerant pas les liens
320
+    if (isset($env['form']) and $env['form']
321
+        and isset($env['_objet_lien']) and $env['_objet_lien']
322
+        and (function_exists('lien_triables') or include_spip('action/editer_liens'))
323
+        and $r = objet_associable($env['_objet_lien'])
324
+        and list($p, $table_lien) = $r
325
+      and lien_triables($table_lien)
326
+      and isset($env['objet']) and $env['objet']
327
+        and isset($env['id_objet']) and $env['id_objet']
328
+        and $objet_source
329
+        and $id = intval($id)
330
+    ) {
331
+        $rang = retrouver_rang_lien($objet_source, $id, $env['objet'], $env['id_objet'], $env['_objet_lien']);
332
+        return ($rang ? $rang : '');
333
+    }
334
+    return recuperer_numero($titre);
335 335
 }
336 336
 
337 337
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
  * @return string
344 344
  */
345 345
 function tri_protege_champ($t) {
346
-	return preg_replace(',[^\s\w.+],', '', $t);
346
+    return preg_replace(',[^\s\w.+],', '', $t);
347 347
 }
348 348
 
349 349
 /**
@@ -356,34 +356,34 @@  discard block
 block discarded – undo
356 356
  * @return string
357 357
  */
358 358
 function tri_champ_order($t, $from = null) {
359
-	if (strncmp($t, 'multi ', 6) == 0) {
360
-		return "multi";
361
-	}
362
-
363
-	$champ = $t;
364
-
365
-	if (strncmp($t, 'num ', 4) == 0) {
366
-		$champ = substr($t, 4);
367
-	}
368
-	// enlever les autres espaces non evacues par tri_protege_champ
369
-	$champ = preg_replace(',\s,', '', $champ);
370
-
371
-	if (is_array($from)) {
372
-		$trouver_table = charger_fonction('trouver_table', 'base');
373
-		foreach ($from as $idt => $table_sql) {
374
-			if ($desc = $trouver_table($table_sql)
375
-				and isset($desc['field'][$champ])
376
-			) {
377
-				$champ = "$idt.$champ";
378
-				break;
379
-			}
380
-		}
381
-	}
382
-	if (strncmp($t, 'num ', 4) == 0) {
383
-		return "0+$champ";
384
-	} else {
385
-		return $champ;
386
-	}
359
+    if (strncmp($t, 'multi ', 6) == 0) {
360
+        return "multi";
361
+    }
362
+
363
+    $champ = $t;
364
+
365
+    if (strncmp($t, 'num ', 4) == 0) {
366
+        $champ = substr($t, 4);
367
+    }
368
+    // enlever les autres espaces non evacues par tri_protege_champ
369
+    $champ = preg_replace(',\s,', '', $champ);
370
+
371
+    if (is_array($from)) {
372
+        $trouver_table = charger_fonction('trouver_table', 'base');
373
+        foreach ($from as $idt => $table_sql) {
374
+            if ($desc = $trouver_table($table_sql)
375
+                and isset($desc['field'][$champ])
376
+            ) {
377
+                $champ = "$idt.$champ";
378
+                break;
379
+            }
380
+        }
381
+    }
382
+    if (strncmp($t, 'num ', 4) == 0) {
383
+        return "0+$champ";
384
+    } else {
385
+        return $champ;
386
+    }
387 387
 }
388 388
 
389 389
 /**
@@ -397,18 +397,18 @@  discard block
 block discarded – undo
397 397
  * @return string
398 398
  */
399 399
 function tri_champ_select($t) {
400
-	if (strncmp($t, 'multi ', 6) == 0) {
401
-		$t = substr($t, 6);
402
-		$t = preg_replace(',\s,', '', $t);
403
-		$t = sql_multi($t, $GLOBALS['spip_lang']);
404
-
405
-		return $t;
406
-	}
407
-	if (trim($t) == 'hasard') {
408
-		return 'rand() AS hasard';
409
-	}
410
-
411
-	return "''";
400
+    if (strncmp($t, 'multi ', 6) == 0) {
401
+        $t = substr($t, 6);
402
+        $t = preg_replace(',\s,', '', $t);
403
+        $t = sql_multi($t, $GLOBALS['spip_lang']);
404
+
405
+        return $t;
406
+    }
407
+    if (trim($t) == 'hasard') {
408
+        return 'rand() AS hasard';
409
+    }
410
+
411
+    return "''";
412 412
 }
413 413
 
414 414
 /**
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
  * @return string
421 421
  */
422 422
 function formate_liste_critere_par_ordre_liste($valeurs, $serveur = ''){
423
-	if (!is_array($valeurs)){
424
-		return '';
425
-	}
426
-	$f = sql_serveur('quote', $serveur, true);
427
-	if (!is_string($f) or !$f){
428
-		return '';
429
-	}
430
-	$valeurs = implode(',', array_map($f, array_unique($valeurs)));
431
-
432
-	return $valeurs;
423
+    if (!is_array($valeurs)){
424
+        return '';
425
+    }
426
+    $f = sql_serveur('quote', $serveur, true);
427
+    if (!is_string($f) or !$f){
428
+        return '';
429
+    }
430
+    $valeurs = implode(',', array_map($f, array_unique($valeurs)));
431
+
432
+    return $valeurs;
433 433
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	if (strlen($intro)) {
84 84
 		$texte = $intro;
85 85
 	} else {
86
-		if (strpos("\n" . $texte, "\n|") === false
86
+		if (strpos("\n".$texte, "\n|") === false
87 87
 			and strlen($texte) > 2.5 * $longueur
88 88
 		) {
89 89
 			if (strpos($texte, "<multi") !== false) {
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 	if ($pas < 1) {
169 169
 		return '';
170 170
 	}
171
-	$ancre = 'pagination' . $nom; // #pagination_articles
172
-	$debut = 'debut' . $nom; // 'debut_articles'
171
+	$ancre = 'pagination'.$nom; // #pagination_articles
172
+	$debut = 'debut'.$nom; // 'debut_articles'
173 173
 
174 174
 	// n'afficher l'ancre qu'une fois
175 175
 	if (!isset($ancres[$ancre])) {
176
-		$bloc_ancre = $ancres[$ancre] = "<a id='" . $ancre . "' class='pagination_ancre'></a>";
176
+		$bloc_ancre = $ancres[$ancre] = "<a id='".$ancre."' class='pagination_ancre'></a>";
177 177
 	} else {
178 178
 		$bloc_ancre = '';
179 179
 	}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	}
205 205
 
206 206
 	if ($modele) {
207
-		$modele = '_' . $modele;
207
+		$modele = '_'.$modele;
208 208
 	}
209 209
 
210 210
 	return recuperer_fond("modeles/pagination$modele", $pagination, array('trim' => true), $connect);
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
  * @param $objet_lien
269 269
  * @return string
270 270
  */
271
-function retrouver_rang_lien($objet_source, $ids, $objet_lie, $idl, $objet_lien){
271
+function retrouver_rang_lien($objet_source, $ids, $objet_lie, $idl, $objet_lien) {
272 272
 	$res = lister_objets_liens($objet_source, $objet_lie, $idl, $objet_lien);
273 273
 	$res = array_column($res, 'rang_lien', $objet_source);
274 274
 
@@ -419,12 +419,12 @@  discard block
 block discarded – undo
419 419
  * @param string $serveur
420 420
  * @return string
421 421
  */
422
-function formate_liste_critere_par_ordre_liste($valeurs, $serveur = ''){
423
-	if (!is_array($valeurs)){
422
+function formate_liste_critere_par_ordre_liste($valeurs, $serveur = '') {
423
+	if (!is_array($valeurs)) {
424 424
 		return '';
425 425
 	}
426 426
 	$f = sql_serveur('quote', $serveur, true);
427
-	if (!is_string($f) or !$f){
427
+	if (!is_string($f) or !$f) {
428 428
 		return '';
429 429
 	}
430 430
 	$valeurs = implode(',', array_map($f, array_unique($valeurs)));
Please login to merge, or discard this patch.
ecrire/inc/filtres.php 2 patches
Indentation   +1997 added lines, -1997 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/charsets');
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
  * @return string Fonction PHP correspondante du filtre
43 43
  */
44 44
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
45
-	include_spip('public/parametrer'); // inclure les fichiers fonctions
46
-	return chercher_filtre($fonc, $default);
45
+    include_spip('public/parametrer'); // inclure les fichiers fonctions
46
+    return chercher_filtre($fonc, $default);
47 47
 }
48 48
 
49 49
 /**
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
  *     Fonction PHP correspondante du filtre demandé
76 76
  */
77 77
 function chercher_filtre($fonc, $default = null) {
78
-	if (!$fonc) {
79
-		return $default;
80
-	}
81
-	// Cas des types mime, sans confondre avec les appels de fonction de classe
82
-	// Foo::Bar
83
-	// qui peuvent etre avec un namespace : space\Foo::Bar
84
-	if (preg_match(',^[\w]+/,', $fonc)) {
85
-		$nom = preg_replace(',\W,', '_', $fonc);
86
-		$f = chercher_filtre($nom);
87
-		// cas du sous-type MIME sans filtre associe, passer au type:
88
-		// si filtre_text_plain pas defini, passe a filtre_text
89
-		if (!$f and $nom !== $fonc) {
90
-			$f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
-		}
92
-
93
-		return $f;
94
-	}
95
-
96
-	include_fichiers_fonctions();
97
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
98
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99
-		// fonction ou name\space\fonction
100
-		if (is_callable($f)) {
101
-			return $f;
102
-		}
103
-		// méthode statique d'une classe Classe::methode ou name\space\Classe::methode
104
-		elseif (false === strpos($f, '::') and is_callable(array($f))) {
105
-			return $f;
106
-		}
107
-	}
108
-
109
-	return $default;
78
+    if (!$fonc) {
79
+        return $default;
80
+    }
81
+    // Cas des types mime, sans confondre avec les appels de fonction de classe
82
+    // Foo::Bar
83
+    // qui peuvent etre avec un namespace : space\Foo::Bar
84
+    if (preg_match(',^[\w]+/,', $fonc)) {
85
+        $nom = preg_replace(',\W,', '_', $fonc);
86
+        $f = chercher_filtre($nom);
87
+        // cas du sous-type MIME sans filtre associe, passer au type:
88
+        // si filtre_text_plain pas defini, passe a filtre_text
89
+        if (!$f and $nom !== $fonc) {
90
+            $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
91
+        }
92
+
93
+        return $f;
94
+    }
95
+
96
+    include_fichiers_fonctions();
97
+    foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
98
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99
+        // fonction ou name\space\fonction
100
+        if (is_callable($f)) {
101
+            return $f;
102
+        }
103
+        // méthode statique d'une classe Classe::methode ou name\space\Classe::methode
104
+        elseif (false === strpos($f, '::') and is_callable(array($f))) {
105
+            return $f;
106
+        }
107
+    }
108
+
109
+    return $default;
110 110
 }
111 111
 
112 112
 /**
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
  *     Chaîne vide sinon (filtre introuvable).
131 131
  **/
132 132
 function appliquer_filtre($arg, $filtre, $force = null) {
133
-	$f = chercher_filtre($filtre);
134
-	if (!$f) {
135
-		if (!$force) {
136
-			return '';
137
-		} else {
138
-			return $arg;
139
-		}
140
-	}
133
+    $f = chercher_filtre($filtre);
134
+    if (!$f) {
135
+        if (!$force) {
136
+            return '';
137
+        } else {
138
+            return $arg;
139
+        }
140
+    }
141 141
 
142
-	$args = func_get_args();
143
-	array_shift($args); // enlever $arg
144
-	array_shift($args); // enlever $filtre
145
-	array_unshift($args, $arg); // remettre $arg
146
-	return call_user_func_array($f, $args);
142
+    $args = func_get_args();
143
+    array_shift($args); // enlever $arg
144
+    array_shift($args); // enlever $filtre
145
+    array_unshift($args, $arg); // remettre $arg
146
+    return call_user_func_array($f, $args);
147 147
 }
148 148
 
149 149
 /**
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
  *     Version de SPIP
160 160
  **/
161 161
 function spip_version() {
162
-	$version = $GLOBALS['spip_version_affichee'];
163
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
164
-		$version .= " $vcs_version";
165
-	}
162
+    $version = $GLOBALS['spip_version_affichee'];
163
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
164
+        $version .= " $vcs_version";
165
+    }
166 166
 
167
-	return $version;
167
+    return $version;
168 168
 }
169 169
 
170 170
 /**
@@ -177,19 +177,19 @@  discard block
 block discarded – undo
177 177
  *    - string|null si $raw = false
178 178
  */
179 179
 function version_vcs_courante($dir, $raw = false) {
180
-	$desc = decrire_version_git($dir);
181
-	if ($desc === null) {
182
-		$desc = decrire_version_svn($dir);
183
-	}
184
-	if ($desc === null or $raw) {
185
-		return $desc;
186
-	}
187
-	// affichage "GIT [master: abcdef]"
188
-	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189
-	if ($desc['branch']) {
190
-		$commit = $desc['branch'] . ': ' . $commit;
191
-	}
192
-	return "{$desc['vcs']} [$commit]";
180
+    $desc = decrire_version_git($dir);
181
+    if ($desc === null) {
182
+        $desc = decrire_version_svn($dir);
183
+    }
184
+    if ($desc === null or $raw) {
185
+        return $desc;
186
+    }
187
+    // affichage "GIT [master: abcdef]"
188
+    $commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189
+    if ($desc['branch']) {
190
+        $commit = $desc['branch'] . ': ' . $commit;
191
+    }
192
+    return "{$desc['vcs']} [$commit]";
193 193
 }
194 194
 
195 195
 /**
@@ -201,24 +201,24 @@  discard block
 block discarded – undo
201 201
  *      array ['branch' => xx, 'commit' => yy] sinon.
202 202
  **/
203 203
 function decrire_version_git($dir) {
204
-	if (!$dir) {
205
-		$dir = '.';
206
-	}
204
+    if (!$dir) {
205
+        $dir = '.';
206
+    }
207 207
 
208
-	// version installee par GIT
209
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
210
-		$currentHead = trim(substr($c, 4));
211
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
212
-			return [
213
-				'vcs' => 'GIT',
214
-				'branch' => basename($currentHead),
215
-				'commit' => trim($hash),
216
-				'commit_short' => substr(trim($hash), 0, 8),
217
-			];
218
-		}
219
-	}
208
+    // version installee par GIT
209
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
210
+        $currentHead = trim(substr($c, 4));
211
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
212
+            return [
213
+                'vcs' => 'GIT',
214
+                'branch' => basename($currentHead),
215
+                'commit' => trim($hash),
216
+                'commit_short' => substr(trim($hash), 0, 8),
217
+            ];
218
+        }
219
+    }
220 220
 
221
-	return null;
221
+    return null;
222 222
 }
223 223
 
224 224
 
@@ -231,25 +231,25 @@  discard block
 block discarded – undo
231 231
  *      array ['commit' => yy, 'date' => xx, 'author' => xx] sinon.
232 232
  **/
233 233
 function decrire_version_svn($dir) {
234
-	if (!$dir) {
235
-		$dir = '.';
236
-	}
237
-	// version installee par SVN
238
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
-		$db = new SQLite3($dir . '/.svn/wc.db');
240
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241
-		if ($result) {
242
-			$row = $result->fetchArray();
243
-			if ($row['changed_revision'] != "") {
244
-				return [
245
-					'vcs' => 'SVN',
246
-					'branch' => '',
247
-					'commit' => $row['changed_revision'],
248
-				];
249
-			}
250
-		}
251
-	}
252
-	return null;
234
+    if (!$dir) {
235
+        $dir = '.';
236
+    }
237
+    // version installee par SVN
238
+    if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
+        $db = new SQLite3($dir . '/.svn/wc.db');
240
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241
+        if ($result) {
242
+            $row = $result->fetchArray();
243
+            if ($row['changed_revision'] != "") {
244
+                return [
245
+                    'vcs' => 'SVN',
246
+                    'branch' => '',
247
+                    'commit' => $row['changed_revision'],
248
+                ];
249
+            }
250
+        }
251
+    }
252
+    return null;
253 253
 }
254 254
 
255 255
 /**
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
  *
268 268
  **/
269 269
 function version_svn_courante($dir) {
270
-	if ($desc = decrire_version_svn($dir)) {
271
-		return -$desc['commit'];
272
-	}
273
-	return 0;
270
+    if ($desc = decrire_version_svn($dir)) {
271
+        return -$desc['commit'];
272
+    }
273
+    return 0;
274 274
 }
275 275
 
276 276
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -314,18 +314,18 @@  discard block
 block discarded – undo
314 314
  *     Code HTML retourné par le filtre
315 315
  **/
316 316
 function filtrer($filtre) {
317
-	$tous = func_get_args();
318
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
319
-		return image_filtrer($tous);
320
-	} elseif ($f = chercher_filtre($filtre)) {
321
-		array_shift($tous);
322
-		return call_user_func_array($f, $tous);
323
-	} else {
324
-		// le filtre n'existe pas, on provoque une erreur
325
-		$msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
326
-		erreur_squelette($msg);
327
-		return '';
328
-	}
317
+    $tous = func_get_args();
318
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
319
+        return image_filtrer($tous);
320
+    } elseif ($f = chercher_filtre($filtre)) {
321
+        array_shift($tous);
322
+        return call_user_func_array($f, $tous);
323
+    } else {
324
+        // le filtre n'existe pas, on provoque une erreur
325
+        $msg = array('zbug_erreur_filtre', array('filtre' => texte_script($filtre)));
326
+        erreur_squelette($msg);
327
+        return '';
328
+    }
329 329
 }
330 330
 
331 331
 /**
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
343 343
  */
344 344
 function trouver_filtre_matrice($filtre) {
345
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
346
-		find_in_path($f, '', true);
347
-		$GLOBALS['spip_matrice'][$filtre] = true;
348
-	}
349
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
345
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
346
+        find_in_path($f, '', true);
347
+        $GLOBALS['spip_matrice'][$filtre] = true;
348
+    }
349
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
350 350
 }
351 351
 
352 352
 
@@ -374,8 +374,8 @@  discard block
 block discarded – undo
374 374
  * @return mixed
375 375
  */
376 376
 function filtre_set(&$Pile, $val, $key, $continue = null) {
377
-	$Pile['vars'][$key] = $val;
378
-	return $continue ? $val : '';
377
+    $Pile['vars'][$key] = $val;
378
+    return $continue ? $val : '';
379 379
 }
380 380
 
381 381
 /**
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
402 402
  */
403 403
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
404
-	$Pile[0][$key] = $val;
405
-	return $continue ? $val : '';
404
+    $Pile[0][$key] = $val;
405
+    return $continue ? $val : '';
406 406
 }
407 407
 
408 408
 /**
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
  * @return string
412 412
  */
413 413
 function filtre_sanitize_env(&$Pile, $keys) {
414
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
415
-	return '';
414
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
415
+    return '';
416 416
 }
417 417
 
418 418
 
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
  * @return mixed Retourne la valeur (sans la modifier).
436 436
  */
437 437
 function filtre_debug($val, $key = null) {
438
-	$debug = (
439
-		is_null($key) ? '' : (var_export($key, true) . " = ")
440
-		) . var_export($val, true);
438
+    $debug = (
439
+        is_null($key) ? '' : (var_export($key, true) . " = ")
440
+        ) . var_export($val, true);
441 441
 
442
-	include_spip('inc/autoriser');
443
-	if (autoriser('webmestre')) {
444
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
445
-	}
442
+    include_spip('inc/autoriser');
443
+    if (autoriser('webmestre')) {
444
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
445
+    }
446 446
 
447
-	spip_log($debug, 'debug');
447
+    spip_log($debug, 'debug');
448 448
 
449
-	return $val;
449
+    return $val;
450 450
 }
451 451
 
452 452
 
@@ -474,71 +474,71 @@  discard block
 block discarded – undo
474 474
  *     Texte qui a reçu les filtres
475 475
  **/
476 476
 function image_filtrer($args) {
477
-	$filtre = array_shift($args); # enlever $filtre
478
-	$texte = array_shift($args);
479
-	if (!strlen($texte)) {
480
-		return;
481
-	}
482
-	find_in_path('filtres_images_mini.php', 'inc/', true);
483
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
484
-	// Cas du nom de fichier local
485
-	if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
486
-		and !preg_match(',^/|[<>]|\s,S', $texte)
487
-		and (
488
-			file_exists(preg_replace(',[?].*$,', '', $texte))
489
-			or tester_url_absolue($texte)
490
-		)
491
-	) {
492
-		array_unshift($args, "<img src='$texte' />");
493
-		$res = call_user_func_array($filtre, $args);
494
-		statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
495
-		return $res;
496
-	}
497
-
498
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
499
-	if (preg_match_all(
500
-		',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
501
-		$texte, $tags, PREG_SET_ORDER)) {
502
-		foreach ($tags as $tag) {
503
-			$class = extraire_attribut($tag[3], 'class');
504
-			if (!$class or
505
-				(strpos($class, 'filtre_inactif') === false
506
-					// compat historique a virer en 3.2
507
-					and strpos($class, 'no_image_filtrer') === false)
508
-			) {
509
-				array_unshift($args, $tag[3]);
510
-				if ($reduit = call_user_func_array($filtre, $args)) {
511
-					// En cas de span spip_documents, modifier le style=...width:
512
-					if ($tag[1]) {
513
-						$w = extraire_attribut($reduit, 'width');
514
-						if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
515
-							$w = $regs[1];
516
-						}
517
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
518
-							$style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
519
-							$replace = inserer_attribut($tag[1], 'style', $style);
520
-							$texte = str_replace($tag[1], $replace, $texte);
521
-						}
522
-					}
523
-					// traiter aussi un eventuel mouseover
524
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
525
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
526
-							$srcover = $match[1];
527
-							array_shift($args);
528
-							array_unshift($args, "<img src='" . $match[1] . "' />");
529
-							$srcover_filter = call_user_func_array($filtre, $args);
530
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
531
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
532
-						}
533
-					}
534
-					$texte = str_replace($tag[3], $reduit, $texte);
535
-				}
536
-				array_shift($args);
537
-			}
538
-		}
539
-	}
540
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
541
-	return $texte;
477
+    $filtre = array_shift($args); # enlever $filtre
478
+    $texte = array_shift($args);
479
+    if (!strlen($texte)) {
480
+        return;
481
+    }
482
+    find_in_path('filtres_images_mini.php', 'inc/', true);
483
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
484
+    // Cas du nom de fichier local
485
+    if (strpos(substr($texte, strlen(_DIR_RACINE)), '..') === false
486
+        and !preg_match(',^/|[<>]|\s,S', $texte)
487
+        and (
488
+            file_exists(preg_replace(',[?].*$,', '', $texte))
489
+            or tester_url_absolue($texte)
490
+        )
491
+    ) {
492
+        array_unshift($args, "<img src='$texte' />");
493
+        $res = call_user_func_array($filtre, $args);
494
+        statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
495
+        return $res;
496
+    }
497
+
498
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
499
+    if (preg_match_all(
500
+        ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
501
+        $texte, $tags, PREG_SET_ORDER)) {
502
+        foreach ($tags as $tag) {
503
+            $class = extraire_attribut($tag[3], 'class');
504
+            if (!$class or
505
+                (strpos($class, 'filtre_inactif') === false
506
+                    // compat historique a virer en 3.2
507
+                    and strpos($class, 'no_image_filtrer') === false)
508
+            ) {
509
+                array_unshift($args, $tag[3]);
510
+                if ($reduit = call_user_func_array($filtre, $args)) {
511
+                    // En cas de span spip_documents, modifier le style=...width:
512
+                    if ($tag[1]) {
513
+                        $w = extraire_attribut($reduit, 'width');
514
+                        if (!$w and preg_match(",width:\s*(\d+)px,S", extraire_attribut($reduit, 'style'), $regs)) {
515
+                            $w = $regs[1];
516
+                        }
517
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
518
+                            $style = preg_replace(",width:\s*\d+px,S", "width:${w}px", $style);
519
+                            $replace = inserer_attribut($tag[1], 'style', $style);
520
+                            $texte = str_replace($tag[1], $replace, $texte);
521
+                        }
522
+                    }
523
+                    // traiter aussi un eventuel mouseover
524
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
525
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
526
+                            $srcover = $match[1];
527
+                            array_shift($args);
528
+                            array_unshift($args, "<img src='" . $match[1] . "' />");
529
+                            $srcover_filter = call_user_func_array($filtre, $args);
530
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
531
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
532
+                        }
533
+                    }
534
+                    $texte = str_replace($tag[3], $reduit, $texte);
535
+                }
536
+                array_shift($args);
537
+            }
538
+        }
539
+    }
540
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
541
+    return $texte;
542 542
 }
543 543
 
544 544
 /**
@@ -553,65 +553,65 @@  discard block
 block discarded – undo
553 553
  **/
554 554
 function taille_image($img, $force_refresh = false) {
555 555
 
556
-	static $largeur_img = array(), $hauteur_img = array();
557
-	$srcWidth = 0;
558
-	$srcHeight = 0;
559
-
560
-	$src = extraire_attribut($img, 'src');
561
-
562
-	if (!$src) {
563
-		$src = $img;
564
-	} else {
565
-		$srcWidth = extraire_attribut($img, 'width');
566
-		$srcHeight = extraire_attribut($img, 'height');
567
-	}
568
-
569
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
570
-	// la copie locale a toutes les chances d'etre la ou de resservir
571
-	if (tester_url_absolue($src)) {
572
-		include_spip('inc/distant');
573
-		$fichier = copie_locale($src);
574
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
575
-	}
576
-	if (($p = strpos($src, '?')) !== false) {
577
-		$src = substr($src, 0, $p);
578
-	}
579
-
580
-	$srcsize = false;
581
-	if (isset($largeur_img[$src]) and !$force_refresh) {
582
-		$srcWidth = $largeur_img[$src];
583
-	}
584
-	if (isset($hauteur_img[$src]) and !$force_refresh) {
585
-		$srcHeight = $hauteur_img[$src];
586
-	}
587
-	if (!$srcWidth or !$srcHeight) {
588
-
589
-		if (file_exists($src)
590
-			and $srcsize = spip_getimagesize($src)
591
-		) {
592
-			if (!$srcWidth) {
593
-				$largeur_img[$src] = $srcWidth = $srcsize[0];
594
-			}
595
-			if (!$srcHeight) {
596
-				$hauteur_img[$src] = $srcHeight = $srcsize[1];
597
-			}
598
-		}
599
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
600
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
601
-		elseif (@file_exists($f = "$src.src")
602
-			and lire_fichier($f, $valeurs)
603
-			and $valeurs = unserialize($valeurs)
604
-		) {
605
-			if (!$srcWidth) {
606
-				$largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
607
-			}
608
-			if (!$srcHeight) {
609
-				$hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
610
-			}
611
-		}
612
-	}
613
-
614
-	return array($srcHeight, $srcWidth);
556
+    static $largeur_img = array(), $hauteur_img = array();
557
+    $srcWidth = 0;
558
+    $srcHeight = 0;
559
+
560
+    $src = extraire_attribut($img, 'src');
561
+
562
+    if (!$src) {
563
+        $src = $img;
564
+    } else {
565
+        $srcWidth = extraire_attribut($img, 'width');
566
+        $srcHeight = extraire_attribut($img, 'height');
567
+    }
568
+
569
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
570
+    // la copie locale a toutes les chances d'etre la ou de resservir
571
+    if (tester_url_absolue($src)) {
572
+        include_spip('inc/distant');
573
+        $fichier = copie_locale($src);
574
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
575
+    }
576
+    if (($p = strpos($src, '?')) !== false) {
577
+        $src = substr($src, 0, $p);
578
+    }
579
+
580
+    $srcsize = false;
581
+    if (isset($largeur_img[$src]) and !$force_refresh) {
582
+        $srcWidth = $largeur_img[$src];
583
+    }
584
+    if (isset($hauteur_img[$src]) and !$force_refresh) {
585
+        $srcHeight = $hauteur_img[$src];
586
+    }
587
+    if (!$srcWidth or !$srcHeight) {
588
+
589
+        if (file_exists($src)
590
+            and $srcsize = spip_getimagesize($src)
591
+        ) {
592
+            if (!$srcWidth) {
593
+                $largeur_img[$src] = $srcWidth = $srcsize[0];
594
+            }
595
+            if (!$srcHeight) {
596
+                $hauteur_img[$src] = $srcHeight = $srcsize[1];
597
+            }
598
+        }
599
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
600
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
601
+        elseif (@file_exists($f = "$src.src")
602
+            and lire_fichier($f, $valeurs)
603
+            and $valeurs = unserialize($valeurs)
604
+        ) {
605
+            if (!$srcWidth) {
606
+                $largeur_img[$src] = $srcWidth = $valeurs["largeur_dest"];
607
+            }
608
+            if (!$srcHeight) {
609
+                $hauteur_img[$src] = $srcHeight = $valeurs["hauteur_dest"];
610
+            }
611
+        }
612
+    }
613
+
614
+    return array($srcHeight, $srcWidth);
615 615
 }
616 616
 
617 617
 
@@ -629,12 +629,12 @@  discard block
 block discarded – undo
629 629
  *     Largeur en pixels, NULL ou 0 si aucune image.
630 630
  **/
631 631
 function largeur($img) {
632
-	if (!$img) {
633
-		return;
634
-	}
635
-	list($h, $l) = taille_image($img);
632
+    if (!$img) {
633
+        return;
634
+    }
635
+    list($h, $l) = taille_image($img);
636 636
 
637
-	return $l;
637
+    return $l;
638 638
 }
639 639
 
640 640
 /**
@@ -651,12 +651,12 @@  discard block
 block discarded – undo
651 651
  *     Hauteur en pixels, NULL ou 0 si aucune image.
652 652
  **/
653 653
 function hauteur($img) {
654
-	if (!$img) {
655
-		return;
656
-	}
657
-	list($h, $l) = taille_image($img);
654
+    if (!$img) {
655
+        return;
656
+    }
657
+    list($h, $l) = taille_image($img);
658 658
 
659
-	return $h;
659
+    return $h;
660 660
 }
661 661
 
662 662
 
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
  * @return string
677 677
  **/
678 678
 function corriger_entites_html($texte) {
679
-	if (strpos($texte, '&amp;') === false) {
680
-		return $texte;
681
-	}
679
+    if (strpos($texte, '&amp;') === false) {
680
+        return $texte;
681
+    }
682 682
 
683
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
683
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
684 684
 }
685 685
 
686 686
 /**
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
  * @return string
696 696
  **/
697 697
 function corriger_toutes_entites_html($texte) {
698
-	if (strpos($texte, '&amp;') === false) {
699
-		return $texte;
700
-	}
698
+    if (strpos($texte, '&amp;') === false) {
699
+        return $texte;
700
+    }
701 701
 
702
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
702
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
703 703
 }
704 704
 
705 705
 /**
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
  * @return string
710 710
  **/
711 711
 function proteger_amp($texte) {
712
-	return str_replace('&', '&amp;', $texte);
712
+    return str_replace('&', '&amp;', $texte);
713 713
 }
714 714
 
715 715
 
@@ -740,20 +740,20 @@  discard block
 block discarded – undo
740 740
  * @return mixed|string
741 741
  */
742 742
 function entites_html($texte, $tout = false, $quote = true) {
743
-	if (!is_string($texte) or !$texte
744
-		or strpbrk($texte, "&\"'<>") == false
745
-	) {
746
-		return $texte;
747
-	}
748
-	include_spip('inc/texte');
749
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
750
-	$flags |= ENT_HTML401;
751
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
752
-	if ($tout) {
753
-		return corriger_toutes_entites_html($texte);
754
-	} else {
755
-		return corriger_entites_html($texte);
756
-	}
743
+    if (!is_string($texte) or !$texte
744
+        or strpbrk($texte, "&\"'<>") == false
745
+    ) {
746
+        return $texte;
747
+    }
748
+    include_spip('inc/texte');
749
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
750
+    $flags |= ENT_HTML401;
751
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
752
+    if ($tout) {
753
+        return corriger_toutes_entites_html($texte);
754
+    } else {
755
+        return corriger_entites_html($texte);
756
+    }
757 757
 }
758 758
 
759 759
 /**
@@ -772,37 +772,37 @@  discard block
 block discarded – undo
772 772
  *     Texte converti
773 773
  **/
774 774
 function filtrer_entites($texte) {
775
-	if (strpos($texte, '&') === false) {
776
-		return $texte;
777
-	}
778
-	// filtrer
779
-	$texte = html2unicode($texte);
780
-	// remettre le tout dans le charset cible
781
-	$texte = unicode2charset($texte);
782
-	// cas particulier des " et ' qu'il faut filtrer aussi
783
-	// (on le faisait deja avec un &quot;)
784
-	if (strpos($texte, "&#") !== false) {
785
-		$texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
786
-	}
775
+    if (strpos($texte, '&') === false) {
776
+        return $texte;
777
+    }
778
+    // filtrer
779
+    $texte = html2unicode($texte);
780
+    // remettre le tout dans le charset cible
781
+    $texte = unicode2charset($texte);
782
+    // cas particulier des " et ' qu'il faut filtrer aussi
783
+    // (on le faisait deja avec un &quot;)
784
+    if (strpos($texte, "&#") !== false) {
785
+        $texte = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $texte);
786
+    }
787 787
 
788
-	return $texte;
788
+    return $texte;
789 789
 }
790 790
 
791 791
 
792 792
 if (!function_exists('filtre_filtrer_entites_dist')) {
793
-	/**
794
-	 * Version sécurisée de filtrer_entites
795
-	 * 
796
-	 * @uses interdire_scripts()
797
-	 * @uses filtrer_entites()
798
-	 * 
799
-	 * @param string $t
800
-	 * @return string
801
-	 */
802
-	function filtre_filtrer_entites_dist($t) {
803
-		include_spip('inc/texte');
804
-		return interdire_scripts(filtrer_entites($t));
805
-	}
793
+    /**
794
+     * Version sécurisée de filtrer_entites
795
+     * 
796
+     * @uses interdire_scripts()
797
+     * @uses filtrer_entites()
798
+     * 
799
+     * @param string $t
800
+     * @return string
801
+     */
802
+    function filtre_filtrer_entites_dist($t) {
803
+        include_spip('inc/texte');
804
+        return interdire_scripts(filtrer_entites($t));
805
+    }
806 806
 }
807 807
 
808 808
 
@@ -817,18 +817,18 @@  discard block
 block discarded – undo
817 817
  * @return string|array
818 818
  **/
819 819
 function supprimer_caracteres_illegaux($texte) {
820
-	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";
821
-	static $to = null;
820
+    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";
821
+    static $to = null;
822 822
 
823
-	if (is_array($texte)) {
824
-		return array_map('supprimer_caracteres_illegaux', $texte);
825
-	}
823
+    if (is_array($texte)) {
824
+        return array_map('supprimer_caracteres_illegaux', $texte);
825
+    }
826 826
 
827
-	if (!$to) {
828
-		$to = str_repeat('-', strlen($from));
829
-	}
827
+    if (!$to) {
828
+        $to = str_repeat('-', strlen($from));
829
+    }
830 830
 
831
-	return strtr($texte, $from, $to);
831
+    return strtr($texte, $from, $to);
832 832
 }
833 833
 
834 834
 /**
@@ -840,10 +840,10 @@  discard block
 block discarded – undo
840 840
  * @return string|array
841 841
  **/
842 842
 function corriger_caracteres($texte) {
843
-	$texte = corriger_caracteres_windows($texte);
844
-	$texte = supprimer_caracteres_illegaux($texte);
843
+    $texte = corriger_caracteres_windows($texte);
844
+    $texte = supprimer_caracteres_illegaux($texte);
845 845
 
846
-	return $texte;
846
+    return $texte;
847 847
 }
848 848
 
849 849
 /**
@@ -861,40 +861,40 @@  discard block
 block discarded – undo
861 861
  */
862 862
 function texte_backend($texte) {
863 863
 
864
-	static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
864
+    static $apostrophe = array("&#8217;", "'"); # n'allouer qu'une fois
865 865
 
866
-	// si on a des liens ou des images, les passer en absolu
867
-	$texte = liens_absolus($texte);
866
+    // si on a des liens ou des images, les passer en absolu
867
+    $texte = liens_absolus($texte);
868 868
 
869
-	// echapper les tags &gt; &lt;
870
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
869
+    // echapper les tags &gt; &lt;
870
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
871 871
 
872
-	// importer les &eacute;
873
-	$texte = filtrer_entites($texte);
872
+    // importer les &eacute;
873
+    $texte = filtrer_entites($texte);
874 874
 
875
-	// " -> &quot; et tout ce genre de choses
876
-	$u = $GLOBALS['meta']['pcre_u'];
877
-	$texte = str_replace("&nbsp;", " ", $texte);
878
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
879
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
880
-	$texte = entites_html($texte, false, false);
881
-	// mais bien echapper les double quotes !
882
-	$texte = str_replace('"', '&#034;', $texte);
875
+    // " -> &quot; et tout ce genre de choses
876
+    $u = $GLOBALS['meta']['pcre_u'];
877
+    $texte = str_replace("&nbsp;", " ", $texte);
878
+    $texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
879
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
880
+    $texte = entites_html($texte, false, false);
881
+    // mais bien echapper les double quotes !
882
+    $texte = str_replace('"', '&#034;', $texte);
883 883
 
884
-	// verifier le charset
885
-	$texte = charset2unicode($texte);
884
+    // verifier le charset
885
+    $texte = charset2unicode($texte);
886 886
 
887
-	// Caracteres problematiques en iso-latin 1
888
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
889
-		$texte = str_replace(chr(156), '&#156;', $texte);
890
-		$texte = str_replace(chr(140), '&#140;', $texte);
891
-		$texte = str_replace(chr(159), '&#159;', $texte);
892
-	}
887
+    // Caracteres problematiques en iso-latin 1
888
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
889
+        $texte = str_replace(chr(156), '&#156;', $texte);
890
+        $texte = str_replace(chr(140), '&#140;', $texte);
891
+        $texte = str_replace(chr(159), '&#159;', $texte);
892
+    }
893 893
 
894
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
895
-	// et le caractere apostrophe alourdit les squelettes avec PHP
896
-	// ==> on les remplace par l'entite HTML
897
-	return str_replace($apostrophe, "'", $texte);
894
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
895
+    // et le caractere apostrophe alourdit les squelettes avec PHP
896
+    // ==> on les remplace par l'entite HTML
897
+    return str_replace($apostrophe, "'", $texte);
898 898
 }
899 899
 
900 900
 /**
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
  *     Texte encodé et quote pour XML
912 912
  */
913 913
 function texte_backendq($texte) {
914
-	return addslashes(texte_backend($texte));
914
+    return addslashes(texte_backend($texte));
915 915
 }
916 916
 
917 917
 
@@ -934,9 +934,9 @@  discard block
 block discarded – undo
934 934
  *     Numéro de titre, sinon chaîne vide
935 935
  **/
936 936
 function supprimer_numero($texte) {
937
-	return preg_replace(
938
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
939
-		"", $texte);
937
+    return preg_replace(
938
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
939
+        "", $texte);
940 940
 }
941 941
 
942 942
 /**
@@ -959,13 +959,13 @@  discard block
 block discarded – undo
959 959
  *     Numéro de titre, sinon chaîne vide
960 960
  **/
961 961
 function recuperer_numero($texte) {
962
-	if (preg_match(
963
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
964
-		$texte, $regs)) {
965
-		return strval($regs[1]);
966
-	} else {
967
-		return '';
968
-	}
962
+    if (preg_match(
963
+        ",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
964
+        $texte, $regs)) {
965
+        return strval($regs[1]);
966
+    } else {
967
+        return '';
968
+    }
969 969
 }
970 970
 
971 971
 /**
@@ -992,13 +992,13 @@  discard block
 block discarded – undo
992 992
  *     Texte converti
993 993
  **/
994 994
 function supprimer_tags($texte, $rempl = "") {
995
-	$texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
996
-	// ne pas oublier un < final non ferme car coupe
997
-	$texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
998
-	// mais qui peut aussi etre un simple signe plus petit que
999
-	$texte = str_replace('<', '&lt;', $texte);
995
+    $texte = preg_replace(",<(!--|\w|/|!\[endif|!\[if)[^>]*>,US", $rempl, $texte);
996
+    // ne pas oublier un < final non ferme car coupe
997
+    $texte = preg_replace(",<(!--|\w|/).*$,US", $rempl, $texte);
998
+    // mais qui peut aussi etre un simple signe plus petit que
999
+    $texte = str_replace('<', '&lt;', $texte);
1000 1000
 
1001
-	return $texte;
1001
+    return $texte;
1002 1002
 }
1003 1003
 
1004 1004
 /**
@@ -1021,9 +1021,9 @@  discard block
 block discarded – undo
1021 1021
  *     Texte converti
1022 1022
  **/
1023 1023
 function echapper_tags($texte, $rempl = "") {
1024
-	$texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1024
+    $texte = preg_replace("/<([^>]*)>/", "&lt;\\1&gt;", $texte);
1025 1025
 
1026
-	return $texte;
1026
+    return $texte;
1027 1027
 }
1028 1028
 
1029 1029
 /**
@@ -1044,18 +1044,18 @@  discard block
 block discarded – undo
1044 1044
  *     Texte converti
1045 1045
  **/
1046 1046
 function textebrut($texte) {
1047
-	$u = $GLOBALS['meta']['pcre_u'];
1048
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1049
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1050
-	$texte = preg_replace("/^\n+/", "", $texte);
1051
-	$texte = preg_replace("/\n+$/", "", $texte);
1052
-	$texte = preg_replace("/\n +/", "\n", $texte);
1053
-	$texte = supprimer_tags($texte);
1054
-	$texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1055
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1056
-	$texte = str_replace("&#8217;", "'", $texte);
1047
+    $u = $GLOBALS['meta']['pcre_u'];
1048
+    $texte = preg_replace('/\s+/S' . $u, " ", $texte);
1049
+    $texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1050
+    $texte = preg_replace("/^\n+/", "", $texte);
1051
+    $texte = preg_replace("/\n+$/", "", $texte);
1052
+    $texte = preg_replace("/\n +/", "\n", $texte);
1053
+    $texte = supprimer_tags($texte);
1054
+    $texte = preg_replace("/(&nbsp;| )+/S", " ", $texte);
1055
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1056
+    $texte = str_replace("&#8217;", "'", $texte);
1057 1057
 
1058
-	return $texte;
1058
+    return $texte;
1059 1059
 }
1060 1060
 
1061 1061
 
@@ -1071,17 +1071,17 @@  discard block
 block discarded – undo
1071 1071
  *     Texte avec liens ouvrants
1072 1072
  **/
1073 1073
 function liens_ouvrants($texte) {
1074
-	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1075
-		$texte, $liens, PREG_PATTERN_ORDER)) {
1076
-		foreach ($liens[0] as $a) {
1077
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1078
-			$ablank = inserer_attribut($a, 'rel', $rel);
1079
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1080
-			$texte = str_replace($a, $ablank, $texte);
1081
-		}
1082
-	}
1074
+    if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1075
+        $texte, $liens, PREG_PATTERN_ORDER)) {
1076
+        foreach ($liens[0] as $a) {
1077
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1078
+            $ablank = inserer_attribut($a, 'rel', $rel);
1079
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1080
+            $texte = str_replace($a, $ablank, $texte);
1081
+        }
1082
+    }
1083 1083
 
1084
-	return $texte;
1084
+    return $texte;
1085 1085
 }
1086 1086
 
1087 1087
 /**
@@ -1091,22 +1091,22 @@  discard block
 block discarded – undo
1091 1091
  * @return string
1092 1092
  */
1093 1093
 function liens_nofollow($texte) {
1094
-	if (stripos($texte, "<a") === false) {
1095
-		return $texte;
1096
-	}
1094
+    if (stripos($texte, "<a") === false) {
1095
+        return $texte;
1096
+    }
1097 1097
 
1098
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1099
-		foreach ($regs[0] as $a) {
1100
-			$rel = extraire_attribut($a, "rel");
1101
-			if (strpos($rel, "nofollow") === false) {
1102
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1103
-				$anofollow = inserer_attribut($a, "rel", $rel);
1104
-				$texte = str_replace($a, $anofollow, $texte);
1105
-			}
1106
-		}
1107
-	}
1098
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1099
+        foreach ($regs[0] as $a) {
1100
+            $rel = extraire_attribut($a, "rel");
1101
+            if (strpos($rel, "nofollow") === false) {
1102
+                $rel = "nofollow" . ($rel ? " $rel" : "");
1103
+                $anofollow = inserer_attribut($a, "rel", $rel);
1104
+                $texte = str_replace($a, $anofollow, $texte);
1105
+            }
1106
+        }
1107
+    }
1108 1108
 
1109
-	return $texte;
1109
+    return $texte;
1110 1110
 }
1111 1111
 
1112 1112
 /**
@@ -1125,12 +1125,12 @@  discard block
 block discarded – undo
1125 1125
  *     Texte sans paraghaphes
1126 1126
  **/
1127 1127
 function PtoBR($texte) {
1128
-	$u = $GLOBALS['meta']['pcre_u'];
1129
-	$texte = preg_replace("@</p>@iS", "\n", $texte);
1130
-	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1131
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1128
+    $u = $GLOBALS['meta']['pcre_u'];
1129
+    $texte = preg_replace("@</p>@iS", "\n", $texte);
1130
+    $texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1131
+    $texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1132 1132
 
1133
-	return $texte;
1133
+    return $texte;
1134 1134
 }
1135 1135
 
1136 1136
 
@@ -1154,14 +1154,14 @@  discard block
 block discarded – undo
1154 1154
  * @return string Texte encadré du style CSS
1155 1155
  */
1156 1156
 function lignes_longues($texte) {
1157
-	if (!strlen(trim($texte))) {
1158
-		return $texte;
1159
-	}
1160
-	include_spip('inc/texte');
1161
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1162
-		'div' : 'span';
1157
+    if (!strlen(trim($texte))) {
1158
+        return $texte;
1159
+    }
1160
+    include_spip('inc/texte');
1161
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1162
+        'div' : 'span';
1163 1163
 
1164
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1164
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1165 1165
 }
1166 1166
 
1167 1167
 /**
@@ -1180,30 +1180,30 @@  discard block
 block discarded – undo
1180 1180
  * @return string Texte en majuscule
1181 1181
  */
1182 1182
 function majuscules($texte) {
1183
-	if (!strlen($texte)) {
1184
-		return '';
1185
-	}
1183
+    if (!strlen($texte)) {
1184
+        return '';
1185
+    }
1186 1186
 
1187
-	// Cas du turc
1188
-	if ($GLOBALS['spip_lang'] == 'tr') {
1189
-		# remplacer hors des tags et des entites
1190
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1191
-			foreach ($regs as $n => $match) {
1192
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1193
-			}
1194
-		}
1187
+    // Cas du turc
1188
+    if ($GLOBALS['spip_lang'] == 'tr') {
1189
+        # remplacer hors des tags et des entites
1190
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1191
+            foreach ($regs as $n => $match) {
1192
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1193
+            }
1194
+        }
1195 1195
 
1196
-		$texte = str_replace('i', '&#304;', $texte);
1196
+        $texte = str_replace('i', '&#304;', $texte);
1197 1197
 
1198
-		if ($regs) {
1199
-			foreach ($regs as $n => $match) {
1200
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1201
-			}
1202
-		}
1203
-	}
1198
+        if ($regs) {
1199
+            foreach ($regs as $n => $match) {
1200
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1201
+            }
1202
+        }
1203
+    }
1204 1204
 
1205
-	// Cas general
1206
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1205
+    // Cas general
1206
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1207 1207
 }
1208 1208
 
1209 1209
 /**
@@ -1221,29 +1221,29 @@  discard block
 block discarded – undo
1221 1221
  * @return string
1222 1222
  **/
1223 1223
 function taille_en_octets($taille) {
1224
-	if (!defined('_KILOBYTE')) {
1225
-		/**
1226
-		 * Définit le nombre d'octets dans un Kilobyte
1227
-		 *
1228
-		 * @var int
1229
-		 **/
1230
-		define('_KILOBYTE', 1024);
1231
-	}
1224
+    if (!defined('_KILOBYTE')) {
1225
+        /**
1226
+         * Définit le nombre d'octets dans un Kilobyte
1227
+         *
1228
+         * @var int
1229
+         **/
1230
+        define('_KILOBYTE', 1024);
1231
+    }
1232 1232
 
1233
-	if ($taille < 1) {
1234
-		return '';
1235
-	}
1236
-	if ($taille < _KILOBYTE) {
1237
-		$taille = _T('taille_octets', array('taille' => $taille));
1238
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1239
-		$taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1240
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1241
-		$taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1242
-	} else {
1243
-		$taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1244
-	}
1233
+    if ($taille < 1) {
1234
+        return '';
1235
+    }
1236
+    if ($taille < _KILOBYTE) {
1237
+        $taille = _T('taille_octets', array('taille' => $taille));
1238
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1239
+        $taille = _T('taille_ko', array('taille' => round($taille / _KILOBYTE, 1)));
1240
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1241
+        $taille = _T('taille_mo', array('taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)));
1242
+    } else {
1243
+        $taille = _T('taille_go', array('taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)));
1244
+    }
1245 1245
 
1246
-	return $taille;
1246
+    return $taille;
1247 1247
 }
1248 1248
 
1249 1249
 
@@ -1265,15 +1265,15 @@  discard block
 block discarded – undo
1265 1265
  *     Texte prêt pour être utilisé en attribut HTML
1266 1266
  **/
1267 1267
 function attribut_html($texte, $textebrut = true) {
1268
-	$u = $GLOBALS['meta']['pcre_u'];
1269
-	if ($textebrut) {
1270
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1271
-	}
1272
-	$texte = texte_backend($texte);
1273
-	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1268
+    $u = $GLOBALS['meta']['pcre_u'];
1269
+    if ($textebrut) {
1270
+        $texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1271
+    }
1272
+    $texte = texte_backend($texte);
1273
+    $texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
1274 1274
 
1275
-	return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1276
-		$texte);
1275
+    return preg_replace(array("/&(amp;|#38;)/", "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/"), array("&", "&#38;"),
1276
+        $texte);
1277 1277
 }
1278 1278
 
1279 1279
 
@@ -1293,12 +1293,12 @@  discard block
 block discarded – undo
1293 1293
  *     URL ou chaîne vide
1294 1294
  **/
1295 1295
 function vider_url($url, $entites = true) {
1296
-	# un message pour abs_url
1297
-	$GLOBALS['mode_abs_url'] = 'url';
1298
-	$url = trim($url);
1299
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1296
+    # un message pour abs_url
1297
+    $GLOBALS['mode_abs_url'] = 'url';
1298
+    $url = trim($url);
1299
+    $r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1300 1300
 
1301
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1301
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1302 1302
 }
1303 1303
 
1304 1304
 
@@ -1313,10 +1313,10 @@  discard block
 block discarded – undo
1313 1313
  * @return string Adresse email maquillée
1314 1314
  **/
1315 1315
 function antispam($texte) {
1316
-	include_spip('inc/acces');
1317
-	$masque = creer_pass_aleatoire(3);
1316
+    include_spip('inc/acces');
1317
+    $masque = creer_pass_aleatoire(3);
1318 1318
 
1319
-	return preg_replace("/@/", " $masque ", $texte);
1319
+    return preg_replace("/@/", " $masque ", $texte);
1320 1320
 }
1321 1321
 
1322 1322
 /**
@@ -1348,12 +1348,12 @@  discard block
 block discarded – undo
1348 1348
  *     True si on a le droit d'accès, false sinon.
1349 1349
  **/
1350 1350
 function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') {
1351
-	include_spip('inc/acces');
1352
-	if ($op) {
1353
-		$dir .= " $op $args";
1354
-	}
1351
+    include_spip('inc/acces');
1352
+    if ($op) {
1353
+        $dir .= " $op $args";
1354
+    }
1355 1355
 
1356
-	return verifier_low_sec($id_auteur, $cle, $dir);
1356
+    return verifier_low_sec($id_auteur, $cle, $dir);
1357 1357
 }
1358 1358
 
1359 1359
 /**
@@ -1378,11 +1378,11 @@  discard block
 block discarded – undo
1378 1378
  *     Retourne $texte, sinon $sinon.
1379 1379
  **/
1380 1380
 function sinon($texte, $sinon = '') {
1381
-	if ($texte or (!is_array($texte) and strlen($texte))) {
1382
-		return $texte;
1383
-	} else {
1384
-		return $sinon;
1385
-	}
1381
+    if ($texte or (!is_array($texte) and strlen($texte))) {
1382
+        return $texte;
1383
+    } else {
1384
+        return $sinon;
1385
+    }
1386 1386
 }
1387 1387
 
1388 1388
 /**
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
  * @return mixed
1407 1407
  **/
1408 1408
 function choixsivide($a, $vide, $pasvide) {
1409
-	return $a ? $pasvide : $vide;
1409
+    return $a ? $pasvide : $vide;
1410 1410
 }
1411 1411
 
1412 1412
 /**
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
  * @return mixed
1431 1431
  **/
1432 1432
 function choixsiegal($a1, $a2, $v, $f) {
1433
-	return ($a1 == $a2) ? $v : $f;
1433
+    return ($a1 == $a2) ? $v : $f;
1434 1434
 }
1435 1435
 
1436 1436
 //
@@ -1449,13 +1449,13 @@  discard block
 block discarded – undo
1449 1449
  * @return string
1450 1450
  **/
1451 1451
 function filtrer_ical($texte) {
1452
-	#include_spip('inc/charsets');
1453
-	$texte = html2unicode($texte);
1454
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1455
-	$texte = preg_replace("/\n/", " ", $texte);
1456
-	$texte = preg_replace("/,/", "\,", $texte);
1452
+    #include_spip('inc/charsets');
1453
+    $texte = html2unicode($texte);
1454
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset'], 1), 'utf-8');
1455
+    $texte = preg_replace("/\n/", " ", $texte);
1456
+    $texte = preg_replace("/,/", "\,", $texte);
1457 1457
 
1458
-	return $texte;
1458
+    return $texte;
1459 1459
 }
1460 1460
 
1461 1461
 
@@ -1480,53 +1480,53 @@  discard block
 block discarded – undo
1480 1480
  * @return string
1481 1481
  **/
1482 1482
 function post_autobr($texte, $delim = "\n_ ") {
1483
-	if (!function_exists('echappe_html')) {
1484
-		include_spip('inc/texte_mini');
1485
-	}
1486
-	$texte = str_replace("\r\n", "\r", $texte);
1487
-	$texte = str_replace("\r", "\n", $texte);
1488
-
1489
-	if (preg_match(",\n+$,", $texte, $fin)) {
1490
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1491
-	} else {
1492
-		$fin = '';
1493
-	}
1494
-
1495
-	$texte = echappe_html($texte, '', true);
1496
-
1497
-	// echapper les modeles
1498
-	if (strpos($texte, "<") !== false) {
1499
-		include_spip('inc/lien');
1500
-		if (defined('_PREG_MODELE')) {
1501
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1502
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1503
-		}
1504
-	}
1505
-
1506
-	$debut = '';
1507
-	$suite = $texte;
1508
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1509
-		$debut .= substr($suite, 0, $t - 1);
1510
-		$suite = substr($suite, $t);
1511
-		$car = substr($suite, 0, 1);
1512
-		if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1513
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1514
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1515
-		) {
1516
-			$debut .= $delim;
1517
-		} else {
1518
-			$debut .= "\n";
1519
-		}
1520
-		if (preg_match(",^\n+,", $suite, $regs)) {
1521
-			$debut .= $regs[0];
1522
-			$suite = substr($suite, strlen($regs[0]));
1523
-		}
1524
-	}
1525
-	$texte = $debut . $suite;
1526
-
1527
-	$texte = echappe_retour($texte);
1528
-
1529
-	return $texte . $fin;
1483
+    if (!function_exists('echappe_html')) {
1484
+        include_spip('inc/texte_mini');
1485
+    }
1486
+    $texte = str_replace("\r\n", "\r", $texte);
1487
+    $texte = str_replace("\r", "\n", $texte);
1488
+
1489
+    if (preg_match(",\n+$,", $texte, $fin)) {
1490
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1491
+    } else {
1492
+        $fin = '';
1493
+    }
1494
+
1495
+    $texte = echappe_html($texte, '', true);
1496
+
1497
+    // echapper les modeles
1498
+    if (strpos($texte, "<") !== false) {
1499
+        include_spip('inc/lien');
1500
+        if (defined('_PREG_MODELE')) {
1501
+            $preg_modeles = "@" . _PREG_MODELE . "@imsS";
1502
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1503
+        }
1504
+    }
1505
+
1506
+    $debut = '';
1507
+    $suite = $texte;
1508
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1509
+        $debut .= substr($suite, 0, $t - 1);
1510
+        $suite = substr($suite, $t);
1511
+        $car = substr($suite, 0, 1);
1512
+        if (($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> "|") and ($car <> "}")
1513
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1514
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1515
+        ) {
1516
+            $debut .= $delim;
1517
+        } else {
1518
+            $debut .= "\n";
1519
+        }
1520
+        if (preg_match(",^\n+,", $suite, $regs)) {
1521
+            $debut .= $regs[0];
1522
+            $suite = substr($suite, strlen($regs[0]));
1523
+        }
1524
+    }
1525
+    $texte = $debut . $suite;
1526
+
1527
+    $texte = echappe_retour($texte);
1528
+
1529
+    return $texte . $fin;
1530 1530
 }
1531 1531
 
1532 1532
 
@@ -1567,46 +1567,46 @@  discard block
 block discarded – undo
1567 1567
  * @return string
1568 1568
  **/
1569 1569
 function extraire_idiome($letexte, $lang = null, $options = array()) {
1570
-	static $traduire = false;
1571
-	if ($letexte
1572
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1573
-	) {
1574
-		if (!$traduire) {
1575
-			$traduire = charger_fonction('traduire', 'inc');
1576
-			include_spip('inc/lang');
1577
-		}
1578
-		if (!$lang) {
1579
-			$lang = $GLOBALS['spip_lang'];
1580
-		}
1581
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1582
-		if (is_bool($options)) {
1583
-			$options = array('echappe_span' => $options);
1584
-		}
1585
-		if (!isset($options['echappe_span'])) {
1586
-			$options = array_merge($options, array('echappe_span' => false));
1587
-		}
1588
-
1589
-		foreach ($regs as $reg) {
1590
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1591
-			$desc = $traduire($cle, $lang, true);
1592
-			$l = $desc->langue;
1593
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1594
-			if (strlen($desc->texte)) {
1595
-				$trad = code_echappement($desc->texte, 'idiome', false);
1596
-				if ($l !== $lang) {
1597
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1598
-				}
1599
-				if (lang_dir($l) !== lang_dir($lang)) {
1600
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1601
-				}
1602
-				if (!$options['echappe_span']) {
1603
-					$trad = echappe_retour($trad, 'idiome');
1604
-				}
1605
-				$letexte = str_replace($reg[0], $trad, $letexte);
1606
-			}
1607
-		}
1608
-	}
1609
-	return $letexte;
1570
+    static $traduire = false;
1571
+    if ($letexte
1572
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1573
+    ) {
1574
+        if (!$traduire) {
1575
+            $traduire = charger_fonction('traduire', 'inc');
1576
+            include_spip('inc/lang');
1577
+        }
1578
+        if (!$lang) {
1579
+            $lang = $GLOBALS['spip_lang'];
1580
+        }
1581
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1582
+        if (is_bool($options)) {
1583
+            $options = array('echappe_span' => $options);
1584
+        }
1585
+        if (!isset($options['echappe_span'])) {
1586
+            $options = array_merge($options, array('echappe_span' => false));
1587
+        }
1588
+
1589
+        foreach ($regs as $reg) {
1590
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1591
+            $desc = $traduire($cle, $lang, true);
1592
+            $l = $desc->langue;
1593
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1594
+            if (strlen($desc->texte)) {
1595
+                $trad = code_echappement($desc->texte, 'idiome', false);
1596
+                if ($l !== $lang) {
1597
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1598
+                }
1599
+                if (lang_dir($l) !== lang_dir($lang)) {
1600
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1601
+                }
1602
+                if (!$options['echappe_span']) {
1603
+                    $trad = echappe_retour($trad, 'idiome');
1604
+                }
1605
+                $letexte = str_replace($reg[0], $trad, $letexte);
1606
+            }
1607
+        }
1608
+    }
1609
+    return $letexte;
1610 1610
 }
1611 1611
 
1612 1612
 /**
@@ -1658,64 +1658,64 @@  discard block
 block discarded – undo
1658 1658
  **/
1659 1659
 function extraire_multi($letexte, $lang = null, $options = array()) {
1660 1660
 
1661
-	if ($letexte
1662
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1663
-	) {
1664
-		if (!$lang) {
1665
-			$lang = $GLOBALS['spip_lang'];
1666
-		}
1667
-
1668
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1669
-		if (is_bool($options)) {
1670
-			$options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1671
-		}
1672
-		if (!isset($options['echappe_span'])) {
1673
-			$options = array_merge($options, array('echappe_span' => false));
1674
-		}
1675
-		if (!isset($options['lang_defaut'])) {
1676
-			$options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1677
-		}
1678
-
1679
-		include_spip('inc/lang');
1680
-		foreach ($regs as $reg) {
1681
-			// chercher la version de la langue courante
1682
-			$trads = extraire_trads($reg[1]);
1683
-			if ($l = approcher_langue($trads, $lang)) {
1684
-				$trad = $trads[$l];
1685
-			} else {
1686
-				if ($options['lang_defaut'] == 'aucune') {
1687
-					$trad = '';
1688
-				} else {
1689
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1690
-					// ou la premiere dispo
1691
-					// mais typographier le texte selon les regles de celle-ci
1692
-					// Attention aux blocs multi sur plusieurs lignes
1693
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1694
-						$l = key($trads);
1695
-					}
1696
-					$trad = $trads[$l];
1697
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1698
-					$trad = $typographie($trad);
1699
-					// Tester si on echappe en span ou en div
1700
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1701
-					include_spip('inc/texte');
1702
-					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1703
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1704
-					$trad = code_echappement($trad, 'multi', false, $mode);
1705
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1706
-					if (lang_dir($l) !== lang_dir($lang)) {
1707
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1708
-					}
1709
-					if (!$options['echappe_span']) {
1710
-						$trad = echappe_retour($trad, 'multi');
1711
-					}
1712
-				}
1713
-			}
1714
-			$letexte = str_replace($reg[0], $trad, $letexte);
1715
-		}
1716
-	}
1717
-
1718
-	return $letexte;
1661
+    if ($letexte
1662
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1663
+    ) {
1664
+        if (!$lang) {
1665
+            $lang = $GLOBALS['spip_lang'];
1666
+        }
1667
+
1668
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1669
+        if (is_bool($options)) {
1670
+            $options = array('echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT);
1671
+        }
1672
+        if (!isset($options['echappe_span'])) {
1673
+            $options = array_merge($options, array('echappe_span' => false));
1674
+        }
1675
+        if (!isset($options['lang_defaut'])) {
1676
+            $options = array_merge($options, array('lang_defaut' => _LANGUE_PAR_DEFAUT));
1677
+        }
1678
+
1679
+        include_spip('inc/lang');
1680
+        foreach ($regs as $reg) {
1681
+            // chercher la version de la langue courante
1682
+            $trads = extraire_trads($reg[1]);
1683
+            if ($l = approcher_langue($trads, $lang)) {
1684
+                $trad = $trads[$l];
1685
+            } else {
1686
+                if ($options['lang_defaut'] == 'aucune') {
1687
+                    $trad = '';
1688
+                } else {
1689
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1690
+                    // ou la premiere dispo
1691
+                    // mais typographier le texte selon les regles de celle-ci
1692
+                    // Attention aux blocs multi sur plusieurs lignes
1693
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1694
+                        $l = key($trads);
1695
+                    }
1696
+                    $trad = $trads[$l];
1697
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1698
+                    $trad = $typographie($trad);
1699
+                    // Tester si on echappe en span ou en div
1700
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1701
+                    include_spip('inc/texte');
1702
+                    $trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1703
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1704
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1705
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1706
+                    if (lang_dir($l) !== lang_dir($lang)) {
1707
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1708
+                    }
1709
+                    if (!$options['echappe_span']) {
1710
+                        $trad = echappe_retour($trad, 'multi');
1711
+                    }
1712
+                }
1713
+            }
1714
+            $letexte = str_replace($reg[0], $trad, $letexte);
1715
+        }
1716
+    }
1717
+
1718
+    return $letexte;
1719 1719
 }
1720 1720
 
1721 1721
 /**
@@ -1731,20 +1731,20 @@  discard block
 block discarded – undo
1731 1731
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1732 1732
  **/
1733 1733
 function extraire_trads($bloc) {
1734
-	$lang = '';
1734
+    $lang = '';
1735 1735
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1736 1736
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1737
-	while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1738
-		$texte = trim($regs[1]);
1739
-		if ($texte or $lang) {
1740
-			$trads[$lang] = $texte;
1741
-		}
1742
-		$bloc = substr($bloc, strlen($regs[0]));
1743
-		$lang = $regs[2];
1744
-	}
1745
-	$trads[$lang] = $bloc;
1737
+    while (preg_match("/^(.*?)[\[]([a-z_]+)[\]]/siS", $bloc, $regs)) {
1738
+        $texte = trim($regs[1]);
1739
+        if ($texte or $lang) {
1740
+            $trads[$lang] = $texte;
1741
+        }
1742
+        $bloc = substr($bloc, strlen($regs[0]));
1743
+        $lang = $regs[2];
1744
+    }
1745
+    $trads[$lang] = $bloc;
1746 1746
 
1747
-	return $trads;
1747
+    return $trads;
1748 1748
 }
1749 1749
 
1750 1750
 
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
  * @return string L'initiale en majuscule
1756 1756
  */
1757 1757
 function filtre_initiale($nom) {
1758
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1758
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1759 1759
 }
1760 1760
 
1761 1761
 
@@ -1800,33 +1800,33 @@  discard block
 block discarded – undo
1800 1800
  *      - null (interne) : si on empile
1801 1801
  **/
1802 1802
 function unique($donnee, $famille = '', $cpt = false) {
1803
-	static $mem = array();
1804
-	// permettre de vider la pile et de la restaurer
1805
-	// pour le calcul de introduction...
1806
-	if ($famille == '_spip_raz_') {
1807
-		$tmp = $mem;
1808
-		$mem = array();
1809
-
1810
-		return $tmp;
1811
-	} elseif ($famille == '_spip_set_') {
1812
-		$mem = $donnee;
1813
-
1814
-		return;
1815
-	}
1816
-	// eviter une notice
1817
-	if (!isset($mem[$famille])) {
1818
-		$mem[$famille] = array();
1819
-	}
1820
-	if ($cpt) {
1821
-		return count($mem[$famille]);
1822
-	}
1823
-	// eviter une notice
1824
-	if (!isset($mem[$famille][$donnee])) {
1825
-		$mem[$famille][$donnee] = 0;
1826
-	}
1827
-	if (!($mem[$famille][$donnee]++)) {
1828
-		return $donnee;
1829
-	}
1803
+    static $mem = array();
1804
+    // permettre de vider la pile et de la restaurer
1805
+    // pour le calcul de introduction...
1806
+    if ($famille == '_spip_raz_') {
1807
+        $tmp = $mem;
1808
+        $mem = array();
1809
+
1810
+        return $tmp;
1811
+    } elseif ($famille == '_spip_set_') {
1812
+        $mem = $donnee;
1813
+
1814
+        return;
1815
+    }
1816
+    // eviter une notice
1817
+    if (!isset($mem[$famille])) {
1818
+        $mem[$famille] = array();
1819
+    }
1820
+    if ($cpt) {
1821
+        return count($mem[$famille]);
1822
+    }
1823
+    // eviter une notice
1824
+    if (!isset($mem[$famille][$donnee])) {
1825
+        $mem[$famille][$donnee] = 0;
1826
+    }
1827
+    if (!($mem[$famille][$donnee]++)) {
1828
+        return $donnee;
1829
+    }
1830 1830
 }
1831 1831
 
1832 1832
 
@@ -1854,18 +1854,18 @@  discard block
 block discarded – undo
1854 1854
  *     Une des valeurs en fonction du compteur.
1855 1855
  **/
1856 1856
 function alterner($i) {
1857
-	// recuperer les arguments (attention fonctions un peu space)
1858
-	$num = func_num_args();
1859
-	$args = func_get_args();
1857
+    // recuperer les arguments (attention fonctions un peu space)
1858
+    $num = func_num_args();
1859
+    $args = func_get_args();
1860 1860
 
1861
-	if ($num == 2 && is_array($args[1])) {
1862
-		$args = $args[1];
1863
-		array_unshift($args, '');
1864
-		$num = count($args);
1865
-	}
1861
+    if ($num == 2 && is_array($args[1])) {
1862
+        $args = $args[1];
1863
+        array_unshift($args, '');
1864
+        $num = count($args);
1865
+    }
1866 1866
 
1867
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1868
-	return $args[(intval($i) - 1) % ($num - 1) + 1];
1867
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1868
+    return $args[(intval($i) - 1) % ($num - 1) + 1];
1869 1869
 }
1870 1870
 
1871 1871
 
@@ -1890,46 +1890,46 @@  discard block
 block discarded – undo
1890 1890
  *     - Tableau complet (si 2e argument)
1891 1891
  **/
1892 1892
 function extraire_attribut($balise, $attribut, $complet = false) {
1893
-	if (is_array($balise)) {
1894
-		array_walk(
1895
-			$balise,
1896
-			function(&$a, $key, $t){
1897
-				$a = extraire_attribut($a, $t);
1898
-			},
1899
-			$attribut
1900
-		);
1901
-
1902
-		return $balise;
1903
-	}
1904
-	if (preg_match(
1905
-		',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1906
-		. $attribut
1907
-		. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1908
-
1909
-		$balise, $r)) {
1910
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1911
-			$r[4] = substr($r[3], 1, -1);
1912
-			$r[3] = $r[3][0];
1913
-		} elseif ($r[3] !== '') {
1914
-			$r[4] = $r[3];
1915
-			$r[3] = '';
1916
-		} else {
1917
-			$r[4] = trim($r[2]);
1918
-		}
1919
-		$att = $r[4];
1920
-		if (strpos($att, "&#") !== false) {
1921
-			$att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1922
-		}
1923
-		$att = filtrer_entites($att);
1924
-	} else {
1925
-		$att = null;
1926
-	}
1927
-
1928
-	if ($complet) {
1929
-		return array($att, $r);
1930
-	} else {
1931
-		return $att;
1932
-	}
1893
+    if (is_array($balise)) {
1894
+        array_walk(
1895
+            $balise,
1896
+            function(&$a, $key, $t){
1897
+                $a = extraire_attribut($a, $t);
1898
+            },
1899
+            $attribut
1900
+        );
1901
+
1902
+        return $balise;
1903
+    }
1904
+    if (preg_match(
1905
+        ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1906
+        . $attribut
1907
+        . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1908
+
1909
+        $balise, $r)) {
1910
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1911
+            $r[4] = substr($r[3], 1, -1);
1912
+            $r[3] = $r[3][0];
1913
+        } elseif ($r[3] !== '') {
1914
+            $r[4] = $r[3];
1915
+            $r[3] = '';
1916
+        } else {
1917
+            $r[4] = trim($r[2]);
1918
+        }
1919
+        $att = $r[4];
1920
+        if (strpos($att, "&#") !== false) {
1921
+            $att = str_replace(array("&#039;", "&#39;", "&#034;", "&#34;"), array("'", "'", '"', '"'), $att);
1922
+        }
1923
+        $att = filtrer_entites($att);
1924
+    } else {
1925
+        $att = null;
1926
+    }
1927
+
1928
+    if ($complet) {
1929
+        return array($att, $r);
1930
+    } else {
1931
+        return $att;
1932
+    }
1933 1933
 }
1934 1934
 
1935 1935
 /**
@@ -1961,37 +1961,37 @@  discard block
 block discarded – undo
1961 1961
  *     Code html modifié
1962 1962
  **/
1963 1963
 function inserer_attribut($balise, $attribut, $val, $proteger = true, $vider = false) {
1964
-	// preparer l'attribut
1965
-	// supprimer les &nbsp; etc mais pas les balises html
1966
-	// qui ont un sens dans un attribut value d'un input
1967
-	if ($proteger) {
1968
-		$val = attribut_html($val, false);
1969
-	}
1970
-
1971
-	// echapper les ' pour eviter tout bug
1972
-	$val = str_replace("'", "&#039;", $val);
1973
-	if ($vider and strlen($val) == 0) {
1974
-		$insert = '';
1975
-	} else {
1976
-		$insert = " $attribut='$val'";
1977
-	}
1978
-
1979
-	list($old, $r) = extraire_attribut($balise, $attribut, true);
1980
-
1981
-	if ($old !== null) {
1982
-		// Remplacer l'ancien attribut du meme nom
1983
-		$balise = $r[1] . $insert . $r[5];
1984
-	} else {
1985
-		// preferer une balise " />" (comme <img />)
1986
-		if (preg_match(',/>,', $balise)) {
1987
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1988
-		} // sinon une balise <a ...> ... </a>
1989
-		else {
1990
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1991
-		}
1992
-	}
1993
-
1994
-	return $balise;
1964
+    // preparer l'attribut
1965
+    // supprimer les &nbsp; etc mais pas les balises html
1966
+    // qui ont un sens dans un attribut value d'un input
1967
+    if ($proteger) {
1968
+        $val = attribut_html($val, false);
1969
+    }
1970
+
1971
+    // echapper les ' pour eviter tout bug
1972
+    $val = str_replace("'", "&#039;", $val);
1973
+    if ($vider and strlen($val) == 0) {
1974
+        $insert = '';
1975
+    } else {
1976
+        $insert = " $attribut='$val'";
1977
+    }
1978
+
1979
+    list($old, $r) = extraire_attribut($balise, $attribut, true);
1980
+
1981
+    if ($old !== null) {
1982
+        // Remplacer l'ancien attribut du meme nom
1983
+        $balise = $r[1] . $insert . $r[5];
1984
+    } else {
1985
+        // preferer une balise " />" (comme <img />)
1986
+        if (preg_match(',/>,', $balise)) {
1987
+            $balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1988
+        } // sinon une balise <a ...> ... </a>
1989
+        else {
1990
+            $balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1991
+        }
1992
+    }
1993
+
1994
+    return $balise;
1995 1995
 }
1996 1996
 
1997 1997
 /**
@@ -2009,7 +2009,7 @@  discard block
 block discarded – undo
2009 2009
  * @return string Code HTML sans l'attribut
2010 2010
  **/
2011 2011
 function vider_attribut($balise, $attribut) {
2012
-	return inserer_attribut($balise, $attribut, '', false, true);
2012
+    return inserer_attribut($balise, $attribut, '', false, true);
2013 2013
 }
2014 2014
 
2015 2015
 
@@ -2021,9 +2021,9 @@  discard block
 block discarded – undo
2021 2021
  * @return string
2022 2022
  */
2023 2023
 function tester_config($id, $mode = '') {
2024
-	include_spip('action/inscrire_auteur');
2024
+    include_spip('action/inscrire_auteur');
2025 2025
 
2026
-	return tester_statut_inscription($mode, $id);
2026
+    return tester_statut_inscription($mode, $id);
2027 2027
 }
2028 2028
 
2029 2029
 //
@@ -2048,7 +2048,7 @@  discard block
 block discarded – undo
2048 2048
  * @return int $a+$b
2049 2049
  **/
2050 2050
 function plus($a, $b) {
2051
-	return $a + $b;
2051
+    return $a + $b;
2052 2052
 }
2053 2053
 function strplus($a, $b) {return strize('plus', $a, $b);}
2054 2054
 /**
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
  * @return int $a-$b
2068 2068
  **/
2069 2069
 function moins($a, $b) {
2070
-	return $a - $b;
2070
+    return $a - $b;
2071 2071
 }
2072 2072
 function strmoins($a, $b) {return strize('moins', $a, $b);}
2073 2073
 
@@ -2088,7 +2088,7 @@  discard block
 block discarded – undo
2088 2088
  * @return int $a*$b
2089 2089
  **/
2090 2090
 function mult($a, $b) {
2091
-	return $a * $b;
2091
+    return $a * $b;
2092 2092
 }
2093 2093
 function strmult($a, $b) {return strize('mult', $a, $b);}
2094 2094
 
@@ -2109,7 +2109,7 @@  discard block
 block discarded – undo
2109 2109
  * @return int $a/$b (ou 0 si $b est nul)
2110 2110
  **/
2111 2111
 function div($a, $b) {
2112
-	return $b ? $a / $b : 0;
2112
+    return $b ? $a / $b : 0;
2113 2113
 }
2114 2114
 function strdiv($a, $b) {return strize('div', $a, $b);}
2115 2115
 
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
  * @return int ($nb % $mod) + $add
2132 2132
  **/
2133 2133
 function modulo($nb, $mod, $add = 0) {
2134
-	return ($mod ? $nb % $mod : 0) + $add;
2134
+    return ($mod ? $nb % $mod : 0) + $add;
2135 2135
 }
2136 2136
 
2137 2137
 
@@ -2146,24 +2146,24 @@  discard block
 block discarded – undo
2146 2146
  *      - true sinon
2147 2147
  **/
2148 2148
 function nom_acceptable($nom) {
2149
-	if (!is_string($nom)) {
2150
-		return false;
2151
-	}
2152
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2153
-		define('_TAGS_NOM_AUTEUR', '');
2154
-	}
2155
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2156
-	foreach ($tags_acceptes as $tag) {
2157
-		if (strlen($tag)) {
2158
-			$remp1[] = '<' . trim($tag) . '>';
2159
-			$remp1[] = '</' . trim($tag) . '>';
2160
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2161
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2162
-		}
2163
-	}
2164
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2149
+    if (!is_string($nom)) {
2150
+        return false;
2151
+    }
2152
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2153
+        define('_TAGS_NOM_AUTEUR', '');
2154
+    }
2155
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2156
+    foreach ($tags_acceptes as $tag) {
2157
+        if (strlen($tag)) {
2158
+            $remp1[] = '<' . trim($tag) . '>';
2159
+            $remp1[] = '</' . trim($tag) . '>';
2160
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2161
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2162
+        }
2163
+    }
2164
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2165 2165
 
2166
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2166
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2167 2167
 }
2168 2168
 
2169 2169
 
@@ -2177,29 +2177,29 @@  discard block
 block discarded – undo
2177 2177
  *      - la normalisation de la dernière adresse donnée sinon
2178 2178
  **/
2179 2179
 function email_valide($adresses) {
2180
-	// eviter d'injecter n'importe quoi dans preg_match
2181
-	if (!is_string($adresses)) {
2182
-		return false;
2183
-	}
2180
+    // eviter d'injecter n'importe quoi dans preg_match
2181
+    if (!is_string($adresses)) {
2182
+        return false;
2183
+    }
2184 2184
 
2185
-	// Si c'est un spammeur autant arreter tout de suite
2186
-	if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2187
-		spip_log("Tentative d'injection de mail : $adresses");
2185
+    // Si c'est un spammeur autant arreter tout de suite
2186
+    if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) {
2187
+        spip_log("Tentative d'injection de mail : $adresses");
2188 2188
 
2189
-		return false;
2190
-	}
2189
+        return false;
2190
+    }
2191 2191
 
2192
-	foreach (explode(',', $adresses) as $v) {
2193
-		// nettoyer certains formats
2194
-		// "Marie Toto <[email protected]>"
2195
-		$adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2196
-		// RFC 822
2197
-		if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2198
-			return false;
2199
-		}
2200
-	}
2192
+    foreach (explode(',', $adresses) as $v) {
2193
+        // nettoyer certains formats
2194
+        // "Marie Toto <[email protected]>"
2195
+        $adresse = trim(preg_replace(",^[^<>\"]*<([^<>\"]+)>$,i", "\\1", $v));
2196
+        // RFC 822
2197
+        if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) {
2198
+            return false;
2199
+        }
2200
+    }
2201 2201
 
2202
-	return $adresse;
2202
+    return $adresse;
2203 2203
 }
2204 2204
 
2205 2205
 /**
@@ -2213,20 +2213,20 @@  discard block
 block discarded – undo
2213 2213
  * @return string Texte
2214 2214
  **/
2215 2215
 function afficher_enclosures($tags) {
2216
-	$s = array();
2217
-	foreach (extraire_balises($tags, 'a') as $tag) {
2218
-		if (extraire_attribut($tag, 'rel') == 'enclosure'
2219
-			and $t = extraire_attribut($tag, 'href')
2220
-		) {
2221
-			$s[] = preg_replace(',>[^<]+</a>,S',
2222
-				'>'
2223
-				. http_img_pack('attachment-16.png', $t,
2224
-					'title="' . attribut_html($t) . '"')
2225
-				. '</a>', $tag);
2226
-		}
2227
-	}
2216
+    $s = array();
2217
+    foreach (extraire_balises($tags, 'a') as $tag) {
2218
+        if (extraire_attribut($tag, 'rel') == 'enclosure'
2219
+            and $t = extraire_attribut($tag, 'href')
2220
+        ) {
2221
+            $s[] = preg_replace(',>[^<]+</a>,S',
2222
+                '>'
2223
+                . http_img_pack('attachment-16.png', $t,
2224
+                    'title="' . attribut_html($t) . '"')
2225
+                . '</a>', $tag);
2226
+        }
2227
+    }
2228 2228
 
2229
-	return join('&nbsp;', $s);
2229
+    return join('&nbsp;', $s);
2230 2230
 }
2231 2231
 
2232 2232
 /**
@@ -2241,15 +2241,15 @@  discard block
 block discarded – undo
2241 2241
  * @return string Liens trouvés
2242 2242
  **/
2243 2243
 function afficher_tags($tags, $rels = 'tag,directory') {
2244
-	$s = array();
2245
-	foreach (extraire_balises($tags, 'a') as $tag) {
2246
-		$rel = extraire_attribut($tag, 'rel');
2247
-		if (strstr(",$rels,", ",$rel,")) {
2248
-			$s[] = $tag;
2249
-		}
2250
-	}
2244
+    $s = array();
2245
+    foreach (extraire_balises($tags, 'a') as $tag) {
2246
+        $rel = extraire_attribut($tag, 'rel');
2247
+        if (strstr(",$rels,", ",$rel,")) {
2248
+            $s[] = $tag;
2249
+        }
2250
+    }
2251 2251
 
2252
-	return join(', ', $s);
2252
+    return join(', ', $s);
2253 2253
 }
2254 2254
 
2255 2255
 
@@ -2271,21 +2271,21 @@  discard block
 block discarded – undo
2271 2271
  * @return string Tag HTML `<a>` avec microformat.
2272 2272
  **/
2273 2273
 function enclosure2microformat($e) {
2274
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2275
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2276
-	}
2277
-	$type = extraire_attribut($e, 'type');
2278
-	if (!$length = extraire_attribut($e, 'length')) {
2279
-		# <media:content : longeur dans fileSize. On tente.
2280
-		$length = extraire_attribut($e, 'fileSize');
2281
-	}
2282
-	$fichier = basename($url);
2274
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2275
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2276
+    }
2277
+    $type = extraire_attribut($e, 'type');
2278
+    if (!$length = extraire_attribut($e, 'length')) {
2279
+        # <media:content : longeur dans fileSize. On tente.
2280
+        $length = extraire_attribut($e, 'fileSize');
2281
+    }
2282
+    $fichier = basename($url);
2283 2283
 
2284
-	return '<a rel="enclosure"'
2285
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2286
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2287
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2288
-	. '>' . $fichier . '</a>';
2284
+    return '<a rel="enclosure"'
2285
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2286
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2287
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2288
+    . '>' . $fichier . '</a>';
2289 2289
 }
2290 2290
 
2291 2291
 /**
@@ -2303,24 +2303,24 @@  discard block
 block discarded – undo
2303 2303
  * @return string Tags RSS `<enclosure>`.
2304 2304
  **/
2305 2305
 function microformat2enclosure($tags) {
2306
-	$enclosures = array();
2307
-	foreach (extraire_balises($tags, 'a') as $e) {
2308
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2309
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2310
-			$type = extraire_attribut($e, 'type');
2311
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2312
-				$length = intval(extraire_attribut($e, 'length'));
2313
-			} # vieux data
2314
-			$fichier = basename($url);
2315
-			$enclosures[] = '<enclosure'
2316
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2317
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2318
-				. ($length ? ' length="' . $length . '"' : '')
2319
-				. ' />';
2320
-		}
2321
-	}
2306
+    $enclosures = array();
2307
+    foreach (extraire_balises($tags, 'a') as $e) {
2308
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2309
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2310
+            $type = extraire_attribut($e, 'type');
2311
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2312
+                $length = intval(extraire_attribut($e, 'length'));
2313
+            } # vieux data
2314
+            $fichier = basename($url);
2315
+            $enclosures[] = '<enclosure'
2316
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2317
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2318
+                . ($length ? ' length="' . $length . '"' : '')
2319
+                . ' />';
2320
+        }
2321
+    }
2322 2322
 
2323
-	return join("\n", $enclosures);
2323
+    return join("\n", $enclosures);
2324 2324
 }
2325 2325
 
2326 2326
 
@@ -2336,16 +2336,16 @@  discard block
 block discarded – undo
2336 2336
  * @return string Tags RSS Atom `<dc:subject>`.
2337 2337
  **/
2338 2338
 function tags2dcsubject($tags) {
2339
-	$subjects = '';
2340
-	foreach (extraire_balises($tags, 'a') as $e) {
2341
-		if (extraire_attribut($e, rel) == 'tag') {
2342
-			$subjects .= '<dc:subject>'
2343
-				. texte_backend(textebrut($e))
2344
-				. '</dc:subject>' . "\n";
2345
-		}
2346
-	}
2339
+    $subjects = '';
2340
+    foreach (extraire_balises($tags, 'a') as $e) {
2341
+        if (extraire_attribut($e, rel) == 'tag') {
2342
+            $subjects .= '<dc:subject>'
2343
+                . texte_backend(textebrut($e))
2344
+                . '</dc:subject>' . "\n";
2345
+        }
2346
+    }
2347 2347
 
2348
-	return $subjects;
2348
+    return $subjects;
2349 2349
 }
2350 2350
 
2351 2351
 /**
@@ -2374,23 +2374,23 @@  discard block
 block discarded – undo
2374 2374
  *     - Tableau de résultats, si tableau en entrée.
2375 2375
  **/
2376 2376
 function extraire_balise($texte, $tag = 'a') {
2377
-	if (is_array($texte)) {
2378
-		array_walk(
2379
-			$texte,
2380
-			function(&$a, $key, $t){
2381
-				$a = extraire_balise($a, $t);
2382
-			},
2383
-			$tag
2384
-		);
2377
+    if (is_array($texte)) {
2378
+        array_walk(
2379
+            $texte,
2380
+            function(&$a, $key, $t){
2381
+                $a = extraire_balise($a, $t);
2382
+            },
2383
+            $tag
2384
+        );
2385 2385
 
2386
-		return $texte;
2387
-	}
2386
+        return $texte;
2387
+    }
2388 2388
 
2389
-	if (preg_match(
2390
-		",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2391
-		$texte, $regs)) {
2392
-		return $regs[0];
2393
-	}
2389
+    if (preg_match(
2390
+        ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2391
+        $texte, $regs)) {
2392
+        return $regs[0];
2393
+    }
2394 2394
 }
2395 2395
 
2396 2396
 /**
@@ -2418,25 +2418,25 @@  discard block
 block discarded – undo
2418 2418
  *     - Tableau de résultats, si tableau en entrée.
2419 2419
  **/
2420 2420
 function extraire_balises($texte, $tag = 'a') {
2421
-	if (is_array($texte)) {
2422
-		array_walk(
2423
-			$texte,
2424
-			function(&$a, $key, $t){
2425
-				$a = extraire_balises($a, $t);
2426
-			},
2427
-			$tag
2428
-		);
2421
+    if (is_array($texte)) {
2422
+        array_walk(
2423
+            $texte,
2424
+            function(&$a, $key, $t){
2425
+                $a = extraire_balises($a, $t);
2426
+            },
2427
+            $tag
2428
+        );
2429 2429
 
2430
-		return $texte;
2431
-	}
2430
+        return $texte;
2431
+    }
2432 2432
 
2433
-	if (preg_match_all(
2434
-		",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2435
-		$texte, $regs, PREG_PATTERN_ORDER)) {
2436
-		return $regs[0];
2437
-	} else {
2438
-		return array();
2439
-	}
2433
+    if (preg_match_all(
2434
+        ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2435
+        $texte, $regs, PREG_PATTERN_ORDER)) {
2436
+        return $regs[0];
2437
+    } else {
2438
+        return array();
2439
+    }
2440 2440
 }
2441 2441
 
2442 2442
 /**
@@ -2465,11 +2465,11 @@  discard block
 block discarded – undo
2465 2465
  *     - `$def` si on n'a pas transmis de tableau
2466 2466
  **/
2467 2467
 function in_any($val, $vals, $def = '') {
2468
-	if (!is_array($vals) and $v = unserialize($vals)) {
2469
-		$vals = $v;
2470
-	}
2468
+    if (!is_array($vals) and $v = unserialize($vals)) {
2469
+        $vals = $v;
2470
+    }
2471 2471
 
2472
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2472
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2473 2473
 }
2474 2474
 
2475 2475
 
@@ -2490,12 +2490,12 @@  discard block
 block discarded – undo
2490 2490
  *     Résultat du calcul
2491 2491
  **/
2492 2492
 function valeur_numerique($expr) {
2493
-	$a = 0;
2494
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2495
-		eval("\$a = $expr;");
2496
-	}
2493
+    $a = 0;
2494
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2495
+        eval("\$a = $expr;");
2496
+    }
2497 2497
 
2498
-	return intval($a);
2498
+    return intval($a);
2499 2499
 }
2500 2500
 
2501 2501
 /**
@@ -2514,7 +2514,7 @@  discard block
 block discarded – undo
2514 2514
  *      Retourne `$a*$b/$c`
2515 2515
  **/
2516 2516
 function regledetrois($a, $b, $c) {
2517
-	return round($a * $b / $c);
2517
+    return round($a * $b / $c);
2518 2518
 }
2519 2519
 
2520 2520
 
@@ -2538,76 +2538,76 @@  discard block
 block discarded – undo
2538 2538
  **/
2539 2539
 function form_hidden($action) {
2540 2540
 
2541
-	$contexte = array();
2542
-	include_spip('inc/urls');
2543
-	if ($p = urls_decoder_url($action, '')
2544
-		and reset($p)
2545
-	) {
2546
-		$fond = array_shift($p);
2547
-		if ($fond != '404') {
2548
-			$contexte = array_shift($p);
2549
-			$contexte['page'] = $fond;
2550
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2551
-		}
2552
-	}
2553
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2554
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2555
-		unset($contexte['type']);
2556
-	}
2557
-	if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2558
-		unset($contexte['type-page']);
2559
-	}
2560
-
2561
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2562
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2563
-	$values = array();
2564
-
2565
-	// d'abord avec celles de l'url
2566
-	if (false !== ($p = strpos($action, '?'))) {
2567
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2568
-			$c = explode('=', $c, 2);
2569
-			$var = array_shift($c);
2570
-			$val = array_shift($c);
2571
-			if ($var) {
2572
-				$val = rawurldecode($val);
2573
-				$var = rawurldecode($var); // decoder les [] eventuels
2574
-				if (preg_match(',\[\]$,S', $var)) {
2575
-					$values[] = array($var, $val);
2576
-				} else {
2577
-					if (!isset($values[$var])) {
2578
-						$values[$var] = array($var, $val);
2579
-					}
2580
-				}
2581
-			}
2582
-		}
2583
-	}
2584
-
2585
-	// ensuite avec celles du contexte, sans doublonner !
2586
-	foreach ($contexte as $var => $val) {
2587
-		if (preg_match(',\[\]$,S', $var)) {
2588
-			$values[] = array($var, $val);
2589
-		} else {
2590
-			if (!isset($values[$var])) {
2591
-				$values[$var] = array($var, $val);
2592
-			}
2593
-		}
2594
-	}
2595
-
2596
-	// puis on rassemble le tout
2597
-	$hidden = array();
2598
-	foreach ($values as $value) {
2599
-		list($var, $val) = $value;
2600
-		$hidden[] = '<input name="'
2601
-			. entites_html($var)
2602
-			. '"'
2603
-			. (is_null($val)
2604
-				? ''
2605
-				: ' value="' . entites_html($val) . '"'
2606
-			)
2607
-			. ' type="hidden"' . "\n/>";
2608
-	}
2609
-
2610
-	return join("", $hidden);
2541
+    $contexte = array();
2542
+    include_spip('inc/urls');
2543
+    if ($p = urls_decoder_url($action, '')
2544
+        and reset($p)
2545
+    ) {
2546
+        $fond = array_shift($p);
2547
+        if ($fond != '404') {
2548
+            $contexte = array_shift($p);
2549
+            $contexte['page'] = $fond;
2550
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2551
+        }
2552
+    }
2553
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2554
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2555
+        unset($contexte['type']);
2556
+    }
2557
+    if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
2558
+        unset($contexte['type-page']);
2559
+    }
2560
+
2561
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2562
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2563
+    $values = array();
2564
+
2565
+    // d'abord avec celles de l'url
2566
+    if (false !== ($p = strpos($action, '?'))) {
2567
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2568
+            $c = explode('=', $c, 2);
2569
+            $var = array_shift($c);
2570
+            $val = array_shift($c);
2571
+            if ($var) {
2572
+                $val = rawurldecode($val);
2573
+                $var = rawurldecode($var); // decoder les [] eventuels
2574
+                if (preg_match(',\[\]$,S', $var)) {
2575
+                    $values[] = array($var, $val);
2576
+                } else {
2577
+                    if (!isset($values[$var])) {
2578
+                        $values[$var] = array($var, $val);
2579
+                    }
2580
+                }
2581
+            }
2582
+        }
2583
+    }
2584
+
2585
+    // ensuite avec celles du contexte, sans doublonner !
2586
+    foreach ($contexte as $var => $val) {
2587
+        if (preg_match(',\[\]$,S', $var)) {
2588
+            $values[] = array($var, $val);
2589
+        } else {
2590
+            if (!isset($values[$var])) {
2591
+                $values[$var] = array($var, $val);
2592
+            }
2593
+        }
2594
+    }
2595
+
2596
+    // puis on rassemble le tout
2597
+    $hidden = array();
2598
+    foreach ($values as $value) {
2599
+        list($var, $val) = $value;
2600
+        $hidden[] = '<input name="'
2601
+            . entites_html($var)
2602
+            . '"'
2603
+            . (is_null($val)
2604
+                ? ''
2605
+                : ' value="' . entites_html($val) . '"'
2606
+            )
2607
+            . ' type="hidden"' . "\n/>";
2608
+    }
2609
+
2610
+    return join("", $hidden);
2611 2611
 }
2612 2612
 
2613 2613
 /**
@@ -2625,15 +2625,15 @@  discard block
 block discarded – undo
2625 2625
  *     Liste (première page, dernière page).
2626 2626
  **/
2627 2627
 function filtre_bornes_pagination_dist($courante, $nombre, $max = 10) {
2628
-	if ($max <= 0 or $max >= $nombre) {
2629
-		return array(1, $nombre);
2630
-	}
2628
+    if ($max <= 0 or $max >= $nombre) {
2629
+        return array(1, $nombre);
2630
+    }
2631 2631
 
2632
-	$premiere = max(1, $courante - floor(($max - 1) / 2));
2633
-	$derniere = min($nombre, $premiere + $max - 2);
2634
-	$premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2632
+    $premiere = max(1, $courante - floor(($max - 1) / 2));
2633
+    $derniere = min($nombre, $premiere + $max - 2);
2634
+    $premiere = $derniere == $nombre ? $derniere - $max + 1 : $premiere;
2635 2635
 
2636
-	return array($premiere, $derniere);
2636
+    return array($premiere, $derniere);
2637 2637
 }
2638 2638
 
2639 2639
 
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
  *    - la première valeur du tableau sinon.
2656 2656
  **/
2657 2657
 function filtre_reset($array) {
2658
-	return !is_array($array) ? null : reset($array);
2658
+    return !is_array($array) ? null : reset($array);
2659 2659
 }
2660 2660
 
2661 2661
 /**
@@ -2676,7 +2676,7 @@  discard block
 block discarded – undo
2676 2676
  *    - la dernière valeur du tableau sinon.
2677 2677
  **/
2678 2678
 function filtre_end($array) {
2679
-	return !is_array($array) ? null : end($array);
2679
+    return !is_array($array) ? null : end($array);
2680 2680
 }
2681 2681
 
2682 2682
 /**
@@ -2696,11 +2696,11 @@  discard block
 block discarded – undo
2696 2696
  *
2697 2697
  **/
2698 2698
 function filtre_push($array, $val) {
2699
-	if (!is_array($array) or !array_push($array, $val)) {
2700
-		return '';
2701
-	}
2699
+    if (!is_array($array) or !array_push($array, $val)) {
2700
+        return '';
2701
+    }
2702 2702
 
2703
-	return $array;
2703
+    return $array;
2704 2704
 }
2705 2705
 
2706 2706
 /**
@@ -2719,7 +2719,7 @@  discard block
 block discarded – undo
2719 2719
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2720 2720
  **/
2721 2721
 function filtre_find($array, $val) {
2722
-	return (is_array($array) and in_array($val, $array));
2722
+    return (is_array($array) and in_array($val, $array));
2723 2723
 }
2724 2724
 
2725 2725
 
@@ -2736,15 +2736,15 @@  discard block
 block discarded – undo
2736 2736
  *     Contenu avec urls en absolus
2737 2737
  **/
2738 2738
 function urls_absolues_css($contenu, $source) {
2739
-	$path = suivre_lien(url_absolue($source), './');
2739
+    $path = suivre_lien(url_absolue($source), './');
2740 2740
 
2741
-	return preg_replace_callback(
2742
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2743
-		function($x) use ($path) {
2744
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2745
-		},
2746
-		$contenu
2747
-	);
2741
+    return preg_replace_callback(
2742
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2743
+        function($x) use ($path) {
2744
+            return "url('" . suivre_lien($path, $x[1]) . "')";
2745
+        },
2746
+        $contenu
2747
+    );
2748 2748
 }
2749 2749
 
2750 2750
 
@@ -2773,118 +2773,118 @@  discard block
 block discarded – undo
2773 2773
  *     Chemin du fichier CSS inversé
2774 2774
  **/
2775 2775
 function direction_css($css, $voulue = '') {
2776
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2777
-		return $css;
2778
-	}
2779
-
2780
-	// si on a precise le sens voulu en argument, le prendre en compte
2781
-	if ($voulue = strtolower($voulue)) {
2782
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2783
-			$voulue = lang_dir($voulue);
2784
-		}
2785
-	} else {
2786
-		$voulue = lang_dir();
2787
-	}
2788
-
2789
-	$r = count($r) > 1;
2790
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2791
-	$dir = $r ? 'rtl' : 'ltr';
2792
-	$ndir = $r ? 'ltr' : 'rtl';
2793
-
2794
-	if ($voulue == $dir) {
2795
-		return $css;
2796
-	}
2797
-
2798
-	if (
2799
-		// url absolue
2800
-		preg_match(",^https?:,i", $css)
2801
-		// ou qui contient un ?
2802
-		or (($p = strpos($css, '?')) !== false)
2803
-	) {
2804
-		$distant = true;
2805
-		$cssf = parse_url($css);
2806
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2807
-		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2808
-	} else {
2809
-		$distant = false;
2810
-		$cssf = $css;
2811
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2812
-		//propose (rien a faire dans ce cas)
2813
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2814
-		if (@file_exists($f)) {
2815
-			return $f;
2816
-		}
2817
-	}
2818
-
2819
-	// 2.
2820
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2821
-	$f = $dir_var
2822
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2823
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2824
-
2825
-	// la css peut etre distante (url absolue !)
2826
-	if ($distant) {
2827
-		include_spip('inc/distant');
2828
-		$res = recuperer_url($css);
2829
-		if (!$res or !$contenu = $res['page']) {
2830
-			return $css;
2831
-		}
2832
-	} else {
2833
-		if ((@filemtime($f) > @filemtime($css))
2834
-			and (_VAR_MODE != 'recalcul')
2835
-		) {
2836
-			return $f;
2837
-		}
2838
-		if (!lire_fichier($css, $contenu)) {
2839
-			return $css;
2840
-		}
2841
-	}
2842
-
2843
-
2844
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2845
-	include_spip("lib/csstidy/class.csstidy");
2846
-	$parser = new csstidy();
2847
-	$parser->set_cfg('optimise_shorthands', 0);
2848
-	$parser->set_cfg('reverse_left_and_right', true);
2849
-	$parser->parse($contenu);
2850
-
2851
-	$contenu = $parser->print->plain();
2852
-
2853
-
2854
-	// reperer les @import auxquels il faut propager le direction_css
2855
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2856
-	$src = array();
2857
-	$src_direction_css = array();
2858
-	$src_faux_abs = array();
2859
-	$d = dirname($css);
2860
-	foreach ($regs[1] as $k => $import_css) {
2861
-		$css_direction = direction_css("$d/$import_css", $voulue);
2862
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2863
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2864
-			$css_direction = substr($css_direction, strlen($d) + 1);
2865
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2866
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2867
-			$css_direction = substr($css_direction, strlen($dir_var));
2868
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2869
-			$css_direction = "/@@@@@@/" . $css_direction;
2870
-		}
2871
-		$src[] = $regs[0][$k];
2872
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2873
-	}
2874
-	$contenu = str_replace($src, $src_direction_css, $contenu);
2875
-
2876
-	$contenu = urls_absolues_css($contenu, $css);
2877
-
2878
-	// virer les fausses url absolues que l'on a mis dans les import
2879
-	if (count($src_faux_abs)) {
2880
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2881
-	}
2882
-
2883
-	if (!ecrire_fichier($f, $contenu)) {
2884
-		return $css;
2885
-	}
2886
-
2887
-	return $f;
2776
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2777
+        return $css;
2778
+    }
2779
+
2780
+    // si on a precise le sens voulu en argument, le prendre en compte
2781
+    if ($voulue = strtolower($voulue)) {
2782
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2783
+            $voulue = lang_dir($voulue);
2784
+        }
2785
+    } else {
2786
+        $voulue = lang_dir();
2787
+    }
2788
+
2789
+    $r = count($r) > 1;
2790
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2791
+    $dir = $r ? 'rtl' : 'ltr';
2792
+    $ndir = $r ? 'ltr' : 'rtl';
2793
+
2794
+    if ($voulue == $dir) {
2795
+        return $css;
2796
+    }
2797
+
2798
+    if (
2799
+        // url absolue
2800
+        preg_match(",^https?:,i", $css)
2801
+        // ou qui contient un ?
2802
+        or (($p = strpos($css, '?')) !== false)
2803
+    ) {
2804
+        $distant = true;
2805
+        $cssf = parse_url($css);
2806
+        $cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2807
+        $cssf = preg_replace(',[?:&=],', "_", $cssf);
2808
+    } else {
2809
+        $distant = false;
2810
+        $cssf = $css;
2811
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2812
+        //propose (rien a faire dans ce cas)
2813
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2814
+        if (@file_exists($f)) {
2815
+            return $f;
2816
+        }
2817
+    }
2818
+
2819
+    // 2.
2820
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2821
+    $f = $dir_var
2822
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2823
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2824
+
2825
+    // la css peut etre distante (url absolue !)
2826
+    if ($distant) {
2827
+        include_spip('inc/distant');
2828
+        $res = recuperer_url($css);
2829
+        if (!$res or !$contenu = $res['page']) {
2830
+            return $css;
2831
+        }
2832
+    } else {
2833
+        if ((@filemtime($f) > @filemtime($css))
2834
+            and (_VAR_MODE != 'recalcul')
2835
+        ) {
2836
+            return $f;
2837
+        }
2838
+        if (!lire_fichier($css, $contenu)) {
2839
+            return $css;
2840
+        }
2841
+    }
2842
+
2843
+
2844
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2845
+    include_spip("lib/csstidy/class.csstidy");
2846
+    $parser = new csstidy();
2847
+    $parser->set_cfg('optimise_shorthands', 0);
2848
+    $parser->set_cfg('reverse_left_and_right', true);
2849
+    $parser->parse($contenu);
2850
+
2851
+    $contenu = $parser->print->plain();
2852
+
2853
+
2854
+    // reperer les @import auxquels il faut propager le direction_css
2855
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2856
+    $src = array();
2857
+    $src_direction_css = array();
2858
+    $src_faux_abs = array();
2859
+    $d = dirname($css);
2860
+    foreach ($regs[1] as $k => $import_css) {
2861
+        $css_direction = direction_css("$d/$import_css", $voulue);
2862
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2863
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2864
+            $css_direction = substr($css_direction, strlen($d) + 1);
2865
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2866
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2867
+            $css_direction = substr($css_direction, strlen($dir_var));
2868
+            $src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2869
+            $css_direction = "/@@@@@@/" . $css_direction;
2870
+        }
2871
+        $src[] = $regs[0][$k];
2872
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
2873
+    }
2874
+    $contenu = str_replace($src, $src_direction_css, $contenu);
2875
+
2876
+    $contenu = urls_absolues_css($contenu, $css);
2877
+
2878
+    // virer les fausses url absolues que l'on a mis dans les import
2879
+    if (count($src_faux_abs)) {
2880
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2881
+    }
2882
+
2883
+    if (!ecrire_fichier($f, $contenu)) {
2884
+        return $css;
2885
+    }
2886
+
2887
+    return $f;
2888 2888
 }
2889 2889
 
2890 2890
 
@@ -2907,43 +2907,43 @@  discard block
 block discarded – undo
2907 2907
  *     - Chemin ou URL du fichier CSS source sinon.
2908 2908
  **/
2909 2909
 function url_absolue_css($css) {
2910
-	if (!preg_match(',\.css$,i', $css, $r)) {
2911
-		return $css;
2912
-	}
2910
+    if (!preg_match(',\.css$,i', $css, $r)) {
2911
+        return $css;
2912
+    }
2913 2913
 
2914
-	$url_absolue_css = url_absolue($css);
2914
+    $url_absolue_css = url_absolue($css);
2915 2915
 
2916
-	$f = basename($css, '.css');
2917
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2918
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2919
-		. '.css';
2916
+    $f = basename($css, '.css');
2917
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
2918
+        . preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2919
+        . '.css';
2920 2920
 
2921
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
2922
-		return $f;
2923
-	}
2921
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
2922
+        return $f;
2923
+    }
2924 2924
 
2925
-	if ($url_absolue_css == $css) {
2926
-		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
2927
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2928
-		) {
2929
-			include_spip('inc/distant');
2930
-			if (!$contenu = recuperer_page($css)) {
2931
-				return $css;
2932
-			}
2933
-		}
2934
-	} elseif (!lire_fichier($css, $contenu)) {
2935
-		return $css;
2936
-	}
2925
+    if ($url_absolue_css == $css) {
2926
+        if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
2927
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2928
+        ) {
2929
+            include_spip('inc/distant');
2930
+            if (!$contenu = recuperer_page($css)) {
2931
+                return $css;
2932
+            }
2933
+        }
2934
+    } elseif (!lire_fichier($css, $contenu)) {
2935
+        return $css;
2936
+    }
2937 2937
 
2938
-	// passer les url relatives a la css d'origine en url absolues
2939
-	$contenu = urls_absolues_css($contenu, $css);
2938
+    // passer les url relatives a la css d'origine en url absolues
2939
+    $contenu = urls_absolues_css($contenu, $css);
2940 2940
 
2941
-	// ecrire la css
2942
-	if (!ecrire_fichier($f, $contenu)) {
2943
-		return $css;
2944
-	}
2941
+    // ecrire la css
2942
+    if (!ecrire_fichier($f, $contenu)) {
2943
+        return $css;
2944
+    }
2945 2945
 
2946
-	return $f;
2946
+    return $f;
2947 2947
 }
2948 2948
 
2949 2949
 
@@ -2977,24 +2977,24 @@  discard block
 block discarded – undo
2977 2977
  *     Valeur trouvée ou valeur par défaut.
2978 2978
  **/
2979 2979
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
2980
-	foreach (explode('/', $cle) as $k) {
2980
+    foreach (explode('/', $cle) as $k) {
2981 2981
 
2982
-		$table = is_string($table) ? @unserialize($table) : $table;
2982
+        $table = is_string($table) ? @unserialize($table) : $table;
2983 2983
 
2984
-		if (is_object($table)) {
2985
-			$table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
2986
-		} elseif (is_array($table)) {
2987
-			if ($conserver_null) {
2988
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
2989
-			} else {
2990
-				$table = isset($table[$k]) ? $table[$k] : $defaut;
2991
-			}
2992
-		} else {
2993
-			$table = $defaut;
2994
-		}
2995
-	}
2984
+        if (is_object($table)) {
2985
+            $table = (($k !== "") and isset($table->$k)) ? $table->$k : $defaut;
2986
+        } elseif (is_array($table)) {
2987
+            if ($conserver_null) {
2988
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
2989
+            } else {
2990
+                $table = isset($table[$k]) ? $table[$k] : $defaut;
2991
+            }
2992
+        } else {
2993
+            $table = $defaut;
2994
+        }
2995
+    }
2996 2996
 
2997
-	return $table;
2997
+    return $table;
2998 2998
 }
2999 2999
 
3000 3000
 /**
@@ -3027,22 +3027,22 @@  discard block
 block discarded – undo
3027 3027
  *     - string : expression trouvée.
3028 3028
  **/
3029 3029
 function filtre_match_dist($texte, $expression, $modif = "UimsS", $capte = 0) {
3030
-	if (intval($modif) and $capte == 0) {
3031
-		$capte = $modif;
3032
-		$modif = "UimsS";
3033
-	}
3034
-	$expression = str_replace("\/", "/", $expression);
3035
-	$expression = str_replace("/", "\/", $expression);
3030
+    if (intval($modif) and $capte == 0) {
3031
+        $capte = $modif;
3032
+        $modif = "UimsS";
3033
+    }
3034
+    $expression = str_replace("\/", "/", $expression);
3035
+    $expression = str_replace("/", "\/", $expression);
3036 3036
 
3037
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3038
-		if (isset($r[$capte])) {
3039
-			return $r[$capte];
3040
-		} else {
3041
-			return true;
3042
-		}
3043
-	}
3037
+    if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3038
+        if (isset($r[$capte])) {
3039
+            return $r[$capte];
3040
+        } else {
3041
+            return true;
3042
+        }
3043
+    }
3044 3044
 
3045
-	return false;
3045
+    return false;
3046 3046
 }
3047 3047
 
3048 3048
 
@@ -3069,10 +3069,10 @@  discard block
 block discarded – undo
3069 3069
  *     Texte
3070 3070
  **/
3071 3071
 function replace($texte, $expression, $replace = '', $modif = "UimsS") {
3072
-	$expression = str_replace("\/", "/", $expression);
3073
-	$expression = str_replace("/", "\/", $expression);
3072
+    $expression = str_replace("\/", "/", $expression);
3073
+    $expression = str_replace("/", "\/", $expression);
3074 3074
 
3075
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3075
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3076 3076
 }
3077 3077
 
3078 3078
 
@@ -3090,21 +3090,21 @@  discard block
 block discarded – undo
3090 3090
  **/
3091 3091
 function traiter_doublons_documents(&$doublons, $letexte) {
3092 3092
 
3093
-	// Verifier dans le texte & les notes (pas beau, helas)
3094
-	$t = $letexte . $GLOBALS['les_notes'];
3093
+    // Verifier dans le texte & les notes (pas beau, helas)
3094
+    $t = $letexte . $GLOBALS['les_notes'];
3095 3095
 
3096
-	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3097
-		and preg_match_all(
3098
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3099
-			$t, $matches, PREG_PATTERN_ORDER)
3100
-	) {
3101
-		if (!isset($doublons['documents'])) {
3102
-			$doublons['documents'] = "";
3103
-		}
3104
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3105
-	}
3096
+    if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3097
+        and preg_match_all(
3098
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3099
+            $t, $matches, PREG_PATTERN_ORDER)
3100
+    ) {
3101
+        if (!isset($doublons['documents'])) {
3102
+            $doublons['documents'] = "";
3103
+        }
3104
+        $doublons['documents'] .= "," . join(',', $matches[1]);
3105
+    }
3106 3106
 
3107
-	return $letexte;
3107
+    return $letexte;
3108 3108
 }
3109 3109
 
3110 3110
 /**
@@ -3118,7 +3118,7 @@  discard block
 block discarded – undo
3118 3118
  * @return string Chaîne vide
3119 3119
  **/
3120 3120
 function vide($texte) {
3121
-	return "";
3121
+    return "";
3122 3122
 }
3123 3123
 
3124 3124
 //
@@ -3147,23 +3147,23 @@  discard block
 block discarded – undo
3147 3147
  *      Code HTML résultant
3148 3148
  **/
3149 3149
 function env_to_params($env, $ignore_params = array()) {
3150
-	$ignore_params = array_merge(
3151
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3152
-		$ignore_params
3153
-	);
3154
-	if (!is_array($env)) {
3155
-		$env = unserialize($env);
3156
-	}
3157
-	$texte = "";
3158
-	if ($env) {
3159
-		foreach ($env as $i => $j) {
3160
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3161
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3162
-			}
3163
-		}
3164
-	}
3165
-
3166
-	return $texte;
3150
+    $ignore_params = array_merge(
3151
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3152
+        $ignore_params
3153
+    );
3154
+    if (!is_array($env)) {
3155
+        $env = unserialize($env);
3156
+    }
3157
+    $texte = "";
3158
+    if ($env) {
3159
+        foreach ($env as $i => $j) {
3160
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3161
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3162
+            }
3163
+        }
3164
+    }
3165
+
3166
+    return $texte;
3167 3167
 }
3168 3168
 
3169 3169
 /**
@@ -3186,23 +3186,23 @@  discard block
 block discarded – undo
3186 3186
  *      Code HTML résultant
3187 3187
  **/
3188 3188
 function env_to_attributs($env, $ignore_params = array()) {
3189
-	$ignore_params = array_merge(
3190
-		array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3191
-		$ignore_params
3192
-	);
3193
-	if (!is_array($env)) {
3194
-		$env = unserialize($env);
3195
-	}
3196
-	$texte = "";
3197
-	if ($env) {
3198
-		foreach ($env as $i => $j) {
3199
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3200
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3201
-			}
3202
-		}
3203
-	}
3189
+    $ignore_params = array_merge(
3190
+        array('id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'),
3191
+        $ignore_params
3192
+    );
3193
+    if (!is_array($env)) {
3194
+        $env = unserialize($env);
3195
+    }
3196
+    $texte = "";
3197
+    if ($env) {
3198
+        foreach ($env as $i => $j) {
3199
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3200
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3201
+            }
3202
+        }
3203
+    }
3204 3204
 
3205
-	return $texte;
3205
+    return $texte;
3206 3206
 }
3207 3207
 
3208 3208
 
@@ -3219,9 +3219,9 @@  discard block
 block discarded – undo
3219 3219
  * @return string Chaînes concaténés
3220 3220
  **/
3221 3221
 function concat() {
3222
-	$args = func_get_args();
3222
+    $args = func_get_args();
3223 3223
 
3224
-	return join('', $args);
3224
+    return join('', $args);
3225 3225
 }
3226 3226
 
3227 3227
 
@@ -3241,23 +3241,23 @@  discard block
 block discarded – undo
3241 3241
  *     Contenu du ou des fichiers, concaténé
3242 3242
  **/
3243 3243
 function charge_scripts($files, $script = true) {
3244
-	$flux = "";
3245
-	foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3246
-		if (!is_string($file)) {
3247
-			continue;
3248
-		}
3249
-		if ($script) {
3250
-			$file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3251
-		}
3252
-		if ($file) {
3253
-			$path = find_in_path($file);
3254
-			if ($path) {
3255
-				$flux .= spip_file_get_contents($path);
3256
-			}
3257
-		}
3258
-	}
3244
+    $flux = "";
3245
+    foreach (is_array($files) ? $files : explode("|", $files) as $file) {
3246
+        if (!is_string($file)) {
3247
+            continue;
3248
+        }
3249
+        if ($script) {
3250
+            $file = preg_match(",^\w+$,", $file) ? "javascript/$file.js" : '';
3251
+        }
3252
+        if ($file) {
3253
+            $path = find_in_path($file);
3254
+            if ($path) {
3255
+                $flux .= spip_file_get_contents($path);
3256
+            }
3257
+        }
3258
+    }
3259 3259
 
3260
-	return $flux;
3260
+    return $flux;
3261 3261
 }
3262 3262
 
3263 3263
 
@@ -3279,64 +3279,64 @@  discard block
 block discarded – undo
3279 3279
  */
3280 3280
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = array()) {
3281 3281
 
3282
-	$img_file = $img;
3283
-	if ($p = strpos($img_file, '?')) {
3284
-		$img_file = substr($img_file,0, $p);
3285
-	}
3286
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3287
-		$img_file = chemin_image($img);
3288
-	}
3289
-	else {
3290
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3291
-			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3292
-			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3293
-			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3294
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3295
-			  and file_exists($variante_svg_generique)) {
3296
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3297
-					$img_file = $variante_svg_size;
3298
-				}
3299
-				else {
3300
-					$img_file = $variante_svg_generique;
3301
-				}
3302
-			}
3303
-		}
3304
-	}
3305
-	if (stripos($atts, 'width') === false) {
3306
-		// utiliser directement l'info de taille presente dans le nom
3307
-		if ((!isset($options['utiliser_suffixe_size'])
3308
-				or $options['utiliser_suffixe_size'] == true
3309
-			  or strpos($img_file, '-xx.svg') !== false)
3310
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3311
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3312
-		) {
3313
-			$largeur = $hauteur = intval($regs[1]);
3314
-		} else {
3315
-			$taille = taille_image($img_file);
3316
-			list($hauteur, $largeur) = $taille;
3317
-			if (!$hauteur or !$largeur) {
3318
-				return "";
3319
-			}
3320
-		}
3321
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3322
-	}
3323
-
3324
-	if (file_exists($img_file)) {
3325
-		$img_file = timestamp($img_file);
3326
-	}
3327
-	if ($alt === false) {
3328
-		$alt = '';
3329
-	}
3330
-	elseif($alt or $alt==='') {
3331
-		$alt = " alt='".attribut_html($alt)."'";
3332
-	}
3333
-	else {
3334
-		$alt = " alt='".attribut_html($title)."'";
3335
-	}
3336
-	return "<img src='$img_file'$alt"
3337
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3338
-	. " " . ltrim($atts)
3339
-	. " />";
3282
+    $img_file = $img;
3283
+    if ($p = strpos($img_file, '?')) {
3284
+        $img_file = substr($img_file,0, $p);
3285
+    }
3286
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3287
+        $img_file = chemin_image($img);
3288
+    }
3289
+    else {
3290
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3291
+            // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3292
+            // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3293
+            if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3294
+              and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3295
+              and file_exists($variante_svg_generique)) {
3296
+                if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3297
+                    $img_file = $variante_svg_size;
3298
+                }
3299
+                else {
3300
+                    $img_file = $variante_svg_generique;
3301
+                }
3302
+            }
3303
+        }
3304
+    }
3305
+    if (stripos($atts, 'width') === false) {
3306
+        // utiliser directement l'info de taille presente dans le nom
3307
+        if ((!isset($options['utiliser_suffixe_size'])
3308
+                or $options['utiliser_suffixe_size'] == true
3309
+              or strpos($img_file, '-xx.svg') !== false)
3310
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3311
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3312
+        ) {
3313
+            $largeur = $hauteur = intval($regs[1]);
3314
+        } else {
3315
+            $taille = taille_image($img_file);
3316
+            list($hauteur, $largeur) = $taille;
3317
+            if (!$hauteur or !$largeur) {
3318
+                return "";
3319
+            }
3320
+        }
3321
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3322
+    }
3323
+
3324
+    if (file_exists($img_file)) {
3325
+        $img_file = timestamp($img_file);
3326
+    }
3327
+    if ($alt === false) {
3328
+        $alt = '';
3329
+    }
3330
+    elseif($alt or $alt==='') {
3331
+        $alt = " alt='".attribut_html($alt)."'";
3332
+    }
3333
+    else {
3334
+        $alt = " alt='".attribut_html($title)."'";
3335
+    }
3336
+    return "<img src='$img_file'$alt"
3337
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3338
+    . " " . ltrim($atts)
3339
+    . " />";
3340 3340
 }
3341 3341
 
3342 3342
 /**
@@ -3348,13 +3348,13 @@  discard block
 block discarded – undo
3348 3348
  * @return string
3349 3349
  */
3350 3350
 function http_style_background($img, $att = '', $size=null) {
3351
-	if ($size and is_numeric($size)){
3352
-		$size = trim($size) . "px";
3353
-	}
3354
-	return " style='background" .
3355
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3356
-		. ($size ? "background-size:{$size};" : '')
3357
-		. "'";
3351
+    if ($size and is_numeric($size)){
3352
+        $size = trim($size) . "px";
3353
+    }
3354
+    return " style='background" .
3355
+        ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3356
+        . ($size ? "background-size:{$size};" : '')
3357
+        . "'";
3358 3358
 }
3359 3359
 
3360 3360
 /**
@@ -3370,17 +3370,17 @@  discard block
 block discarded – undo
3370 3370
  *     Code HTML de la balise IMG
3371 3371
  */
3372 3372
 function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3373
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3374
-	// ecriture courte : on donne le width en 2e arg
3375
-	if (empty($width) and is_numeric($alt)) {
3376
-		$width = $alt;
3377
-		$alt = '';
3378
-	}
3379
-	if ($width) {
3380
-		$atts .= " width='{$width}'";
3381
-	}
3382
-	return http_img_pack($img, $alt, $atts, '',
3383
-		array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3373
+    $atts = $class ? " class='" . attribut_html($class) . "'" : '';
3374
+    // ecriture courte : on donne le width en 2e arg
3375
+    if (empty($width) and is_numeric($alt)) {
3376
+        $width = $alt;
3377
+        $alt = '';
3378
+    }
3379
+    if ($width) {
3380
+        $atts .= " width='{$width}'";
3381
+    }
3382
+    return http_img_pack($img, $alt, $atts, '',
3383
+        array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3384 3384
 }
3385 3385
 
3386 3386
 
@@ -3396,42 +3396,42 @@  discard block
 block discarded – undo
3396 3396
  * @return string
3397 3397
  */
3398 3398
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3399
-	$img_file = $img;
3400
-	if ($p = strpos($img_file, '?')) {
3401
-		$img_file = substr($img_file,0, $p);
3402
-	}
3399
+    $img_file = $img;
3400
+    if ($p = strpos($img_file, '?')) {
3401
+        $img_file = substr($img_file,0, $p);
3402
+    }
3403 3403
 
3404
-	if (!$img_file or !$svg = file_get_contents($img_file)) {
3405
-		return '';
3406
-	}
3404
+    if (!$img_file or !$svg = file_get_contents($img_file)) {
3405
+        return '';
3406
+    }
3407 3407
 
3408
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3409
-		return '';
3410
-	}
3411
-	$balise_svg = $match[0];
3412
-	$balise_svg_source = $balise_svg;
3408
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3409
+        return '';
3410
+    }
3411
+    $balise_svg = $match[0];
3412
+    $balise_svg_source = $balise_svg;
3413 3413
 
3414
-	// entete XML à supprimer
3415
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3414
+    // entete XML à supprimer
3415
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3416 3416
 
3417
-	// IE est toujours mon ami
3418
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3419
-	if ($class) {
3420
-		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3421
-	}
3422
-	if ($alt){
3423
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3424
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3425
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3426
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3427
-		$balise_svg .= $title;
3428
-	}
3429
-	else {
3430
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3431
-	}
3432
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3417
+    // IE est toujours mon ami
3418
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3419
+    if ($class) {
3420
+        $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3421
+    }
3422
+    if ($alt){
3423
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3424
+        $id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3425
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3426
+        $title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3427
+        $balise_svg .= $title;
3428
+    }
3429
+    else {
3430
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3431
+    }
3432
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3433 3433
 
3434
-	return $svg;
3434
+    return $svg;
3435 3435
 }
3436 3436
 
3437 3437
 
@@ -3454,17 +3454,17 @@  discard block
 block discarded – undo
3454 3454
  *     Code HTML résultant
3455 3455
  **/
3456 3456
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3457
-	$texte = '';
3458
-	if (is_array($tableau)) {
3459
-		foreach ($tableau as $k => $v) {
3460
-			$res = recuperer_fond('modeles/' . $modele,
3461
-				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3462
-			);
3463
-			$texte .= $res;
3464
-		}
3465
-	}
3457
+    $texte = '';
3458
+    if (is_array($tableau)) {
3459
+        foreach ($tableau as $k => $v) {
3460
+            $res = recuperer_fond('modeles/' . $modele,
3461
+                array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3462
+            );
3463
+            $texte .= $res;
3464
+        }
3465
+    }
3466 3466
 
3467
-	return $texte;
3467
+    return $texte;
3468 3468
 }
3469 3469
 
3470 3470
 
@@ -3489,37 +3489,37 @@  discard block
 block discarded – undo
3489 3489
  *         - tout : retourne toutes les informations du plugin actif
3490 3490
  **/
3491 3491
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3492
-	include_spip('inc/plugin');
3493
-	$plugin = strtoupper($plugin);
3494
-	$plugins_actifs = liste_plugin_actifs();
3495
-
3496
-	if (!$plugin) {
3497
-		return serialize(array_keys($plugins_actifs));
3498
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3499
-		return '';
3500
-	} elseif (($type_info == 'est_actif') and !$reload) {
3501
-		return $plugins_actifs[$plugin] ? 1 : 0;
3502
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3503
-		return $plugins_actifs[$plugin][$type_info];
3504
-	} else {
3505
-		$get_infos = charger_fonction('get_infos', 'plugins');
3506
-		// On prend en compte les extensions
3507
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3508
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3509
-		} else {
3510
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3511
-		}
3512
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3513
-			return '';
3514
-		}
3515
-		if ($type_info == 'tout') {
3516
-			return $infos;
3517
-		} elseif ($type_info == 'est_actif') {
3518
-			return $infos ? 1 : 0;
3519
-		} else {
3520
-			return strval($infos[$type_info]);
3521
-		}
3522
-	}
3492
+    include_spip('inc/plugin');
3493
+    $plugin = strtoupper($plugin);
3494
+    $plugins_actifs = liste_plugin_actifs();
3495
+
3496
+    if (!$plugin) {
3497
+        return serialize(array_keys($plugins_actifs));
3498
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3499
+        return '';
3500
+    } elseif (($type_info == 'est_actif') and !$reload) {
3501
+        return $plugins_actifs[$plugin] ? 1 : 0;
3502
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3503
+        return $plugins_actifs[$plugin][$type_info];
3504
+    } else {
3505
+        $get_infos = charger_fonction('get_infos', 'plugins');
3506
+        // On prend en compte les extensions
3507
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3508
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3509
+        } else {
3510
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3511
+        }
3512
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3513
+            return '';
3514
+        }
3515
+        if ($type_info == 'tout') {
3516
+            return $infos;
3517
+        } elseif ($type_info == 'est_actif') {
3518
+            return $infos ? 1 : 0;
3519
+        } else {
3520
+            return strval($infos[$type_info]);
3521
+        }
3522
+    }
3523 3523
 }
3524 3524
 
3525 3525
 
@@ -3546,9 +3546,9 @@  discard block
 block discarded – undo
3546 3546
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3547 3547
  */
3548 3548
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3549
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3549
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3550 3550
 
3551
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3551
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3552 3552
 }
3553 3553
 
3554 3554
 
@@ -3578,13 +3578,13 @@  discard block
 block discarded – undo
3578 3578
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3579 3579
  */
3580 3580
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3581
-	static $puce_statut = null;
3582
-	if (!$puce_statut) {
3583
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3584
-	}
3581
+    static $puce_statut = null;
3582
+    if (!$puce_statut) {
3583
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3584
+    }
3585 3585
 
3586
-	return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3587
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3586
+    return $puce_statut($id_objet, $statut, $id_parent, $objet, false,
3587
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false);
3588 3588
 }
3589 3589
 
3590 3590
 
@@ -3611,100 +3611,100 @@  discard block
 block discarded – undo
3611 3611
  *   hash du contexte
3612 3612
  */
3613 3613
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3614
-	if (is_string($c)
3615
-		and @unserialize($c) !== false
3616
-	) {
3617
-		$c = unserialize($c);
3618
-	}
3619
-
3620
-	// supprimer les parametres debut_x
3621
-	// pour que la pagination ajax ne soit pas plantee
3622
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3623
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3624
-	if (is_array($c)) {
3625
-		foreach ($c as $k => $v) {
3626
-			if (strpos($k, 'debut_') === 0) {
3627
-				unset($c[$k]);
3628
-			}
3629
-		}
3630
-	}
3631
-
3632
-	if (!function_exists('calculer_cle_action')) {
3633
-		include_spip("inc/securiser_action");
3634
-	}
3635
-
3636
-	$c = serialize($c);
3637
-	$cle = calculer_cle_action($form . $c);
3638
-	$c = "$cle:$c";
3639
-
3640
-	// on ne stocke pas les contextes dans des fichiers en cache
3641
-	// par defaut, sauf si cette configuration a été forcée
3642
-	// OU que la longueur de l’argument géneré est plus long
3643
-	// que ce qui est toléré.
3644
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3645
-	if (!$cache_contextes_ajax) {
3646
-		$env = $c;
3647
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3648
-			$env = gzdeflate($env);
3649
-			// https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3650
-			if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3651
-				$cache_contextes_ajax = true;
3652
-				spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3653
-			}
3654
-		}
3655
-		$env = _xor($env);
3656
-		$env = base64_encode($env);
3657
-		$len = strlen($env);
3658
-		// Si l’url est trop longue pour le navigateur
3659
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3660
-		if ($len > $max_len) {
3661
-			$cache_contextes_ajax = true;
3662
-			spip_log("Contextes AJAX forces en fichiers !"
3663
-				. " Cela arrive lorsque la valeur du contexte" 
3664
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3665
-				, _LOG_AVERTISSEMENT);
3666
-		}
3667
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3668
-		elseif (
3669
-			$max_len = @ini_get('suhosin.get.max_value_length')
3670
-			and $max_len < $len
3671
-		) {
3672
-			$cache_contextes_ajax = true;
3673
-			spip_log("Contextes AJAX forces en fichiers !"
3674
-				. " Cela arrive lorsque la valeur du contexte"
3675
-				. " depasse la longueur maximale autorisee par Suhosin"
3676
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3677
-				. " Vous devriez modifier les parametres de Suhosin"
3678
-				. " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3679
-		} 
3680
-
3681
-	}
3682
-
3683
-	if ($cache_contextes_ajax) {
3684
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3685
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3686
-		$md5 = md5($c);
3687
-		ecrire_fichier("$dir/c$md5", $c);
3688
-		$env = $md5;
3689
-	}
3690
-
3691
-	if ($emboite === null) {
3692
-		return $env;
3693
-	}
3694
-	if (!trim($emboite)) {
3695
-		return "";
3696
-	}
3697
-	// toujours encoder l'url source dans le bloc ajax
3698
-	$r = self();
3699
-	$r = ' data-origin="' . $r . '"';
3700
-	$class = 'ajaxbloc';
3701
-	if ($ajaxid and is_string($ajaxid)) {
3702
-		// ajaxid est normalement conforme a un nom de classe css
3703
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3704
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3705
-	}
3706
-
3707
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3614
+    if (is_string($c)
3615
+        and @unserialize($c) !== false
3616
+    ) {
3617
+        $c = unserialize($c);
3618
+    }
3619
+
3620
+    // supprimer les parametres debut_x
3621
+    // pour que la pagination ajax ne soit pas plantee
3622
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3623
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3624
+    if (is_array($c)) {
3625
+        foreach ($c as $k => $v) {
3626
+            if (strpos($k, 'debut_') === 0) {
3627
+                unset($c[$k]);
3628
+            }
3629
+        }
3630
+    }
3631
+
3632
+    if (!function_exists('calculer_cle_action')) {
3633
+        include_spip("inc/securiser_action");
3634
+    }
3635
+
3636
+    $c = serialize($c);
3637
+    $cle = calculer_cle_action($form . $c);
3638
+    $c = "$cle:$c";
3639
+
3640
+    // on ne stocke pas les contextes dans des fichiers en cache
3641
+    // par defaut, sauf si cette configuration a été forcée
3642
+    // OU que la longueur de l’argument géneré est plus long
3643
+    // que ce qui est toléré.
3644
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3645
+    if (!$cache_contextes_ajax) {
3646
+        $env = $c;
3647
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3648
+            $env = gzdeflate($env);
3649
+            // https://core.spip.net/issues/2667 | https://bugs.php.net/bug.php?id=61287
3650
+            if ((PHP_VERSION_ID == 50400) and !@gzinflate($env)) {
3651
+                $cache_contextes_ajax = true;
3652
+                spip_log("Contextes AJAX forces en fichiers ! Erreur PHP 5.4.0", _LOG_AVERTISSEMENT);
3653
+            }
3654
+        }
3655
+        $env = _xor($env);
3656
+        $env = base64_encode($env);
3657
+        $len = strlen($env);
3658
+        // Si l’url est trop longue pour le navigateur
3659
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3660
+        if ($len > $max_len) {
3661
+            $cache_contextes_ajax = true;
3662
+            spip_log("Contextes AJAX forces en fichiers !"
3663
+                . " Cela arrive lorsque la valeur du contexte" 
3664
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len."
3665
+                , _LOG_AVERTISSEMENT);
3666
+        }
3667
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3668
+        elseif (
3669
+            $max_len = @ini_get('suhosin.get.max_value_length')
3670
+            and $max_len < $len
3671
+        ) {
3672
+            $cache_contextes_ajax = true;
3673
+            spip_log("Contextes AJAX forces en fichiers !"
3674
+                . " Cela arrive lorsque la valeur du contexte"
3675
+                . " depasse la longueur maximale autorisee par Suhosin"
3676
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3677
+                . " Vous devriez modifier les parametres de Suhosin"
3678
+                . " pour accepter au moins 1024 caracteres.", _LOG_AVERTISSEMENT);
3679
+        } 
3680
+
3681
+    }
3682
+
3683
+    if ($cache_contextes_ajax) {
3684
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3685
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3686
+        $md5 = md5($c);
3687
+        ecrire_fichier("$dir/c$md5", $c);
3688
+        $env = $md5;
3689
+    }
3690
+
3691
+    if ($emboite === null) {
3692
+        return $env;
3693
+    }
3694
+    if (!trim($emboite)) {
3695
+        return "";
3696
+    }
3697
+    // toujours encoder l'url source dans le bloc ajax
3698
+    $r = self();
3699
+    $r = ' data-origin="' . $r . '"';
3700
+    $class = 'ajaxbloc';
3701
+    if ($ajaxid and is_string($ajaxid)) {
3702
+        // ajaxid est normalement conforme a un nom de classe css
3703
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3704
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3705
+    }
3706
+
3707
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3708 3708
 }
3709 3709
 
3710 3710
 /**
@@ -3724,36 +3724,36 @@  discard block
 block discarded – undo
3724 3724
  *   - false : erreur de décodage
3725 3725
  */
3726 3726
 function decoder_contexte_ajax($c, $form = '') {
3727
-	if (!function_exists('calculer_cle_action')) {
3728
-		include_spip("inc/securiser_action");
3729
-	}
3730
-	if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3731
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3732
-		and lire_fichier("$dir/c$c", $contexte)
3733
-	) {
3734
-		$c = $contexte;
3735
-	} else {
3736
-		$c = @base64_decode($c);
3737
-		$c = _xor($c);
3738
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3739
-			$c = @gzinflate($c);
3740
-		}
3741
-	}
3742
-
3743
-	// extraire la signature en debut de contexte
3744
-	// et la verifier avant de deserializer
3745
-	// format : signature:donneesserializees
3746
-	if ($p = strpos($c,":")){
3747
-		$cle = substr($c,0,$p);
3748
-		$c = substr($c,$p+1);
3749
-
3750
-		if ($cle == calculer_cle_action($form . $c)) {
3751
-			$env = @unserialize($c);
3752
-			return $env;
3753
-		}
3754
-	}
3755
-
3756
-	return false;
3727
+    if (!function_exists('calculer_cle_action')) {
3728
+        include_spip("inc/securiser_action");
3729
+    }
3730
+    if (((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
3731
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
3732
+        and lire_fichier("$dir/c$c", $contexte)
3733
+    ) {
3734
+        $c = $contexte;
3735
+    } else {
3736
+        $c = @base64_decode($c);
3737
+        $c = _xor($c);
3738
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3739
+            $c = @gzinflate($c);
3740
+        }
3741
+    }
3742
+
3743
+    // extraire la signature en debut de contexte
3744
+    // et la verifier avant de deserializer
3745
+    // format : signature:donneesserializees
3746
+    if ($p = strpos($c,":")){
3747
+        $cle = substr($c,0,$p);
3748
+        $c = substr($c,$p+1);
3749
+
3750
+        if ($cle == calculer_cle_action($form . $c)) {
3751
+            $env = @unserialize($c);
3752
+            return $env;
3753
+        }
3754
+    }
3755
+
3756
+    return false;
3757 3757
 }
3758 3758
 
3759 3759
 
@@ -3771,20 +3771,20 @@  discard block
 block discarded – undo
3771 3771
  *    Message décrypté ou encrypté
3772 3772
  **/
3773 3773
 function _xor($message, $key = null) {
3774
-	if (is_null($key)) {
3775
-		if (!function_exists('calculer_cle_action')) {
3776
-			include_spip("inc/securiser_action");
3777
-		}
3778
-		$key = pack("H*", calculer_cle_action('_xor'));
3779
-	}
3774
+    if (is_null($key)) {
3775
+        if (!function_exists('calculer_cle_action')) {
3776
+            include_spip("inc/securiser_action");
3777
+        }
3778
+        $key = pack("H*", calculer_cle_action('_xor'));
3779
+    }
3780 3780
 
3781
-	$keylen = strlen($key);
3782
-	$messagelen = strlen($message);
3783
-	for ($i = 0; $i < $messagelen; $i++) {
3784
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3785
-	}
3781
+    $keylen = strlen($key);
3782
+    $messagelen = strlen($message);
3783
+    for ($i = 0; $i < $messagelen; $i++) {
3784
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3785
+    }
3786 3786
 
3787
-	return $message;
3787
+    return $message;
3788 3788
 }
3789 3789
 
3790 3790
 /**
@@ -3842,22 +3842,22 @@  discard block
 block discarded – undo
3842 3842
  *   Code HTML
3843 3843
  */
3844 3844
 function lien_ou_expose($url, $libelle = null, $on = false, $class = "", $title = "", $rel = "", $evt = '') {
3845
-	if ($on) {
3846
-		$bal = "strong";
3847
-		$att = "class='on'";
3848
-	} else {
3849
-		$bal = 'a';
3850
-		$att = "href='$url'"
3851
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3852
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3853
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3854
-			. $evt;
3855
-	}
3856
-	if ($libelle === null) {
3857
-		$libelle = $url;
3858
-	}
3845
+    if ($on) {
3846
+        $bal = "strong";
3847
+        $att = "class='on'";
3848
+    } else {
3849
+        $bal = 'a';
3850
+        $att = "href='$url'"
3851
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
3852
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
3853
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3854
+            . $evt;
3855
+    }
3856
+    if ($libelle === null) {
3857
+        $libelle = $url;
3858
+    }
3859 3859
 
3860
-	return "<$bal $att>$libelle</$bal>";
3860
+    return "<$bal $att>$libelle</$bal>";
3861 3861
 }
3862 3862
 
3863 3863
 
@@ -3874,18 +3874,18 @@  discard block
 block discarded – undo
3874 3874
  * @return string : la chaine de langue finale en utilisant la fonction _T()
3875 3875
  */
3876 3876
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = array()) {
3877
-	if (!is_numeric($nb) or $nb == 0) {
3878
-		return "";
3879
-	}
3880
-	if (!is_array($vars)) {
3881
-		return "";
3882
-	}
3883
-	$vars[$var] = $nb;
3884
-	if ($nb >= 2) {
3885
-		return _T($chaine_plusieurs, $vars);
3886
-	} else {
3887
-		return _T($chaine_un, $vars);
3888
-	}
3877
+    if (!is_numeric($nb) or $nb == 0) {
3878
+        return "";
3879
+    }
3880
+    if (!is_array($vars)) {
3881
+        return "";
3882
+    }
3883
+    $vars[$var] = $nb;
3884
+    if ($nb >= 2) {
3885
+        return _T($chaine_plusieurs, $vars);
3886
+    } else {
3887
+        return _T($chaine_un, $vars);
3888
+    }
3889 3889
 }
3890 3890
 
3891 3891
 
@@ -3910,56 +3910,56 @@  discard block
 block discarded – undo
3910 3910
  * @return string
3911 3911
  */
3912 3912
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
3913
-	if (in_array($fonction, array("del", "supprimer.gif"))) {
3914
-		$class .= ' danger';
3915
-	} elseif ($fonction == "rien.gif") {
3916
-		$fonction = "";
3917
-	} elseif ($fonction == "delsafe") {
3918
-		$fonction = "del";
3919
-	}
3920
-
3921
-	$fond_origine = $fond;
3922
-	// remappage des icone : article-24.png+new => article-new-24.png
3923
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
3924
-		list($fond, $fonction) = $icone_renommer($fond, $fonction);
3925
-	}
3926
-
3927
-	// ajouter le type d'objet dans la class de l'icone
3928
-	$class .= " " . substr(basename($fond), 0, -4);
3929
-
3930
-	$alt = attribut_html($texte);
3931
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
3932
-
3933
-	$ajax = "";
3934
-	if (strpos($class, "ajax") !== false) {
3935
-		$ajax = "ajax";
3936
-		if (strpos($class, "preload") !== false) {
3937
-			$ajax .= " preload";
3938
-		}
3939
-		if (strpos($class, "nocache") !== false) {
3940
-			$ajax .= " nocache";
3941
-		}
3942
-		$ajax = " class='$ajax'";
3943
-	}
3944
-
3945
-	$size = 24;
3946
-	if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
3947
-	  or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
3948
-		$size = $match[1];
3949
-	}
3950
-
3951
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
3952
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
3953
-
3954
-	if ($type == 'lien') {
3955
-		return "<span class='icone s$size $class'>"
3956
-		. "<a href='$lien'$title$ajax$javascript>"
3957
-		. $icone
3958
-		. "<b>$texte</b>"
3959
-		. "</a></span>\n";
3960
-	} else {
3961
-		return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
3962
-	}
3913
+    if (in_array($fonction, array("del", "supprimer.gif"))) {
3914
+        $class .= ' danger';
3915
+    } elseif ($fonction == "rien.gif") {
3916
+        $fonction = "";
3917
+    } elseif ($fonction == "delsafe") {
3918
+        $fonction = "del";
3919
+    }
3920
+
3921
+    $fond_origine = $fond;
3922
+    // remappage des icone : article-24.png+new => article-new-24.png
3923
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
3924
+        list($fond, $fonction) = $icone_renommer($fond, $fonction);
3925
+    }
3926
+
3927
+    // ajouter le type d'objet dans la class de l'icone
3928
+    $class .= " " . substr(basename($fond), 0, -4);
3929
+
3930
+    $alt = attribut_html($texte);
3931
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
3932
+
3933
+    $ajax = "";
3934
+    if (strpos($class, "ajax") !== false) {
3935
+        $ajax = "ajax";
3936
+        if (strpos($class, "preload") !== false) {
3937
+            $ajax .= " preload";
3938
+        }
3939
+        if (strpos($class, "nocache") !== false) {
3940
+            $ajax .= " nocache";
3941
+        }
3942
+        $ajax = " class='$ajax'";
3943
+    }
3944
+
3945
+    $size = 24;
3946
+    if (preg_match("/-([0-9]{1,3})[.](gif|png|svg)$/i", $fond, $match)
3947
+      or preg_match("/-([0-9]{1,3})([.](gif|png|svg))?$/i", $fond_origine, $match)) {
3948
+        $size = $match[1];
3949
+    }
3950
+
3951
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
3952
+    $icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
3953
+
3954
+    if ($type == 'lien') {
3955
+        return "<span class='icone s$size $class'>"
3956
+        . "<a href='$lien'$title$ajax$javascript>"
3957
+        . $icone
3958
+        . "<b>$texte</b>"
3959
+        . "</a></span>\n";
3960
+    } else {
3961
+        return bouton_action("$icone<b>$texte</b>", $lien, "icone s$size $class", $javascript, $alt);
3962
+    }
3963 3963
 }
3964 3964
 
3965 3965
 /**
@@ -3983,7 +3983,7 @@  discard block
 block discarded – undo
3983 3983
  *     Code HTML du lien
3984 3984
  **/
3985 3985
 function icone_base($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
3986
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
3986
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
3987 3987
 }
3988 3988
 
3989 3989
 /**
@@ -4018,7 +4018,7 @@  discard block
 block discarded – undo
4018 4018
  *     Code HTML du lien
4019 4019
  **/
4020 4020
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4021
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4021
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4022 4022
 }
4023 4023
 
4024 4024
 /**
@@ -4063,7 +4063,7 @@  discard block
 block discarded – undo
4063 4063
  *     Code HTML du lien
4064 4064
  **/
4065 4065
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") {
4066
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4066
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4067 4067
 }
4068 4068
 
4069 4069
 /**
@@ -4094,7 +4094,7 @@  discard block
 block discarded – undo
4094 4094
  *     Code HTML du lien
4095 4095
  **/
4096 4096
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = "", $class = "", $confirm = "") {
4097
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4097
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, "horizontale $class", $confirm);
4098 4098
 }
4099 4099
 
4100 4100
 /**
@@ -4124,7 +4124,7 @@  discard block
 block discarded – undo
4124 4124
  *     Code HTML du lien
4125 4125
  */
4126 4126
 function filtre_icone_dist($lien, $texte, $fond, $align = "", $fonction = "", $class = "", $javascript = "") {
4127
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4127
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4128 4128
 }
4129 4129
 
4130 4130
 
@@ -4172,26 +4172,26 @@  discard block
 block discarded – undo
4172 4172
  * @return string Code CSS
4173 4173
  */
4174 4174
 function bando_images_background() {
4175
-	include_spip('inc/bandeau');
4176
-	// recuperer tous les boutons et leurs images
4177
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4175
+    include_spip('inc/bandeau');
4176
+    // recuperer tous les boutons et leurs images
4177
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4178 4178
 
4179
-	$res = "";
4180
-	foreach ($boutons as $page => $detail) {
4181
-		if ($detail->icone and strlen(trim($detail->icone))) {
4182
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4183
-		}
4184
-		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4185
-		if (is_array($detail->sousmenu)) {
4186
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4187
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4188
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4189
-				}
4190
-			}
4191
-		}
4192
-	}
4179
+    $res = "";
4180
+    foreach ($boutons as $page => $detail) {
4181
+        if ($detail->icone and strlen(trim($detail->icone))) {
4182
+            $res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4183
+        }
4184
+        $selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4185
+        if (is_array($detail->sousmenu)) {
4186
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4187
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4188
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4189
+                }
4190
+            }
4191
+        }
4192
+    }
4193 4193
 
4194
-	return $res;
4194
+    return $res;
4195 4195
 }
4196 4196
 
4197 4197
 /**
@@ -4210,19 +4210,19 @@  discard block
 block discarded – undo
4210 4210
  * @return string
4211 4211
  */
4212 4212
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4213
-	if ($confirm) {
4214
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4215
-		if ($callback) {
4216
-			$callback = "$confirm?($callback):false";
4217
-		} else {
4218
-			$callback = $confirm;
4219
-		}
4220
-	}
4221
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4222
-	$title = $title ? " title='$title'" : "";
4213
+    if ($confirm) {
4214
+        $confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4215
+        if ($callback) {
4216
+            $callback = "$confirm?($callback):false";
4217
+        } else {
4218
+            $callback = $confirm;
4219
+        }
4220
+    }
4221
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4222
+    $title = $title ? " title='$title'" : "";
4223 4223
 
4224
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4225
-	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4224
+    return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4225
+    . "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4226 4226
 }
4227 4227
 
4228 4228
 /**
@@ -4243,78 +4243,78 @@  discard block
 block discarded – undo
4243 4243
  * @return string
4244 4244
  */
4245 4245
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = "") {
4246
-	static $trouver_table = null;
4247
-	static $objets;
4248
-
4249
-	// On verifie qu'on a tout ce qu'il faut
4250
-	$id_objet = intval($id_objet);
4251
-	if (!($id_objet and $type_objet and $info)) {
4252
-		return '';
4253
-	}
4254
-
4255
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4256
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4257
-		return '';
4258
-	}
4259
-
4260
-	// Si on demande l'url, on retourne direct la fonction
4261
-	if ($info == 'url') {
4262
-		return generer_url_entite($id_objet, $type_objet);
4263
-	}
4264
-
4265
-	// Sinon on va tout chercher dans la table et on garde en memoire
4266
-	$demande_titre = ($info == 'titre');
4267
-
4268
-	// 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
4269
-	if (!isset($objets[$type_objet][$id_objet])
4270
-		or
4271
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4272
-	) {
4273
-		if (!$trouver_table) {
4274
-			$trouver_table = charger_fonction('trouver_table', 'base');
4275
-		}
4276
-		$desc = $trouver_table(table_objet_sql($type_objet));
4277
-		if (!$desc) {
4278
-			return $objets[$type_objet] = false;
4279
-		}
4280
-
4281
-		// Si on demande le titre, on le gere en interne
4282
-		$champ_titre = "";
4283
-		if ($demande_titre) {
4284
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4285
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4286
-		}
4287
-		include_spip('base/abstract_sql');
4288
-		include_spip('base/connect_sql');
4289
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4290
-			'*' . $champ_titre,
4291
-			$desc['table_sql'],
4292
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4293
-		);
4294
-	}
4295
-
4296
-	// Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4297
-	if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4298
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4299
-	} // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4300
-	else {
4301
-		if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4302
-			$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4303
-		} // Sinon on prend directement le champ SQL tel quel
4304
-		else {
4305
-			$info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4306
-		}
4307
-	}
4308
-
4309
-	// On va ensuite appliquer les traitements automatiques si besoin
4310
-	if (!$etoile) {
4311
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4312
-		// mais ce fonctionnement est a ameliorer !
4313
-		$info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4314
-			array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4315
-	}
4316
-
4317
-	return $info_generee;
4246
+    static $trouver_table = null;
4247
+    static $objets;
4248
+
4249
+    // On verifie qu'on a tout ce qu'il faut
4250
+    $id_objet = intval($id_objet);
4251
+    if (!($id_objet and $type_objet and $info)) {
4252
+        return '';
4253
+    }
4254
+
4255
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4256
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4257
+        return '';
4258
+    }
4259
+
4260
+    // Si on demande l'url, on retourne direct la fonction
4261
+    if ($info == 'url') {
4262
+        return generer_url_entite($id_objet, $type_objet);
4263
+    }
4264
+
4265
+    // Sinon on va tout chercher dans la table et on garde en memoire
4266
+    $demande_titre = ($info == 'titre');
4267
+
4268
+    // 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
4269
+    if (!isset($objets[$type_objet][$id_objet])
4270
+        or
4271
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4272
+    ) {
4273
+        if (!$trouver_table) {
4274
+            $trouver_table = charger_fonction('trouver_table', 'base');
4275
+        }
4276
+        $desc = $trouver_table(table_objet_sql($type_objet));
4277
+        if (!$desc) {
4278
+            return $objets[$type_objet] = false;
4279
+        }
4280
+
4281
+        // Si on demande le titre, on le gere en interne
4282
+        $champ_titre = "";
4283
+        if ($demande_titre) {
4284
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4285
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4286
+        }
4287
+        include_spip('base/abstract_sql');
4288
+        include_spip('base/connect_sql');
4289
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4290
+            '*' . $champ_titre,
4291
+            $desc['table_sql'],
4292
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4293
+        );
4294
+    }
4295
+
4296
+    // Si la fonction generer_TRUC_TYPE existe, on l'utilise pour formater $info_generee
4297
+    if ($generer = charger_fonction("generer_${info}_${type_objet}", '', true)) {
4298
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet]);
4299
+    } // Si la fonction generer_TRUC_entite existe, on l'utilise pour formater $info_generee
4300
+    else {
4301
+        if ($generer = charger_fonction("generer_${info}_entite", '', true)) {
4302
+            $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet]);
4303
+        } // Sinon on prend directement le champ SQL tel quel
4304
+        else {
4305
+            $info_generee = (isset($objets[$type_objet][$id_objet][$info]) ? $objets[$type_objet][$id_objet][$info] : '');
4306
+        }
4307
+    }
4308
+
4309
+    // On va ensuite appliquer les traitements automatiques si besoin
4310
+    if (!$etoile) {
4311
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4312
+        // mais ce fonctionnement est a ameliorer !
4313
+        $info_generee = appliquer_traitement_champ($info_generee, $info, table_objet($type_objet),
4314
+            array('id_objet' => $id_objet, 'objet' => $type_objet, ''));
4315
+    }
4316
+
4317
+    return $info_generee;
4318 4318
 }
4319 4319
 
4320 4320
 /**
@@ -4328,44 +4328,44 @@  discard block
 block discarded – undo
4328 4328
  * @return string
4329 4329
  */
4330 4330
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = array(), $connect = '') {
4331
-	if (!$champ) {
4332
-		return $texte;
4333
-	}
4331
+    if (!$champ) {
4332
+        return $texte;
4333
+    }
4334 4334
 	
4335
-	// On charge toujours les filtres de texte car la majorité des traitements les utilisent
4336
-	// et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4337
-	include_spip('inc/texte');
4335
+    // On charge toujours les filtres de texte car la majorité des traitements les utilisent
4336
+    // et il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4337
+    include_spip('inc/texte');
4338 4338
 	
4339
-	$champ = strtoupper($champ);
4340
-	$traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4341
-	if (!$traitements or !is_array($traitements)) {
4342
-		return $texte;
4343
-	}
4339
+    $champ = strtoupper($champ);
4340
+    $traitements = isset($GLOBALS['table_des_traitements'][$champ]) ? $GLOBALS['table_des_traitements'][$champ] : false;
4341
+    if (!$traitements or !is_array($traitements)) {
4342
+        return $texte;
4343
+    }
4344 4344
 
4345
-	$traitement = '';
4346
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4347
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4348
-		$table_objet = table_objet($table_objet);
4349
-		if (isset($traitements[$table_objet])) {
4350
-			$traitement = $traitements[$table_objet];
4351
-		}
4352
-	}
4353
-	if (!$traitement and isset($traitements[0])) {
4354
-		$traitement = $traitements[0];
4355
-	}
4356
-	// (sinon prendre le premier de la liste par defaut ?)
4345
+    $traitement = '';
4346
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4347
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4348
+        $table_objet = table_objet($table_objet);
4349
+        if (isset($traitements[$table_objet])) {
4350
+            $traitement = $traitements[$table_objet];
4351
+        }
4352
+    }
4353
+    if (!$traitement and isset($traitements[0])) {
4354
+        $traitement = $traitements[0];
4355
+    }
4356
+    // (sinon prendre le premier de la liste par defaut ?)
4357 4357
 
4358
-	if (!$traitement) {
4359
-		return $texte;
4360
-	}
4358
+    if (!$traitement) {
4359
+        return $texte;
4360
+    }
4361 4361
 
4362
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4362
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4363 4363
 
4364
-	// Fournir $connect et $Pile[0] au traitement si besoin
4365
-	$Pile = array(0 => $env);
4366
-	eval("\$texte = $traitement;");
4364
+    // Fournir $connect et $Pile[0] au traitement si besoin
4365
+    $Pile = array(0 => $env);
4366
+    eval("\$texte = $traitement;");
4367 4367
 
4368
-	return $texte;
4368
+    return $texte;
4369 4369
 }
4370 4370
 
4371 4371
 
@@ -4379,21 +4379,21 @@  discard block
 block discarded – undo
4379 4379
  * @return string
4380 4380
  */
4381 4381
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4382
-	include_spip('inc/liens');
4383
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4384
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4385
-	// le raccourcis n'est plus valide
4386
-	$titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4387
-	// on essaye avec generer_info_entite ?
4388
-	if (!strlen($titre) and !$connect) {
4389
-		$titre = generer_info_entite($id_objet, $objet, 'titre');
4390
-	}
4391
-	if (!strlen($titre)) {
4392
-		$titre = _T('info_sans_titre');
4393
-	}
4394
-	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4382
+    include_spip('inc/liens');
4383
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4384
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4385
+    // le raccourcis n'est plus valide
4386
+    $titre = isset($titre['titre']) ? typo($titre['titre']) : '';
4387
+    // on essaye avec generer_info_entite ?
4388
+    if (!strlen($titre) and !$connect) {
4389
+        $titre = generer_info_entite($id_objet, $objet, 'titre');
4390
+    }
4391
+    if (!strlen($titre)) {
4392
+        $titre = _T('info_sans_titre');
4393
+    }
4394
+    $url = generer_url_entite($id_objet, $objet, '', '', $connect);
4395 4395
 
4396
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4396
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4397 4397
 }
4398 4398
 
4399 4399
 
@@ -4410,15 +4410,15 @@  discard block
 block discarded – undo
4410 4410
  * @return string
4411 4411
  */
4412 4412
 function wrap($texte, $wrap) {
4413
-	$balises = extraire_balises($wrap);
4414
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4415
-		$texte = $wrap . $texte;
4416
-		$regs = array_reverse($regs[1]);
4417
-		$wrap = "</" . implode("></", $regs) . ">";
4418
-		$texte = $texte . $wrap;
4419
-	}
4413
+    $balises = extraire_balises($wrap);
4414
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4415
+        $texte = $wrap . $texte;
4416
+        $regs = array_reverse($regs[1]);
4417
+        $wrap = "</" . implode("></", $regs) . ">";
4418
+        $texte = $texte . $wrap;
4419
+    }
4420 4420
 
4421
-	return $texte;
4421
+    return $texte;
4422 4422
 }
4423 4423
 
4424 4424
 
@@ -4438,43 +4438,43 @@  discard block
 block discarded – undo
4438 4438
  * @return array|mixed|string
4439 4439
  */
4440 4440
 function filtre_print_dist($u, $join = "<br />", $indent = 0) {
4441
-	if (is_string($u)) {
4442
-		$u = typo($u);
4441
+    if (is_string($u)) {
4442
+        $u = typo($u);
4443 4443
 
4444
-		return $u;
4445
-	}
4444
+        return $u;
4445
+    }
4446 4446
 
4447
-	// caster $u en array si besoin
4448
-	if (is_object($u)) {
4449
-		$u = (array)$u;
4450
-	}
4447
+    // caster $u en array si besoin
4448
+    if (is_object($u)) {
4449
+        $u = (array)$u;
4450
+    }
4451 4451
 
4452
-	if (is_array($u)) {
4453
-		$out = "";
4454
-		// toutes les cles sont numeriques ?
4455
-		// et aucun enfant n'est un tableau
4456
-		// liste simple separee par des virgules
4457
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4458
-		$array_values = array_map('is_array', $u);
4459
-		$object_values = array_map('is_object', $u);
4460
-		if (array_sum($numeric_keys) == count($numeric_keys)
4461
-			and !array_sum($array_values)
4462
-			and !array_sum($object_values)
4463
-		) {
4464
-			return join(", ", array_map('filtre_print_dist', $u));
4465
-		}
4452
+    if (is_array($u)) {
4453
+        $out = "";
4454
+        // toutes les cles sont numeriques ?
4455
+        // et aucun enfant n'est un tableau
4456
+        // liste simple separee par des virgules
4457
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4458
+        $array_values = array_map('is_array', $u);
4459
+        $object_values = array_map('is_object', $u);
4460
+        if (array_sum($numeric_keys) == count($numeric_keys)
4461
+            and !array_sum($array_values)
4462
+            and !array_sum($object_values)
4463
+        ) {
4464
+            return join(", ", array_map('filtre_print_dist', $u));
4465
+        }
4466 4466
 
4467
-		// sinon on passe a la ligne et on indente
4468
-		$i_str = str_pad("", $indent, " ");
4469
-		foreach ($u as $k => $v) {
4470
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4471
-		}
4467
+        // sinon on passe a la ligne et on indente
4468
+        $i_str = str_pad("", $indent, " ");
4469
+        foreach ($u as $k => $v) {
4470
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4471
+        }
4472 4472
 
4473
-		return $out;
4474
-	}
4473
+        return $out;
4474
+    }
4475 4475
 
4476
-	// on sait pas quoi faire...
4477
-	return $u;
4476
+    // on sait pas quoi faire...
4477
+    return $u;
4478 4478
 }
4479 4479
 
4480 4480
 
@@ -4487,10 +4487,10 @@  discard block
 block discarded – undo
4487 4487
  * @return string|array
4488 4488
  */
4489 4489
 function objet_info($objet, $info) {
4490
-	$table = table_objet_sql($objet);
4491
-	$infos = lister_tables_objets_sql($table);
4490
+    $table = table_objet_sql($objet);
4491
+    $infos = lister_tables_objets_sql($table);
4492 4492
 
4493
-	return (isset($infos[$info]) ? $infos[$info] : '');
4493
+    return (isset($infos[$info]) ? $infos[$info] : '');
4494 4494
 }
4495 4495
 
4496 4496
 /**
@@ -4505,11 +4505,11 @@  discard block
 block discarded – undo
4505 4505
  *     Texte traduit du comptage, tel que '3 articles'
4506 4506
  */
4507 4507
 function objet_afficher_nb($nb, $objet) {
4508
-	if (!$nb) {
4509
-		return _T(objet_info($objet, 'info_aucun_objet'));
4510
-	} else {
4511
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4512
-	}
4508
+    if (!$nb) {
4509
+        return _T(objet_info($objet, 'info_aucun_objet'));
4510
+    } else {
4511
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), array('nb' => $nb));
4512
+    }
4513 4513
 }
4514 4514
 
4515 4515
 /**
@@ -4521,11 +4521,11 @@  discard block
 block discarded – undo
4521 4521
  * @return string
4522 4522
  */
4523 4523
 function objet_icone($objet, $taille = 24, $class='') {
4524
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4525
-	$icone = chemin_image($icone);
4526
-	$balise_img = charger_filtre('balise_img');
4524
+    $icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4525
+    $icone = chemin_image($icone);
4526
+    $balise_img = charger_filtre('balise_img');
4527 4527
 
4528
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4528
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4529 4529
 }
4530 4530
 
4531 4531
 /**
@@ -4546,12 +4546,12 @@  discard block
 block discarded – undo
4546 4546
  * @return string
4547 4547
  */
4548 4548
 function objet_T($objet, $chaine, $args = array(), $options = array()){
4549
-	$chaine = explode(':',$chaine);
4550
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4551
-		return $t;
4552
-	}
4553
-	$chaine = implode(':',$chaine);
4554
-	return _T($chaine, $args, $options);
4549
+    $chaine = explode(':',$chaine);
4550
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4551
+        return $t;
4552
+    }
4553
+    $chaine = implode(':',$chaine);
4554
+    return _T($chaine, $args, $options);
4555 4555
 }
4556 4556
 
4557 4557
 /**
@@ -4565,17 +4565,17 @@  discard block
 block discarded – undo
4565 4565
  * @return string      Code HTML
4566 4566
  */
4567 4567
 function insert_head_css_conditionnel($flux) {
4568
-	if (strpos($flux, '<!-- insert_head_css -->') === false
4569
-		and $p = strpos($flux, '<!-- insert_head -->')
4570
-	) {
4571
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4572
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4573
-			$p = $p1;
4574
-		}
4575
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4576
-	}
4568
+    if (strpos($flux, '<!-- insert_head_css -->') === false
4569
+        and $p = strpos($flux, '<!-- insert_head -->')
4570
+    ) {
4571
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4572
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
4573
+            $p = $p1;
4574
+        }
4575
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4576
+    }
4577 4577
 
4578
-	return $flux;
4578
+    return $flux;
4579 4579
 }
4580 4580
 
4581 4581
 /**
@@ -4596,69 +4596,69 @@  discard block
 block discarded – undo
4596 4596
  * @return string
4597 4597
  */
4598 4598
 function produire_fond_statique($fond, $contexte = array(), $options = array(), $connect = '') {
4599
-	if (isset($contexte['format'])) {
4600
-		$extension = $contexte['format'];
4601
-		unset($contexte['format']);
4602
-	} else {
4603
-		$extension = "html";
4604
-		if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4605
-			$extension = $m[1];
4606
-		}
4607
-	}
4608
-	// recuperer le contenu produit par le squelette
4609
-	$options['raw'] = true;
4610
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4611
-
4612
-	// calculer le nom de la css
4613
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4614
-	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4615
-	$contexte_implicite = calculer_contexte_implicite();
4616
-
4617
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4618
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4619
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4620
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4621
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4622
-	}
4623
-	else {
4624
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4625
-		ksort($contexte);
4626
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4627
-	}
4628
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4629
-
4630
-	// mettre a jour le fichier si il n'existe pas
4631
-	// ou trop ancien
4632
-	// le dernier fichier produit est toujours suffixe par .last
4633
-	// et recopie sur le fichier cible uniquement si il change
4634
-	if (!file_exists($filename)
4635
-		or !file_exists($filename . ".last")
4636
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4637
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4638
-	) {
4639
-		$contenu = $cache['texte'];
4640
-		// passer les urls en absolu si c'est une css
4641
-		if ($extension == "css") {
4642
-			$contenu = urls_absolues_css($contenu,
4643
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4644
-		}
4645
-
4646
-		$comment = '';
4647
-		// ne pas insérer de commentaire si c'est du json
4648
-		if ($extension != "json") {
4649
-			$comment = "/* #PRODUIRE{fond=$fond";
4650
-			foreach ($contexte as $k => $v) {
4651
-				$comment .= ",$k=$v";
4652
-			}
4653
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4654
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4655
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4656
-		}
4657
-		// et ecrire le fichier si il change
4658
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4659
-	}
4660
-
4661
-	return timestamp($filename);
4599
+    if (isset($contexte['format'])) {
4600
+        $extension = $contexte['format'];
4601
+        unset($contexte['format']);
4602
+    } else {
4603
+        $extension = "html";
4604
+        if (preg_match(',[.](css|js|json)$,', $fond, $m)) {
4605
+            $extension = $m[1];
4606
+        }
4607
+    }
4608
+    // recuperer le contenu produit par le squelette
4609
+    $options['raw'] = true;
4610
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4611
+
4612
+    // calculer le nom de la css
4613
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4614
+    $nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4615
+    $contexte_implicite = calculer_contexte_implicite();
4616
+
4617
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4618
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4619
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4620
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4621
+        $hash = md5($contexte_implicite['host'] . '::'. $cache);
4622
+    }
4623
+    else {
4624
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4625
+        ksort($contexte);
4626
+        $hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4627
+    }
4628
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4629
+
4630
+    // mettre a jour le fichier si il n'existe pas
4631
+    // ou trop ancien
4632
+    // le dernier fichier produit est toujours suffixe par .last
4633
+    // et recopie sur le fichier cible uniquement si il change
4634
+    if (!file_exists($filename)
4635
+        or !file_exists($filename . ".last")
4636
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4637
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4638
+    ) {
4639
+        $contenu = $cache['texte'];
4640
+        // passer les urls en absolu si c'est une css
4641
+        if ($extension == "css") {
4642
+            $contenu = urls_absolues_css($contenu,
4643
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond));
4644
+        }
4645
+
4646
+        $comment = '';
4647
+        // ne pas insérer de commentaire si c'est du json
4648
+        if ($extension != "json") {
4649
+            $comment = "/* #PRODUIRE{fond=$fond";
4650
+            foreach ($contexte as $k => $v) {
4651
+                $comment .= ",$k=$v";
4652
+            }
4653
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4654
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4655
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
4656
+        }
4657
+        // et ecrire le fichier si il change
4658
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4659
+    }
4660
+
4661
+    return timestamp($filename);
4662 4662
 }
4663 4663
 
4664 4664
 /**
@@ -4671,14 +4671,14 @@  discard block
 block discarded – undo
4671 4671
  *    $fichier auquel on a ajouté le timestamp
4672 4672
  */
4673 4673
 function timestamp($fichier) {
4674
-	if (!$fichier
4675
-		or !file_exists($fichier)
4676
-		or !$m = filemtime($fichier)
4677
-	) {
4678
-		return $fichier;
4679
-	}
4674
+    if (!$fichier
4675
+        or !file_exists($fichier)
4676
+        or !$m = filemtime($fichier)
4677
+    ) {
4678
+        return $fichier;
4679
+    }
4680 4680
 
4681
-	return "$fichier?$m";
4681
+    return "$fichier?$m";
4682 4682
 }
4683 4683
 
4684 4684
 /**
@@ -4688,11 +4688,11 @@  discard block
 block discarded – undo
4688 4688
  * @return string
4689 4689
  */
4690 4690
 function supprimer_timestamp($url) {
4691
-	if (strpos($url, "?") === false) {
4692
-		return $url;
4693
-	}
4691
+    if (strpos($url, "?") === false) {
4692
+        return $url;
4693
+    }
4694 4694
 
4695
-	return preg_replace(",\?[[:digit:]]+$,", "", $url);
4695
+    return preg_replace(",\?[[:digit:]]+$,", "", $url);
4696 4696
 }
4697 4697
 
4698 4698
 /**
@@ -4707,9 +4707,9 @@  discard block
 block discarded – undo
4707 4707
  * @return string
4708 4708
  */
4709 4709
 function filtre_nettoyer_titre_email_dist($titre) {
4710
-	include_spip('inc/envoyer_mail');
4710
+    include_spip('inc/envoyer_mail');
4711 4711
 
4712
-	return nettoyer_titre_email($titre);
4712
+    return nettoyer_titre_email($titre);
4713 4713
 }
4714 4714
 
4715 4715
 /**
@@ -4731,19 +4731,19 @@  discard block
 block discarded – undo
4731 4731
  * @return string
4732 4732
  */
4733 4733
 function filtre_chercher_rubrique_dist(
4734
-	$titre,
4735
-	$id_objet,
4736
-	$id_parent,
4737
-	$objet,
4738
-	$id_secteur,
4739
-	$restreint,
4740
-	$actionable = false,
4741
-	$retour_sans_cadre = false
4734
+    $titre,
4735
+    $id_objet,
4736
+    $id_parent,
4737
+    $objet,
4738
+    $id_secteur,
4739
+    $restreint,
4740
+    $actionable = false,
4741
+    $retour_sans_cadre = false
4742 4742
 ) {
4743
-	include_spip('inc/filtres_ecrire');
4743
+    include_spip('inc/filtres_ecrire');
4744 4744
 
4745
-	return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4746
-		$retour_sans_cadre);
4745
+    return chercher_rubrique($titre, $id_objet, $id_parent, $objet, $id_secteur, $restreint, $actionable,
4746
+        $retour_sans_cadre);
4747 4747
 }
4748 4748
 
4749 4749
 /**
@@ -4772,56 +4772,56 @@  discard block
 block discarded – undo
4772 4772
  *     Chaîne vide si l'accès est autorisé
4773 4773
  */
4774 4774
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
4775
-	if ($ok) {
4776
-		return '';
4777
-	}
4778
-
4779
-	// Vider tous les tampons
4780
-	$level = @ob_get_level();
4781
-	while ($level--) {
4782
-		@ob_end_clean();
4783
-	}
4784
-
4785
-	include_spip('inc/headers');
4786
-
4787
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4788
-	if ($url) {
4789
-		redirige_par_entete($url, '', $statut);
4790
-	}
4791
-
4792
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
4793
-	if (!is_numeric($statut) and is_null($message)) {
4794
-		$message = $statut;
4795
-		$statut = 0;
4796
-	}
4797
-	if (!$message) {
4798
-		$message = '';
4799
-	}
4800
-	$statut = intval($statut);
4801
-
4802
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4803
-	if (test_espace_prive()) {
4804
-		if (!$statut or !in_array($statut, array(404, 403))) {
4805
-			$statut = 403;
4806
-		}
4807
-		http_status(403);
4808
-		$echec = charger_fonction('403', 'exec');
4809
-		$echec($message);
4810
-	} else {
4811
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4812
-		if (!$statut) {
4813
-			$statut = 404;
4814
-		}
4815
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
4816
-		http_status($statut);
4817
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4818
-		if ($statut >= 400) {
4819
-			echo recuperer_fond("$statut", array('erreur' => $message));
4820
-		}
4821
-	}
4822
-
4823
-
4824
-	exit;
4775
+    if ($ok) {
4776
+        return '';
4777
+    }
4778
+
4779
+    // Vider tous les tampons
4780
+    $level = @ob_get_level();
4781
+    while ($level--) {
4782
+        @ob_end_clean();
4783
+    }
4784
+
4785
+    include_spip('inc/headers');
4786
+
4787
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
4788
+    if ($url) {
4789
+        redirige_par_entete($url, '', $statut);
4790
+    }
4791
+
4792
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
4793
+    if (!is_numeric($statut) and is_null($message)) {
4794
+        $message = $statut;
4795
+        $statut = 0;
4796
+    }
4797
+    if (!$message) {
4798
+        $message = '';
4799
+    }
4800
+    $statut = intval($statut);
4801
+
4802
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
4803
+    if (test_espace_prive()) {
4804
+        if (!$statut or !in_array($statut, array(404, 403))) {
4805
+            $statut = 403;
4806
+        }
4807
+        http_status(403);
4808
+        $echec = charger_fonction('403', 'exec');
4809
+        $echec($message);
4810
+    } else {
4811
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
4812
+        if (!$statut) {
4813
+            $statut = 404;
4814
+        }
4815
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
4816
+        http_status($statut);
4817
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
4818
+        if ($statut >= 400) {
4819
+            echo recuperer_fond("$statut", array('erreur' => $message));
4820
+        }
4821
+    }
4822
+
4823
+
4824
+    exit;
4825 4825
 }
4826 4826
 
4827 4827
 /**
@@ -4832,11 +4832,11 @@  discard block
 block discarded – undo
4832 4832
  * @return string
4833 4833
  */
4834 4834
 function filtre_compacte_dist($source, $format = null) {
4835
-	if (function_exists('compacte')) {
4836
-		return compacte($source, $format);
4837
-	}
4835
+    if (function_exists('compacte')) {
4836
+        return compacte($source, $format);
4837
+    }
4838 4838
 
4839
-	return $source;
4839
+    return $source;
4840 4840
 }
4841 4841
 
4842 4842
 
@@ -4848,29 +4848,29 @@  discard block
 block discarded – undo
4848 4848
  * @return string
4849 4849
  */
4850 4850
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4851
-	$l = strlen($passe);
4852
-
4853
-	if ($l<=8 or !$afficher_partiellement){
4854
-		if (!$l) {
4855
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4856
-		}
4857
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4858
-	}
4859
-
4860
-	if (is_null($portion_pourcent)) {
4861
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4862
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4863
-		}
4864
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4865
-	}
4866
-	if ($portion_pourcent >= 100) {
4867
-		return $passe;
4868
-	}
4869
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4870
-	$e = max($e, 0);
4871
-	$mid = str_pad('',$l-2*$e,'*');
4872
-	if ($e>0 and strlen($mid)>8){
4873
-		$mid = '***...***';
4874
-	}
4875
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4851
+    $l = strlen($passe);
4852
+
4853
+    if ($l<=8 or !$afficher_partiellement){
4854
+        if (!$l) {
4855
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4856
+        }
4857
+        return str_pad('',$afficher_partiellement ? $l : 16,'*');
4858
+    }
4859
+
4860
+    if (is_null($portion_pourcent)) {
4861
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
4862
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
4863
+        }
4864
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
4865
+    }
4866
+    if ($portion_pourcent >= 100) {
4867
+        return $passe;
4868
+    }
4869
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
4870
+    $e = max($e, 0);
4871
+    $mid = str_pad('',$l-2*$e,'*');
4872
+    if ($e>0 and strlen($mid)>8){
4873
+        $mid = '***...***';
4874
+    }
4875
+    return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4876 4876
 }
4877 4877
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	}
95 95
 
96 96
 	include_fichiers_fonctions();
97
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
97
+	foreach (array('filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc) as $f) {
98 98
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99 99
 		// fonction ou name\space\fonction
100 100
 		if (is_callable($f)) {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	// affichage "GIT [master: abcdef]"
188 188
 	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
189 189
 	if ($desc['branch']) {
190
-		$commit = $desc['branch'] . ': ' . $commit;
190
+		$commit = $desc['branch'].': '.$commit;
191 191
 	}
192 192
 	return "{$desc['vcs']} [$commit]";
193 193
 }
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	}
207 207
 
208 208
 	// version installee par GIT
209
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
209
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
210 210
 		$currentHead = trim(substr($c, 4));
211
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
211
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
212 212
 			return [
213 213
 				'vcs' => 'GIT',
214 214
 				'branch' => basename($currentHead),
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 		$dir = '.';
236 236
 	}
237 237
 	// version installee par SVN
238
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
239
-		$db = new SQLite3($dir . '/.svn/wc.db');
238
+	if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) {
239
+		$db = new SQLite3($dir.'/.svn/wc.db');
240 240
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
241 241
 		if ($result) {
242 242
 			$row = $result->fetchArray();
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 
276 276
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
277 277
 // et laisser passer les fonctions personnelles baptisees image_...
278
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
279
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
280
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
281
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
282
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
278
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
279
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
280
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
281
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
282
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
283 283
 
284 284
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
285 285
 $GLOBALS['spip_matrice']['couleur_foncer'] = 'inc/filtres_images_mini.php';
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
  */
437 437
 function filtre_debug($val, $key = null) {
438 438
 	$debug = (
439
-		is_null($key) ? '' : (var_export($key, true) . " = ")
440
-		) . var_export($val, true);
439
+		is_null($key) ? '' : (var_export($key, true)." = ")
440
+		).var_export($val, true);
441 441
 
442 442
 	include_spip('inc/autoriser');
443 443
 	if (autoriser('webmestre')) {
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
526 526
 							$srcover = $match[1];
527 527
 							array_shift($args);
528
-							array_unshift($args, "<img src='" . $match[1] . "' />");
528
+							array_unshift($args, "<img src='".$match[1]."' />");
529 529
 							$srcover_filter = call_user_func_array($filtre, $args);
530 530
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
531 531
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 	// " -> &quot; et tout ce genre de choses
876 876
 	$u = $GLOBALS['meta']['pcre_u'];
877 877
 	$texte = str_replace("&nbsp;", " ", $texte);
878
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
878
+	$texte = preg_replace('/\s{2,}/S'.$u, " ", $texte);
879 879
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
880 880
 	$texte = entites_html($texte, false, false);
881 881
 	// mais bien echapper les double quotes !
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
  **/
936 936
 function supprimer_numero($texte) {
937 937
 	return preg_replace(
938
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
938
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
939 939
 		"", $texte);
940 940
 }
941 941
 
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
  **/
961 961
 function recuperer_numero($texte) {
962 962
 	if (preg_match(
963
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
963
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
964 964
 		$texte, $regs)) {
965 965
 		return strval($regs[1]);
966 966
 	} else {
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
  **/
1046 1046
 function textebrut($texte) {
1047 1047
 	$u = $GLOBALS['meta']['pcre_u'];
1048
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1049
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1048
+	$texte = preg_replace('/\s+/S'.$u, " ", $texte);
1049
+	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
1050 1050
 	$texte = preg_replace("/^\n+/", "", $texte);
1051 1051
 	$texte = preg_replace("/\n+$/", "", $texte);
1052 1052
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1075 1075
 		$texte, $liens, PREG_PATTERN_ORDER)) {
1076 1076
 		foreach ($liens[0] as $a) {
1077
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1077
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1078 1078
 			$ablank = inserer_attribut($a, 'rel', $rel);
1079 1079
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1080 1080
 			$texte = str_replace($a, $ablank, $texte);
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 		foreach ($regs[0] as $a) {
1100 1100
 			$rel = extraire_attribut($a, "rel");
1101 1101
 			if (strpos($rel, "nofollow") === false) {
1102
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1102
+				$rel = "nofollow".($rel ? " $rel" : "");
1103 1103
 				$anofollow = inserer_attribut($a, "rel", $rel);
1104 1104
 				$texte = str_replace($a, $anofollow, $texte);
1105 1105
 			}
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 	$u = $GLOBALS['meta']['pcre_u'];
1129 1129
 	$texte = preg_replace("@</p>@iS", "\n", $texte);
1130 1130
 	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1131
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1131
+	$texte = preg_replace("@^\s*<br />@S".$u, "", $texte);
1132 1132
 
1133 1133
 	return $texte;
1134 1134
 }
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 		return $texte;
1159 1159
 	}
1160 1160
 	include_spip('inc/texte');
1161
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1161
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1162 1162
 		'div' : 'span';
1163 1163
 
1164 1164
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 function attribut_html($texte, $textebrut = true) {
1268 1268
 	$u = $GLOBALS['meta']['pcre_u'];
1269 1269
 	if ($textebrut) {
1270
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1270
+		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte));
1271 1271
 	}
1272 1272
 	$texte = texte_backend($texte);
1273 1273
 	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 	# un message pour abs_url
1297 1297
 	$GLOBALS['mode_abs_url'] = 'url';
1298 1298
 	$url = trim($url);
1299
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1299
+	$r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS';
1300 1300
 
1301 1301
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1302 1302
 }
@@ -1498,14 +1498,14 @@  discard block
 block discarded – undo
1498 1498
 	if (strpos($texte, "<") !== false) {
1499 1499
 		include_spip('inc/lien');
1500 1500
 		if (defined('_PREG_MODELE')) {
1501
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1501
+			$preg_modeles = "@"._PREG_MODELE."@imsS";
1502 1502
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1503 1503
 		}
1504 1504
 	}
1505 1505
 
1506 1506
 	$debut = '';
1507 1507
 	$suite = $texte;
1508
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1508
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1509 1509
 		$debut .= substr($suite, 0, $t - 1);
1510 1510
 		$suite = substr($suite, $t);
1511 1511
 		$car = substr($suite, 0, 1);
@@ -1522,11 +1522,11 @@  discard block
 block discarded – undo
1522 1522
 			$suite = substr($suite, strlen($regs[0]));
1523 1523
 		}
1524 1524
 	}
1525
-	$texte = $debut . $suite;
1525
+	$texte = $debut.$suite;
1526 1526
 
1527 1527
 	$texte = echappe_retour($texte);
1528 1528
 
1529
-	return $texte . $fin;
1529
+	return $texte.$fin;
1530 1530
 }
1531 1531
 
1532 1532
 
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 		}
1588 1588
 
1589 1589
 		foreach ($regs as $reg) {
1590
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1590
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1591 1591
 			$desc = $traduire($cle, $lang, true);
1592 1592
 			$l = $desc->langue;
1593 1593
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1701 1701
 					include_spip('inc/texte');
1702 1702
 					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1703
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1703
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1704 1704
 					$trad = code_echappement($trad, 'multi', false, $mode);
1705 1705
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1706 1706
 					if (lang_dir($l) !== lang_dir($lang)) {
@@ -1893,7 +1893,7 @@  discard block
 block discarded – undo
1893 1893
 	if (is_array($balise)) {
1894 1894
 		array_walk(
1895 1895
 			$balise,
1896
-			function(&$a, $key, $t){
1896
+			function(&$a, $key, $t) {
1897 1897
 				$a = extraire_attribut($a, $t);
1898 1898
 			},
1899 1899
 			$attribut
@@ -1980,14 +1980,14 @@  discard block
 block discarded – undo
1980 1980
 
1981 1981
 	if ($old !== null) {
1982 1982
 		// Remplacer l'ancien attribut du meme nom
1983
-		$balise = $r[1] . $insert . $r[5];
1983
+		$balise = $r[1].$insert.$r[5];
1984 1984
 	} else {
1985 1985
 		// preferer une balise " />" (comme <img />)
1986 1986
 		if (preg_match(',/>,', $balise)) {
1987
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
1987
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
1988 1988
 		} // sinon une balise <a ...> ... </a>
1989 1989
 		else {
1990
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
1990
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
1991 1991
 		}
1992 1992
 	}
1993 1993
 
@@ -2029,8 +2029,8 @@  discard block
 block discarded – undo
2029 2029
 //
2030 2030
 // Quelques fonctions de calcul arithmetique
2031 2031
 //
2032
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
2033
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
2032
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
2033
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
2034 2034
 
2035 2035
 /**
2036 2036
  * Additionne 2 nombres
@@ -2050,7 +2050,7 @@  discard block
 block discarded – undo
2050 2050
 function plus($a, $b) {
2051 2051
 	return $a + $b;
2052 2052
 }
2053
-function strplus($a, $b) {return strize('plus', $a, $b);}
2053
+function strplus($a, $b) {return strize('plus', $a, $b); }
2054 2054
 /**
2055 2055
  * Soustrait 2 nombres
2056 2056
  *
@@ -2069,7 +2069,7 @@  discard block
 block discarded – undo
2069 2069
 function moins($a, $b) {
2070 2070
 	return $a - $b;
2071 2071
 }
2072
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2072
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2073 2073
 
2074 2074
 /**
2075 2075
  * Multiplie 2 nombres
@@ -2090,7 +2090,7 @@  discard block
 block discarded – undo
2090 2090
 function mult($a, $b) {
2091 2091
 	return $a * $b;
2092 2092
 }
2093
-function strmult($a, $b) {return strize('mult', $a, $b);}
2093
+function strmult($a, $b) {return strize('mult', $a, $b); }
2094 2094
 
2095 2095
 /**
2096 2096
  * Divise 2 nombres
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 function div($a, $b) {
2112 2112
 	return $b ? $a / $b : 0;
2113 2113
 }
2114
-function strdiv($a, $b) {return strize('div', $a, $b);}
2114
+function strdiv($a, $b) {return strize('div', $a, $b); }
2115 2115
 
2116 2116
 /**
2117 2117
  * Retourne le modulo 2 nombres
@@ -2152,13 +2152,13 @@  discard block
 block discarded – undo
2152 2152
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2153 2153
 		define('_TAGS_NOM_AUTEUR', '');
2154 2154
 	}
2155
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2155
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2156 2156
 	foreach ($tags_acceptes as $tag) {
2157 2157
 		if (strlen($tag)) {
2158
-			$remp1[] = '<' . trim($tag) . '>';
2159
-			$remp1[] = '</' . trim($tag) . '>';
2160
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2161
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2158
+			$remp1[] = '<'.trim($tag).'>';
2159
+			$remp1[] = '</'.trim($tag).'>';
2160
+			$remp2[] = '\x60'.trim($tag).'\x61';
2161
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2162 2162
 		}
2163 2163
 	}
2164 2164
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
 			$s[] = preg_replace(',>[^<]+</a>,S',
2222 2222
 				'>'
2223 2223
 				. http_img_pack('attachment-16.png', $t,
2224
-					'title="' . attribut_html($t) . '"')
2224
+					'title="'.attribut_html($t).'"')
2225 2225
 				. '</a>', $tag);
2226 2226
 		}
2227 2227
 	}
@@ -2282,10 +2282,10 @@  discard block
 block discarded – undo
2282 2282
 	$fichier = basename($url);
2283 2283
 
2284 2284
 	return '<a rel="enclosure"'
2285
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2286
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2287
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2288
-	. '>' . $fichier . '</a>';
2285
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2286
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2287
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2288
+	. '>'.$fichier.'</a>';
2289 2289
 }
2290 2290
 
2291 2291
 /**
@@ -2313,9 +2313,9 @@  discard block
 block discarded – undo
2313 2313
 			} # vieux data
2314 2314
 			$fichier = basename($url);
2315 2315
 			$enclosures[] = '<enclosure'
2316
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2317
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2318
-				. ($length ? ' length="' . $length . '"' : '')
2316
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2317
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2318
+				. ($length ? ' length="'.$length.'"' : '')
2319 2319
 				. ' />';
2320 2320
 		}
2321 2321
 	}
@@ -2341,7 +2341,7 @@  discard block
 block discarded – undo
2341 2341
 		if (extraire_attribut($e, rel) == 'tag') {
2342 2342
 			$subjects .= '<dc:subject>'
2343 2343
 				. texte_backend(textebrut($e))
2344
-				. '</dc:subject>' . "\n";
2344
+				. '</dc:subject>'."\n";
2345 2345
 		}
2346 2346
 	}
2347 2347
 
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
 	if (is_array($texte)) {
2378 2378
 		array_walk(
2379 2379
 			$texte,
2380
-			function(&$a, $key, $t){
2380
+			function(&$a, $key, $t) {
2381 2381
 				$a = extraire_balise($a, $t);
2382 2382
 			},
2383 2383
 			$tag
@@ -2421,7 +2421,7 @@  discard block
 block discarded – undo
2421 2421
 	if (is_array($texte)) {
2422 2422
 		array_walk(
2423 2423
 			$texte,
2424
-			function(&$a, $key, $t){
2424
+			function(&$a, $key, $t) {
2425 2425
 				$a = extraire_balises($a, $t);
2426 2426
 			},
2427 2427
 			$tag
@@ -2547,7 +2547,7 @@  discard block
 block discarded – undo
2547 2547
 		if ($fond != '404') {
2548 2548
 			$contexte = array_shift($p);
2549 2549
 			$contexte['page'] = $fond;
2550
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2550
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2551 2551
 		}
2552 2552
 	}
2553 2553
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2602,9 +2602,9 @@  discard block
 block discarded – undo
2602 2602
 			. '"'
2603 2603
 			. (is_null($val)
2604 2604
 				? ''
2605
-				: ' value="' . entites_html($val) . '"'
2605
+				: ' value="'.entites_html($val).'"'
2606 2606
 			)
2607
-			. ' type="hidden"' . "\n/>";
2607
+			. ' type="hidden"'."\n/>";
2608 2608
 	}
2609 2609
 
2610 2610
 	return join("", $hidden);
@@ -2741,7 +2741,7 @@  discard block
 block discarded – undo
2741 2741
 	return preg_replace_callback(
2742 2742
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2743 2743
 		function($x) use ($path) {
2744
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2744
+			return "url('".suivre_lien($path, $x[1])."')";
2745 2745
 		},
2746 2746
 		$contenu
2747 2747
 	);
@@ -2803,14 +2803,14 @@  discard block
 block discarded – undo
2803 2803
 	) {
2804 2804
 		$distant = true;
2805 2805
 		$cssf = parse_url($css);
2806
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2806
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2807 2807
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2808 2808
 	} else {
2809 2809
 		$distant = false;
2810 2810
 		$cssf = $css;
2811 2811
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2812 2812
 		//propose (rien a faire dans ce cas)
2813
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2813
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2814 2814
 		if (@file_exists($f)) {
2815 2815
 			return $f;
2816 2816
 		}
@@ -2820,7 +2820,7 @@  discard block
 block discarded – undo
2820 2820
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2821 2821
 	$f = $dir_var
2822 2822
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2823
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2823
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2824 2824
 
2825 2825
 	// la css peut etre distante (url absolue !)
2826 2826
 	if ($distant) {
@@ -2865,8 +2865,8 @@  discard block
 block discarded – undo
2865 2865
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2866 2866
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2867 2867
 			$css_direction = substr($css_direction, strlen($dir_var));
2868
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
2869
-			$css_direction = "/@@@@@@/" . $css_direction;
2868
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
2869
+			$css_direction = "/@@@@@@/".$css_direction;
2870 2870
 		}
2871 2871
 		$src[] = $regs[0][$k];
2872 2872
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -2915,7 +2915,7 @@  discard block
 block discarded – undo
2915 2915
 
2916 2916
 	$f = basename($css, '.css');
2917 2917
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2918
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2918
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
2919 2919
 		. '.css';
2920 2920
 
2921 2921
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -2924,7 +2924,7 @@  discard block
 block discarded – undo
2924 2924
 
2925 2925
 	if ($url_absolue_css == $css) {
2926 2926
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
2927
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2927
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
2928 2928
 		) {
2929 2929
 			include_spip('inc/distant');
2930 2930
 			if (!$contenu = recuperer_page($css)) {
@@ -3034,7 +3034,7 @@  discard block
 block discarded – undo
3034 3034
 	$expression = str_replace("\/", "/", $expression);
3035 3035
 	$expression = str_replace("/", "\/", $expression);
3036 3036
 
3037
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3037
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3038 3038
 		if (isset($r[$capte])) {
3039 3039
 			return $r[$capte];
3040 3040
 		} else {
@@ -3072,7 +3072,7 @@  discard block
 block discarded – undo
3072 3072
 	$expression = str_replace("\/", "/", $expression);
3073 3073
 	$expression = str_replace("/", "\/", $expression);
3074 3074
 
3075
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3075
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3076 3076
 }
3077 3077
 
3078 3078
 
@@ -3091,7 +3091,7 @@  discard block
 block discarded – undo
3091 3091
 function traiter_doublons_documents(&$doublons, $letexte) {
3092 3092
 
3093 3093
 	// Verifier dans le texte & les notes (pas beau, helas)
3094
-	$t = $letexte . $GLOBALS['les_notes'];
3094
+	$t = $letexte.$GLOBALS['les_notes'];
3095 3095
 
3096 3096
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3097 3097
 		and preg_match_all(
@@ -3101,7 +3101,7 @@  discard block
 block discarded – undo
3101 3101
 		if (!isset($doublons['documents'])) {
3102 3102
 			$doublons['documents'] = "";
3103 3103
 		}
3104
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3104
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3105 3105
 	}
3106 3106
 
3107 3107
 	return $letexte;
@@ -3158,7 +3158,7 @@  discard block
 block discarded – undo
3158 3158
 	if ($env) {
3159 3159
 		foreach ($env as $i => $j) {
3160 3160
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3161
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3161
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3162 3162
 			}
3163 3163
 		}
3164 3164
 	}
@@ -3197,7 +3197,7 @@  discard block
 block discarded – undo
3197 3197
 	if ($env) {
3198 3198
 		foreach ($env as $i => $j) {
3199 3199
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3200
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3200
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3201 3201
 			}
3202 3202
 		}
3203 3203
 	}
@@ -3281,19 +3281,19 @@  discard block
 block discarded – undo
3281 3281
 
3282 3282
 	$img_file = $img;
3283 3283
 	if ($p = strpos($img_file, '?')) {
3284
-		$img_file = substr($img_file,0, $p);
3284
+		$img_file = substr($img_file, 0, $p);
3285 3285
 	}
3286 3286
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3287 3287
 		$img_file = chemin_image($img);
3288 3288
 	}
3289 3289
 	else {
3290
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3290
+		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3291 3291
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3292 3292
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3293 3293
 			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3294
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3294
+			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg"
3295 3295
 			  and file_exists($variante_svg_generique)) {
3296
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3296
+				if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) {
3297 3297
 					$img_file = $variante_svg_size;
3298 3298
 				}
3299 3299
 				else {
@@ -3318,7 +3318,7 @@  discard block
 block discarded – undo
3318 3318
 				return "";
3319 3319
 			}
3320 3320
 		}
3321
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3321
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3322 3322
 	}
3323 3323
 
3324 3324
 	if (file_exists($img_file)) {
@@ -3327,15 +3327,15 @@  discard block
 block discarded – undo
3327 3327
 	if ($alt === false) {
3328 3328
 		$alt = '';
3329 3329
 	}
3330
-	elseif($alt or $alt==='') {
3330
+	elseif ($alt or $alt === '') {
3331 3331
 		$alt = " alt='".attribut_html($alt)."'";
3332 3332
 	}
3333 3333
 	else {
3334 3334
 		$alt = " alt='".attribut_html($title)."'";
3335 3335
 	}
3336 3336
 	return "<img src='$img_file'$alt"
3337
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3338
-	. " " . ltrim($atts)
3337
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3338
+	. " ".ltrim($atts)
3339 3339
 	. " />";
3340 3340
 }
3341 3341
 
@@ -3347,12 +3347,12 @@  discard block
 block discarded – undo
3347 3347
  * @param string $size
3348 3348
  * @return string
3349 3349
  */
3350
-function http_style_background($img, $att = '', $size=null) {
3351
-	if ($size and is_numeric($size)){
3352
-		$size = trim($size) . "px";
3350
+function http_style_background($img, $att = '', $size = null) {
3351
+	if ($size and is_numeric($size)) {
3352
+		$size = trim($size)."px";
3353 3353
 	}
3354
-	return " style='background" .
3355
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3354
+	return " style='background".
3355
+		($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";"
3356 3356
 		. ($size ? "background-size:{$size};" : '')
3357 3357
 		. "'";
3358 3358
 }
@@ -3369,8 +3369,8 @@  discard block
 block discarded – undo
3369 3369
  * @return string
3370 3370
  *     Code HTML de la balise IMG
3371 3371
  */
3372
-function filtre_balise_img_dist($img, $alt = "", $class = "", $width=null) {
3373
-	$atts = $class ? " class='" . attribut_html($class) . "'" : '';
3372
+function filtre_balise_img_dist($img, $alt = "", $class = "", $width = null) {
3373
+	$atts = $class ? " class='".attribut_html($class)."'" : '';
3374 3374
 	// ecriture courte : on donne le width en 2e arg
3375 3375
 	if (empty($width) and is_numeric($alt)) {
3376 3376
 		$width = $alt;
@@ -3398,7 +3398,7 @@  discard block
 block discarded – undo
3398 3398
 function filtre_balise_svg_dist($img, $alt = "", $class = "") {
3399 3399
 	$img_file = $img;
3400 3400
 	if ($p = strpos($img_file, '?')) {
3401
-		$img_file = substr($img_file,0, $p);
3401
+		$img_file = substr($img_file, 0, $p);
3402 3402
 	}
3403 3403
 
3404 3404
 	if (!$img_file or !$svg = file_get_contents($img_file)) {
@@ -3412,18 +3412,18 @@  discard block
 block discarded – undo
3412 3412
 	$balise_svg_source = $balise_svg;
3413 3413
 
3414 3414
 	// entete XML à supprimer
3415
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3415
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3416 3416
 
3417 3417
 	// IE est toujours mon ami
3418 3418
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3419 3419
 	if ($class) {
3420 3420
 		$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3421 3421
 	}
3422
-	if ($alt){
3422
+	if ($alt) {
3423 3423
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3424
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3424
+		$id = "img-svg-title-".substr(md5("$img_file:$svg:$alt"), 0, 4);
3425 3425
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3426
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3426
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3427 3427
 		$balise_svg .= $title;
3428 3428
 	}
3429 3429
 	else {
@@ -3457,7 +3457,7 @@  discard block
 block discarded – undo
3457 3457
 	$texte = '';
3458 3458
 	if (is_array($tableau)) {
3459 3459
 		foreach ($tableau as $k => $v) {
3460
-			$res = recuperer_fond('modeles/' . $modele,
3460
+			$res = recuperer_fond('modeles/'.$modele,
3461 3461
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3462 3462
 			);
3463 3463
 			$texte .= $res;
@@ -3634,7 +3634,7 @@  discard block
 block discarded – undo
3634 3634
 	}
3635 3635
 
3636 3636
 	$c = serialize($c);
3637
-	$cle = calculer_cle_action($form . $c);
3637
+	$cle = calculer_cle_action($form.$c);
3638 3638
 	$c = "$cle:$c";
3639 3639
 
3640 3640
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3696,15 +3696,15 @@  discard block
 block discarded – undo
3696 3696
 	}
3697 3697
 	// toujours encoder l'url source dans le bloc ajax
3698 3698
 	$r = self();
3699
-	$r = ' data-origin="' . $r . '"';
3699
+	$r = ' data-origin="'.$r.'"';
3700 3700
 	$class = 'ajaxbloc';
3701 3701
 	if ($ajaxid and is_string($ajaxid)) {
3702 3702
 		// ajaxid est normalement conforme a un nom de classe css
3703 3703
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3704
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3704
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3705 3705
 	}
3706 3706
 
3707
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3707
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3708 3708
 }
3709 3709
 
3710 3710
 /**
@@ -3743,11 +3743,11 @@  discard block
 block discarded – undo
3743 3743
 	// extraire la signature en debut de contexte
3744 3744
 	// et la verifier avant de deserializer
3745 3745
 	// format : signature:donneesserializees
3746
-	if ($p = strpos($c,":")){
3747
-		$cle = substr($c,0,$p);
3748
-		$c = substr($c,$p+1);
3746
+	if ($p = strpos($c, ":")) {
3747
+		$cle = substr($c, 0, $p);
3748
+		$c = substr($c, $p + 1);
3749 3749
 
3750
-		if ($cle == calculer_cle_action($form . $c)) {
3750
+		if ($cle == calculer_cle_action($form.$c)) {
3751 3751
 			$env = @unserialize($c);
3752 3752
 			return $env;
3753 3753
 		}
@@ -3848,9 +3848,9 @@  discard block
 block discarded – undo
3848 3848
 	} else {
3849 3849
 		$bal = 'a';
3850 3850
 		$att = "href='$url'"
3851
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
3852
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
3853
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
3851
+			. ($title ? " title='".attribut_html($title)."'" : '')
3852
+			. ($class ? " class='".attribut_html($class)."'" : '')
3853
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
3854 3854
 			. $evt;
3855 3855
 	}
3856 3856
 	if ($libelle === null) {
@@ -3925,7 +3925,7 @@  discard block
 block discarded – undo
3925 3925
 	}
3926 3926
 
3927 3927
 	// ajouter le type d'objet dans la class de l'icone
3928
-	$class .= " " . substr(basename($fond), 0, -4);
3928
+	$class .= " ".substr(basename($fond), 0, -4);
3929 3929
 
3930 3930
 	$alt = attribut_html($texte);
3931 3931
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -3949,7 +3949,7 @@  discard block
 block discarded – undo
3949 3949
 	}
3950 3950
 
3951 3951
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
3952
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
3952
+	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "")."\">$icone</span>";
3953 3953
 
3954 3954
 	if ($type == 'lien') {
3955 3955
 		return "<span class='icone s$size $class'>"
@@ -4179,13 +4179,13 @@  discard block
 block discarded – undo
4179 4179
 	$res = "";
4180 4180
 	foreach ($boutons as $page => $detail) {
4181 4181
 		if ($detail->icone and strlen(trim($detail->icone))) {
4182
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4182
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4183 4183
 		}
4184 4184
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4185 4185
 		if (is_array($detail->sousmenu)) {
4186 4186
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4187 4187
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4188
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4188
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4189 4189
 				}
4190 4190
 			}
4191 4191
 		}
@@ -4211,17 +4211,17 @@  discard block
 block discarded – undo
4211 4211
  */
4212 4212
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4213 4213
 	if ($confirm) {
4214
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4214
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4215 4215
 		if ($callback) {
4216 4216
 			$callback = "$confirm?($callback):false";
4217 4217
 		} else {
4218 4218
 			$callback = $confirm;
4219 4219
 		}
4220 4220
 	}
4221
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4221
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4222 4222
 	$title = $title ? " title='$title'" : "";
4223 4223
 
4224
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4224
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4225 4225
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4226 4226
 }
4227 4227
 
@@ -4282,14 +4282,14 @@  discard block
 block discarded – undo
4282 4282
 		$champ_titre = "";
4283 4283
 		if ($demande_titre) {
4284 4284
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4285
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4285
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4286 4286
 		}
4287 4287
 		include_spip('base/abstract_sql');
4288 4288
 		include_spip('base/connect_sql');
4289 4289
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4290
-			'*' . $champ_titre,
4290
+			'*'.$champ_titre,
4291 4291
 			$desc['table_sql'],
4292
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4292
+			id_table_objet($type_objet).' = '.intval($id_objet)
4293 4293
 		);
4294 4294
 	}
4295 4295
 
@@ -4359,7 +4359,7 @@  discard block
 block discarded – undo
4359 4359
 		return $texte;
4360 4360
 	}
4361 4361
 
4362
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4362
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4363 4363
 
4364 4364
 	// Fournir $connect et $Pile[0] au traitement si besoin
4365 4365
 	$Pile = array(0 => $env);
@@ -4393,7 +4393,7 @@  discard block
 block discarded – undo
4393 4393
 	}
4394 4394
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4395 4395
 
4396
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4396
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4397 4397
 }
4398 4398
 
4399 4399
 
@@ -4412,10 +4412,10 @@  discard block
 block discarded – undo
4412 4412
 function wrap($texte, $wrap) {
4413 4413
 	$balises = extraire_balises($wrap);
4414 4414
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4415
-		$texte = $wrap . $texte;
4415
+		$texte = $wrap.$texte;
4416 4416
 		$regs = array_reverse($regs[1]);
4417
-		$wrap = "</" . implode("></", $regs) . ">";
4418
-		$texte = $texte . $wrap;
4417
+		$wrap = "</".implode("></", $regs).">";
4418
+		$texte = $texte.$wrap;
4419 4419
 	}
4420 4420
 
4421 4421
 	return $texte;
@@ -4446,7 +4446,7 @@  discard block
 block discarded – undo
4446 4446
 
4447 4447
 	// caster $u en array si besoin
4448 4448
 	if (is_object($u)) {
4449
-		$u = (array)$u;
4449
+		$u = (array) $u;
4450 4450
 	}
4451 4451
 
4452 4452
 	if (is_array($u)) {
@@ -4467,7 +4467,7 @@  discard block
 block discarded – undo
4467 4467
 		// sinon on passe a la ligne et on indente
4468 4468
 		$i_str = str_pad("", $indent, " ");
4469 4469
 		foreach ($u as $k => $v) {
4470
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4470
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4471 4471
 		}
4472 4472
 
4473 4473
 		return $out;
@@ -4520,8 +4520,8 @@  discard block
 block discarded – undo
4520 4520
  * @param string $class
4521 4521
  * @return string
4522 4522
  */
4523
-function objet_icone($objet, $taille = 24, $class='') {
4524
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4523
+function objet_icone($objet, $taille = 24, $class = '') {
4524
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4525 4525
 	$icone = chemin_image($icone);
4526 4526
 	$balise_img = charger_filtre('balise_img');
4527 4527
 
@@ -4545,12 +4545,12 @@  discard block
 block discarded – undo
4545 4545
  * @param array $options
4546 4546
  * @return string
4547 4547
  */
4548
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4549
-	$chaine = explode(':',$chaine);
4550
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4548
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4549
+	$chaine = explode(':', $chaine);
4550
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4551 4551
 		return $t;
4552 4552
 	}
4553
-	$chaine = implode(':',$chaine);
4553
+	$chaine = implode(':', $chaine);
4554 4554
 	return _T($chaine, $args, $options);
4555 4555
 }
4556 4556
 
@@ -4610,7 +4610,7 @@  discard block
 block discarded – undo
4610 4610
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4611 4611
 
4612 4612
 	// calculer le nom de la css
4613
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4613
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4614 4614
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4615 4615
 	$contexte_implicite = calculer_contexte_implicite();
4616 4616
 
@@ -4618,22 +4618,22 @@  discard block
 block discarded – undo
4618 4618
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4619 4619
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4620 4620
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4621
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4621
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
4622 4622
 	}
4623 4623
 	else {
4624 4624
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4625 4625
 		ksort($contexte);
4626
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4626
+		$hash = md5($fond.json_encode($contexte_implicite).json_encode($contexte).$connect);
4627 4627
 	}
4628
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4628
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4629 4629
 
4630 4630
 	// mettre a jour le fichier si il n'existe pas
4631 4631
 	// ou trop ancien
4632 4632
 	// le dernier fichier produit est toujours suffixe par .last
4633 4633
 	// et recopie sur le fichier cible uniquement si il change
4634 4634
 	if (!file_exists($filename)
4635
-		or !file_exists($filename . ".last")
4636
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4635
+		or !file_exists($filename.".last")
4636
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4637 4637
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4638 4638
 	) {
4639 4639
 		$contenu = $cache['texte'];
@@ -4652,10 +4652,10 @@  discard block
 block discarded – undo
4652 4652
 			}
4653 4653
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4654 4654
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4655
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4655
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4656 4656
 		}
4657 4657
 		// et ecrire le fichier si il change
4658
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4658
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
4659 4659
 	}
4660 4660
 
4661 4661
 	return timestamp($filename);
@@ -4850,11 +4850,11 @@  discard block
 block discarded – undo
4850 4850
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
4851 4851
 	$l = strlen($passe);
4852 4852
 
4853
-	if ($l<=8 or !$afficher_partiellement){
4853
+	if ($l <= 8 or !$afficher_partiellement) {
4854 4854
 		if (!$l) {
4855 4855
 			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
4856 4856
 		}
4857
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
4857
+		return str_pad('', $afficher_partiellement ? $l : 16, '*');
4858 4858
 	}
4859 4859
 
4860 4860
 	if (is_null($portion_pourcent)) {
@@ -4868,9 +4868,9 @@  discard block
 block discarded – undo
4868 4868
 	}
4869 4869
 	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
4870 4870
 	$e = max($e, 0);
4871
-	$mid = str_pad('',$l-2*$e,'*');
4872
-	if ($e>0 and strlen($mid)>8){
4871
+	$mid = str_pad('', $l - 2 * $e, '*');
4872
+	if ($e > 0 and strlen($mid) > 8) {
4873 4873
 		$mid = '***...***';
4874 4874
 	}
4875
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
4875
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
4876 4876
 }
4877 4877
\ No newline at end of file
Please login to merge, or discard this patch.