Completed
Push — master ( 82502a...9e5dec )
by cam
10:28
created
ecrire/inc/definir_menus_favoris.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,21 +20,21 @@
 block discarded – undo
20 20
  * Retourne la liste des menus favoris par défaut ainsi que leur rang
21 21
  */
22 22
 function inc_definir_menus_favoris_dist() {
23
-	$liste = [
23
+    $liste = [
24 24
 
25
-		// Menu Édition,
26
-		'auteurs' => 1,
27
-		'rubriques' => 2,
28
-		'articles' => 3,
25
+        // Menu Édition,
26
+        'auteurs' => 1,
27
+        'rubriques' => 2,
28
+        'articles' => 3,
29 29
 
30
-		// Menu Maintenance
31
-		'admin_vider' => 1,
30
+        // Menu Maintenance
31
+        'admin_vider' => 1,
32 32
 
33
-		// Menu Configurations
34
-		'configurer_identite' => 1,
35
-		'admin_plugin' => 2,
33
+        // Menu Configurations
34
+        'configurer_identite' => 1,
35
+        'admin_plugin' => 2,
36 36
 
37
-	];
37
+    ];
38 38
 
39
-	return $liste;
39
+    return $liste;
40 40
 }
Please login to merge, or discard this patch.
ecrire/inc/puce_statut.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -416,7 +416,7 @@
 block discarded – undo
416 416
 	$h = generer_action_auteur('instituer_objet', "$type-$id-$statut");
417 417
 	$t = supprimer_tags($titre);
418 418
 
419
-	return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>';
419
+	return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>".http_img_pack($img, $t).'</a>';
420 420
 }
421 421
 
422 422
 // compat
Please login to merge, or discard this patch.
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 if (!defined('_ACTIVER_PUCE_RAPIDE')) {
25
-	/**
26
-	 * Activer le changement rapide de statut sur les listes d'objets ?
27
-	 *
28
-	 * Peut ralentir un site sur des listes très longues.
29
-	 *
30
-	 * @var bool
31
-	 **/
32
-	define('_ACTIVER_PUCE_RAPIDE', true);
25
+    /**
26
+     * Activer le changement rapide de statut sur les listes d'objets ?
27
+     *
28
+     * Peut ralentir un site sur des listes très longues.
29
+     *
30
+     * @var bool
31
+     **/
32
+    define('_ACTIVER_PUCE_RAPIDE', true);
33 33
 }
34 34
 
35 35
 /**
@@ -57,31 +57,31 @@  discard block
 block discarded – undo
57 57
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
58 58
  */
59 59
 function inc_puce_statut_dist(
60
-	$id_objet,
61
-	$statut,
62
-	$id_parent,
63
-	$type,
64
-	$ajax = false,
65
-	$menu_rapide = _ACTIVER_PUCE_RAPIDE
60
+    $id_objet,
61
+    $statut,
62
+    $id_parent,
63
+    $type,
64
+    $ajax = false,
65
+    $menu_rapide = _ACTIVER_PUCE_RAPIDE
66 66
 ) {
67
-	static $f_puce_statut = [];
68
-	$type = objet_type($type);
69
-	// cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques
70
-	if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) {
71
-		$f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true);
72
-	}
73
-	if ($f_puce_statut[$type]) {
74
-		return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide);
75
-	}
76
-
77
-	// si statut_image trouve quelque chose (et '' est quelque chose)
78
-	// composer une puce, avec si possible changement rapide
79
-	elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) {
80
-		return $puce;
81
-	} // sinon fausse puce avec le type de l'image
82
-	else {
83
-		return http_img_pack("$type-16.png", '');
84
-	}
67
+    static $f_puce_statut = [];
68
+    $type = objet_type($type);
69
+    // cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques
70
+    if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) {
71
+        $f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true);
72
+    }
73
+    if ($f_puce_statut[$type]) {
74
+        return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide);
75
+    }
76
+
77
+    // si statut_image trouve quelque chose (et '' est quelque chose)
78
+    // composer une puce, avec si possible changement rapide
79
+    elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) {
80
+        return $puce;
81
+    } // sinon fausse puce avec le type de l'image
82
+    else {
83
+        return http_img_pack("$type-16.png", '');
84
+    }
85 85
 }
86 86
 
87 87
 /**
@@ -110,41 +110,41 @@  discard block
 block discarded – undo
110 110
  *   null si pas capable de déterminer l'image
111 111
  */
112 112
 function statut_image($objet, $statut) {
113
-	$src = null;
114
-	$table = table_objet_sql($objet);
115
-	$desc = lister_tables_objets_sql($table);
116
-	if (isset($desc['statut_images'])) {
117
-		// si une declaration statut_images
118
-		// mais rien pour le statut demande, ne rien afficher
119
-		$src = '';
120
-		if (isset($desc['statut_images'][$statut])) {
121
-			$src = $desc['statut_images'][$statut];
122
-		} // sinon image par defaut ?
123
-		elseif (isset($desc['statut_images'][0])) {
124
-			$src = $desc['statut_images'][0];
125
-		}
126
-	} else {
127
-		switch ($statut) {
128
-			case 'prepa':
129
-				$src = 'puce-preparer-xx.svg?12px';
130
-				break;
131
-			case 'prop':
132
-				$src = 'puce-proposer-xx.svg?12px';
133
-				break;
134
-			case 'publie':
135
-				$src = 'puce-publier-xx.svg?12px';
136
-				break;
137
-			case 'refuse':
138
-				$src = 'puce-refuser-xx.svg?12px';
139
-				break;
140
-			case 'poubelle':
141
-			case 'poub':
142
-				$src = 'puce-supprimer-xx.svg?12px';
143
-				break;
144
-		}
145
-	}
146
-
147
-	return $src;
113
+    $src = null;
114
+    $table = table_objet_sql($objet);
115
+    $desc = lister_tables_objets_sql($table);
116
+    if (isset($desc['statut_images'])) {
117
+        // si une declaration statut_images
118
+        // mais rien pour le statut demande, ne rien afficher
119
+        $src = '';
120
+        if (isset($desc['statut_images'][$statut])) {
121
+            $src = $desc['statut_images'][$statut];
122
+        } // sinon image par defaut ?
123
+        elseif (isset($desc['statut_images'][0])) {
124
+            $src = $desc['statut_images'][0];
125
+        }
126
+    } else {
127
+        switch ($statut) {
128
+            case 'prepa':
129
+                $src = 'puce-preparer-xx.svg?12px';
130
+                break;
131
+            case 'prop':
132
+                $src = 'puce-proposer-xx.svg?12px';
133
+                break;
134
+            case 'publie':
135
+                $src = 'puce-publier-xx.svg?12px';
136
+                break;
137
+            case 'refuse':
138
+                $src = 'puce-refuser-xx.svg?12px';
139
+                break;
140
+            case 'poubelle':
141
+            case 'poub':
142
+                $src = 'puce-supprimer-xx.svg?12px';
143
+                break;
144
+        }
145
+    }
146
+
147
+    return $src;
148 148
 }
149 149
 
150 150
 /**
@@ -172,40 +172,40 @@  discard block
 block discarded – undo
172 172
  * @return string
173 173
  */
174 174
 function statut_titre($objet, $statut) {
175
-	$titre = '';
176
-	$table = table_objet_sql($objet);
177
-	$desc = lister_tables_objets_sql($table);
178
-	if (isset($desc['statut_titres'])) {
179
-		// si une declaration statut_titres
180
-		// mais rien pour le statut demande, ne rien afficher
181
-		if (isset($desc['statut_titres'][$statut])) {
182
-			$titre = $desc['statut_titres'][$statut];
183
-		} // sinon image par defaut ?
184
-		elseif (isset($desc['statut_titres'][0])) {
185
-			$titre = $desc['statut_titres'][0];
186
-		}
187
-	} else {
188
-		switch ($statut) {
189
-			case 'prepa':
190
-				$titre = 'texte_statut_en_cours_redaction';
191
-				break;
192
-			case 'prop':
193
-				$titre = 'texte_statut_propose_evaluation';
194
-				break;
195
-			case 'publie':
196
-				$titre = 'texte_statut_publie';
197
-				break;
198
-			case 'refuse':
199
-				$titre = 'texte_statut_refuse';
200
-				break;
201
-			case 'poubelle':
202
-			case 'poub':
203
-				$titre = 'texte_statut_poubelle';
204
-				break;
205
-		}
206
-	}
207
-
208
-	return $titre ? _T($titre) : '';
175
+    $titre = '';
176
+    $table = table_objet_sql($objet);
177
+    $desc = lister_tables_objets_sql($table);
178
+    if (isset($desc['statut_titres'])) {
179
+        // si une declaration statut_titres
180
+        // mais rien pour le statut demande, ne rien afficher
181
+        if (isset($desc['statut_titres'][$statut])) {
182
+            $titre = $desc['statut_titres'][$statut];
183
+        } // sinon image par defaut ?
184
+        elseif (isset($desc['statut_titres'][0])) {
185
+            $titre = $desc['statut_titres'][0];
186
+        }
187
+    } else {
188
+        switch ($statut) {
189
+            case 'prepa':
190
+                $titre = 'texte_statut_en_cours_redaction';
191
+                break;
192
+            case 'prop':
193
+                $titre = 'texte_statut_propose_evaluation';
194
+                break;
195
+            case 'publie':
196
+                $titre = 'texte_statut_publie';
197
+                break;
198
+            case 'refuse':
199
+                $titre = 'texte_statut_refuse';
200
+                break;
201
+            case 'poubelle':
202
+            case 'poub':
203
+                $titre = 'texte_statut_poubelle';
204
+                break;
205
+        }
206
+    }
207
+
208
+    return $titre ? _T($titre) : '';
209 209
 }
210 210
 
211 211
 
@@ -225,37 +225,37 @@  discard block
 block discarded – undo
225 225
  * @return string
226 226
  */
227 227
 function statut_texte_instituer($objet, $statut) {
228
-	$texte = '';
229
-	$table = table_objet_sql($objet);
230
-	$desc = lister_tables_objets_sql($table);
231
-	if (isset($desc['statut_textes_instituer'])) {
232
-		// si une declaration statut_titres
233
-		// mais rien pour le statut demande, ne rien afficher
234
-		if (isset($desc['statut_textes_instituer'][$statut])) {
235
-			$texte = $desc['statut_textes_instituer'][$statut];
236
-		}
237
-	} else {
238
-		switch ($statut) {
239
-			case 'prepa':
240
-				$texte = 'texte_statut_en_cours_redaction';
241
-				break;
242
-			case 'prop':
243
-				$texte = 'texte_statut_propose_evaluation';
244
-				break;
245
-			case 'publie':
246
-				$texte = 'texte_statut_publie';
247
-				break;
248
-			case 'refuse':
249
-				$texte = 'texte_statut_refuse';
250
-				break;
251
-			case 'poubelle':
252
-			case 'poub':
253
-				$texte = 'texte_statut_poubelle';
254
-				break;
255
-		}
256
-	}
257
-
258
-	return $texte ? _T($texte) : '';
228
+    $texte = '';
229
+    $table = table_objet_sql($objet);
230
+    $desc = lister_tables_objets_sql($table);
231
+    if (isset($desc['statut_textes_instituer'])) {
232
+        // si une declaration statut_titres
233
+        // mais rien pour le statut demande, ne rien afficher
234
+        if (isset($desc['statut_textes_instituer'][$statut])) {
235
+            $texte = $desc['statut_textes_instituer'][$statut];
236
+        }
237
+    } else {
238
+        switch ($statut) {
239
+            case 'prepa':
240
+                $texte = 'texte_statut_en_cours_redaction';
241
+                break;
242
+            case 'prop':
243
+                $texte = 'texte_statut_propose_evaluation';
244
+                break;
245
+            case 'publie':
246
+                $texte = 'texte_statut_publie';
247
+                break;
248
+            case 'refuse':
249
+                $texte = 'texte_statut_refuse';
250
+                break;
251
+            case 'poubelle':
252
+            case 'poub':
253
+                $texte = 'texte_statut_poubelle';
254
+                break;
255
+        }
256
+    }
257
+
258
+    return $texte ? _T($texte) : '';
259 259
 }
260 260
 
261 261
 
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
  * @return string
276 276
  */
277 277
 function puce_statut_auteur_dist($id, $statut, $id_parent, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) {
278
-	$img = statut_image('auteur', $statut);
279
-	if (!$img) {
280
-		return '';
281
-	}
282
-	$alt = statut_titre('auteur', $statut);
278
+    $img = statut_image('auteur', $statut);
279
+    if (!$img) {
280
+        return '';
281
+    }
282
+    $alt = statut_titre('auteur', $statut);
283 283
 
284
-	$fond = '';
285
-	$titre = '';
284
+    $fond = '';
285
+    $titre = '';
286 286
 
287
-	/*
287
+    /*
288 288
 	if ($type != 'auteur') {
289 289
 	  $img2 = chemin_image('del-16.png');
290 290
 	  $titre = _T('titre_image_redacteur');
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 	}
295 295
 	*/
296 296
 
297
-	return http_img_pack($img, $alt, $fond, $alt);
297
+    return http_img_pack($img, $alt, $fond, $alt);
298 298
 }
299 299
 
300 300
 
301 301
 function puce_statut_rubrique_dist($id, $statut, $id_rubrique, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) {
302
-	return http_img_pack('rubrique-16.png', '');
302
+    return http_img_pack('rubrique-16.png', '');
303 303
 }
304 304
 
305 305
 /**
@@ -323,110 +323,110 @@  discard block
 block discarded – undo
323 323
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
324 324
  **/
325 325
 function puce_statut_changement_rapide(
326
-	$id,
327
-	$statut,
328
-	$id_rubrique,
329
-	$type = 'article',
330
-	$ajax = false,
331
-	$menu_rapide = _ACTIVER_PUCE_RAPIDE
326
+    $id,
327
+    $statut,
328
+    $id_rubrique,
329
+    $type = 'article',
330
+    $ajax = false,
331
+    $menu_rapide = _ACTIVER_PUCE_RAPIDE
332 332
 ) {
333
-	$src = statut_image($type, $statut);
334
-	if (!$src) {
335
-		return $src;
336
-	}
337
-
338
-	if (
339
-		!$id
340
-		or !_SPIP_AJAX
341
-		or !$menu_rapide
342
-	) {
343
-		$ajax_node = '';
344
-	} else {
345
-		$ajax_node = " class='imgstatut$type$id'";
346
-	}
347
-
348
-
349
-	$t = statut_titre($type, $statut);
350
-	$inser_puce = http_img_pack($src, $t, $ajax_node, $t);
351
-
352
-	if (!$ajax_node) {
353
-		return $inser_puce;
354
-	}
355
-
356
-	$table = table_objet_sql($type);
357
-	$desc = lister_tables_objets_sql($table);
358
-	if (!isset($desc['statut_textes_instituer'])) {
359
-		return $inser_puce;
360
-	}
361
-
362
-	if (!function_exists('autoriser')) {
363
-		include_spip('inc/autoriser');
364
-	}
365
-
366
-	// cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique)
367
-	if ($id_rubrique) {
368
-		if (!autoriser('publierdans', 'rubrique', $id_rubrique)) {
369
-			return $inser_puce;
370
-		}
371
-	} // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie
372
-	else {
373
-		if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) {
374
-			return $inser_puce;
375
-		}
376
-	}
377
-
378
-	$coord = array_flip(array_keys($desc['statut_textes_instituer']));
379
-	if (!isset($coord[$statut])) {
380
-		return $inser_puce;
381
-	}
382
-
383
-	$unit = 18/*widh de img*/ + 0/*padding*/
384
-	;
385
-	$margin = 0; /* marge a gauche + droite */
386
-	$zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/
387
-	;
388
-	$clip = $zero + ($unit * $coord[$statut]);
389
-
390
-	if ($ajax) {
391
-		$width = $unit * (is_countable($desc['statut_textes_instituer']) ? count($desc['statut_textes_instituer']) : 0) + $margin;
392
-		$out = "<span class='puce_objet_fixe $type'>"
393
-			. $inser_puce
394
-			. '</span>'
395
-			. "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
396
-		$i = 0;
397
-		foreach ($desc['statut_textes_instituer'] as $s => $t) {
398
-			$out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t));
399
-		}
400
-		$out .= '</span>';
401
-
402
-		return $out;
403
-	} else {
404
-		$nom = 'puce_statut_';
405
-		$action = generer_url_ecrire('puce_statut', '', true);
406
-		$lang_dir = lang_dir(lang_typo());
407
-
408
-		return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>"
409
-		. $inser_puce
410
-		. '</span>';
411
-	}
333
+    $src = statut_image($type, $statut);
334
+    if (!$src) {
335
+        return $src;
336
+    }
337
+
338
+    if (
339
+        !$id
340
+        or !_SPIP_AJAX
341
+        or !$menu_rapide
342
+    ) {
343
+        $ajax_node = '';
344
+    } else {
345
+        $ajax_node = " class='imgstatut$type$id'";
346
+    }
347
+
348
+
349
+    $t = statut_titre($type, $statut);
350
+    $inser_puce = http_img_pack($src, $t, $ajax_node, $t);
351
+
352
+    if (!$ajax_node) {
353
+        return $inser_puce;
354
+    }
355
+
356
+    $table = table_objet_sql($type);
357
+    $desc = lister_tables_objets_sql($table);
358
+    if (!isset($desc['statut_textes_instituer'])) {
359
+        return $inser_puce;
360
+    }
361
+
362
+    if (!function_exists('autoriser')) {
363
+        include_spip('inc/autoriser');
364
+    }
365
+
366
+    // cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique)
367
+    if ($id_rubrique) {
368
+        if (!autoriser('publierdans', 'rubrique', $id_rubrique)) {
369
+            return $inser_puce;
370
+        }
371
+    } // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie
372
+    else {
373
+        if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) {
374
+            return $inser_puce;
375
+        }
376
+    }
377
+
378
+    $coord = array_flip(array_keys($desc['statut_textes_instituer']));
379
+    if (!isset($coord[$statut])) {
380
+        return $inser_puce;
381
+    }
382
+
383
+    $unit = 18/*widh de img*/ + 0/*padding*/
384
+    ;
385
+    $margin = 0; /* marge a gauche + droite */
386
+    $zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/
387
+    ;
388
+    $clip = $zero + ($unit * $coord[$statut]);
389
+
390
+    if ($ajax) {
391
+        $width = $unit * (is_countable($desc['statut_textes_instituer']) ? count($desc['statut_textes_instituer']) : 0) + $margin;
392
+        $out = "<span class='puce_objet_fixe $type'>"
393
+            . $inser_puce
394
+            . '</span>'
395
+            . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
396
+        $i = 0;
397
+        foreach ($desc['statut_textes_instituer'] as $s => $t) {
398
+            $out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t));
399
+        }
400
+        $out .= '</span>';
401
+
402
+        return $out;
403
+    } else {
404
+        $nom = 'puce_statut_';
405
+        $action = generer_url_ecrire('puce_statut', '', true);
406
+        $lang_dir = lang_dir(lang_typo());
407
+
408
+        return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>"
409
+        . $inser_puce
410
+        . '</span>';
411
+    }
412 412
 }
413 413
 
414 414
 
415 415
 function afficher_script_statut($id, $type, $n, $img, $statut, $titre, $act = '') {
416
-	$h = generer_action_auteur('instituer_objet', "$type-$id-$statut");
417
-	$t = supprimer_tags($titre);
416
+    $h = generer_action_auteur('instituer_objet', "$type-$id-$statut");
417
+    $t = supprimer_tags($titre);
418 418
 
419
-	return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>';
419
+    return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>';
420 420
 }
421 421
 
422 422
 // compat
423 423
 // La couleur du statut
424 424
 
425 425
 function puce_statut($statut, $atts = '') {
426
-	$src = statut_image('article', $statut);
427
-	if (!$src) {
428
-		return '';
429
-	}
426
+    $src = statut_image('article', $statut);
427
+    if (!$src) {
428
+        return '';
429
+    }
430 430
 
431
-	return http_img_pack($src, statut_titre('article', $statut), $atts);
431
+    return http_img_pack($src, statut_titre('article', $statut), $atts);
432 432
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_images_lib_mini.php 3 patches
Braces   +4 added lines, -9 removed lines patch added patch discarded remove patch
@@ -524,8 +524,7 @@  discard block
 block discarded – undo
524 524
 			process_image_svg_identite($ret);
525 525
 			$ret['creer'] = false;
526 526
 		}
527
-	}
528
-	else {
527
+	} else {
529 528
 		if (!function_exists($ret['fonction_imagecreatefrom'])) {
530 529
 			return false;
531 530
 		}
@@ -628,8 +627,7 @@  discard block
 block discarded – undo
628 627
 
629 628
 	if (isset($info['mime'])) {
630 629
 		$mime = $info['mime'];
631
-	}
632
-	else {
630
+	} else {
633 631
 		$mime = image_type_to_mime_type($info[2]);
634 632
 	}
635 633
 
@@ -1408,9 +1406,7 @@  discard block
 block discarded – undo
1408 1406
 	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1409 1407
 		$vignette = $destination . '.' . $format;
1410 1408
 		@copy($image, $vignette);
1411
-	}
1412
-
1413
-	elseif ($valeurs['format_source'] === 'svg') {
1409
+	} elseif ($valeurs['format_source'] === 'svg') {
1414 1410
 		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1415 1411
 			$format_sortie = 'svg';
1416 1412
 			$vignette = $destination . '.' . $format_sortie;
@@ -1846,8 +1842,7 @@  discard block
 block discarded – undo
1846 1842
 		$date = test_espace_prive() ? ('?' . $date) : '';
1847 1843
 
1848 1844
 		return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1849
-	}
1850
-	else {
1845
+	} else {
1851 1846
 		# BMP, tiff ... les redacteurs osent tout!
1852 1847
 		return $img;
1853 1848
 	}
Please login to merge, or discard this patch.
Indentation   +1323 added lines, -1323 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 include_spip('inc/filtres'); // par precaution
24 24
 include_spip('inc/filtres_images_mini'); // par precaution
@@ -38,21 +38,21 @@  discard block
 block discarded – undo
38 38
  *     Le code de la couleur en hexadécimal.
39 39
  */
40 40
 function _couleur_dec_to_hex($red, $green, $blue) {
41
-	$red = dechex($red);
42
-	$green = dechex($green);
43
-	$blue = dechex($blue);
44
-
45
-	if (strlen($red) == 1) {
46
-		$red = '0' . $red;
47
-	}
48
-	if (strlen($green) == 1) {
49
-		$green = '0' . $green;
50
-	}
51
-	if (strlen($blue) == 1) {
52
-		$blue = '0' . $blue;
53
-	}
54
-
55
-	return "$red$green$blue";
41
+    $red = dechex($red);
42
+    $green = dechex($green);
43
+    $blue = dechex($blue);
44
+
45
+    if (strlen($red) == 1) {
46
+        $red = '0' . $red;
47
+    }
48
+    if (strlen($green) == 1) {
49
+        $green = '0' . $green;
50
+    }
51
+    if (strlen($blue) == 1) {
52
+        $blue = '0' . $blue;
53
+    }
54
+
55
+    return "$red$green$blue";
56 56
 }
57 57
 
58 58
 /**
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
  *     Un tableau des 3 éléments : rouge, vert, bleu.
65 65
  */
66 66
 function _couleur_hex_to_dec($couleur) {
67
-	$couleur = couleur_html_to_hex($couleur);
68
-	$couleur = ltrim($couleur, '#');
69
-	if (strlen($couleur) === 3) {
70
-		$couleur = $couleur[0] . $couleur[0] . $couleur[1] . $couleur[1] . $couleur[2] . $couleur[2];
71
-	}
72
-	$retour = [];
73
-	$retour['red'] = hexdec(substr($couleur, 0, 2));
74
-	$retour['green'] = hexdec(substr($couleur, 2, 2));
75
-	$retour['blue'] = hexdec(substr($couleur, 4, 2));
76
-
77
-	return $retour;
67
+    $couleur = couleur_html_to_hex($couleur);
68
+    $couleur = ltrim($couleur, '#');
69
+    if (strlen($couleur) === 3) {
70
+        $couleur = $couleur[0] . $couleur[0] . $couleur[1] . $couleur[1] . $couleur[2] . $couleur[2];
71
+    }
72
+    $retour = [];
73
+    $retour['red'] = hexdec(substr($couleur, 0, 2));
74
+    $retour['green'] = hexdec(substr($couleur, 2, 2));
75
+    $retour['blue'] = hexdec(substr($couleur, 4, 2));
76
+
77
+    return $retour;
78 78
 }
79 79
 
80 80
 
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
  *     Le code de la couleur en hexadécimal.
92 92
  */
93 93
 function _couleur_hsl_to_hex($hue, $saturation, $lightness) {
94
-	$rgb = _couleur_hsl_to_rgb($hue, $saturation, $lightness);
95
-	return _couleur_dec_to_hex($rgb['r'], $rgb['g'], $rgb['b']);
94
+    $rgb = _couleur_hsl_to_rgb($hue, $saturation, $lightness);
95
+    return _couleur_dec_to_hex($rgb['r'], $rgb['g'], $rgb['b']);
96 96
 }
97 97
 
98 98
 /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
  *     Un tableau des 3 éléments : teinte, saturation, luminosité.
105 105
  */
106 106
 function _couleur_hex_to_hsl($couleur) {
107
-	$rgb = _couleur_hex_to_dec($couleur);
108
-	return _couleur_rgb_to_hsl($rgb['red'], $rgb['green'], $rgb['blue']);
107
+    $rgb = _couleur_hex_to_dec($couleur);
108
+    return _couleur_rgb_to_hsl($rgb['red'], $rgb['green'], $rgb['blue']);
109 109
 }
110 110
 
111 111
 /**
@@ -120,59 +120,59 @@  discard block
 block discarded – undo
120 120
  * @return array
121 121
  */
122 122
 function _couleur_rgb_to_hsl($R, $G, $B) {
123
-	$H = null;
124
-	$var_R = ($R / 255); // Where RGB values = 0 ÷ 255
125
-	$var_G = ($G / 255);
126
-	$var_B = ($B / 255);
127
-
128
-	$var_Min = min($var_R, $var_G, $var_B);   //Min. value of RGB
129
-	$var_Max = max($var_R, $var_G, $var_B);   //Max. value of RGB
130
-	$del_Max = $var_Max - $var_Min;           //Delta RGB value
131
-
132
-	$L = ($var_Max + $var_Min) / 2;
133
-
134
-	if ($del_Max == 0) {
135
-		//This is a gray, no chroma...
136
-		$H = 0; //HSL results = 0 ÷ 1
137
-		$S = 0;
138
-	} else {
139
-		// Chromatic data...
140
-		if ($L < 0.5) {
141
-			$S = $del_Max / ($var_Max + $var_Min);
142
-		} else {
143
-			$S = $del_Max / (2 - $var_Max - $var_Min);
144
-		}
145
-
146
-		$del_R = ((($var_Max - $var_R) / 6) + ($del_Max / 2)) / $del_Max;
147
-		$del_G = ((($var_Max - $var_G) / 6) + ($del_Max / 2)) / $del_Max;
148
-		$del_B = ((($var_Max - $var_B) / 6) + ($del_Max / 2)) / $del_Max;
149
-
150
-		if ($var_R == $var_Max) {
151
-			$H = $del_B - $del_G;
152
-		} else {
153
-			if ($var_G == $var_Max) {
154
-				$H = (1 / 3) + $del_R - $del_B;
155
-			} else {
156
-				if ($var_B == $var_Max) {
157
-					$H = (2 / 3) + $del_G - $del_R;
158
-				}
159
-			}
160
-		}
161
-
162
-		if ($H < 0) {
163
-			$H += 1;
164
-		}
165
-		if ($H > 1) {
166
-			$H -= 1;
167
-		}
168
-	}
169
-
170
-	$ret = [];
171
-	$ret['h'] = $H;
172
-	$ret['s'] = $S;
173
-	$ret['l'] = $L;
174
-
175
-	return $ret;
123
+    $H = null;
124
+    $var_R = ($R / 255); // Where RGB values = 0 ÷ 255
125
+    $var_G = ($G / 255);
126
+    $var_B = ($B / 255);
127
+
128
+    $var_Min = min($var_R, $var_G, $var_B);   //Min. value of RGB
129
+    $var_Max = max($var_R, $var_G, $var_B);   //Max. value of RGB
130
+    $del_Max = $var_Max - $var_Min;           //Delta RGB value
131
+
132
+    $L = ($var_Max + $var_Min) / 2;
133
+
134
+    if ($del_Max == 0) {
135
+        //This is a gray, no chroma...
136
+        $H = 0; //HSL results = 0 ÷ 1
137
+        $S = 0;
138
+    } else {
139
+        // Chromatic data...
140
+        if ($L < 0.5) {
141
+            $S = $del_Max / ($var_Max + $var_Min);
142
+        } else {
143
+            $S = $del_Max / (2 - $var_Max - $var_Min);
144
+        }
145
+
146
+        $del_R = ((($var_Max - $var_R) / 6) + ($del_Max / 2)) / $del_Max;
147
+        $del_G = ((($var_Max - $var_G) / 6) + ($del_Max / 2)) / $del_Max;
148
+        $del_B = ((($var_Max - $var_B) / 6) + ($del_Max / 2)) / $del_Max;
149
+
150
+        if ($var_R == $var_Max) {
151
+            $H = $del_B - $del_G;
152
+        } else {
153
+            if ($var_G == $var_Max) {
154
+                $H = (1 / 3) + $del_R - $del_B;
155
+            } else {
156
+                if ($var_B == $var_Max) {
157
+                    $H = (2 / 3) + $del_G - $del_R;
158
+                }
159
+            }
160
+        }
161
+
162
+        if ($H < 0) {
163
+            $H += 1;
164
+        }
165
+        if ($H > 1) {
166
+            $H -= 1;
167
+        }
168
+    }
169
+
170
+    $ret = [];
171
+    $ret['h'] = $H;
172
+    $ret['s'] = $S;
173
+    $ret['l'] = $L;
174
+
175
+    return $ret;
176 176
 }
177 177
 
178 178
 
@@ -188,52 +188,52 @@  discard block
 block discarded – undo
188 188
  * @return array
189 189
  */
190 190
 function _couleur_hsl_to_rgb($H, $S, $L) {
191
-	// helper
192
-	$hue_2_rgb = function ($v1, $v2, $vH) {
193
-		if ($vH < 0) {
194
-			$vH += 1;
195
-		}
196
-		if ($vH > 1) {
197
-			$vH -= 1;
198
-		}
199
-		if ((6 * $vH) < 1) {
200
-			return ($v1 + ($v2 - $v1) * 6 * $vH);
201
-		}
202
-		if ((2 * $vH) < 1) {
203
-			return ($v2);
204
-		}
205
-		if ((3 * $vH) < 2) {
206
-			return ($v1 + ($v2 - $v1) * ((2 / 3) - $vH) * 6);
207
-		}
208
-
209
-		return ($v1);
210
-	};
211
-
212
-	if ($S == 0) {
213
-		// HSV values = 0 -> 1
214
-		$R = $L * 255;
215
-		$G = $L * 255;
216
-		$B = $L * 255;
217
-	} else {
218
-		if ($L < 0.5) {
219
-			$var_2 = $L * (1 + $S);
220
-		} else {
221
-			$var_2 = ($L + $S) - ($S * $L);
222
-		}
223
-
224
-		$var_1 = 2 * $L - $var_2;
225
-
226
-		$R = 255 * $hue_2_rgb($var_1, $var_2, $H + (1 / 3));
227
-		$G = 255 * $hue_2_rgb($var_1, $var_2, $H);
228
-		$B = 255 * $hue_2_rgb($var_1, $var_2, $H - (1 / 3));
229
-	}
230
-
231
-	$ret = [];
232
-	$ret['r'] = floor($R);
233
-	$ret['g'] = floor($G);
234
-	$ret['b'] = floor($B);
235
-
236
-	return $ret;
191
+    // helper
192
+    $hue_2_rgb = function ($v1, $v2, $vH) {
193
+        if ($vH < 0) {
194
+            $vH += 1;
195
+        }
196
+        if ($vH > 1) {
197
+            $vH -= 1;
198
+        }
199
+        if ((6 * $vH) < 1) {
200
+            return ($v1 + ($v2 - $v1) * 6 * $vH);
201
+        }
202
+        if ((2 * $vH) < 1) {
203
+            return ($v2);
204
+        }
205
+        if ((3 * $vH) < 2) {
206
+            return ($v1 + ($v2 - $v1) * ((2 / 3) - $vH) * 6);
207
+        }
208
+
209
+        return ($v1);
210
+    };
211
+
212
+    if ($S == 0) {
213
+        // HSV values = 0 -> 1
214
+        $R = $L * 255;
215
+        $G = $L * 255;
216
+        $B = $L * 255;
217
+    } else {
218
+        if ($L < 0.5) {
219
+            $var_2 = $L * (1 + $S);
220
+        } else {
221
+            $var_2 = ($L + $S) - ($S * $L);
222
+        }
223
+
224
+        $var_1 = 2 * $L - $var_2;
225
+
226
+        $R = 255 * $hue_2_rgb($var_1, $var_2, $H + (1 / 3));
227
+        $G = 255 * $hue_2_rgb($var_1, $var_2, $H);
228
+        $B = 255 * $hue_2_rgb($var_1, $var_2, $H - (1 / 3));
229
+    }
230
+
231
+    $ret = [];
232
+    $ret['r'] = floor($R);
233
+    $ret['g'] = floor($G);
234
+    $ret['b'] = floor($B);
235
+
236
+    return $ret;
237 237
 }
238 238
 
239 239
 /**
@@ -251,11 +251,11 @@  discard block
 block discarded – undo
251 251
  *     true si il faut supprimer le fichier temporaire ; false sinon.
252 252
  */
253 253
 function statut_effacer_images_temporaires($stat) {
254
-	static $statut = false; // par defaut on grave toute les images
255
-	if ($stat === 'get') {
256
-		return $statut;
257
-	}
258
-	$statut = $stat ? true : false;
254
+    static $statut = false; // par defaut on grave toute les images
255
+    if ($stat === 'get') {
256
+        return $statut;
257
+    }
258
+    $statut = $stat ? true : false;
259 259
 }
260 260
 
261 261
 
@@ -308,243 +308,243 @@  discard block
 block discarded – undo
308 308
  *     - array : tableau décrivant de l'image
309 309
  */
310 310
 function _image_valeurs_trans($img, $effet, $forcer_format = false, $fonction_creation = null, $find_in_path = false, $support_svg = false) {
311
-	$ret = [];
312
-	$f = null;
313
-	static $images_recalcul = [];
314
-	if (strlen($img) == 0) {
315
-		return false;
316
-	}
317
-
318
-	$source = trim(extraire_attribut($img, 'src') ?? '');
319
-	if (strlen($source) < 1) {
320
-		$source = $img;
321
-		$img = "<img src='$source' />";
322
-	} elseif (
323
-		preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
324
-		and $extension = _image_trouver_extension_depuis_mime('image/' . $regs[1])
325
-		and in_array($extension, _image_extensions_acceptees_en_entree())
326
-	) {
327
-		# gerer img src="data:....base64"
328
-		$local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
329
-		if (!file_exists($local)) {
330
-			ecrire_fichier($local, base64_decode($regs[2]));
331
-		}
332
-		if ($sanitizer = charger_fonction($extension, 'sanitizer', true)) {
333
-			$sanitizer($local);
334
-		}
335
-		$source = $local;
336
-		$img = inserer_attribut($img, 'src', $source);
337
-		# eviter les mauvaises surprises lors de conversions de format
338
-		$img = inserer_attribut($img, 'width', '');
339
-		$img = inserer_attribut($img, 'height', '');
340
-	}
341
-
342
-	// les protocoles web prennent au moins 3 lettres
343
-	if (tester_url_absolue($source)) {
344
-		include_spip('inc/distant');
345
-		$fichier = _DIR_RACINE . copie_locale($source);
346
-		if (!$fichier) {
347
-			return '';
348
-		}
349
-		if (
350
-			$extension = _image_trouver_extension($fichier)
351
-			and $sanitizer = charger_fonction($extension, 'sanitizer', true)
352
-		) {
353
-			$sanitizer($fichier);
354
-		}
355
-	} else {
356
-		// enlever le timestamp eventuel
357
-		if (strpos($source, '?') !== false) {
358
-			$source = preg_replace(',[?][0-9]+$,', '', $source);
359
-		}
360
-		if (
361
-			strpos($source, '?') !== false
362
-			and strncmp($source, _DIR_IMG, strlen(_DIR_IMG)) == 0
363
-			and file_exists($f = preg_replace(',[?].*$,', '', $source))
364
-		) {
365
-			$source = $f;
366
-		}
367
-		$fichier = $source;
368
-	}
369
-
370
-	$terminaison_dest = '';
371
-	if ($terminaison = _image_trouver_extension($fichier)) {
372
-		$terminaison_dest = ($terminaison == 'gif') ? 'png' : $terminaison;
373
-	}
374
-
375
-	if (
376
-		$forcer_format !== false
377
-		// ignorer forcer_format si on a une image svg, que le filtre appelant ne supporte pas SVG, et que le forcage est un autre format image
378
-		and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format, _image_extensions_acceptees_en_sortie()))
379
-	) {
380
-		$terminaison_dest = $forcer_format;
381
-	}
382
-
383
-	if (!$terminaison_dest) {
384
-		return false;
385
-	}
386
-
387
-	$nom_fichier = substr($fichier, 0, strlen($fichier) - (strlen($terminaison) + 1));
388
-	$fichier_dest = $nom_fichier;
389
-	if (
390
-		($find_in_path and $f = find_in_path($fichier) and $fichier = $f)
391
-		or @file_exists($f = $fichier)
392
-	) {
393
-		// on passe la balise img a taille image qui exraira les attributs si possible
394
-		// au lieu de faire un acces disque sur le fichier
395
-		[$ret['hauteur'], $ret['largeur']] = taille_image($find_in_path ? $f : $img);
396
-		$date_src = @filemtime($f);
397
-	} elseif (
398
-		@file_exists($f = "$fichier.src")
399
-		and lire_fichier($f, $valeurs)
400
-		and $valeurs = unserialize($valeurs)
401
-		and isset($valeurs['hauteur_dest'])
402
-		and isset($valeurs['largeur_dest'])
403
-	) {
404
-		$ret['hauteur'] = $valeurs['hauteur_dest'];
405
-		$ret['largeur'] = $valeurs['largeur_dest'];
406
-		$date_src = $valeurs['date'];
407
-	} // pas de fichier source par la
408
-	else {
409
-		return false;
410
-	}
411
-
412
-	// pas de taille mesurable
413
-	if (!($ret['hauteur'] or $ret['largeur'])) {
414
-		return false;
415
-	}
416
-
417
-	// les images calculees dependent du chemin du fichier source
418
-	// pour une meme image source et un meme filtre on aboutira a 2 fichiers selon si l'appel est dans le public ou dans le prive
419
-	// ce n'est pas totalement optimal en terme de stockage, mais chaque image est associee a un fichier .src
420
-	// qui contient la methode de reconstrucion (le filtre + les arguments d'appel) et les arguments different entre prive et public
421
-	// la mise en commun du fichier image cree donc un bug et des problemes qui necessiteraient beaucoup de complexite de code
422
-	// alors que ca concerne peu de site au final
423
-	// la release de r23632+r23633+r23634 a provoque peu de remontee de bug attestant du peu de sites impactes
424
-	$identifiant = $fichier;
425
-
426
-	// cas general :
427
-	// on a un dossier cache commun et un nom de fichier qui varie avec l'effet
428
-	// cas particulier de reduire :
429
-	// un cache par dimension, et le nom de fichier est conserve, suffixe par la dimension aussi
430
-	$cache = 'cache-gd2';
431
-	if (substr($effet, 0, 7) == 'reduire') {
432
-		[, $maxWidth, $maxHeight] = explode('-', $effet);
433
-		[$destWidth, $destHeight] = _image_ratio($ret['largeur'], $ret['hauteur'], $maxWidth, $maxHeight);
434
-		$ret['largeur_dest'] = $destWidth;
435
-		$ret['hauteur_dest'] = $destHeight;
436
-		$effet = "L{$destWidth}xH$destHeight";
437
-		$cache = 'cache-vignettes';
438
-		$fichier_dest = basename($fichier_dest);
439
-		if (($ret['largeur'] <= $maxWidth) && ($ret['hauteur'] <= $maxHeight)) {
440
-			// on garde la terminaison initiale car image simplement copiee
441
-			// et on postfixe son nom avec un md5 du path
442
-			$terminaison_dest = $terminaison;
443
-			$fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
444
-		} else {
445
-			$fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
446
-		}
447
-		$cache = sous_repertoire(_DIR_VAR, $cache);
448
-		$cache = sous_repertoire($cache, $effet);
449
-	} else {
450
-		$fichier_dest = md5("$identifiant-$effet");
451
-		$cache = sous_repertoire(_DIR_VAR, $cache);
452
-		$cache = sous_repertoire($cache, substr($fichier_dest, 0, 2));
453
-		$fichier_dest = substr($fichier_dest, 2);
454
-	}
455
-
456
-	$fichier_dest = $cache . $fichier_dest . '.' . $terminaison_dest;
457
-
458
-	$GLOBALS['images_calculees'][] = $fichier_dest;
459
-
460
-	$creer = true;
461
-	// si recalcul des images demande, recalculer chaque image une fois
462
-	if (defined('_VAR_IMAGES') and _VAR_IMAGES and !isset($images_recalcul[$fichier_dest])) {
463
-		$images_recalcul[$fichier_dest] = true;
464
-	} else {
465
-		if (@file_exists($f = $fichier_dest)) {
466
-			if (filemtime($f) >= $date_src) {
467
-				$creer = false;
468
-			}
469
-		} else {
470
-			if (
471
-				@file_exists($f = "$fichier_dest.src")
472
-				and lire_fichier($f, $valeurs)
473
-				and $valeurs = unserialize($valeurs)
474
-				and $valeurs['date'] >= $date_src
475
-			) {
476
-				$creer = false;
477
-			}
478
-		}
479
-	}
480
-	if ($creer) {
481
-		if (!@file_exists($fichier)) {
482
-			if (!@file_exists("$fichier.src")) {
483
-				spip_log("Image absente : $fichier");
484
-
485
-				return false;
486
-			}
487
-			# on reconstruit l'image source absente a partir de la chaine des .src
488
-			reconstruire_image_intermediaire($fichier);
489
-		}
490
-	}
491
-
492
-	if ($creer) {
493
-		spip_log(
494
-			'filtre image ' . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
495
-			'images' . _LOG_DEBUG
496
-		);
497
-	}
498
-
499
-	$term_fonction = _image_trouver_extension_pertinente($fichier);
500
-	$ret['fonction_imagecreatefrom'] = '_imagecreatefrom' . $term_fonction;
501
-	$ret['fichier'] = $fichier;
502
-	$ret['fonction_image'] = '_image_image' . $terminaison_dest;
503
-	$ret['fichier_dest'] = $fichier_dest;
504
-	$ret['format_source'] = _image_extension_normalisee($terminaison);
505
-	$ret['format_dest'] = $terminaison_dest;
506
-	$ret['date_src'] = $date_src;
507
-	$ret['creer'] = $creer;
508
-	$ret['class'] = extraire_attribut($img, 'class');
509
-	$ret['alt'] = extraire_attribut($img, 'alt');
510
-	$ret['style'] = extraire_attribut($img, 'style');
511
-	$ret['tag'] = $img;
512
-	if ($fonction_creation) {
513
-		$ret['reconstruction'] = $fonction_creation;
514
-		# ecrire ici comment creer le fichier, car il est pas sur qu'on l'ecrira reelement
515
-		# cas de image_reduire qui finalement ne reduit pas l'image source
516
-		# ca evite d'essayer de le creer au prochain hit si il n'est pas la
517
-		#ecrire_fichier($ret['fichier_dest'].'.src',serialize($ret),true);
518
-	}
519
-
520
-	$ret = pipeline('image_preparer_filtre', [
521
-			'args' => [
522
-				'img' => $img,
523
-				'effet' => $effet,
524
-				'forcer_format' => $forcer_format,
525
-				'fonction_creation' => $fonction_creation,
526
-				'find_in_path' => $find_in_path,
527
-			],
528
-			'data' => $ret
529
-		]);
530
-
531
-	// une globale pour le debug en cas de crash memoire
532
-	$GLOBALS['derniere_image_calculee'] = $ret;
533
-
534
-	// traiter le cas particulier des SVG : si le filtre n'a pas annonce explicitement qu'il savait faire, on delegue
535
-	if ($term_fonction === 'svg') {
536
-		if ($creer and !$support_svg) {
537
-			process_image_svg_identite($ret);
538
-			$ret['creer'] = false;
539
-		}
540
-	}
541
-	else {
542
-		if (!function_exists($ret['fonction_imagecreatefrom'])) {
543
-			return false;
544
-		}
545
-	}
546
-
547
-	return $ret;
311
+    $ret = [];
312
+    $f = null;
313
+    static $images_recalcul = [];
314
+    if (strlen($img) == 0) {
315
+        return false;
316
+    }
317
+
318
+    $source = trim(extraire_attribut($img, 'src') ?? '');
319
+    if (strlen($source) < 1) {
320
+        $source = $img;
321
+        $img = "<img src='$source' />";
322
+    } elseif (
323
+        preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
324
+        and $extension = _image_trouver_extension_depuis_mime('image/' . $regs[1])
325
+        and in_array($extension, _image_extensions_acceptees_en_entree())
326
+    ) {
327
+        # gerer img src="data:....base64"
328
+        $local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
329
+        if (!file_exists($local)) {
330
+            ecrire_fichier($local, base64_decode($regs[2]));
331
+        }
332
+        if ($sanitizer = charger_fonction($extension, 'sanitizer', true)) {
333
+            $sanitizer($local);
334
+        }
335
+        $source = $local;
336
+        $img = inserer_attribut($img, 'src', $source);
337
+        # eviter les mauvaises surprises lors de conversions de format
338
+        $img = inserer_attribut($img, 'width', '');
339
+        $img = inserer_attribut($img, 'height', '');
340
+    }
341
+
342
+    // les protocoles web prennent au moins 3 lettres
343
+    if (tester_url_absolue($source)) {
344
+        include_spip('inc/distant');
345
+        $fichier = _DIR_RACINE . copie_locale($source);
346
+        if (!$fichier) {
347
+            return '';
348
+        }
349
+        if (
350
+            $extension = _image_trouver_extension($fichier)
351
+            and $sanitizer = charger_fonction($extension, 'sanitizer', true)
352
+        ) {
353
+            $sanitizer($fichier);
354
+        }
355
+    } else {
356
+        // enlever le timestamp eventuel
357
+        if (strpos($source, '?') !== false) {
358
+            $source = preg_replace(',[?][0-9]+$,', '', $source);
359
+        }
360
+        if (
361
+            strpos($source, '?') !== false
362
+            and strncmp($source, _DIR_IMG, strlen(_DIR_IMG)) == 0
363
+            and file_exists($f = preg_replace(',[?].*$,', '', $source))
364
+        ) {
365
+            $source = $f;
366
+        }
367
+        $fichier = $source;
368
+    }
369
+
370
+    $terminaison_dest = '';
371
+    if ($terminaison = _image_trouver_extension($fichier)) {
372
+        $terminaison_dest = ($terminaison == 'gif') ? 'png' : $terminaison;
373
+    }
374
+
375
+    if (
376
+        $forcer_format !== false
377
+        // ignorer forcer_format si on a une image svg, que le filtre appelant ne supporte pas SVG, et que le forcage est un autre format image
378
+        and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format, _image_extensions_acceptees_en_sortie()))
379
+    ) {
380
+        $terminaison_dest = $forcer_format;
381
+    }
382
+
383
+    if (!$terminaison_dest) {
384
+        return false;
385
+    }
386
+
387
+    $nom_fichier = substr($fichier, 0, strlen($fichier) - (strlen($terminaison) + 1));
388
+    $fichier_dest = $nom_fichier;
389
+    if (
390
+        ($find_in_path and $f = find_in_path($fichier) and $fichier = $f)
391
+        or @file_exists($f = $fichier)
392
+    ) {
393
+        // on passe la balise img a taille image qui exraira les attributs si possible
394
+        // au lieu de faire un acces disque sur le fichier
395
+        [$ret['hauteur'], $ret['largeur']] = taille_image($find_in_path ? $f : $img);
396
+        $date_src = @filemtime($f);
397
+    } elseif (
398
+        @file_exists($f = "$fichier.src")
399
+        and lire_fichier($f, $valeurs)
400
+        and $valeurs = unserialize($valeurs)
401
+        and isset($valeurs['hauteur_dest'])
402
+        and isset($valeurs['largeur_dest'])
403
+    ) {
404
+        $ret['hauteur'] = $valeurs['hauteur_dest'];
405
+        $ret['largeur'] = $valeurs['largeur_dest'];
406
+        $date_src = $valeurs['date'];
407
+    } // pas de fichier source par la
408
+    else {
409
+        return false;
410
+    }
411
+
412
+    // pas de taille mesurable
413
+    if (!($ret['hauteur'] or $ret['largeur'])) {
414
+        return false;
415
+    }
416
+
417
+    // les images calculees dependent du chemin du fichier source
418
+    // pour une meme image source et un meme filtre on aboutira a 2 fichiers selon si l'appel est dans le public ou dans le prive
419
+    // ce n'est pas totalement optimal en terme de stockage, mais chaque image est associee a un fichier .src
420
+    // qui contient la methode de reconstrucion (le filtre + les arguments d'appel) et les arguments different entre prive et public
421
+    // la mise en commun du fichier image cree donc un bug et des problemes qui necessiteraient beaucoup de complexite de code
422
+    // alors que ca concerne peu de site au final
423
+    // la release de r23632+r23633+r23634 a provoque peu de remontee de bug attestant du peu de sites impactes
424
+    $identifiant = $fichier;
425
+
426
+    // cas general :
427
+    // on a un dossier cache commun et un nom de fichier qui varie avec l'effet
428
+    // cas particulier de reduire :
429
+    // un cache par dimension, et le nom de fichier est conserve, suffixe par la dimension aussi
430
+    $cache = 'cache-gd2';
431
+    if (substr($effet, 0, 7) == 'reduire') {
432
+        [, $maxWidth, $maxHeight] = explode('-', $effet);
433
+        [$destWidth, $destHeight] = _image_ratio($ret['largeur'], $ret['hauteur'], $maxWidth, $maxHeight);
434
+        $ret['largeur_dest'] = $destWidth;
435
+        $ret['hauteur_dest'] = $destHeight;
436
+        $effet = "L{$destWidth}xH$destHeight";
437
+        $cache = 'cache-vignettes';
438
+        $fichier_dest = basename($fichier_dest);
439
+        if (($ret['largeur'] <= $maxWidth) && ($ret['hauteur'] <= $maxHeight)) {
440
+            // on garde la terminaison initiale car image simplement copiee
441
+            // et on postfixe son nom avec un md5 du path
442
+            $terminaison_dest = $terminaison;
443
+            $fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
444
+        } else {
445
+            $fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
446
+        }
447
+        $cache = sous_repertoire(_DIR_VAR, $cache);
448
+        $cache = sous_repertoire($cache, $effet);
449
+    } else {
450
+        $fichier_dest = md5("$identifiant-$effet");
451
+        $cache = sous_repertoire(_DIR_VAR, $cache);
452
+        $cache = sous_repertoire($cache, substr($fichier_dest, 0, 2));
453
+        $fichier_dest = substr($fichier_dest, 2);
454
+    }
455
+
456
+    $fichier_dest = $cache . $fichier_dest . '.' . $terminaison_dest;
457
+
458
+    $GLOBALS['images_calculees'][] = $fichier_dest;
459
+
460
+    $creer = true;
461
+    // si recalcul des images demande, recalculer chaque image une fois
462
+    if (defined('_VAR_IMAGES') and _VAR_IMAGES and !isset($images_recalcul[$fichier_dest])) {
463
+        $images_recalcul[$fichier_dest] = true;
464
+    } else {
465
+        if (@file_exists($f = $fichier_dest)) {
466
+            if (filemtime($f) >= $date_src) {
467
+                $creer = false;
468
+            }
469
+        } else {
470
+            if (
471
+                @file_exists($f = "$fichier_dest.src")
472
+                and lire_fichier($f, $valeurs)
473
+                and $valeurs = unserialize($valeurs)
474
+                and $valeurs['date'] >= $date_src
475
+            ) {
476
+                $creer = false;
477
+            }
478
+        }
479
+    }
480
+    if ($creer) {
481
+        if (!@file_exists($fichier)) {
482
+            if (!@file_exists("$fichier.src")) {
483
+                spip_log("Image absente : $fichier");
484
+
485
+                return false;
486
+            }
487
+            # on reconstruit l'image source absente a partir de la chaine des .src
488
+            reconstruire_image_intermediaire($fichier);
489
+        }
490
+    }
491
+
492
+    if ($creer) {
493
+        spip_log(
494
+            'filtre image ' . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
495
+            'images' . _LOG_DEBUG
496
+        );
497
+    }
498
+
499
+    $term_fonction = _image_trouver_extension_pertinente($fichier);
500
+    $ret['fonction_imagecreatefrom'] = '_imagecreatefrom' . $term_fonction;
501
+    $ret['fichier'] = $fichier;
502
+    $ret['fonction_image'] = '_image_image' . $terminaison_dest;
503
+    $ret['fichier_dest'] = $fichier_dest;
504
+    $ret['format_source'] = _image_extension_normalisee($terminaison);
505
+    $ret['format_dest'] = $terminaison_dest;
506
+    $ret['date_src'] = $date_src;
507
+    $ret['creer'] = $creer;
508
+    $ret['class'] = extraire_attribut($img, 'class');
509
+    $ret['alt'] = extraire_attribut($img, 'alt');
510
+    $ret['style'] = extraire_attribut($img, 'style');
511
+    $ret['tag'] = $img;
512
+    if ($fonction_creation) {
513
+        $ret['reconstruction'] = $fonction_creation;
514
+        # ecrire ici comment creer le fichier, car il est pas sur qu'on l'ecrira reelement
515
+        # cas de image_reduire qui finalement ne reduit pas l'image source
516
+        # ca evite d'essayer de le creer au prochain hit si il n'est pas la
517
+        #ecrire_fichier($ret['fichier_dest'].'.src',serialize($ret),true);
518
+    }
519
+
520
+    $ret = pipeline('image_preparer_filtre', [
521
+            'args' => [
522
+                'img' => $img,
523
+                'effet' => $effet,
524
+                'forcer_format' => $forcer_format,
525
+                'fonction_creation' => $fonction_creation,
526
+                'find_in_path' => $find_in_path,
527
+            ],
528
+            'data' => $ret
529
+        ]);
530
+
531
+    // une globale pour le debug en cas de crash memoire
532
+    $GLOBALS['derniere_image_calculee'] = $ret;
533
+
534
+    // traiter le cas particulier des SVG : si le filtre n'a pas annonce explicitement qu'il savait faire, on delegue
535
+    if ($term_fonction === 'svg') {
536
+        if ($creer and !$support_svg) {
537
+            process_image_svg_identite($ret);
538
+            $ret['creer'] = false;
539
+        }
540
+    }
541
+    else {
542
+        if (!function_exists($ret['fonction_imagecreatefrom'])) {
543
+            return false;
544
+        }
545
+    }
546
+
547
+    return $ret;
548 548
 }
549 549
 
550 550
 
@@ -553,54 +553,54 @@  discard block
 block discarded – undo
553 553
  * @return array
554 554
  */
555 555
 function _image_extensions_acceptees_en_entree() {
556
-	static $extensions = null;
557
-	if (empty($extensions)) {
558
-		$extensions = ['png', 'gif', 'jpg', 'jpeg'];
559
-		if (!empty($GLOBALS['meta']['gd_formats'])) {
560
-			// action=tester renseigne gd_formats et detecte le support de webp
561
-			$extensions = array_merge(explode(',', $GLOBALS['meta']['gd_formats']));
562
-			$extensions = array_map('trim', $extensions);
563
-			$extensions = array_filter($extensions);
564
-			if (in_array('jpg', $extensions)) {
565
-				$extensions[] = 'jpeg';
566
-			}
567
-			$extensions = array_unique($extensions);
568
-		}
569
-		$extensions[] = 'svg'; // on le supporte toujours avec des fonctions specifiques
570
-	}
571
-
572
-	return $extensions;
556
+    static $extensions = null;
557
+    if (empty($extensions)) {
558
+        $extensions = ['png', 'gif', 'jpg', 'jpeg'];
559
+        if (!empty($GLOBALS['meta']['gd_formats'])) {
560
+            // action=tester renseigne gd_formats et detecte le support de webp
561
+            $extensions = array_merge(explode(',', $GLOBALS['meta']['gd_formats']));
562
+            $extensions = array_map('trim', $extensions);
563
+            $extensions = array_filter($extensions);
564
+            if (in_array('jpg', $extensions)) {
565
+                $extensions[] = 'jpeg';
566
+            }
567
+            $extensions = array_unique($extensions);
568
+        }
569
+        $extensions[] = 'svg'; // on le supporte toujours avec des fonctions specifiques
570
+    }
571
+
572
+    return $extensions;
573 573
 }
574 574
 
575 575
 /**
576 576
  * @return array|string[]|null
577 577
  */
578 578
 function _image_extensions_acceptees_en_sortie() {
579
-	static $extensions = null;
580
-	if (empty($extensions)) {
581
-		$extensions = _image_extensions_acceptees_en_entree();
582
-		$extensions = array_diff($extensions, ['jpeg']);
583
-		if (in_array('gif', $extensions) and !function_exists('imagegif')) {
584
-			$extensions = array_diff($extensions, ['gif']);
585
-		}
586
-		if (in_array('webp', $extensions) and !function_exists('imagewebp')) {
587
-			$extensions = array_diff($extensions, ['webp']);
588
-		}
589
-	}
590
-
591
-	return $extensions;
579
+    static $extensions = null;
580
+    if (empty($extensions)) {
581
+        $extensions = _image_extensions_acceptees_en_entree();
582
+        $extensions = array_diff($extensions, ['jpeg']);
583
+        if (in_array('gif', $extensions) and !function_exists('imagegif')) {
584
+            $extensions = array_diff($extensions, ['gif']);
585
+        }
586
+        if (in_array('webp', $extensions) and !function_exists('imagewebp')) {
587
+            $extensions = array_diff($extensions, ['webp']);
588
+        }
589
+    }
590
+
591
+    return $extensions;
592 592
 }
593 593
 
594 594
 function _image_extension_normalisee($extension) {
595
-	$extension = strtolower($extension);
596
-	if ($extension === 'jpeg') {
597
-		$extension = 'jpg';
598
-	}
599
-	return $extension;
595
+    $extension = strtolower($extension);
596
+    if ($extension === 'jpeg') {
597
+        $extension = 'jpg';
598
+    }
599
+    return $extension;
600 600
 }
601 601
 
602 602
 function _image_extensions_conservent_transparence() {
603
-	return ['png', 'webp'];
603
+    return ['png', 'webp'];
604 604
 }
605 605
 
606 606
 
@@ -610,12 +610,12 @@  discard block
 block discarded – undo
610 610
  * @return string
611 611
  */
612 612
 function _image_trouver_extension($path) {
613
-	$preg_extensions = implode('|', _image_extensions_acceptees_en_entree());
614
-	if (preg_match(",\.($preg_extensions)($|[?]),i", $path, $regs)) {
615
-		$terminaison = strtolower($regs[1]);
616
-		return $terminaison;
617
-	}
618
-	return '';
613
+    $preg_extensions = implode('|', _image_extensions_acceptees_en_entree());
614
+    if (preg_match(",\.($preg_extensions)($|[?]),i", $path, $regs)) {
615
+        $terminaison = strtolower($regs[1]);
616
+        return $terminaison;
617
+    }
618
+    return '';
619 619
 }
620 620
 
621 621
 /**
@@ -626,33 +626,33 @@  discard block
 block discarded – undo
626 626
  * @return string Extension, dans le format attendu par les fonctions 'gd' ('jpeg' pour les .jpg par exemple)
627 627
  */
628 628
 function _image_trouver_extension_pertinente($path) {
629
-	$path = supprimer_timestamp($path);
630
-	$terminaison = _image_trouver_extension($path);
631
-	if ($terminaison == 'jpg') {
632
-		$terminaison = 'jpeg';
633
-	}
634
-
635
-	if (!file_exists($path)) {
636
-		return $terminaison;
637
-	}
638
-
639
-	if (!$info = @spip_getimagesize($path)) {
640
-		return $terminaison;
641
-	}
642
-
643
-	if (isset($info['mime'])) {
644
-		$mime = $info['mime'];
645
-	}
646
-	else {
647
-		$mime = image_type_to_mime_type($info[2]);
648
-	}
649
-
650
-	$_terminaison = _image_trouver_extension_depuis_mime($mime);
651
-	if ($_terminaison and $_terminaison !== $terminaison) {
652
-		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.' . _LOG_INFO_IMPORTANTE);
653
-		$terminaison = $_terminaison;
654
-	}
655
-	return $terminaison;
629
+    $path = supprimer_timestamp($path);
630
+    $terminaison = _image_trouver_extension($path);
631
+    if ($terminaison == 'jpg') {
632
+        $terminaison = 'jpeg';
633
+    }
634
+
635
+    if (!file_exists($path)) {
636
+        return $terminaison;
637
+    }
638
+
639
+    if (!$info = @spip_getimagesize($path)) {
640
+        return $terminaison;
641
+    }
642
+
643
+    if (isset($info['mime'])) {
644
+        $mime = $info['mime'];
645
+    }
646
+    else {
647
+        $mime = image_type_to_mime_type($info[2]);
648
+    }
649
+
650
+    $_terminaison = _image_trouver_extension_depuis_mime($mime);
651
+    if ($_terminaison and $_terminaison !== $terminaison) {
652
+        spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.' . _LOG_INFO_IMPORTANTE);
653
+        $terminaison = $_terminaison;
654
+    }
655
+    return $terminaison;
656 656
 }
657 657
 
658 658
 /**
@@ -660,36 +660,36 @@  discard block
 block discarded – undo
660 660
  * @return string
661 661
  */
662 662
 function _image_trouver_extension_depuis_mime($mime) {
663
-	switch (strtolower($mime)) {
664
-		case 'image/png':
665
-		case 'image/x-png':
666
-			$terminaison = 'png';
667
-			break;
668
-
669
-		case 'image/jpg':
670
-		case 'image/jpeg':
671
-		case 'image/pjpeg':
672
-			$terminaison = 'jpeg';
673
-			break;
674
-
675
-		case 'image/gif':
676
-			$terminaison = 'gif';
677
-			break;
678
-
679
-		case 'image/webp':
680
-		case 'image/x-webp':
681
-			$terminaison = 'webp';
682
-			break;
683
-
684
-		case 'image/svg+xml':
685
-			$terminaison = 'svg';
686
-			break;
687
-
688
-		default:
689
-			$terminaison = '';
690
-	}
691
-
692
-	return $terminaison;
663
+    switch (strtolower($mime)) {
664
+        case 'image/png':
665
+        case 'image/x-png':
666
+            $terminaison = 'png';
667
+            break;
668
+
669
+        case 'image/jpg':
670
+        case 'image/jpeg':
671
+        case 'image/pjpeg':
672
+            $terminaison = 'jpeg';
673
+            break;
674
+
675
+        case 'image/gif':
676
+            $terminaison = 'gif';
677
+            break;
678
+
679
+        case 'image/webp':
680
+        case 'image/x-webp':
681
+            $terminaison = 'webp';
682
+            break;
683
+
684
+        case 'image/svg+xml':
685
+            $terminaison = 'svg';
686
+            break;
687
+
688
+        default:
689
+            $terminaison = '';
690
+    }
691
+
692
+    return $terminaison;
693 693
 }
694 694
 
695 695
 
@@ -709,18 +709,18 @@  discard block
 block discarded – undo
709 709
  *     Une ressource de type Image GD.
710 710
  */
711 711
 function _imagecreatefrom_func(string $func, string $filename) {
712
-	if (!function_exists($func)) {
713
-		spip_log("GD indisponible : $func inexistante. Traitement $filename impossible.", _LOG_CRITIQUE);
714
-		erreur_squelette("GD indisponible : $func inexistante. Traitement $filename impossible.");
715
-		return null;
716
-	}
717
-	$img = @$func($filename);
718
-	if (!$img) {
719
-		spip_log("Erreur lecture imagecreatefromjpeg $filename", _LOG_CRITIQUE);
720
-		erreur_squelette("Erreur lecture imagecreatefromjpeg $filename");
721
-		$img = imagecreate(10, 10);
722
-	}
723
-	return $img;
712
+    if (!function_exists($func)) {
713
+        spip_log("GD indisponible : $func inexistante. Traitement $filename impossible.", _LOG_CRITIQUE);
714
+        erreur_squelette("GD indisponible : $func inexistante. Traitement $filename impossible.");
715
+        return null;
716
+    }
717
+    $img = @$func($filename);
718
+    if (!$img) {
719
+        spip_log("Erreur lecture imagecreatefromjpeg $filename", _LOG_CRITIQUE);
720
+        erreur_squelette("Erreur lecture imagecreatefromjpeg $filename");
721
+        $img = imagecreate(10, 10);
722
+    }
723
+    return $img;
724 724
 }
725 725
 
726 726
 /**
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
  *     Une ressource de type Image GD.
737 737
  */
738 738
 function _imagecreatefromjpeg($filename) {
739
-	return _imagecreatefrom_func('imagecreatefromjpeg', $filename);
739
+    return _imagecreatefrom_func('imagecreatefromjpeg', $filename);
740 740
 }
741 741
 
742 742
 /**
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
  *     Une ressource de type Image GD.
753 753
  */
754 754
 function _imagecreatefrompng($filename) {
755
-	return _imagecreatefrom_func('imagecreatefrompng', $filename);
755
+    return _imagecreatefrom_func('imagecreatefrompng', $filename);
756 756
 }
757 757
 
758 758
 /**
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
  *     Une ressource de type Image GD.
769 769
  */
770 770
 function _imagecreatefromgif($filename) {
771
-	return _imagecreatefrom_func('imagecreatefromgif', $filename);
771
+    return _imagecreatefrom_func('imagecreatefromgif', $filename);
772 772
 }
773 773
 
774 774
 
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
  *     Une ressource de type Image GD.
786 786
  */
787 787
 function _imagecreatefromwebp($filename) {
788
-	return _imagecreatefrom_func('imagecreatefromwebp', $filename);
788
+    return _imagecreatefrom_func('imagecreatefromwebp', $filename);
789 789
 }
790 790
 
791 791
 /**
@@ -803,24 +803,24 @@  discard block
 block discarded – undo
803 803
  *     - true si une image est bien retournée.
804 804
  */
805 805
 function _image_imagepng($img, $fichier) {
806
-	if (!function_exists('imagepng')) {
807
-		return false;
808
-	}
809
-	$tmp = $fichier . '.tmp';
810
-	$ret = imagepng($img, $tmp);
811
-	if (file_exists($tmp)) {
812
-		$taille_test = getimagesize($tmp);
813
-		if ($taille_test[0] < 1) {
814
-			return false;
815
-		}
816
-
817
-		spip_unlink($fichier); // le fichier peut deja exister
818
-		@rename($tmp, $fichier);
819
-
820
-		return $ret;
821
-	}
822
-
823
-	return false;
806
+    if (!function_exists('imagepng')) {
807
+        return false;
808
+    }
809
+    $tmp = $fichier . '.tmp';
810
+    $ret = imagepng($img, $tmp);
811
+    if (file_exists($tmp)) {
812
+        $taille_test = getimagesize($tmp);
813
+        if ($taille_test[0] < 1) {
814
+            return false;
815
+        }
816
+
817
+        spip_unlink($fichier); // le fichier peut deja exister
818
+        @rename($tmp, $fichier);
819
+
820
+        return $ret;
821
+    }
822
+
823
+    return false;
824 824
 }
825 825
 
826 826
 /**
@@ -838,24 +838,24 @@  discard block
 block discarded – undo
838 838
  *     - true si une image est bien retournée.
839 839
  */
840 840
 function _image_imagegif($img, $fichier) {
841
-	if (!function_exists('imagegif')) {
842
-		return false;
843
-	}
844
-	$tmp = $fichier . '.tmp';
845
-	$ret = imagegif($img, $tmp);
846
-	if (file_exists($tmp)) {
847
-		$taille_test = getimagesize($tmp);
848
-		if ($taille_test[0] < 1) {
849
-			return false;
850
-		}
851
-
852
-		spip_unlink($fichier); // le fichier peut deja exister
853
-		@rename($tmp, $fichier);
854
-
855
-		return $ret;
856
-	}
857
-
858
-	return false;
841
+    if (!function_exists('imagegif')) {
842
+        return false;
843
+    }
844
+    $tmp = $fichier . '.tmp';
845
+    $ret = imagegif($img, $tmp);
846
+    if (file_exists($tmp)) {
847
+        $taille_test = getimagesize($tmp);
848
+        if ($taille_test[0] < 1) {
849
+            return false;
850
+        }
851
+
852
+        spip_unlink($fichier); // le fichier peut deja exister
853
+        @rename($tmp, $fichier);
854
+
855
+        return $ret;
856
+    }
857
+
858
+    return false;
859 859
 }
860 860
 
861 861
 /**
@@ -878,29 +878,29 @@  discard block
 block discarded – undo
878 878
  *     - true si une image est bien retournée.
879 879
  */
880 880
 function _image_imagejpg($img, $fichier, $qualite = _IMG_GD_QUALITE) {
881
-	if (!function_exists('imagejpeg')) {
882
-		return false;
883
-	}
884
-	$tmp = $fichier . '.tmp';
881
+    if (!function_exists('imagejpeg')) {
882
+        return false;
883
+    }
884
+    $tmp = $fichier . '.tmp';
885 885
 
886
-	// Enable interlancing
887
-	imageinterlace($img, true);
886
+    // Enable interlancing
887
+    imageinterlace($img, true);
888 888
 
889
-	$ret = imagejpeg($img, $tmp, $qualite);
889
+    $ret = imagejpeg($img, $tmp, $qualite);
890 890
 
891
-	if (file_exists($tmp)) {
892
-		$taille_test = getimagesize($tmp);
893
-		if ($taille_test[0] < 1) {
894
-			return false;
895
-		}
891
+    if (file_exists($tmp)) {
892
+        $taille_test = getimagesize($tmp);
893
+        if ($taille_test[0] < 1) {
894
+            return false;
895
+        }
896 896
 
897
-		spip_unlink($fichier); // le fichier peut deja exister
898
-		@rename($tmp, $fichier);
897
+        spip_unlink($fichier); // le fichier peut deja exister
898
+        @rename($tmp, $fichier);
899 899
 
900
-		return $ret;
901
-	}
900
+        return $ret;
901
+    }
902 902
 
903
-	return false;
903
+    return false;
904 904
 }
905 905
 
906 906
 /**
@@ -918,9 +918,9 @@  discard block
 block discarded – undo
918 918
  *     true si le fichier a bien été créé ; false sinon.
919 919
  */
920 920
 function _image_imageico($img, $fichier) {
921
-	$gd_image_array = [$img];
921
+    $gd_image_array = [$img];
922 922
 
923
-	return ecrire_fichier($fichier, phpthumb_functions::GD2ICOstring($gd_image_array));
923
+    return ecrire_fichier($fichier, phpthumb_functions::GD2ICOstring($gd_image_array));
924 924
 }
925 925
 
926 926
 
@@ -939,24 +939,24 @@  discard block
 block discarded – undo
939 939
  *     - true si une image est bien retournée.
940 940
  */
941 941
 function _image_imagewebp($img, $fichier, $qualite = _IMG_GD_QUALITE) {
942
-	if (!function_exists('imagewebp')) {
943
-		return false;
944
-	}
945
-	$tmp = $fichier . '.tmp';
946
-	$ret = imagewebp($img, $tmp, $qualite);
947
-	if (file_exists($tmp)) {
948
-		$taille_test = getimagesize($tmp);
949
-		if ($taille_test[0] < 1) {
950
-			return false;
951
-		}
952
-
953
-		spip_unlink($fichier); // le fichier peut deja exister
954
-		@rename($tmp, $fichier);
955
-
956
-		return $ret;
957
-	}
958
-
959
-	return false;
942
+    if (!function_exists('imagewebp')) {
943
+        return false;
944
+    }
945
+    $tmp = $fichier . '.tmp';
946
+    $ret = imagewebp($img, $tmp, $qualite);
947
+    if (file_exists($tmp)) {
948
+        $taille_test = getimagesize($tmp);
949
+        if ($taille_test[0] < 1) {
950
+            return false;
951
+        }
952
+
953
+        spip_unlink($fichier); // le fichier peut deja exister
954
+        @rename($tmp, $fichier);
955
+
956
+        return $ret;
957
+    }
958
+
959
+    return false;
960 960
 }
961 961
 
962 962
 /**
@@ -976,35 +976,35 @@  discard block
 block discarded – undo
976 976
  */
977 977
 function _image_imagesvg($img, $fichier) {
978 978
 
979
-	$tmp = $fichier . '.tmp';
980
-	if (strpos($img, '<') === false) {
981
-		$img = supprimer_timestamp($img);
982
-		if (!file_exists($img)) {
983
-			return false;
984
-		}
985
-		@copy($img, $tmp);
986
-		if (filesize($tmp) == filesize($img)) {
987
-			spip_unlink($fichier); // le fichier peut deja exister
988
-			@rename($tmp, $fichier);
989
-			return true;
990
-		}
991
-		return false;
992
-	}
993
-
994
-	file_put_contents($tmp, $img);
995
-	if (file_exists($tmp)) {
996
-		$taille_test = spip_getimagesize($tmp);
997
-		if ($taille_test[0] < 1) {
998
-			return false;
999
-		}
1000
-
1001
-		spip_unlink($fichier); // le fichier peut deja exister
1002
-		@rename($tmp, $fichier);
1003
-
1004
-		return true;
1005
-	}
1006
-
1007
-	return false;
979
+    $tmp = $fichier . '.tmp';
980
+    if (strpos($img, '<') === false) {
981
+        $img = supprimer_timestamp($img);
982
+        if (!file_exists($img)) {
983
+            return false;
984
+        }
985
+        @copy($img, $tmp);
986
+        if (filesize($tmp) == filesize($img)) {
987
+            spip_unlink($fichier); // le fichier peut deja exister
988
+            @rename($tmp, $fichier);
989
+            return true;
990
+        }
991
+        return false;
992
+    }
993
+
994
+    file_put_contents($tmp, $img);
995
+    if (file_exists($tmp)) {
996
+        $taille_test = spip_getimagesize($tmp);
997
+        if ($taille_test[0] < 1) {
998
+            return false;
999
+        }
1000
+
1001
+        spip_unlink($fichier); // le fichier peut deja exister
1002
+        @rename($tmp, $fichier);
1003
+
1004
+        return true;
1005
+    }
1006
+
1007
+    return false;
1008 1008
 }
1009 1009
 
1010 1010
 
@@ -1032,30 +1032,30 @@  discard block
 block discarded – undo
1032 1032
  *     - false sinon.
1033 1033
  */
1034 1034
 function _image_gd_output($img, $valeurs, $qualite = _IMG_GD_QUALITE, $fonction = null) {
1035
-	if (is_null($fonction)) {
1036
-		$fonction = '_image_image' . $valeurs['format_dest'];
1037
-	}
1038
-	$ret = false;
1039
-	#un flag pour reperer les images gravees
1040
-	$lock = (
1041
-		!statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1042
-		or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'))
1043
-	);
1044
-	if (
1045
-		function_exists($fonction)
1046
-		&& ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
1047
-		&& isset($valeurs['reconstruction']) # et on sait comment la resonctruire le cas echeant
1048
-		&& !$lock
1049
-	) {
1050
-		if (@file_exists($valeurs['fichier_dest'])) {
1051
-			// dans tous les cas mettre a jour la taille de l'image finale
1052
-			[$valeurs['hauteur_dest'], $valeurs['largeur_dest']] = taille_image($valeurs['fichier_dest']);
1053
-			$valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1054
-			ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1055
-		}
1056
-	}
1057
-
1058
-	return $ret;
1035
+    if (is_null($fonction)) {
1036
+        $fonction = '_image_image' . $valeurs['format_dest'];
1037
+    }
1038
+    $ret = false;
1039
+    #un flag pour reperer les images gravees
1040
+    $lock = (
1041
+        !statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1042
+        or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'))
1043
+    );
1044
+    if (
1045
+        function_exists($fonction)
1046
+        && ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
1047
+        && isset($valeurs['reconstruction']) # et on sait comment la resonctruire le cas echeant
1048
+        && !$lock
1049
+    ) {
1050
+        if (@file_exists($valeurs['fichier_dest'])) {
1051
+            // dans tous les cas mettre a jour la taille de l'image finale
1052
+            [$valeurs['hauteur_dest'], $valeurs['largeur_dest']] = taille_image($valeurs['fichier_dest']);
1053
+            $valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1054
+            ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1055
+        }
1056
+    }
1057
+
1058
+    return $ret;
1059 1059
 }
1060 1060
 
1061 1061
 /**
@@ -1068,27 +1068,27 @@  discard block
 block discarded – undo
1068 1068
  *     Chemin vers le fichier manquant
1069 1069
  **/
1070 1070
 function reconstruire_image_intermediaire($fichier_manquant) {
1071
-	$reconstruire = [];
1072
-	$fichier = $fichier_manquant;
1073
-	while (
1074
-		strpos($fichier, '://') === false
1075
-		and !@file_exists($fichier)
1076
-		and lire_fichier($src = "$fichier.src", $source)
1077
-		and $valeurs = unserialize($source)
1078
-		and ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1079
-	) {
1080
-		spip_unlink($src); // si jamais on a un timeout pendant la reconstruction, elle se fera naturellement au hit suivant
1081
-		$reconstruire[] = $valeurs['reconstruction'];
1082
-	}
1083
-	while (count($reconstruire)) {
1084
-		$r = array_pop($reconstruire);
1085
-		$fonction = $r[0];
1086
-		$args = $r[1];
1087
-		$fonction(...$args);
1088
-	}
1089
-	// cette image intermediaire est commune a plusieurs series de filtre, il faut la conserver
1090
-	// mais l'on peut nettoyer les miettes de sa creation
1091
-	ramasse_miettes($fichier_manquant);
1071
+    $reconstruire = [];
1072
+    $fichier = $fichier_manquant;
1073
+    while (
1074
+        strpos($fichier, '://') === false
1075
+        and !@file_exists($fichier)
1076
+        and lire_fichier($src = "$fichier.src", $source)
1077
+        and $valeurs = unserialize($source)
1078
+        and ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1079
+    ) {
1080
+        spip_unlink($src); // si jamais on a un timeout pendant la reconstruction, elle se fera naturellement au hit suivant
1081
+        $reconstruire[] = $valeurs['reconstruction'];
1082
+    }
1083
+    while (count($reconstruire)) {
1084
+        $r = array_pop($reconstruire);
1085
+        $fonction = $r[0];
1086
+        $args = $r[1];
1087
+        $fonction(...$args);
1088
+    }
1089
+    // cette image intermediaire est commune a plusieurs series de filtre, il faut la conserver
1090
+    // mais l'on peut nettoyer les miettes de sa creation
1091
+    ramasse_miettes($fichier_manquant);
1092 1092
 }
1093 1093
 
1094 1094
 /**
@@ -1108,28 +1108,28 @@  discard block
 block discarded – undo
1108 1108
  *     Chemin du fichier d'image calculé
1109 1109
  **/
1110 1110
 function ramasse_miettes($fichier) {
1111
-	if (
1112
-		strpos($fichier, '://') !== false
1113
-		or !lire_fichier($src = "$fichier.src", $source)
1114
-		or !$valeurs = unserialize($source)
1115
-	) {
1116
-		return;
1117
-	}
1118
-	spip_unlink($src); # on supprime la reference a sa source pour marquer cette image comme non intermediaire
1119
-	while (
1120
-		($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1121
-		and (substr($fichier, 0, strlen(_DIR_VAR)) == _DIR_VAR) # et est dans local
1122
-		and (lire_fichier(
1123
-			$src = "$fichier.src",
1124
-			$source
1125
-		)) # le fichier a une source connue (c'est donc une image calculee intermediaire)
1126
-		and ($valeurs = unserialize($source))  # et valide
1127
-	) {
1128
-		# on efface le fichier
1129
-		spip_unlink($fichier);
1130
-		# mais laisse le .src qui permet de savoir comment reconstruire l'image si besoin
1131
-		#spip_unlink($src);
1132
-	}
1111
+    if (
1112
+        strpos($fichier, '://') !== false
1113
+        or !lire_fichier($src = "$fichier.src", $source)
1114
+        or !$valeurs = unserialize($source)
1115
+    ) {
1116
+        return;
1117
+    }
1118
+    spip_unlink($src); # on supprime la reference a sa source pour marquer cette image comme non intermediaire
1119
+    while (
1120
+        ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1121
+        and (substr($fichier, 0, strlen(_DIR_VAR)) == _DIR_VAR) # et est dans local
1122
+        and (lire_fichier(
1123
+            $src = "$fichier.src",
1124
+            $source
1125
+        )) # le fichier a une source connue (c'est donc une image calculee intermediaire)
1126
+        and ($valeurs = unserialize($source))  # et valide
1127
+    ) {
1128
+        # on efface le fichier
1129
+        spip_unlink($fichier);
1130
+        # mais laisse le .src qui permet de savoir comment reconstruire l'image si besoin
1131
+        #spip_unlink($src);
1132
+    }
1133 1133
 }
1134 1134
 
1135 1135
 
@@ -1154,31 +1154,31 @@  discard block
 block discarded – undo
1154 1154
  *     Code HTML de l'image
1155 1155
  **/
1156 1156
 function image_graver($img) {
1157
-	// appeler le filtre post_image_filtrer qui permet de faire
1158
-	// des traitements auto a la fin d'une serie de filtres
1159
-	$img = pipeline('post_image_filtrer', $img);
1160
-
1161
-	$fichier_ori = $fichier = extraire_attribut($img, 'src');
1162
-	if (($p = strpos($fichier, '?')) !== false) {
1163
-		$fichier = substr($fichier, 0, $p);
1164
-	}
1165
-	if (strlen($fichier) < 1) {
1166
-		$fichier = $img;
1167
-	}
1168
-	# si jamais le fichier final n'a pas ete calcule car suppose temporaire
1169
-	# et qu'il ne s'agit pas d'une URL
1170
-	if (strpos($fichier, '://') === false and !@file_exists($fichier)) {
1171
-		reconstruire_image_intermediaire($fichier);
1172
-	}
1173
-	ramasse_miettes($fichier);
1174
-
1175
-	// ajouter le timestamp si besoin
1176
-	if (strpos($fichier_ori, '?') === false) {
1177
-		// on utilise str_replace pour attraper le onmouseover des logo si besoin
1178
-		$img = str_replace($fichier_ori, timestamp($fichier_ori), $img);
1179
-	}
1180
-
1181
-	return $img;
1157
+    // appeler le filtre post_image_filtrer qui permet de faire
1158
+    // des traitements auto a la fin d'une serie de filtres
1159
+    $img = pipeline('post_image_filtrer', $img);
1160
+
1161
+    $fichier_ori = $fichier = extraire_attribut($img, 'src');
1162
+    if (($p = strpos($fichier, '?')) !== false) {
1163
+        $fichier = substr($fichier, 0, $p);
1164
+    }
1165
+    if (strlen($fichier) < 1) {
1166
+        $fichier = $img;
1167
+    }
1168
+    # si jamais le fichier final n'a pas ete calcule car suppose temporaire
1169
+    # et qu'il ne s'agit pas d'une URL
1170
+    if (strpos($fichier, '://') === false and !@file_exists($fichier)) {
1171
+        reconstruire_image_intermediaire($fichier);
1172
+    }
1173
+    ramasse_miettes($fichier);
1174
+
1175
+    // ajouter le timestamp si besoin
1176
+    if (strpos($fichier_ori, '?') === false) {
1177
+        // on utilise str_replace pour attraper le onmouseover des logo si besoin
1178
+        $img = str_replace($fichier_ori, timestamp($fichier_ori), $img);
1179
+    }
1180
+
1181
+    return $img;
1182 1182
 }
1183 1183
 
1184 1184
 /**
@@ -1205,34 +1205,34 @@  discard block
 block discarded – undo
1205 1205
  *     Code html modifié de la balise.
1206 1206
  **/
1207 1207
 function _image_tag_changer_taille($tag, $width, $height, $style = false) {
1208
-	if ($style === false) {
1209
-		$style = extraire_attribut($tag, 'style');
1210
-	}
1211
-
1212
-	// enlever le width et height du style
1213
-	if ($style) {
1214
-		$style = preg_replace(',(^|;)\s*(width|height)\s*:\s*[^;]+,ims', '', $style);
1215
-	}
1216
-	if ($style and $style[0] === ';') {
1217
-		$style = substr($style, 1);
1218
-	}
1219
-
1220
-	// mettre des attributs de width et height sur les images,
1221
-	// ca accelere le rendu du navigateur
1222
-	// ca permet aux navigateurs de reserver la bonne taille
1223
-	// quand on a desactive l'affichage des images.
1224
-	$tag = inserer_attribut($tag, 'width', round($width));
1225
-	$tag = inserer_attribut($tag, 'height', round($height));
1226
-
1227
-	// attributs deprecies. Transformer en CSS
1228
-	if ($espace = extraire_attribut($tag, 'hspace')) {
1229
-		$style = "margin:{$espace}px;" . $style;
1230
-		$tag = inserer_attribut($tag, 'hspace', '');
1231
-	}
1232
-
1233
-	$tag = inserer_attribut($tag, 'style', (string) $style, true, $style ? false : true);
1234
-
1235
-	return $tag;
1208
+    if ($style === false) {
1209
+        $style = extraire_attribut($tag, 'style');
1210
+    }
1211
+
1212
+    // enlever le width et height du style
1213
+    if ($style) {
1214
+        $style = preg_replace(',(^|;)\s*(width|height)\s*:\s*[^;]+,ims', '', $style);
1215
+    }
1216
+    if ($style and $style[0] === ';') {
1217
+        $style = substr($style, 1);
1218
+    }
1219
+
1220
+    // mettre des attributs de width et height sur les images,
1221
+    // ca accelere le rendu du navigateur
1222
+    // ca permet aux navigateurs de reserver la bonne taille
1223
+    // quand on a desactive l'affichage des images.
1224
+    $tag = inserer_attribut($tag, 'width', round($width));
1225
+    $tag = inserer_attribut($tag, 'height', round($height));
1226
+
1227
+    // attributs deprecies. Transformer en CSS
1228
+    if ($espace = extraire_attribut($tag, 'hspace')) {
1229
+        $style = "margin:{$espace}px;" . $style;
1230
+        $tag = inserer_attribut($tag, 'hspace', '');
1231
+    }
1232
+
1233
+    $tag = inserer_attribut($tag, 'style', (string) $style, true, $style ? false : true);
1234
+
1235
+    return $tag;
1236 1236
 }
1237 1237
 
1238 1238
 
@@ -1258,72 +1258,72 @@  discard block
 block discarded – undo
1258 1258
  *     Retourne le code HTML de l'image
1259 1259
  **/
1260 1260
 function _image_ecrire_tag($valeurs, $surcharge = []) {
1261
-	$valeurs = pipeline('image_ecrire_tag_preparer', $valeurs);
1262
-
1263
-	// fermer les tags img pas bien fermes;
1264
-	$tag = str_replace('>', '/>', str_replace('/>', '>', $valeurs['tag']));
1265
-
1266
-	// le style
1267
-	$style = $valeurs['style'];
1268
-	if (isset($surcharge['style'])) {
1269
-		$style = $surcharge['style'];
1270
-		unset($surcharge['style']);
1271
-	}
1272
-
1273
-	// traiter specifiquement la largeur et la hauteur
1274
-	$width = $valeurs['largeur'];
1275
-	if (isset($surcharge['width'])) {
1276
-		$width = $surcharge['width'];
1277
-		unset($surcharge['width']);
1278
-	}
1279
-	$height = $valeurs['hauteur'];
1280
-	if (isset($surcharge['height'])) {
1281
-		$height = $surcharge['height'];
1282
-		unset($surcharge['height']);
1283
-	}
1284
-
1285
-	$tag = _image_tag_changer_taille($tag, $width, $height, $style);
1286
-	// traiter specifiquement le src qui peut etre repris dans un onmouseout
1287
-	// on remplace toute les ref a src dans le tag
1288
-	$src = extraire_attribut($tag, 'src');
1289
-	if (isset($surcharge['src'])) {
1290
-		$tag = str_replace($src, $surcharge['src'], $tag);
1291
-		// si il y a des & dans src, alors ils peuvent provenir d'un &amp
1292
-		// pas garanti comme methode, mais mieux que rien
1293
-		if (strpos($src, '&') !== false) {
1294
-			$tag = str_replace(str_replace('&', '&amp;', $src), $surcharge['src'], $tag);
1295
-		}
1296
-		$src = $surcharge['src'];
1297
-		unset($surcharge['src']);
1298
-	}
1299
-
1300
-	$class = $valeurs['class'];
1301
-	if (isset($surcharge['class'])) {
1302
-		$class = $surcharge['class'];
1303
-		unset($surcharge['class']);
1304
-	}
1305
-	if (is_scalar($class) && strlen($class)) {
1306
-		$tag = inserer_attribut($tag, 'class', $class);
1307
-	}
1308
-
1309
-	if (count($surcharge)) {
1310
-		foreach ($surcharge as $attribut => $valeur) {
1311
-			$tag = inserer_attribut($tag, $attribut, $valeur);
1312
-		}
1313
-	}
1314
-
1315
-	$tag = pipeline(
1316
-		'image_ecrire_tag_finir',
1317
-		[
1318
-			'args' => [
1319
-				'valeurs' => $valeurs,
1320
-				'surcharge' => $surcharge,
1321
-			],
1322
-			'data' => $tag
1323
-		]
1324
-	);
1325
-
1326
-	return $tag;
1261
+    $valeurs = pipeline('image_ecrire_tag_preparer', $valeurs);
1262
+
1263
+    // fermer les tags img pas bien fermes;
1264
+    $tag = str_replace('>', '/>', str_replace('/>', '>', $valeurs['tag']));
1265
+
1266
+    // le style
1267
+    $style = $valeurs['style'];
1268
+    if (isset($surcharge['style'])) {
1269
+        $style = $surcharge['style'];
1270
+        unset($surcharge['style']);
1271
+    }
1272
+
1273
+    // traiter specifiquement la largeur et la hauteur
1274
+    $width = $valeurs['largeur'];
1275
+    if (isset($surcharge['width'])) {
1276
+        $width = $surcharge['width'];
1277
+        unset($surcharge['width']);
1278
+    }
1279
+    $height = $valeurs['hauteur'];
1280
+    if (isset($surcharge['height'])) {
1281
+        $height = $surcharge['height'];
1282
+        unset($surcharge['height']);
1283
+    }
1284
+
1285
+    $tag = _image_tag_changer_taille($tag, $width, $height, $style);
1286
+    // traiter specifiquement le src qui peut etre repris dans un onmouseout
1287
+    // on remplace toute les ref a src dans le tag
1288
+    $src = extraire_attribut($tag, 'src');
1289
+    if (isset($surcharge['src'])) {
1290
+        $tag = str_replace($src, $surcharge['src'], $tag);
1291
+        // si il y a des & dans src, alors ils peuvent provenir d'un &amp
1292
+        // pas garanti comme methode, mais mieux que rien
1293
+        if (strpos($src, '&') !== false) {
1294
+            $tag = str_replace(str_replace('&', '&amp;', $src), $surcharge['src'], $tag);
1295
+        }
1296
+        $src = $surcharge['src'];
1297
+        unset($surcharge['src']);
1298
+    }
1299
+
1300
+    $class = $valeurs['class'];
1301
+    if (isset($surcharge['class'])) {
1302
+        $class = $surcharge['class'];
1303
+        unset($surcharge['class']);
1304
+    }
1305
+    if (is_scalar($class) && strlen($class)) {
1306
+        $tag = inserer_attribut($tag, 'class', $class);
1307
+    }
1308
+
1309
+    if (count($surcharge)) {
1310
+        foreach ($surcharge as $attribut => $valeur) {
1311
+            $tag = inserer_attribut($tag, $attribut, $valeur);
1312
+        }
1313
+    }
1314
+
1315
+    $tag = pipeline(
1316
+        'image_ecrire_tag_finir',
1317
+        [
1318
+            'args' => [
1319
+                'valeurs' => $valeurs,
1320
+                'surcharge' => $surcharge,
1321
+            ],
1322
+            'data' => $tag
1323
+        ]
1324
+    );
1325
+
1326
+    return $tag;
1327 1327
 }
1328 1328
 
1329 1329
 /**
@@ -1346,267 +1346,267 @@  discard block
 block discarded – undo
1346 1346
  *     Description de l'image, sinon null.
1347 1347
  **/
1348 1348
 function _image_creer_vignette($valeurs, $maxWidth, $maxHeight, $process = 'AUTO', $force = false) {
1349
-	$srcHeight = null;
1350
-	$retour = [];
1351
-	// ordre de preference des formats graphiques pour creer les vignettes
1352
-	// le premier format disponible, selon la methode demandee, est utilise
1353
-	$image = $valeurs['fichier'];
1354
-	$format = $valeurs['format_source'];
1355
-	$destdir = dirname($valeurs['fichier_dest']);
1356
-	$destfile = basename($valeurs['fichier_dest'], '.' . $valeurs['format_dest']);
1357
-
1358
-	$format_sortie = $valeurs['format_dest'];
1359
-
1360
-	if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1361
-		$process = $GLOBALS['meta']['image_process'];
1362
-	}
1363
-
1364
-	// si le doc n'est pas une image dans un format accetpable, refuser
1365
-	if (!$force and !in_array($format, formats_image_acceptables(in_array($process, ['gd1', 'gd2'])))) {
1366
-		return;
1367
-	}
1368
-	$destination = "$destdir/$destfile";
1369
-
1370
-	// calculer la taille
1371
-	if (($srcWidth = $valeurs['largeur']) && ($srcHeight = $valeurs['hauteur'])) {
1372
-		if (!($destWidth = $valeurs['largeur_dest']) || !($destHeight = $valeurs['hauteur_dest'])) {
1373
-			[$destWidth, $destHeight] = _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight);
1374
-		}
1375
-	} elseif ($process == 'convert' or $process == 'imagick') {
1376
-		$destWidth = $maxWidth;
1377
-		$destHeight = $maxHeight;
1378
-	} else {
1379
-		spip_log("echec $process sur $image");
1380
-
1381
-		return;
1382
-	}
1383
-
1384
-	$vignette = '';
1385
-
1386
-	// Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1387
-	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1388
-		$vignette = $destination . '.' . $format;
1389
-		@copy($image, $vignette);
1390
-	}
1391
-
1392
-	elseif ($valeurs['format_source'] === 'svg') {
1393
-		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1394
-			$format_sortie = 'svg';
1395
-			$vignette = $destination . '.' . $format_sortie;
1396
-			$valeurs['fichier_dest'] = $vignette;
1397
-			_image_gd_output($svg, $valeurs);
1398
-		}
1399
-	}
1400
-
1401
-	// imagemagick en ligne de commande
1402
-	elseif ($process == 'convert') {
1403
-		if (!defined('_CONVERT_COMMAND')) {
1404
-			define('_CONVERT_COMMAND', 'convert');
1405
-		} // Securite : mes_options.php peut preciser le chemin absolu
1406
-		if (!defined('_RESIZE_COMMAND')) {
1407
-			define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1408
-		}
1409
-		$vignette = $destination . '.' . $format_sortie;
1410
-		$commande = str_replace(
1411
-			['%x', '%y', '%src', '%dest'],
1412
-			[
1413
-				$destWidth,
1414
-				$destHeight,
1415
-				escapeshellcmd($image),
1416
-				escapeshellcmd($vignette)
1417
-			],
1418
-			_RESIZE_COMMAND
1419
-		);
1420
-		spip_log($commande);
1421
-		exec($commande);
1422
-		if (!@file_exists($vignette)) {
1423
-			spip_log("echec convert sur $vignette");
1424
-
1425
-			return;  // echec commande
1426
-		}
1427
-	}
1428
-
1429
-	// php5 imagemagick
1430
-	elseif ($process == 'imagick') {
1431
-		if (!class_exists(\Imagick::class)) {
1432
-			spip_log('Classe Imagick absente !', _LOG_ERREUR);
1433
-
1434
-			return;
1435
-		}
1436
-
1437
-		// chemin compatible Windows
1438
-		$output = realpath(dirname($destination));
1439
-		if (!$output) {
1440
-			return;
1441
-		}
1442
-		$vignette = $output . DIRECTORY_SEPARATOR . basename($destination) . '.' . $format_sortie;
1443
-
1444
-		$imagick = new Imagick();
1445
-		$imagick->readImage(realpath($image));
1446
-		$imagick->resizeImage(
1447
-			$destWidth,
1448
-			$destHeight,
1449
-			Imagick::FILTER_LANCZOS,
1450
-			1
1451
-		);//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1452
-		$imagick->writeImage($vignette);
1453
-
1454
-		if (!@file_exists($vignette)) {
1455
-			spip_log("echec imagick sur $vignette");
1456
-
1457
-			return;
1458
-		}
1459
-		// remettre le chemin relatif car c'est ce qu'attend SPIP pour la suite (en particlier action/tester)
1460
-		$vignette = $destination . '.' . $format_sortie;
1461
-	}
1462
-
1463
-	// netpbm
1464
-	elseif ($process == 'netpbm') {
1465
-		if (!defined('_PNMSCALE_COMMAND')) {
1466
-			define('_PNMSCALE_COMMAND', 'pnmscale');
1467
-		} // Securite : mes_options.php peut preciser le chemin absolu
1468
-		if (_PNMSCALE_COMMAND == '') {
1469
-			return;
1470
-		}
1471
-		$vignette = $destination . '.' . $format_sortie;
1472
-		$pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND);
1473
-		if ($format == 'jpg') {
1474
-			$jpegtopnm_command = str_replace('pnmscale', 'jpegtopnm', _PNMSCALE_COMMAND);
1475
-			exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1476
-			if (!($s = @filesize($vignette))) {
1477
-				spip_unlink($vignette);
1478
-			}
1479
-			if (!@file_exists($vignette)) {
1480
-				spip_log("echec netpbm-jpg sur $vignette");
1481
-
1482
-				return;
1483
-			}
1484
-		} else {
1485
-			if ($format == 'gif') {
1486
-				$giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND);
1487
-				exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1488
-				if (!($s = @filesize($vignette))) {
1489
-					spip_unlink($vignette);
1490
-				}
1491
-				if (!@file_exists($vignette)) {
1492
-					spip_log("echec netpbm-gif sur $vignette");
1493
-
1494
-					return;
1495
-				}
1496
-			} else {
1497
-				if ($format == 'png') {
1498
-					$pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND);
1499
-					exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1500
-					if (!($s = @filesize($vignette))) {
1501
-						spip_unlink($vignette);
1502
-					}
1503
-					if (!@file_exists($vignette)) {
1504
-						spip_log("echec netpbm-png sur $vignette");
1505
-
1506
-						return;
1507
-					}
1508
-				}
1509
-			}
1510
-		}
1511
-	}
1512
-
1513
-	// gd ou gd2
1514
-	elseif ($process == 'gd1' or $process == 'gd2') {
1515
-		if (!function_exists('gd_info')) {
1516
-			spip_log('Librairie GD absente !', _LOG_ERREUR);
1517
-
1518
-			return;
1519
-		}
1520
-		if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1521
-			spip_log('vignette gd1/gd2 impossible : ' . $srcWidth * $srcHeight . 'pixels');
1522
-
1523
-			return;
1524
-		}
1525
-		$destFormat = $format_sortie;
1526
-		if (!$destFormat) {
1527
-			spip_log("pas de format pour $image");
1528
-
1529
-			return;
1530
-		}
1531
-
1532
-		$fonction_imagecreatefrom = $valeurs['fonction_imagecreatefrom'];
1533
-		if (!function_exists($fonction_imagecreatefrom)) {
1534
-			return;
1535
-		}
1536
-		$srcImage = @$fonction_imagecreatefrom($image);
1537
-		if (!$srcImage) {
1538
-			spip_log('echec gd1/gd2');
1539
-
1540
-			return;
1541
-		}
1542
-
1543
-		// Initialisation de l'image destination
1544
-		$destImage = null;
1545
-		if ($process == 'gd2' and $destFormat != 'gif') {
1546
-			$destImage = ImageCreateTrueColor($destWidth, $destHeight);
1547
-		}
1548
-		if (!$destImage) {
1549
-			$destImage = ImageCreate($destWidth, $destHeight);
1550
-		}
1551
-
1552
-		// Recopie de l'image d'origine avec adaptation de la taille
1553
-		$ok = false;
1554
-		if (($process == 'gd2') and function_exists('ImageCopyResampled')) {
1555
-			if ($format == 'gif') {
1556
-				// Si un GIF est transparent,
1557
-				// fabriquer un PNG transparent
1558
-				$transp = imagecolortransparent($srcImage);
1559
-				if ($transp > 0) {
1560
-					$destFormat = 'png';
1561
-				}
1562
-			}
1563
-			if (in_array($destFormat, _image_extensions_conservent_transparence())) {
1564
-				// Conserver la transparence
1565
-				if (function_exists('imageAntiAlias')) {
1566
-					imageAntiAlias($destImage, true);
1567
-				}
1568
-				@imagealphablending($destImage, false);
1569
-				@imagesavealpha($destImage, true);
1570
-			}
1571
-			$ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1572
-		}
1573
-		if (!$ok) {
1574
-			$ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1575
-		}
1576
-
1577
-		// Sauvegarde de l'image destination
1578
-		$valeurs['fichier_dest'] = $vignette = "$destination.$destFormat";
1579
-		$valeurs['format_dest'] = $format = $destFormat;
1580
-		_image_gd_output($destImage, $valeurs);
1581
-
1582
-		if ($srcImage) {
1583
-			ImageDestroy($srcImage);
1584
-		}
1585
-		ImageDestroy($destImage);
1586
-	}
1587
-
1588
-	if (!$vignette or !$size = @spip_getimagesize($vignette)) {
1589
-		$size = [$destWidth, $destHeight];
1590
-	}
1591
-
1592
-	// Gaffe: en safe mode, pas d'acces a la vignette,
1593
-	// donc risque de balancer "width='0'", ce qui masque l'image sous MSIE
1594
-	if ($size[0] < 1) {
1595
-		$size[0] = $destWidth;
1596
-	}
1597
-	if ($size[1] < 1) {
1598
-		$size[1] = $destHeight;
1599
-	}
1600
-
1601
-	$retour['width'] = $largeur = $size[0];
1602
-	$retour['height'] = $hauteur = $size[1];
1603
-
1604
-	$retour['fichier'] = $vignette;
1605
-	$retour['format'] = $format;
1606
-	$retour['date'] = @filemtime($vignette);
1607
-
1608
-	// renvoyer l'image
1609
-	return $retour;
1349
+    $srcHeight = null;
1350
+    $retour = [];
1351
+    // ordre de preference des formats graphiques pour creer les vignettes
1352
+    // le premier format disponible, selon la methode demandee, est utilise
1353
+    $image = $valeurs['fichier'];
1354
+    $format = $valeurs['format_source'];
1355
+    $destdir = dirname($valeurs['fichier_dest']);
1356
+    $destfile = basename($valeurs['fichier_dest'], '.' . $valeurs['format_dest']);
1357
+
1358
+    $format_sortie = $valeurs['format_dest'];
1359
+
1360
+    if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1361
+        $process = $GLOBALS['meta']['image_process'];
1362
+    }
1363
+
1364
+    // si le doc n'est pas une image dans un format accetpable, refuser
1365
+    if (!$force and !in_array($format, formats_image_acceptables(in_array($process, ['gd1', 'gd2'])))) {
1366
+        return;
1367
+    }
1368
+    $destination = "$destdir/$destfile";
1369
+
1370
+    // calculer la taille
1371
+    if (($srcWidth = $valeurs['largeur']) && ($srcHeight = $valeurs['hauteur'])) {
1372
+        if (!($destWidth = $valeurs['largeur_dest']) || !($destHeight = $valeurs['hauteur_dest'])) {
1373
+            [$destWidth, $destHeight] = _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight);
1374
+        }
1375
+    } elseif ($process == 'convert' or $process == 'imagick') {
1376
+        $destWidth = $maxWidth;
1377
+        $destHeight = $maxHeight;
1378
+    } else {
1379
+        spip_log("echec $process sur $image");
1380
+
1381
+        return;
1382
+    }
1383
+
1384
+    $vignette = '';
1385
+
1386
+    // Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1387
+    if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1388
+        $vignette = $destination . '.' . $format;
1389
+        @copy($image, $vignette);
1390
+    }
1391
+
1392
+    elseif ($valeurs['format_source'] === 'svg') {
1393
+        if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1394
+            $format_sortie = 'svg';
1395
+            $vignette = $destination . '.' . $format_sortie;
1396
+            $valeurs['fichier_dest'] = $vignette;
1397
+            _image_gd_output($svg, $valeurs);
1398
+        }
1399
+    }
1400
+
1401
+    // imagemagick en ligne de commande
1402
+    elseif ($process == 'convert') {
1403
+        if (!defined('_CONVERT_COMMAND')) {
1404
+            define('_CONVERT_COMMAND', 'convert');
1405
+        } // Securite : mes_options.php peut preciser le chemin absolu
1406
+        if (!defined('_RESIZE_COMMAND')) {
1407
+            define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1408
+        }
1409
+        $vignette = $destination . '.' . $format_sortie;
1410
+        $commande = str_replace(
1411
+            ['%x', '%y', '%src', '%dest'],
1412
+            [
1413
+                $destWidth,
1414
+                $destHeight,
1415
+                escapeshellcmd($image),
1416
+                escapeshellcmd($vignette)
1417
+            ],
1418
+            _RESIZE_COMMAND
1419
+        );
1420
+        spip_log($commande);
1421
+        exec($commande);
1422
+        if (!@file_exists($vignette)) {
1423
+            spip_log("echec convert sur $vignette");
1424
+
1425
+            return;  // echec commande
1426
+        }
1427
+    }
1428
+
1429
+    // php5 imagemagick
1430
+    elseif ($process == 'imagick') {
1431
+        if (!class_exists(\Imagick::class)) {
1432
+            spip_log('Classe Imagick absente !', _LOG_ERREUR);
1433
+
1434
+            return;
1435
+        }
1436
+
1437
+        // chemin compatible Windows
1438
+        $output = realpath(dirname($destination));
1439
+        if (!$output) {
1440
+            return;
1441
+        }
1442
+        $vignette = $output . DIRECTORY_SEPARATOR . basename($destination) . '.' . $format_sortie;
1443
+
1444
+        $imagick = new Imagick();
1445
+        $imagick->readImage(realpath($image));
1446
+        $imagick->resizeImage(
1447
+            $destWidth,
1448
+            $destHeight,
1449
+            Imagick::FILTER_LANCZOS,
1450
+            1
1451
+        );//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1452
+        $imagick->writeImage($vignette);
1453
+
1454
+        if (!@file_exists($vignette)) {
1455
+            spip_log("echec imagick sur $vignette");
1456
+
1457
+            return;
1458
+        }
1459
+        // remettre le chemin relatif car c'est ce qu'attend SPIP pour la suite (en particlier action/tester)
1460
+        $vignette = $destination . '.' . $format_sortie;
1461
+    }
1462
+
1463
+    // netpbm
1464
+    elseif ($process == 'netpbm') {
1465
+        if (!defined('_PNMSCALE_COMMAND')) {
1466
+            define('_PNMSCALE_COMMAND', 'pnmscale');
1467
+        } // Securite : mes_options.php peut preciser le chemin absolu
1468
+        if (_PNMSCALE_COMMAND == '') {
1469
+            return;
1470
+        }
1471
+        $vignette = $destination . '.' . $format_sortie;
1472
+        $pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND);
1473
+        if ($format == 'jpg') {
1474
+            $jpegtopnm_command = str_replace('pnmscale', 'jpegtopnm', _PNMSCALE_COMMAND);
1475
+            exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1476
+            if (!($s = @filesize($vignette))) {
1477
+                spip_unlink($vignette);
1478
+            }
1479
+            if (!@file_exists($vignette)) {
1480
+                spip_log("echec netpbm-jpg sur $vignette");
1481
+
1482
+                return;
1483
+            }
1484
+        } else {
1485
+            if ($format == 'gif') {
1486
+                $giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND);
1487
+                exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1488
+                if (!($s = @filesize($vignette))) {
1489
+                    spip_unlink($vignette);
1490
+                }
1491
+                if (!@file_exists($vignette)) {
1492
+                    spip_log("echec netpbm-gif sur $vignette");
1493
+
1494
+                    return;
1495
+                }
1496
+            } else {
1497
+                if ($format == 'png') {
1498
+                    $pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND);
1499
+                    exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1500
+                    if (!($s = @filesize($vignette))) {
1501
+                        spip_unlink($vignette);
1502
+                    }
1503
+                    if (!@file_exists($vignette)) {
1504
+                        spip_log("echec netpbm-png sur $vignette");
1505
+
1506
+                        return;
1507
+                    }
1508
+                }
1509
+            }
1510
+        }
1511
+    }
1512
+
1513
+    // gd ou gd2
1514
+    elseif ($process == 'gd1' or $process == 'gd2') {
1515
+        if (!function_exists('gd_info')) {
1516
+            spip_log('Librairie GD absente !', _LOG_ERREUR);
1517
+
1518
+            return;
1519
+        }
1520
+        if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1521
+            spip_log('vignette gd1/gd2 impossible : ' . $srcWidth * $srcHeight . 'pixels');
1522
+
1523
+            return;
1524
+        }
1525
+        $destFormat = $format_sortie;
1526
+        if (!$destFormat) {
1527
+            spip_log("pas de format pour $image");
1528
+
1529
+            return;
1530
+        }
1531
+
1532
+        $fonction_imagecreatefrom = $valeurs['fonction_imagecreatefrom'];
1533
+        if (!function_exists($fonction_imagecreatefrom)) {
1534
+            return;
1535
+        }
1536
+        $srcImage = @$fonction_imagecreatefrom($image);
1537
+        if (!$srcImage) {
1538
+            spip_log('echec gd1/gd2');
1539
+
1540
+            return;
1541
+        }
1542
+
1543
+        // Initialisation de l'image destination
1544
+        $destImage = null;
1545
+        if ($process == 'gd2' and $destFormat != 'gif') {
1546
+            $destImage = ImageCreateTrueColor($destWidth, $destHeight);
1547
+        }
1548
+        if (!$destImage) {
1549
+            $destImage = ImageCreate($destWidth, $destHeight);
1550
+        }
1551
+
1552
+        // Recopie de l'image d'origine avec adaptation de la taille
1553
+        $ok = false;
1554
+        if (($process == 'gd2') and function_exists('ImageCopyResampled')) {
1555
+            if ($format == 'gif') {
1556
+                // Si un GIF est transparent,
1557
+                // fabriquer un PNG transparent
1558
+                $transp = imagecolortransparent($srcImage);
1559
+                if ($transp > 0) {
1560
+                    $destFormat = 'png';
1561
+                }
1562
+            }
1563
+            if (in_array($destFormat, _image_extensions_conservent_transparence())) {
1564
+                // Conserver la transparence
1565
+                if (function_exists('imageAntiAlias')) {
1566
+                    imageAntiAlias($destImage, true);
1567
+                }
1568
+                @imagealphablending($destImage, false);
1569
+                @imagesavealpha($destImage, true);
1570
+            }
1571
+            $ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1572
+        }
1573
+        if (!$ok) {
1574
+            $ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1575
+        }
1576
+
1577
+        // Sauvegarde de l'image destination
1578
+        $valeurs['fichier_dest'] = $vignette = "$destination.$destFormat";
1579
+        $valeurs['format_dest'] = $format = $destFormat;
1580
+        _image_gd_output($destImage, $valeurs);
1581
+
1582
+        if ($srcImage) {
1583
+            ImageDestroy($srcImage);
1584
+        }
1585
+        ImageDestroy($destImage);
1586
+    }
1587
+
1588
+    if (!$vignette or !$size = @spip_getimagesize($vignette)) {
1589
+        $size = [$destWidth, $destHeight];
1590
+    }
1591
+
1592
+    // Gaffe: en safe mode, pas d'acces a la vignette,
1593
+    // donc risque de balancer "width='0'", ce qui masque l'image sous MSIE
1594
+    if ($size[0] < 1) {
1595
+        $size[0] = $destWidth;
1596
+    }
1597
+    if ($size[1] < 1) {
1598
+        $size[1] = $destHeight;
1599
+    }
1600
+
1601
+    $retour['width'] = $largeur = $size[0];
1602
+    $retour['height'] = $hauteur = $size[1];
1603
+
1604
+    $retour['fichier'] = $vignette;
1605
+    $retour['format'] = $format;
1606
+    $retour['date'] = @filemtime($vignette);
1607
+
1608
+    // renvoyer l'image
1609
+    return $retour;
1610 1610
 }
1611 1611
 
1612 1612
 /**
@@ -1626,25 +1626,25 @@  discard block
 block discarded – undo
1626 1626
  * @return array Liste [ largeur, hauteur, ratio de réduction ]
1627 1627
  **/
1628 1628
 function _image_ratio(int $srcWidth, int $srcHeight, int $maxWidth, int $maxHeight): array {
1629
-	$ratioWidth = $srcWidth / $maxWidth;
1630
-	$ratioHeight = $srcHeight / $maxHeight;
1631
-
1632
-	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1633
-		$destWidth = $srcWidth;
1634
-		$destHeight = $srcHeight;
1635
-	} elseif ($ratioWidth < $ratioHeight) {
1636
-		$destWidth = $srcWidth / $ratioHeight;
1637
-		$destHeight = $maxHeight;
1638
-	} else {
1639
-		$destWidth = $maxWidth;
1640
-		$destHeight = $srcHeight / $ratioWidth;
1641
-	}
1642
-
1643
-	return [
1644
-		intval(round($destWidth)),
1645
-		intval(round($destHeight)),
1646
-		max($ratioWidth, $ratioHeight)
1647
-	];
1629
+    $ratioWidth = $srcWidth / $maxWidth;
1630
+    $ratioHeight = $srcHeight / $maxHeight;
1631
+
1632
+    if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1633
+        $destWidth = $srcWidth;
1634
+        $destHeight = $srcHeight;
1635
+    } elseif ($ratioWidth < $ratioHeight) {
1636
+        $destWidth = $srcWidth / $ratioHeight;
1637
+        $destHeight = $maxHeight;
1638
+    } else {
1639
+        $destWidth = $maxWidth;
1640
+        $destHeight = $srcHeight / $ratioWidth;
1641
+    }
1642
+
1643
+    return [
1644
+        intval(round($destWidth)),
1645
+        intval(round($destHeight)),
1646
+        max($ratioWidth, $ratioHeight)
1647
+    ];
1648 1648
 }
1649 1649
 
1650 1650
 /**
@@ -1664,25 +1664,25 @@  discard block
 block discarded – undo
1664 1664
  * @return array Liste [ largeur, hauteur, ratio de réduction ]
1665 1665
  **/
1666 1666
 function ratio_passe_partout(int $srcWidth, int $srcHeight, int $maxWidth, int $maxHeight): array {
1667
-	$ratioWidth = $srcWidth / $maxWidth;
1668
-	$ratioHeight = $srcHeight / $maxHeight;
1669
-
1670
-	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1671
-		$destWidth = $srcWidth;
1672
-		$destHeight = $srcHeight;
1673
-	} elseif ($ratioWidth > $ratioHeight) {
1674
-		$destWidth = $srcWidth / $ratioHeight;
1675
-		$destHeight = $maxHeight;
1676
-	} else {
1677
-		$destWidth = $maxWidth;
1678
-		$destHeight = $srcHeight / $ratioWidth;
1679
-	}
1680
-
1681
-	return [
1682
-		intval(round($destWidth)),
1683
-		intval(round($destHeight)),
1684
-		min($ratioWidth, $ratioHeight)
1685
-	];
1667
+    $ratioWidth = $srcWidth / $maxWidth;
1668
+    $ratioHeight = $srcHeight / $maxHeight;
1669
+
1670
+    if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1671
+        $destWidth = $srcWidth;
1672
+        $destHeight = $srcHeight;
1673
+    } elseif ($ratioWidth > $ratioHeight) {
1674
+        $destWidth = $srcWidth / $ratioHeight;
1675
+        $destHeight = $maxHeight;
1676
+    } else {
1677
+        $destWidth = $maxWidth;
1678
+        $destHeight = $srcHeight / $ratioWidth;
1679
+    }
1680
+
1681
+    return [
1682
+        intval(round($destWidth)),
1683
+        intval(round($destHeight)),
1684
+        min($ratioWidth, $ratioHeight)
1685
+    ];
1686 1686
 }
1687 1687
 
1688 1688
 
@@ -1695,12 +1695,12 @@  discard block
 block discarded – undo
1695 1695
  * @return string
1696 1696
  */
1697 1697
 function process_image_svg_identite($image) {
1698
-	if ($image['creer']) {
1699
-		$source = $image['fichier'];
1700
-		_image_gd_output($source, $image);
1701
-	}
1698
+    if ($image['creer']) {
1699
+        $source = $image['fichier'];
1700
+        _image_gd_output($source, $image);
1701
+    }
1702 1702
 
1703
-	return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1703
+    return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1704 1704
 }
1705 1705
 
1706 1706
 
@@ -1733,109 +1733,109 @@  discard block
 block discarded – undo
1733 1733
  *     Code HTML de la balise img produite
1734 1734
  **/
1735 1735
 function process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process = 'AUTO') {
1736
-	$image = false;
1737
-	if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1738
-		$process = $GLOBALS['meta']['image_process'];
1739
-	}
1740
-	# determiner le format de sortie
1741
-	$format_sortie = false; // le choix par defaut sera bon
1742
-	if ($process == 'netpbm') {
1743
-		$format_sortie = 'jpg';
1744
-	} elseif ($process == 'gd1' or $process == 'gd2') {
1745
-		$image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1746
-		// on verifie que l'extension choisie est bonne (en principe oui)
1747
-		$gd_formats = formats_image_acceptables(true);
1748
-		if (
1749
-			is_array($image)
1750
-			and (!in_array($image['format_dest'], $gd_formats)
1751
-				or (!in_array($image['format_dest'], _image_extensions_acceptees_en_sortie()))
1752
-			)
1753
-		) {
1754
-			if ($image['format_source'] == 'jpg') {
1755
-				$formats_sortie = ['jpg', 'png', 'gif'];
1756
-			} else // les gif sont passes en png preferentiellement pour etre homogene aux autres filtres images
1757
-			{
1758
-				$formats_sortie = ['png', 'jpg', 'gif'];
1759
-			}
1760
-			// Choisir le format destination
1761
-			// - on sauve de preference en JPEG (meilleure compression)
1762
-			// - pour le GIF : les GD recentes peuvent le lire mais pas l'ecrire
1763
-			# bug : gd_formats contient la liste des fichiers qu'on sait *lire*,
1764
-			# pas *ecrire*
1765
-			$format_sortie = '';
1766
-			foreach ($formats_sortie as $fmt) {
1767
-				if (in_array($fmt, $gd_formats) and in_array($fmt, _image_extensions_acceptees_en_sortie())) {
1768
-					$format_sortie = $fmt;
1769
-					break;
1770
-				}
1771
-			}
1772
-			$image = false;
1773
-		}
1774
-	}
1775
-
1776
-	if (!is_array($image)) {
1777
-		$image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1778
-	}
1779
-
1780
-	if (!is_array($image) or !$image['largeur'] or !$image['hauteur']) {
1781
-		spip_log("image_reduire_src:pas de version locale de $img ou extension non prise en charge");
1782
-		// on peut resizer en mode html si on dispose des elements
1783
-		[$srcw, $srch] = taille_image($img);
1784
-		if ($srcw and $srch) {
1785
-			[$w, $h] = _image_ratio($srcw, $srch, $taille, $taille_y);
1786
-
1787
-			return _image_tag_changer_taille($img, $w, $h);
1788
-		}
1789
-		// la on n'a pas d'infos sur l'image source... on refile le truc a css
1790
-		// sous la forme style='max-width: NNpx;'
1791
-		return inserer_attribut(
1792
-			$img,
1793
-			'style',
1794
-			"max-width: {$taille}px;max-width: min(100%,{$taille}px); max-height: {$taille_y}px"
1795
-		);
1796
-	}
1797
-
1798
-	// si l'image est plus petite que la cible retourner une copie cachee de l'image
1799
-	if (($image['largeur'] <= $taille) && ($image['hauteur'] <= $taille_y)) {
1800
-		if ($image['creer']) {
1801
-			@copy($image['fichier'], $image['fichier_dest']);
1802
-		}
1803
-
1804
-		return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1805
-	}
1806
-
1807
-	if ($image['creer'] == false && !$force) {
1808
-		return _image_ecrire_tag(
1809
-			$image,
1810
-			['src' => $image['fichier_dest'], 'width' => $image['largeur_dest'], 'height' => $image['hauteur_dest']]
1811
-		);
1812
-	}
1813
-
1814
-	if (in_array($image['format_source'], _image_extensions_acceptees_en_entree())) {
1815
-		$destWidth = $image['largeur_dest'];
1816
-		$destHeight = $image['hauteur_dest'];
1817
-		$logo = $image['fichier'];
1818
-		$date = $image['date_src'];
1819
-		$preview = _image_creer_vignette($image, $taille, $taille_y, $process, $force);
1820
-
1821
-		if ($preview && $preview['fichier']) {
1822
-			$logo = $preview['fichier'];
1823
-			$destWidth = $preview['width'];
1824
-			$destHeight = $preview['height'];
1825
-			$date = $preview['date'];
1826
-		}
1827
-		// dans l'espace prive mettre un timestamp sur l'adresse
1828
-		// de l'image, de facon a tromper le cache du navigateur
1829
-		// quand on fait supprimer/reuploader un logo
1830
-		// (pas de filemtime si SAFE MODE)
1831
-		$date = test_espace_prive() ? ('?' . $date) : '';
1832
-
1833
-		return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1834
-	}
1835
-	else {
1836
-		# BMP, tiff ... les redacteurs osent tout!
1837
-		return $img;
1838
-	}
1736
+    $image = false;
1737
+    if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1738
+        $process = $GLOBALS['meta']['image_process'];
1739
+    }
1740
+    # determiner le format de sortie
1741
+    $format_sortie = false; // le choix par defaut sera bon
1742
+    if ($process == 'netpbm') {
1743
+        $format_sortie = 'jpg';
1744
+    } elseif ($process == 'gd1' or $process == 'gd2') {
1745
+        $image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1746
+        // on verifie que l'extension choisie est bonne (en principe oui)
1747
+        $gd_formats = formats_image_acceptables(true);
1748
+        if (
1749
+            is_array($image)
1750
+            and (!in_array($image['format_dest'], $gd_formats)
1751
+                or (!in_array($image['format_dest'], _image_extensions_acceptees_en_sortie()))
1752
+            )
1753
+        ) {
1754
+            if ($image['format_source'] == 'jpg') {
1755
+                $formats_sortie = ['jpg', 'png', 'gif'];
1756
+            } else // les gif sont passes en png preferentiellement pour etre homogene aux autres filtres images
1757
+            {
1758
+                $formats_sortie = ['png', 'jpg', 'gif'];
1759
+            }
1760
+            // Choisir le format destination
1761
+            // - on sauve de preference en JPEG (meilleure compression)
1762
+            // - pour le GIF : les GD recentes peuvent le lire mais pas l'ecrire
1763
+            # bug : gd_formats contient la liste des fichiers qu'on sait *lire*,
1764
+            # pas *ecrire*
1765
+            $format_sortie = '';
1766
+            foreach ($formats_sortie as $fmt) {
1767
+                if (in_array($fmt, $gd_formats) and in_array($fmt, _image_extensions_acceptees_en_sortie())) {
1768
+                    $format_sortie = $fmt;
1769
+                    break;
1770
+                }
1771
+            }
1772
+            $image = false;
1773
+        }
1774
+    }
1775
+
1776
+    if (!is_array($image)) {
1777
+        $image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1778
+    }
1779
+
1780
+    if (!is_array($image) or !$image['largeur'] or !$image['hauteur']) {
1781
+        spip_log("image_reduire_src:pas de version locale de $img ou extension non prise en charge");
1782
+        // on peut resizer en mode html si on dispose des elements
1783
+        [$srcw, $srch] = taille_image($img);
1784
+        if ($srcw and $srch) {
1785
+            [$w, $h] = _image_ratio($srcw, $srch, $taille, $taille_y);
1786
+
1787
+            return _image_tag_changer_taille($img, $w, $h);
1788
+        }
1789
+        // la on n'a pas d'infos sur l'image source... on refile le truc a css
1790
+        // sous la forme style='max-width: NNpx;'
1791
+        return inserer_attribut(
1792
+            $img,
1793
+            'style',
1794
+            "max-width: {$taille}px;max-width: min(100%,{$taille}px); max-height: {$taille_y}px"
1795
+        );
1796
+    }
1797
+
1798
+    // si l'image est plus petite que la cible retourner une copie cachee de l'image
1799
+    if (($image['largeur'] <= $taille) && ($image['hauteur'] <= $taille_y)) {
1800
+        if ($image['creer']) {
1801
+            @copy($image['fichier'], $image['fichier_dest']);
1802
+        }
1803
+
1804
+        return _image_ecrire_tag($image, ['src' => $image['fichier_dest']]);
1805
+    }
1806
+
1807
+    if ($image['creer'] == false && !$force) {
1808
+        return _image_ecrire_tag(
1809
+            $image,
1810
+            ['src' => $image['fichier_dest'], 'width' => $image['largeur_dest'], 'height' => $image['hauteur_dest']]
1811
+        );
1812
+    }
1813
+
1814
+    if (in_array($image['format_source'], _image_extensions_acceptees_en_entree())) {
1815
+        $destWidth = $image['largeur_dest'];
1816
+        $destHeight = $image['hauteur_dest'];
1817
+        $logo = $image['fichier'];
1818
+        $date = $image['date_src'];
1819
+        $preview = _image_creer_vignette($image, $taille, $taille_y, $process, $force);
1820
+
1821
+        if ($preview && $preview['fichier']) {
1822
+            $logo = $preview['fichier'];
1823
+            $destWidth = $preview['width'];
1824
+            $destHeight = $preview['height'];
1825
+            $date = $preview['date'];
1826
+        }
1827
+        // dans l'espace prive mettre un timestamp sur l'adresse
1828
+        // de l'image, de facon a tromper le cache du navigateur
1829
+        // quand on fait supprimer/reuploader un logo
1830
+        // (pas de filemtime si SAFE MODE)
1831
+        $date = test_espace_prive() ? ('?' . $date) : '';
1832
+
1833
+        return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1834
+    }
1835
+    else {
1836
+        # BMP, tiff ... les redacteurs osent tout!
1837
+        return $img;
1838
+    }
1839 1839
 }
1840 1840
 
1841 1841
 /**
@@ -1849,145 +1849,145 @@  discard block
 block discarded – undo
1849 1849
  * Class phpthumb_functions
1850 1850
  */
1851 1851
 class phpthumb_functions {
1852
-	/**
1853
-	 * Retourne la couleur d'un pixel dans une image
1854
-	 *
1855
-	 * @param resource|GdImage $img
1856
-	 * @param int $x
1857
-	 * @param int $y
1858
-	 * @return array|bool
1859
-	 */
1860
-	public static function GetPixelColor(&$img, $x, $y) {
1861
-		if (is_resource($img) || (is_object($img) && $img instanceof \GdImage)) {
1862
-			return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
1863
-		}
1864
-		return false;
1865
-	}
1866
-
1867
-	/**
1868
-	 * Retourne un nombre dans une représentation en Little Endian
1869
-	 *
1870
-	 * @param int $number
1871
-	 * @param int $minbytes
1872
-	 * @return string
1873
-	 */
1874
-	public static function LittleEndian2String($number, $minbytes = 1) {
1875
-		$intstring = '';
1876
-		while ($number > 0) {
1877
-			$intstring = $intstring . chr($number & 255);
1878
-			$number >>= 8;
1879
-		}
1880
-
1881
-		return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
1882
-	}
1883
-
1884
-	/**
1885
-	 * Transforme une ressource GD en image au format ICO
1886
-	 *
1887
-	 * @param array $gd_image_array
1888
-	 *     Tableau de ressources d'images GD
1889
-	 * @return string
1890
-	 *     Image au format ICO
1891
-	 */
1892
-	public static function GD2ICOstring(&$gd_image_array) {
1893
-		foreach ($gd_image_array as $key => $gd_image) {
1894
-			$ImageWidths[$key] = ImageSX($gd_image);
1895
-			$ImageHeights[$key] = ImageSY($gd_image);
1896
-			$bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
1897
-			$totalcolors[$key] = ImageColorsTotal($gd_image);
1898
-
1899
-			$icXOR[$key] = '';
1900
-			for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
1901
-				for ($x = 0; $x < $ImageWidths[$key]; $x++) {
1902
-					$argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
1903
-					$a = round(255 * ((127 - $argb['alpha']) / 127));
1904
-					$r = $argb['red'];
1905
-					$g = $argb['green'];
1906
-					$b = $argb['blue'];
1907
-
1908
-					if ($bpp[$key] == 32) {
1909
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1910
-					} elseif ($bpp[$key] == 24) {
1911
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r);
1912
-					}
1913
-
1914
-					if ($a < 128) {
1915
-						@$icANDmask[$key][$y] .= '1';
1916
-					} else {
1917
-						@$icANDmask[$key][$y] .= '0';
1918
-					}
1919
-				}
1920
-				// mask bits are 32-bit aligned per scanline
1921
-				while (strlen($icANDmask[$key][$y]) % 32) {
1922
-					$icANDmask[$key][$y] .= '0';
1923
-				}
1924
-			}
1925
-			$icAND[$key] = '';
1926
-			foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
1927
-				for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
1928
-					$icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
1929
-				}
1930
-			}
1931
-		}
1932
-
1933
-		foreach ($gd_image_array as $key => $gd_image) {
1934
-			$biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
1935
-
1936
-			// BITMAPINFOHEADER - 40 bytes
1937
-			$BitmapInfoHeader[$key] = '';
1938
-			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1939
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1940
-			// The biHeight member specifies the combined
1941
-			// height of the XOR and AND masks.
1942
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1943
-			$BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1944
-			$BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1945
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1946
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1947
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1948
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1949
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1950
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1951
-		}
1952
-
1953
-
1954
-		$icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1955
-		$icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1956
-		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1957
-
1958
-		$dwImageOffset = 6 + (count($gd_image_array) * 16);
1959
-		foreach ($gd_image_array as $key => $gd_image) {
1960
-			// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1961
-
1962
-			$icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1963
-			$icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1964
-			$icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1965
-			$icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1966
-
1967
-			$icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
1968
-			$icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1969
-
1970
-			$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
1971
-			$icondata .= phpthumb_functions::LittleEndian2String(
1972
-				$dwBytesInRes,
1973
-				4
1974
-			);     // dwBytesInRes;	// How many bytes in this resource?
1975
-
1976
-			$icondata .= phpthumb_functions::LittleEndian2String(
1977
-				$dwImageOffset,
1978
-				4
1979
-			);    // dwImageOffset;   // Where in the file is this image?
1980
-			$dwImageOffset += strlen($BitmapInfoHeader[$key]);
1981
-			$dwImageOffset += strlen($icXOR[$key]);
1982
-			$dwImageOffset += strlen($icAND[$key]);
1983
-		}
1984
-
1985
-		foreach ($gd_image_array as $key => $gd_image) {
1986
-			$icondata .= $BitmapInfoHeader[$key];
1987
-			$icondata .= $icXOR[$key];
1988
-			$icondata .= $icAND[$key];
1989
-		}
1990
-
1991
-		return $icondata;
1992
-	}
1852
+    /**
1853
+     * Retourne la couleur d'un pixel dans une image
1854
+     *
1855
+     * @param resource|GdImage $img
1856
+     * @param int $x
1857
+     * @param int $y
1858
+     * @return array|bool
1859
+     */
1860
+    public static function GetPixelColor(&$img, $x, $y) {
1861
+        if (is_resource($img) || (is_object($img) && $img instanceof \GdImage)) {
1862
+            return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
1863
+        }
1864
+        return false;
1865
+    }
1866
+
1867
+    /**
1868
+     * Retourne un nombre dans une représentation en Little Endian
1869
+     *
1870
+     * @param int $number
1871
+     * @param int $minbytes
1872
+     * @return string
1873
+     */
1874
+    public static function LittleEndian2String($number, $minbytes = 1) {
1875
+        $intstring = '';
1876
+        while ($number > 0) {
1877
+            $intstring = $intstring . chr($number & 255);
1878
+            $number >>= 8;
1879
+        }
1880
+
1881
+        return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
1882
+    }
1883
+
1884
+    /**
1885
+     * Transforme une ressource GD en image au format ICO
1886
+     *
1887
+     * @param array $gd_image_array
1888
+     *     Tableau de ressources d'images GD
1889
+     * @return string
1890
+     *     Image au format ICO
1891
+     */
1892
+    public static function GD2ICOstring(&$gd_image_array) {
1893
+        foreach ($gd_image_array as $key => $gd_image) {
1894
+            $ImageWidths[$key] = ImageSX($gd_image);
1895
+            $ImageHeights[$key] = ImageSY($gd_image);
1896
+            $bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
1897
+            $totalcolors[$key] = ImageColorsTotal($gd_image);
1898
+
1899
+            $icXOR[$key] = '';
1900
+            for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
1901
+                for ($x = 0; $x < $ImageWidths[$key]; $x++) {
1902
+                    $argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
1903
+                    $a = round(255 * ((127 - $argb['alpha']) / 127));
1904
+                    $r = $argb['red'];
1905
+                    $g = $argb['green'];
1906
+                    $b = $argb['blue'];
1907
+
1908
+                    if ($bpp[$key] == 32) {
1909
+                        $icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1910
+                    } elseif ($bpp[$key] == 24) {
1911
+                        $icXOR[$key] .= chr($b) . chr($g) . chr($r);
1912
+                    }
1913
+
1914
+                    if ($a < 128) {
1915
+                        @$icANDmask[$key][$y] .= '1';
1916
+                    } else {
1917
+                        @$icANDmask[$key][$y] .= '0';
1918
+                    }
1919
+                }
1920
+                // mask bits are 32-bit aligned per scanline
1921
+                while (strlen($icANDmask[$key][$y]) % 32) {
1922
+                    $icANDmask[$key][$y] .= '0';
1923
+                }
1924
+            }
1925
+            $icAND[$key] = '';
1926
+            foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
1927
+                for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
1928
+                    $icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
1929
+                }
1930
+            }
1931
+        }
1932
+
1933
+        foreach ($gd_image_array as $key => $gd_image) {
1934
+            $biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
1935
+
1936
+            // BITMAPINFOHEADER - 40 bytes
1937
+            $BitmapInfoHeader[$key] = '';
1938
+            $BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1939
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1940
+            // The biHeight member specifies the combined
1941
+            // height of the XOR and AND masks.
1942
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1943
+            $BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1944
+            $BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1945
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1946
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1947
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1948
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1949
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1950
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1951
+        }
1952
+
1953
+
1954
+        $icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1955
+        $icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1956
+        $icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1957
+
1958
+        $dwImageOffset = 6 + (count($gd_image_array) * 16);
1959
+        foreach ($gd_image_array as $key => $gd_image) {
1960
+            // ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1961
+
1962
+            $icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1963
+            $icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1964
+            $icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1965
+            $icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1966
+
1967
+            $icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
1968
+            $icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1969
+
1970
+            $dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
1971
+            $icondata .= phpthumb_functions::LittleEndian2String(
1972
+                $dwBytesInRes,
1973
+                4
1974
+            );     // dwBytesInRes;	// How many bytes in this resource?
1975
+
1976
+            $icondata .= phpthumb_functions::LittleEndian2String(
1977
+                $dwImageOffset,
1978
+                4
1979
+            );    // dwImageOffset;   // Where in the file is this image?
1980
+            $dwImageOffset += strlen($BitmapInfoHeader[$key]);
1981
+            $dwImageOffset += strlen($icXOR[$key]);
1982
+            $dwImageOffset += strlen($icAND[$key]);
1983
+        }
1984
+
1985
+        foreach ($gd_image_array as $key => $gd_image) {
1986
+            $icondata .= $BitmapInfoHeader[$key];
1987
+            $icondata .= $icXOR[$key];
1988
+            $icondata .= $icAND[$key];
1989
+        }
1990
+
1991
+        return $icondata;
1992
+    }
1993 1993
 }
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 	$blue = dechex($blue);
44 44
 
45 45
 	if (strlen($red) == 1) {
46
-		$red = '0' . $red;
46
+		$red = '0'.$red;
47 47
 	}
48 48
 	if (strlen($green) == 1) {
49
-		$green = '0' . $green;
49
+		$green = '0'.$green;
50 50
 	}
51 51
 	if (strlen($blue) == 1) {
52
-		$blue = '0' . $blue;
52
+		$blue = '0'.$blue;
53 53
 	}
54 54
 
55 55
 	return "$red$green$blue";
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	$couleur = couleur_html_to_hex($couleur);
68 68
 	$couleur = ltrim($couleur, '#');
69 69
 	if (strlen($couleur) === 3) {
70
-		$couleur = $couleur[0] . $couleur[0] . $couleur[1] . $couleur[1] . $couleur[2] . $couleur[2];
70
+		$couleur = $couleur[0].$couleur[0].$couleur[1].$couleur[1].$couleur[2].$couleur[2];
71 71
 	}
72 72
 	$retour = [];
73 73
 	$retour['red'] = hexdec(substr($couleur, 0, 2));
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	$var_G = ($G / 255);
126 126
 	$var_B = ($B / 255);
127 127
 
128
-	$var_Min = min($var_R, $var_G, $var_B);   //Min. value of RGB
129
-	$var_Max = max($var_R, $var_G, $var_B);   //Max. value of RGB
130
-	$del_Max = $var_Max - $var_Min;           //Delta RGB value
128
+	$var_Min = min($var_R, $var_G, $var_B); //Min. value of RGB
129
+	$var_Max = max($var_R, $var_G, $var_B); //Max. value of RGB
130
+	$del_Max = $var_Max - $var_Min; //Delta RGB value
131 131
 
132 132
 	$L = ($var_Max + $var_Min) / 2;
133 133
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
  */
190 190
 function _couleur_hsl_to_rgb($H, $S, $L) {
191 191
 	// helper
192
-	$hue_2_rgb = function ($v1, $v2, $vH) {
192
+	$hue_2_rgb = function($v1, $v2, $vH) {
193 193
 		if ($vH < 0) {
194 194
 			$vH += 1;
195 195
 		}
@@ -321,11 +321,11 @@  discard block
 block discarded – undo
321 321
 		$img = "<img src='$source' />";
322 322
 	} elseif (
323 323
 		preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
324
-		and $extension = _image_trouver_extension_depuis_mime('image/' . $regs[1])
324
+		and $extension = _image_trouver_extension_depuis_mime('image/'.$regs[1])
325 325
 		and in_array($extension, _image_extensions_acceptees_en_entree())
326 326
 	) {
327 327
 		# gerer img src="data:....base64"
328
-		$local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
328
+		$local = sous_repertoire(_DIR_VAR, 'image-data').md5($regs[2]).'.'._image_extension_normalisee($extension);
329 329
 		if (!file_exists($local)) {
330 330
 			ecrire_fichier($local, base64_decode($regs[2]));
331 331
 		}
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	// les protocoles web prennent au moins 3 lettres
343 343
 	if (tester_url_absolue($source)) {
344 344
 		include_spip('inc/distant');
345
-		$fichier = _DIR_RACINE . copie_locale($source);
345
+		$fichier = _DIR_RACINE.copie_locale($source);
346 346
 		if (!$fichier) {
347 347
 			return '';
348 348
 		}
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 			// on garde la terminaison initiale car image simplement copiee
441 441
 			// et on postfixe son nom avec un md5 du path
442 442
 			$terminaison_dest = $terminaison;
443
-			$fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
443
+			$fichier_dest .= '-'.substr(md5("$identifiant"), 0, 5);
444 444
 		} else {
445
-			$fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
445
+			$fichier_dest .= '-'.substr(md5("$identifiant-$effet"), 0, 5);
446 446
 		}
447 447
 		$cache = sous_repertoire(_DIR_VAR, $cache);
448 448
 		$cache = sous_repertoire($cache, $effet);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 		$fichier_dest = substr($fichier_dest, 2);
454 454
 	}
455 455
 
456
-	$fichier_dest = $cache . $fichier_dest . '.' . $terminaison_dest;
456
+	$fichier_dest = $cache.$fichier_dest.'.'.$terminaison_dest;
457 457
 
458 458
 	$GLOBALS['images_calculees'][] = $fichier_dest;
459 459
 
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
 
492 492
 	if ($creer) {
493 493
 		spip_log(
494
-			'filtre image ' . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
495
-			'images' . _LOG_DEBUG
494
+			'filtre image '.($fonction_creation ? reset($fonction_creation) : '')."[$effet] sur $fichier",
495
+			'images'._LOG_DEBUG
496 496
 		);
497 497
 	}
498 498
 
499 499
 	$term_fonction = _image_trouver_extension_pertinente($fichier);
500
-	$ret['fonction_imagecreatefrom'] = '_imagecreatefrom' . $term_fonction;
500
+	$ret['fonction_imagecreatefrom'] = '_imagecreatefrom'.$term_fonction;
501 501
 	$ret['fichier'] = $fichier;
502
-	$ret['fonction_image'] = '_image_image' . $terminaison_dest;
502
+	$ret['fonction_image'] = '_image_image'.$terminaison_dest;
503 503
 	$ret['fichier_dest'] = $fichier_dest;
504 504
 	$ret['format_source'] = _image_extension_normalisee($terminaison);
505 505
 	$ret['format_dest'] = $terminaison_dest;
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 
650 650
 	$_terminaison = _image_trouver_extension_depuis_mime($mime);
651 651
 	if ($_terminaison and $_terminaison !== $terminaison) {
652
-		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.' . _LOG_INFO_IMPORTANTE);
652
+		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", 'images.'._LOG_INFO_IMPORTANTE);
653 653
 		$terminaison = $_terminaison;
654 654
 	}
655 655
 	return $terminaison;
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 	if (!function_exists('imagepng')) {
807 807
 		return false;
808 808
 	}
809
-	$tmp = $fichier . '.tmp';
809
+	$tmp = $fichier.'.tmp';
810 810
 	$ret = imagepng($img, $tmp);
811 811
 	if (file_exists($tmp)) {
812 812
 		$taille_test = getimagesize($tmp);
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	if (!function_exists('imagegif')) {
842 842
 		return false;
843 843
 	}
844
-	$tmp = $fichier . '.tmp';
844
+	$tmp = $fichier.'.tmp';
845 845
 	$ret = imagegif($img, $tmp);
846 846
 	if (file_exists($tmp)) {
847 847
 		$taille_test = getimagesize($tmp);
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	if (!function_exists('imagejpeg')) {
882 882
 		return false;
883 883
 	}
884
-	$tmp = $fichier . '.tmp';
884
+	$tmp = $fichier.'.tmp';
885 885
 
886 886
 	// Enable interlancing
887 887
 	imageinterlace($img, true);
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 	if (!function_exists('imagewebp')) {
943 943
 		return false;
944 944
 	}
945
-	$tmp = $fichier . '.tmp';
945
+	$tmp = $fichier.'.tmp';
946 946
 	$ret = imagewebp($img, $tmp, $qualite);
947 947
 	if (file_exists($tmp)) {
948 948
 		$taille_test = getimagesize($tmp);
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
  */
977 977
 function _image_imagesvg($img, $fichier) {
978 978
 
979
-	$tmp = $fichier . '.tmp';
979
+	$tmp = $fichier.'.tmp';
980 980
 	if (strpos($img, '<') === false) {
981 981
 		$img = supprimer_timestamp($img);
982 982
 		if (!file_exists($img)) {
@@ -1033,13 +1033,13 @@  discard block
 block discarded – undo
1033 1033
  */
1034 1034
 function _image_gd_output($img, $valeurs, $qualite = _IMG_GD_QUALITE, $fonction = null) {
1035 1035
 	if (is_null($fonction)) {
1036
-		$fonction = '_image_image' . $valeurs['format_dest'];
1036
+		$fonction = '_image_image'.$valeurs['format_dest'];
1037 1037
 	}
1038 1038
 	$ret = false;
1039 1039
 	#un flag pour reperer les images gravees
1040 1040
 	$lock = (
1041 1041
 		!statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1042
-		or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'))
1042
+		or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'].'.src'))
1043 1043
 	);
1044 1044
 	if (
1045 1045
 		function_exists($fonction)
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 			// dans tous les cas mettre a jour la taille de l'image finale
1052 1052
 			[$valeurs['hauteur_dest'], $valeurs['largeur_dest']] = taille_image($valeurs['fichier_dest']);
1053 1053
 			$valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1054
-			ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1054
+			ecrire_fichier($valeurs['fichier_dest'].'.src', serialize($valeurs), true);
1055 1055
 		}
1056 1056
 	}
1057 1057
 
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 
1227 1227
 	// attributs deprecies. Transformer en CSS
1228 1228
 	if ($espace = extraire_attribut($tag, 'hspace')) {
1229
-		$style = "margin:{$espace}px;" . $style;
1229
+		$style = "margin:{$espace}px;".$style;
1230 1230
 		$tag = inserer_attribut($tag, 'hspace', '');
1231 1231
 	}
1232 1232
 
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 	$image = $valeurs['fichier'];
1354 1354
 	$format = $valeurs['format_source'];
1355 1355
 	$destdir = dirname($valeurs['fichier_dest']);
1356
-	$destfile = basename($valeurs['fichier_dest'], '.' . $valeurs['format_dest']);
1356
+	$destfile = basename($valeurs['fichier_dest'], '.'.$valeurs['format_dest']);
1357 1357
 
1358 1358
 	$format_sortie = $valeurs['format_dest'];
1359 1359
 
@@ -1385,14 +1385,14 @@  discard block
 block discarded – undo
1385 1385
 
1386 1386
 	// Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1387 1387
 	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1388
-		$vignette = $destination . '.' . $format;
1388
+		$vignette = $destination.'.'.$format;
1389 1389
 		@copy($image, $vignette);
1390 1390
 	}
1391 1391
 
1392 1392
 	elseif ($valeurs['format_source'] === 'svg') {
1393 1393
 		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1394 1394
 			$format_sortie = 'svg';
1395
-			$vignette = $destination . '.' . $format_sortie;
1395
+			$vignette = $destination.'.'.$format_sortie;
1396 1396
 			$valeurs['fichier_dest'] = $vignette;
1397 1397
 			_image_gd_output($svg, $valeurs);
1398 1398
 		}
@@ -1404,9 +1404,9 @@  discard block
 block discarded – undo
1404 1404
 			define('_CONVERT_COMMAND', 'convert');
1405 1405
 		} // Securite : mes_options.php peut preciser le chemin absolu
1406 1406
 		if (!defined('_RESIZE_COMMAND')) {
1407
-			define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1407
+			define('_RESIZE_COMMAND', _CONVERT_COMMAND.' -quality '._IMG_CONVERT_QUALITE.' -resize %xx%y! %src %dest');
1408 1408
 		}
1409
-		$vignette = $destination . '.' . $format_sortie;
1409
+		$vignette = $destination.'.'.$format_sortie;
1410 1410
 		$commande = str_replace(
1411 1411
 			['%x', '%y', '%src', '%dest'],
1412 1412
 			[
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 		if (!@file_exists($vignette)) {
1423 1423
 			spip_log("echec convert sur $vignette");
1424 1424
 
1425
-			return;  // echec commande
1425
+			return; // echec commande
1426 1426
 		}
1427 1427
 	}
1428 1428
 
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
 		if (!$output) {
1440 1440
 			return;
1441 1441
 		}
1442
-		$vignette = $output . DIRECTORY_SEPARATOR . basename($destination) . '.' . $format_sortie;
1442
+		$vignette = $output.DIRECTORY_SEPARATOR.basename($destination).'.'.$format_sortie;
1443 1443
 
1444 1444
 		$imagick = new Imagick();
1445 1445
 		$imagick->readImage(realpath($image));
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 			$destHeight,
1449 1449
 			Imagick::FILTER_LANCZOS,
1450 1450
 			1
1451
-		);//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1451
+		); //, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1452 1452
 		$imagick->writeImage($vignette);
1453 1453
 
1454 1454
 		if (!@file_exists($vignette)) {
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
 			return;
1458 1458
 		}
1459 1459
 		// remettre le chemin relatif car c'est ce qu'attend SPIP pour la suite (en particlier action/tester)
1460
-		$vignette = $destination . '.' . $format_sortie;
1460
+		$vignette = $destination.'.'.$format_sortie;
1461 1461
 	}
1462 1462
 
1463 1463
 	// netpbm
@@ -1468,11 +1468,11 @@  discard block
 block discarded – undo
1468 1468
 		if (_PNMSCALE_COMMAND == '') {
1469 1469
 			return;
1470 1470
 		}
1471
-		$vignette = $destination . '.' . $format_sortie;
1471
+		$vignette = $destination.'.'.$format_sortie;
1472 1472
 		$pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND);
1473 1473
 		if ($format == 'jpg') {
1474 1474
 			$jpegtopnm_command = str_replace('pnmscale', 'jpegtopnm', _PNMSCALE_COMMAND);
1475
-			exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1475
+			exec("$jpegtopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1476 1476
 			if (!($s = @filesize($vignette))) {
1477 1477
 				spip_unlink($vignette);
1478 1478
 			}
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
 		} else {
1485 1485
 			if ($format == 'gif') {
1486 1486
 				$giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND);
1487
-				exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1487
+				exec("$giftopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1488 1488
 				if (!($s = @filesize($vignette))) {
1489 1489
 					spip_unlink($vignette);
1490 1490
 				}
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
 			} else {
1497 1497
 				if ($format == 'png') {
1498 1498
 					$pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND);
1499
-					exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1499
+					exec("$pngtopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1500 1500
 					if (!($s = @filesize($vignette))) {
1501 1501
 						spip_unlink($vignette);
1502 1502
 					}
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
 			return;
1519 1519
 		}
1520 1520
 		if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1521
-			spip_log('vignette gd1/gd2 impossible : ' . $srcWidth * $srcHeight . 'pixels');
1521
+			spip_log('vignette gd1/gd2 impossible : '.$srcWidth * $srcHeight.'pixels');
1522 1522
 
1523 1523
 			return;
1524 1524
 		}
@@ -1828,7 +1828,7 @@  discard block
 block discarded – undo
1828 1828
 		// de l'image, de facon a tromper le cache du navigateur
1829 1829
 		// quand on fait supprimer/reuploader un logo
1830 1830
 		// (pas de filemtime si SAFE MODE)
1831
-		$date = test_espace_prive() ? ('?' . $date) : '';
1831
+		$date = test_espace_prive() ? ('?'.$date) : '';
1832 1832
 
1833 1833
 		return _image_ecrire_tag($image, ['src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight]);
1834 1834
 	}
@@ -1874,7 +1874,7 @@  discard block
 block discarded – undo
1874 1874
 	public static function LittleEndian2String($number, $minbytes = 1) {
1875 1875
 		$intstring = '';
1876 1876
 		while ($number > 0) {
1877
-			$intstring = $intstring . chr($number & 255);
1877
+			$intstring = $intstring.chr($number & 255);
1878 1878
 			$number >>= 8;
1879 1879
 		}
1880 1880
 
@@ -1906,9 +1906,9 @@  discard block
 block discarded – undo
1906 1906
 					$b = $argb['blue'];
1907 1907
 
1908 1908
 					if ($bpp[$key] == 32) {
1909
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1909
+						$icXOR[$key] .= chr($b).chr($g).chr($r).chr($a);
1910 1910
 					} elseif ($bpp[$key] == 24) {
1911
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r);
1911
+						$icXOR[$key] .= chr($b).chr($g).chr($r);
1912 1912
 					}
1913 1913
 
1914 1914
 					if ($a < 128) {
@@ -1935,48 +1935,48 @@  discard block
 block discarded – undo
1935 1935
 
1936 1936
 			// BITMAPINFOHEADER - 40 bytes
1937 1937
 			$BitmapInfoHeader[$key] = '';
1938
-			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1939
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1938
+			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00"; // DWORD  biSize;
1939
+			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4); // LONG   biWidth;
1940 1940
 			// The biHeight member specifies the combined
1941 1941
 			// height of the XOR and AND masks.
1942 1942
 			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1943
-			$BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1944
-			$BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1945
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1946
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1947
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1948
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1949
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1950
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1943
+			$BitmapInfoHeader[$key] .= "\x01\x00"; // WORD   biPlanes;
1944
+			$BitmapInfoHeader[$key] .= chr($bpp[$key])."\x00"; // wBitCount;
1945
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biCompression;
1946
+			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4); // DWORD  biSizeImage;
1947
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG   biXPelsPerMeter;
1948
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG   biYPelsPerMeter;
1949
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biClrUsed;
1950
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biClrImportant;
1951 1951
 		}
1952 1952
 
1953 1953
 
1954
-		$icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1955
-		$icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1956
-		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1954
+		$icondata = "\x00\x00"; // idReserved;   // Reserved (must be 0)
1955
+		$icondata .= "\x01\x00"; // idType;	   // Resource Type (1 for icons)
1956
+		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2); // idCount;	  // How many images?
1957 1957
 
1958 1958
 		$dwImageOffset = 6 + (count($gd_image_array) * 16);
1959 1959
 		foreach ($gd_image_array as $key => $gd_image) {
1960 1960
 			// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1961 1961
 
1962
-			$icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1963
-			$icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1964
-			$icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1965
-			$icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1962
+			$icondata .= chr($ImageWidths[$key]); // bWidth;		  // Width, in pixels, of the image
1963
+			$icondata .= chr($ImageHeights[$key]); // bHeight;		 // Height, in pixels, of the image
1964
+			$icondata .= chr($totalcolors[$key]); // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1965
+			$icondata .= "\x00"; // bReserved;	   // Reserved ( must be 0)
1966 1966
 
1967
-			$icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
1968
-			$icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1967
+			$icondata .= "\x01\x00"; // wPlanes;		 // Color Planes
1968
+			$icondata .= chr($bpp[$key])."\x00"; // wBitCount;	   // Bits per pixel
1969 1969
 
1970 1970
 			$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
1971 1971
 			$icondata .= phpthumb_functions::LittleEndian2String(
1972 1972
 				$dwBytesInRes,
1973 1973
 				4
1974
-			);     // dwBytesInRes;	// How many bytes in this resource?
1974
+			); // dwBytesInRes;	// How many bytes in this resource?
1975 1975
 
1976 1976
 			$icondata .= phpthumb_functions::LittleEndian2String(
1977 1977
 				$dwImageOffset,
1978 1978
 				4
1979
-			);    // dwImageOffset;   // Where in the file is this image?
1979
+			); // dwImageOffset;   // Where in the file is this image?
1980 1980
 			$dwImageOffset += strlen($BitmapInfoHeader[$key]);
1981 1981
 			$dwImageOffset += strlen($icXOR[$key]);
1982 1982
 			$dwImageOffset += strlen($icAND[$key]);
Please login to merge, or discard this patch.
ecrire/inc/presentation_mini.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		$rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
189 189
 	}
190 190
 
191
-	return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
191
+	return $rejouer.(defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
192 192
 }
193 193
 
194 194
 /**
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 	//
235 235
 	if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
236 236
 		if ($vcs['vcs'] === 'GIT') {
237
-			$url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
237
+			$url = 'https://git.spip.net/spip/spip/commit/'.$vcs['commit'];
238 238
 		} elseif ($vcs['vcs'] === 'SVN') {
239
-			$url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
239
+			$url = 'https://core.spip.net/projects/spip/repository/revisions/'.$vcs['commit'];
240 240
 		} else {
241 241
 			$url = '';
242 242
 		}
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
 			$commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
247 247
 		}
248 248
 		if ($vcs['branch']) {
249
-			$commit = $vcs['branch'] . ': ' . $commit;
249
+			$commit = $vcs['branch'].': '.$commit;
250 250
 		}
251 251
 		$version .= " {$vcs['vcs']} [$commit]";
252 252
 	}
253 253
 
254 254
 	// et la version de l'ecran de securite
255 255
 	$secu = defined('_ECRAN_SECURITE')
256
-		? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
256
+		? '<br />'._T('ecran_securite', ['version' => _ECRAN_SECURITE])
257 257
 		: '';
258 258
 
259 259
 	return _T(
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 		[
262 262
 			'spip' => "<b>SPIP $version</b> ",
263 263
 			'lien_gpl' =>
264
-				"<a href='" . generer_url_ecrire(
264
+				"<a href='".generer_url_ecrire(
265 265
 					'aide',
266
-					'aide=licence&var_lang=' . $GLOBALS['spip_lang']
267
-				) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
266
+					'aide=licence&var_lang='.$GLOBALS['spip_lang']
267
+				)."' class=\"aide popin\">"._T('info_copyright_gpl').'</a>'
268 268
 		]
269 269
 	)
270 270
 	. $secu;
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 		$onfocus = '';
292 292
 	}
293 293
 
294
-	$form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
295
-	$form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
294
+	$form = '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="recherche" accesskey="r"'.$onfocus.' />';
295
+	$form .= "<input type='image' src='".chemin_image('rechercher-20.png')."' name='submit' class='submit' alt='"._T('info_rechercher')."' />";
296 296
 
297
-	return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
297
+	return "<div class='spip_recherche'>".generer_form_ecrire($page, $form.$complement, " method='get'").'</div>';
298 298
 }
Please login to merge, or discard this patch.
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Affichage
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @return string Code HTML
26 26
  */
27 27
 function debut_grand_cadre() {
28
- return "\n<div class = 'table_page'>\n";
28
+    return "\n<div class = 'table_page'>\n";
29 29
 }
30 30
 
31 31
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @return string Code HTML
35 35
  */
36 36
 function fin_grand_cadre() {
37
- return "\n</div>";
37
+    return "\n</div>";
38 38
 }
39 39
 
40 40
 // Debut de la colonne de gauche
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
  * @return string Code HTML
50 50
  */
51 51
 function debut_gauche() {
52
-	return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n";
52
+    return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n";
53 53
 }
54 54
 
55 55
 /**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
  * @return string Code HTML
59 59
  */
60 60
 function fin_gauche() {
61
- return "</div></div><br class = 'nettoyeur' />";
61
+    return "</div></div><br class = 'nettoyeur' />";
62 62
 }
63 63
 
64 64
 /**
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
  * @return string Code HTML
68 68
  */
69 69
 function creer_colonne_droite() {
70
-	static $deja_colonne_droite;
71
-	if ($deja_colonne_droite) {
72
-		return '';
73
-	}
74
-	$deja_colonne_droite = true;
70
+    static $deja_colonne_droite;
71
+    if ($deja_colonne_droite) {
72
+        return '';
73
+    }
74
+    $deja_colonne_droite = true;
75 75
 
76
-	return "\n</div><div id='extra' class='lat' role='complementary'>";
76
+    return "\n</div><div id='extra' class='lat' role='complementary'>";
77 77
 }
78 78
 
79 79
 /**
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
  * @return string Code HTML
83 83
  */
84 84
 function debut_droite() {
85
-	return liste_objets_bloques(_request('exec'))
86
-	. creer_colonne_droite()
87
-	. '</div>'
88
-	. "\n<div id='contenu'>";
85
+    return liste_objets_bloques(_request('exec'))
86
+    . creer_colonne_droite()
87
+    . '</div>'
88
+    . "\n<div id='contenu'>";
89 89
 }
90 90
 
91 91
 /**
@@ -107,32 +107,32 @@  discard block
 block discarded – undo
107 107
  *     Code HTML
108 108
  **/
109 109
 function liste_objets_bloques($exec, $contexte = [], $auteur = null): string {
110
-	$res = '';
111
-	include_spip('inc/config');
112
-	if (lire_config('articles_modif', 'non') !== 'non') {
113
-		include_spip('inc/drapeau_edition');
114
-		if (is_null($auteur)) {
115
-			$auteur = $GLOBALS['visiteur_session'];
116
-		}
117
-		if (
118
-			$en_cours = trouver_objet_exec($exec)
119
-			and $en_cours['edition']
120
-			and $type = $en_cours['type']
121
-			and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
122
-				or $id = _request($en_cours['id_table_objet']))
123
-		) {
124
-			// marquer le fait que l'objet est ouvert en edition par toto
125
-			// a telle date ; une alerte sera donnee aux autres redacteurs
126
-			signale_edition($id, $auteur, $type);
127
-		}
128
-
129
-		$objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
130
-		if (count($objets_ouverts)) {
131
-			$res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]);
132
-		}
133
-	}
134
-
135
-	return $res;
110
+    $res = '';
111
+    include_spip('inc/config');
112
+    if (lire_config('articles_modif', 'non') !== 'non') {
113
+        include_spip('inc/drapeau_edition');
114
+        if (is_null($auteur)) {
115
+            $auteur = $GLOBALS['visiteur_session'];
116
+        }
117
+        if (
118
+            $en_cours = trouver_objet_exec($exec)
119
+            and $en_cours['edition']
120
+            and $type = $en_cours['type']
121
+            and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']])
122
+                or $id = _request($en_cours['id_table_objet']))
123
+        ) {
124
+            // marquer le fait que l'objet est ouvert en edition par toto
125
+            // a telle date ; une alerte sera donnee aux autres redacteurs
126
+            signale_edition($id, $auteur, $type);
127
+        }
128
+
129
+        $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']);
130
+        if (count($objets_ouverts)) {
131
+            $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]);
132
+        }
133
+    }
134
+
135
+    return $res;
136 136
 }
137 137
 
138 138
 
@@ -146,20 +146,20 @@  discard block
 block discarded – undo
146 146
  * @return string Code HTML
147 147
  **/
148 148
 function fin_page() {
149
-	include_spip('inc/pipelines');
150
-	// avec &var_profile=1 on a le tableau de mesures SQL
151
-	$debug = ((_request('exec') !== 'valider_xml')
152
-		and ((_request('var_mode') == 'debug')
153
-			or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
154
-			and isset($_COOKIE['spip_admin'])));
155
-	$t = '</div><div id="pied"><div class="largeur">'
156
-		. recuperer_fond('prive/squelettes/inclure/pied')
157
-		. '</div>'
158
-		. '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page()
159
-		. ($debug ? erreur_squelette() : '')
160
-		. "</body></html>\n";
161
-
162
-	return f_queue($t);
149
+    include_spip('inc/pipelines');
150
+    // avec &var_profile=1 on a le tableau de mesures SQL
151
+    $debug = ((_request('exec') !== 'valider_xml')
152
+        and ((_request('var_mode') == 'debug')
153
+            or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps'])
154
+            and isset($_COOKIE['spip_admin'])));
155
+    $t = '</div><div id="pied"><div class="largeur">'
156
+        . recuperer_fond('prive/squelettes/inclure/pied')
157
+        . '</div>'
158
+        . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page()
159
+        . ($debug ? erreur_squelette() : '')
160
+        . "</body></html>\n";
161
+
162
+    return f_queue($t);
163 163
 }
164 164
 
165 165
 /**
@@ -174,22 +174,22 @@  discard block
 block discarded – undo
174 174
  * @return string Code HTML
175 175
  **/
176 176
 function html_tests_js() {
177
-	if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
178
-		// pour le pied de page (deja defini si on est validation XML)
179
-		define(
180
-			'_TESTER_NOSCRIPT',
181
-			"<noscript>\n<div style='display:none;'><img src='"
182
-			. generer_url_ecrire('test_ajax', 'js=-1')
183
-			. "' width='1' height='1' alt='' /></div></noscript>\n"
184
-		);
185
-	}
186
-
187
-	$rejouer = '';
188
-	if (defined('_SESSION_REJOUER')) {
189
-		$rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
190
-	}
191
-
192
-	return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
177
+    if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) {
178
+        // pour le pied de page (deja defini si on est validation XML)
179
+        define(
180
+            '_TESTER_NOSCRIPT',
181
+            "<noscript>\n<div style='display:none;'><img src='"
182
+            . generer_url_ecrire('test_ajax', 'js=-1')
183
+            . "' width='1' height='1' alt='' /></div></noscript>\n"
184
+        );
185
+    }
186
+
187
+    $rejouer = '';
188
+    if (defined('_SESSION_REJOUER')) {
189
+        $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER;
190
+    }
191
+
192
+    return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : '');
193 193
 }
194 194
 
195 195
 /**
@@ -199,25 +199,25 @@  discard block
 block discarded – undo
199 199
  **/
200 200
 function info_maj_spip() {
201 201
 
202
-	$maj = $GLOBALS['meta']['info_maj_spip'] ?? null;
203
-	if (!$maj) {
204
-		return '';
205
-	}
202
+    $maj = $GLOBALS['meta']['info_maj_spip'] ?? null;
203
+    if (!$maj) {
204
+        return '';
205
+    }
206 206
 
207
-	$maj = explode('|', $maj);
208
-	// c'est une ancienne notif, on a fait la maj depuis !
209
-	if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
210
-		return '';
211
-	}
207
+    $maj = explode('|', $maj);
208
+    // c'est une ancienne notif, on a fait la maj depuis !
209
+    if ($GLOBALS['spip_version_branche'] !== reset($maj)) {
210
+        return '';
211
+    }
212 212
 
213
-	if (!autoriser('webmestre')) {
214
-		return '';
215
-	}
213
+    if (!autoriser('webmestre')) {
214
+        return '';
215
+    }
216 216
 
217
-	array_shift($maj);
218
-	$maj = implode('|', $maj);
217
+    array_shift($maj);
218
+    $maj = implode('|', $maj);
219 219
 
220
-	return "$maj<br />";
220
+    return "$maj<br />";
221 221
 }
222 222
 
223 223
 /**
@@ -228,47 +228,47 @@  discard block
 block discarded – undo
228 228
  **/
229 229
 function info_copyright() {
230 230
 
231
-	$version = $GLOBALS['spip_version_affichee'];
232
-
233
-	//
234
-	// Mention, le cas echeant, de la revision SVN courante
235
-	//
236
-	if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
237
-		if ($vcs['vcs'] === 'GIT') {
238
-			$url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
239
-		} elseif ($vcs['vcs'] === 'SVN') {
240
-			$url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
241
-		} else {
242
-			$url = '';
243
-		}
244
-		// affichage "GIT [master: abcdef]"
245
-		$commit = $vcs['commit_short'] ?? $vcs['commit'];
246
-		if ($url) {
247
-			$commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
248
-		}
249
-		if ($vcs['branch']) {
250
-			$commit = $vcs['branch'] . ': ' . $commit;
251
-		}
252
-		$version .= " {$vcs['vcs']} [$commit]";
253
-	}
254
-
255
-	// et la version de l'ecran de securite
256
-	$secu = defined('_ECRAN_SECURITE')
257
-		? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
258
-		: '';
259
-
260
-	return _T(
261
-		'info_copyright',
262
-		[
263
-			'spip' => "<b>SPIP $version</b> ",
264
-			'lien_gpl' =>
265
-				"<a href='" . generer_url_ecrire(
266
-					'aide',
267
-					'aide=licence&var_lang=' . $GLOBALS['spip_lang']
268
-				) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
269
-		]
270
-	)
271
-	. $secu;
231
+    $version = $GLOBALS['spip_version_affichee'];
232
+
233
+    //
234
+    // Mention, le cas echeant, de la revision SVN courante
235
+    //
236
+    if ($vcs = version_vcs_courante(_DIR_RACINE, true)) {
237
+        if ($vcs['vcs'] === 'GIT') {
238
+            $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit'];
239
+        } elseif ($vcs['vcs'] === 'SVN') {
240
+            $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit'];
241
+        } else {
242
+            $url = '';
243
+        }
244
+        // affichage "GIT [master: abcdef]"
245
+        $commit = $vcs['commit_short'] ?? $vcs['commit'];
246
+        if ($url) {
247
+            $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>";
248
+        }
249
+        if ($vcs['branch']) {
250
+            $commit = $vcs['branch'] . ': ' . $commit;
251
+        }
252
+        $version .= " {$vcs['vcs']} [$commit]";
253
+    }
254
+
255
+    // et la version de l'ecran de securite
256
+    $secu = defined('_ECRAN_SECURITE')
257
+        ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE])
258
+        : '';
259
+
260
+    return _T(
261
+        'info_copyright',
262
+        [
263
+            'spip' => "<b>SPIP $version</b> ",
264
+            'lien_gpl' =>
265
+                "<a href='" . generer_url_ecrire(
266
+                    'aide',
267
+                    'aide=licence&var_lang=' . $GLOBALS['spip_lang']
268
+                ) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>'
269
+        ]
270
+    )
271
+    . $secu;
272 272
 }
273 273
 
274 274
 /**
@@ -283,17 +283,17 @@  discard block
 block discarded – undo
283 283
  * @return string             Code HTML
284 284
  **/
285 285
 function formulaire_recherche($page, $complement = '') {
286
-	$recherche = _request('recherche');
287
-	$recherche_aff = entites_html($recherche);
288
-	if (!strlen($recherche)) {
289
-		$recherche_aff = _T('info_rechercher');
290
-		$onfocus = " onfocus=\"this.value='';\"";
291
-	} else {
292
-		$onfocus = '';
293
-	}
294
-
295
-	$form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
296
-	$form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
297
-
298
-	return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
286
+    $recherche = _request('recherche');
287
+    $recherche_aff = entites_html($recherche);
288
+    if (!strlen($recherche)) {
289
+        $recherche_aff = _T('info_rechercher');
290
+        $onfocus = " onfocus=\"this.value='';\"";
291
+    } else {
292
+        $onfocus = '';
293
+    }
294
+
295
+    $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />';
296
+    $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />";
297
+
298
+    return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>';
299 299
 }
Please login to merge, or discard this patch.
ecrire/inc/minipres.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -193,11 +193,9 @@
 block discarded – undo
193 193
 
194 194
 		if ($statut and test_espace_prive()) {
195 195
 			$corps = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil'));
196
-		}
197
-		elseif (!empty($_COOKIE['spip_admin'])) {
196
+		} elseif (!empty($_COOKIE['spip_admin'])) {
198 197
 			$corps = bouton_action(_T('public:lien_connecter'), generer_url_public('login'));
199
-		}
200
-		else {
198
+		} else {
201 199
 			$corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']);
202 200
 		}
203 201
 		$corps = "<div class='boutons'>$corps</div>";
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 			lire_fichier($file, $c);
75 75
 			$css .= $c;
76 76
 		}
77
-		$css = "<style type='text/css'>" . $css . '</style>';
77
+		$css = "<style type='text/css'>".$css.'</style>';
78 78
 	} else {
79 79
 		foreach ($files as $name) {
80 80
 			$file = direction_css(find_in_theme($name));
@@ -87,19 +87,19 @@  discard block
 block discarded – undo
87 87
 		define('_DOCTYPE_ECRIRE', '');
88 88
 	}
89 89
 
90
-	return _DOCTYPE_ECRIRE .
91
-	html_lang_attributes() .
92
-	"<head>\n" .
93
-	'<title>' .
94
-	textebrut($titre) .
95
-	"</title>\n" .
96
-	"<meta name='viewport' content='width=device-width' />\n" .
97
-	$css .
90
+	return _DOCTYPE_ECRIRE.
91
+	html_lang_attributes().
92
+	"<head>\n".
93
+	'<title>'.
94
+	textebrut($titre).
95
+	"</title>\n".
96
+	"<meta name='viewport' content='width=device-width' />\n".
97
+	$css.
98 98
 	'</head>
99
-<body' . $onLoad . " class='minipres'>
99
+<body' . $onLoad." class='minipres'>
100 100
 	<div id='minipres'>
101 101
 	<h1>" .
102
-	$titre .
102
+	$titre.
103 103
 	"</h1>
104 104
 	<div>\n";
105 105
 }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 		$titre = ($titre == 'install')
184 184
 			? _T('avis_espace_interdit')
185
-			: $titre . '&nbsp;: ' . _T('info_acces_interdit');
185
+			: $titre.'&nbsp;: '._T('info_acces_interdit');
186 186
 
187 187
 		$statut = $GLOBALS['visiteur_session']['statut'] ?? '';
188 188
 		$nom = $GLOBALS['visiteur_session']['nom'] ?? '';
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			$corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']);
202 202
 		}
203 203
 		$corps = "<div class='boutons'>$corps</div>";
204
-		spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']);
204
+		spip_log($nom." $titre ".$_SERVER['REQUEST_URI']);
205 205
 	}
206 206
 
207 207
 	if (!_AJAX) {
@@ -219,6 +219,6 @@  discard block
 block discarded – undo
219 219
 		foreach ($_POST as $v => $c) {
220 220
 			$url = parametre_url($url, $v, $c, '&');
221 221
 		}
222
-		ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false);
222
+		ajax_retour('<div>'.$titre.redirige_formulaire($url).'</div>', false);
223 223
 	}
224 224
 }
Please login to merge, or discard this patch.
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Minipres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/headers');
@@ -46,61 +46,61 @@  discard block
 block discarded – undo
46 46
  */
47 47
 function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false) {
48 48
 
49
-	utiliser_langue_visiteur();
50
-
51
-	http_no_cache();
52
-
53
-	if ($titre == 'AUTO') {
54
-		$titre = _T('info_installation_systeme_publication');
55
-	}
56
-
57
-	# le charset est en utf-8, pour recuperer le nom comme il faut
58
-	# lors de l'installation
59
-	if (!headers_sent()) {
60
-		header('Content-Type: text/html; charset=utf-8');
61
-	}
62
-
63
-	$css = '';
64
-	$files = ['reset.css', 'clear.css', 'minipres.css'];
65
-	if ($all_inline) {
66
-		// inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande)
67
-		foreach ($files as $name) {
68
-			$file = direction_css(find_in_theme($name));
69
-			if (function_exists('minifier')) {
70
-				$file = minifier($file);
71
-			} else {
72
-				$file = url_absolue_css($file); // precaution
73
-			}
74
-			lire_fichier($file, $c);
75
-			$css .= $c;
76
-		}
77
-		$css = "<style type='text/css'>" . $css . '</style>';
78
-	} else {
79
-		foreach ($files as $name) {
80
-			$file = direction_css(find_in_theme($name));
81
-			$css .= "<link rel='stylesheet' href='$file' type='text/css' />\n";
82
-		}
83
-	}
84
-
85
-	// au cas ou minipres() est appele avant spip_initialisation_suite()
86
-	if (!defined('_DOCTYPE_ECRIRE')) {
87
-		define('_DOCTYPE_ECRIRE', '');
88
-	}
89
-
90
-	return _DOCTYPE_ECRIRE .
91
-	html_lang_attributes() .
92
-	"<head>\n" .
93
-	'<title>' .
94
-	textebrut($titre) .
95
-	"</title>\n" .
96
-	"<meta name='viewport' content='width=device-width' />\n" .
97
-	$css .
98
-	'</head>
49
+    utiliser_langue_visiteur();
50
+
51
+    http_no_cache();
52
+
53
+    if ($titre == 'AUTO') {
54
+        $titre = _T('info_installation_systeme_publication');
55
+    }
56
+
57
+    # le charset est en utf-8, pour recuperer le nom comme il faut
58
+    # lors de l'installation
59
+    if (!headers_sent()) {
60
+        header('Content-Type: text/html; charset=utf-8');
61
+    }
62
+
63
+    $css = '';
64
+    $files = ['reset.css', 'clear.css', 'minipres.css'];
65
+    if ($all_inline) {
66
+        // inliner les CSS (optimisation de la page minipres qui passe en un seul hit a la demande)
67
+        foreach ($files as $name) {
68
+            $file = direction_css(find_in_theme($name));
69
+            if (function_exists('minifier')) {
70
+                $file = minifier($file);
71
+            } else {
72
+                $file = url_absolue_css($file); // precaution
73
+            }
74
+            lire_fichier($file, $c);
75
+            $css .= $c;
76
+        }
77
+        $css = "<style type='text/css'>" . $css . '</style>';
78
+    } else {
79
+        foreach ($files as $name) {
80
+            $file = direction_css(find_in_theme($name));
81
+            $css .= "<link rel='stylesheet' href='$file' type='text/css' />\n";
82
+        }
83
+    }
84
+
85
+    // au cas ou minipres() est appele avant spip_initialisation_suite()
86
+    if (!defined('_DOCTYPE_ECRIRE')) {
87
+        define('_DOCTYPE_ECRIRE', '');
88
+    }
89
+
90
+    return _DOCTYPE_ECRIRE .
91
+    html_lang_attributes() .
92
+    "<head>\n" .
93
+    '<title>' .
94
+    textebrut($titre) .
95
+    "</title>\n" .
96
+    "<meta name='viewport' content='width=device-width' />\n" .
97
+    $css .
98
+    '</head>
99 99
 <body' . $onLoad . " class='minipres'>
100 100
 	<div id='minipres'>
101 101
 	<h1>" .
102
-	$titre .
103
-	"</h1>
102
+    $titre .
103
+    "</h1>
104 104
 	<div>\n";
105 105
 }
106 106
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
  * @return string Code HTML
111 111
  */
112 112
 function install_fin_html() {
113
-	return "\n\t</div>\n\t</div>\n</body>\n</html>";
113
+    return "\n\t</div>\n\t</div>\n</body>\n</html>";
114 114
 }
115 115
 
116 116
 
@@ -148,88 +148,88 @@  discard block
 block discarded – undo
148 148
  */
149 149
 function minipres($titre = '', $corps = '', $options = []) {
150 150
 
151
-	// compat signature old
152
-	// minipres($titre='', $corps="", $onload='', $all_inline = false)
153
-	$args = func_get_args();
154
-	if (isset($args[2]) and is_string($args[2])) {
155
-		$options = ['onload' => $args[2]];
156
-	}
157
-	if (isset($args[3])) {
158
-		$options['all_inline'] = $args[3];
159
-	}
160
-
161
-	$options = array_merge([
162
-		'onload' => '',
163
-		'all_inline' => false,
164
-	], $options);
165
-
166
-	if (!defined('_AJAX')) {
167
-		define('_AJAX', false);
168
-	} // par securite
169
-	if (!$titre) {
170
-		if (!isset($options['status'])) {
171
-			$options['status'] = 403;
172
-		}
173
-		if (
174
-			!$titre = _request('action')
175
-			and !$titre = _request('exec')
176
-			and !$titre = _request('page')
177
-		) {
178
-			$titre = '?';
179
-		}
180
-
181
-		$titre = spip_htmlspecialchars($titre);
182
-
183
-		$titre = ($titre == 'install')
184
-			? _T('avis_espace_interdit')
185
-			: $titre . '&nbsp;: ' . _T('info_acces_interdit');
186
-
187
-		$statut = $GLOBALS['visiteur_session']['statut'] ?? '';
188
-		$nom = $GLOBALS['visiteur_session']['nom'] ?? '';
189
-
190
-		if ($statut != '0minirezo') {
191
-			$titre = _T('info_acces_interdit');
192
-		}
193
-
194
-		if ($statut and test_espace_prive()) {
195
-			$corps = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil'));
196
-		}
197
-		elseif (!empty($_COOKIE['spip_admin'])) {
198
-			$corps = bouton_action(_T('public:lien_connecter'), generer_url_public('login'));
199
-		}
200
-		else {
201
-			$corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']);
202
-		}
203
-		$corps = "<div class='boutons'>$corps</div>";
204
-		spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']);
205
-	}
206
-
207
-	if (!_AJAX) {
208
-		if (isset($options['status'])) {
209
-			http_response_code($options['status']);
210
-		}
211
-
212
-		$html = install_debut_html($titre, $options['onload'], $options['all_inline'])
213
-				. $corps
214
-				. install_fin_html();
215
-
216
-		if (
217
-			$GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
218
-			and empty($options['all_inline'])
219
-		) {
220
-			define('_SET_HTML_BASE', true);
221
-			include_spip('public/assembler');
222
-			$GLOBALS['html'] = true;
223
-			page_base_href($html);
224
-		}
225
-		return $html;
226
-	} else {
227
-		include_spip('inc/headers');
228
-		include_spip('inc/actions');
229
-		$url = self('&', true);
230
-		foreach ($_POST as $v => $c) {
231
-			$url = parametre_url($url, $v, $c, '&');
232
-		}
233
-		ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false);
234
-	}
151
+    // compat signature old
152
+    // minipres($titre='', $corps="", $onload='', $all_inline = false)
153
+    $args = func_get_args();
154
+    if (isset($args[2]) and is_string($args[2])) {
155
+        $options = ['onload' => $args[2]];
156
+    }
157
+    if (isset($args[3])) {
158
+        $options['all_inline'] = $args[3];
159
+    }
160
+
161
+    $options = array_merge([
162
+        'onload' => '',
163
+        'all_inline' => false,
164
+    ], $options);
165
+
166
+    if (!defined('_AJAX')) {
167
+        define('_AJAX', false);
168
+    } // par securite
169
+    if (!$titre) {
170
+        if (!isset($options['status'])) {
171
+            $options['status'] = 403;
172
+        }
173
+        if (
174
+            !$titre = _request('action')
175
+            and !$titre = _request('exec')
176
+            and !$titre = _request('page')
177
+        ) {
178
+            $titre = '?';
179
+        }
180
+
181
+        $titre = spip_htmlspecialchars($titre);
182
+
183
+        $titre = ($titre == 'install')
184
+            ? _T('avis_espace_interdit')
185
+            : $titre . '&nbsp;: ' . _T('info_acces_interdit');
186
+
187
+        $statut = $GLOBALS['visiteur_session']['statut'] ?? '';
188
+        $nom = $GLOBALS['visiteur_session']['nom'] ?? '';
189
+
190
+        if ($statut != '0minirezo') {
191
+            $titre = _T('info_acces_interdit');
192
+        }
193
+
194
+        if ($statut and test_espace_prive()) {
195
+            $corps = bouton_action(_T('public:accueil_site'), generer_url_ecrire('accueil'));
196
+        }
197
+        elseif (!empty($_COOKIE['spip_admin'])) {
198
+            $corps = bouton_action(_T('public:lien_connecter'), generer_url_public('login'));
199
+        }
200
+        else {
201
+            $corps = bouton_action(_T('public:accueil_site'), $GLOBALS['meta']['adresse_site']);
202
+        }
203
+        $corps = "<div class='boutons'>$corps</div>";
204
+        spip_log($nom . " $titre " . $_SERVER['REQUEST_URI']);
205
+    }
206
+
207
+    if (!_AJAX) {
208
+        if (isset($options['status'])) {
209
+            http_response_code($options['status']);
210
+        }
211
+
212
+        $html = install_debut_html($titre, $options['onload'], $options['all_inline'])
213
+                . $corps
214
+                . install_fin_html();
215
+
216
+        if (
217
+            $GLOBALS['profondeur_url'] >= (_DIR_RESTREINT ? 1 : 2)
218
+            and empty($options['all_inline'])
219
+        ) {
220
+            define('_SET_HTML_BASE', true);
221
+            include_spip('public/assembler');
222
+            $GLOBALS['html'] = true;
223
+            page_base_href($html);
224
+        }
225
+        return $html;
226
+    } else {
227
+        include_spip('inc/headers');
228
+        include_spip('inc/actions');
229
+        $url = self('&', true);
230
+        foreach ($_POST as $v => $c) {
231
+            $url = parametre_url($url, $v, $c, '&');
232
+        }
233
+        ajax_retour('<div>' . $titre . redirige_formulaire($url) . '</div>', false);
234
+    }
235 235
 }
Please login to merge, or discard this patch.
ecrire/inc/boutons.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 			&& autoriser('onglet', "_$id")
103 103
 		) {
104 104
 			$onglets[$id] = new Bouton(
105
-				isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
106
-				$infos['titre'],  // titre
105
+				isset($infos['icone']) ? find_in_theme($infos['icone']) : '', // icone
106
+				$infos['titre'], // titre
107 107
 				(isset($infos['action']) and $infos['action'])
108 108
 					? generer_url_ecrire(
109 109
 						$infos['action'],
@@ -142,5 +142,5 @@  discard block
 block discarded – undo
142 142
 		$res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
143 143
 	}
144 144
 
145
-	return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
145
+	return !$res ? '' : (debut_onglet($class).$res.fin_onglet());
146 146
 }
Please login to merge, or discard this patch.
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -25,58 +25,58 @@  discard block
 block discarded – undo
25 25
  * privée ou dans un de ses sous menus
26 26
  */
27 27
 class Bouton {
28
-	/** L'icone à mettre dans le bouton */
29
-	public string $icone;
30
-
31
-	/** Le nom de l'entrée d'i18n associé */
32
-	public string $libelle;
33
-
34
-	/** @var null|string L'URL de la page (null => ?exec=nom) */
35
-	public $url = null;
36
-
37
-	/** @var null|string|array Arguments supplementaires de l'URL */
38
-	public $urlArg = null;
39
-
40
-	/** @var null|string URL du javascript */
41
-	public $url2 = null;
42
-
43
-	/** @var null|string Pour ouvrir dans une fenetre a part */
44
-	public $target = null;
45
-
46
-	/** Sous-barre de boutons / onglets */
47
-	public array $sousmenu = [];
48
-
49
-	/** Position dans le menu */
50
-	public int $position = 0;
51
-
52
-	/** Entrée favorite ? */
53
-	public bool $favori = false;
54
-
55
-
56
-	/**
57
-	 * Définit un bouton
58
-	 *
59
-	 * @param string $icone
60
-	 *    L'icone à mettre dans le bouton
61
-	 * @param string $libelle
62
-	 *    Le nom de l'entrée i18n associé
63
-	 * @param null|string $url
64
-	 *    L'URL de la page
65
-	 * @param null|string|array $urlArg
66
-	 *    Arguments supplémentaires de l'URL
67
-	 * @param null|string $url2
68
-	 *    URL du javascript
69
-	 * @param null|mixed $target
70
-	 *    Pour ouvrir une fenêtre à part
71
-	 */
72
-	public function __construct($icone, $libelle, $url = null, $urlArg = null, $url2 = null, $target = null) {
73
-		$this->icone = $icone;
74
-		$this->libelle = $libelle;
75
-		$this->url = $url;
76
-		$this->urlArg = $urlArg;
77
-		$this->url2 = $url2;
78
-		$this->target = $target;
79
-	}
28
+    /** L'icone à mettre dans le bouton */
29
+    public string $icone;
30
+
31
+    /** Le nom de l'entrée d'i18n associé */
32
+    public string $libelle;
33
+
34
+    /** @var null|string L'URL de la page (null => ?exec=nom) */
35
+    public $url = null;
36
+
37
+    /** @var null|string|array Arguments supplementaires de l'URL */
38
+    public $urlArg = null;
39
+
40
+    /** @var null|string URL du javascript */
41
+    public $url2 = null;
42
+
43
+    /** @var null|string Pour ouvrir dans une fenetre a part */
44
+    public $target = null;
45
+
46
+    /** Sous-barre de boutons / onglets */
47
+    public array $sousmenu = [];
48
+
49
+    /** Position dans le menu */
50
+    public int $position = 0;
51
+
52
+    /** Entrée favorite ? */
53
+    public bool $favori = false;
54
+
55
+
56
+    /**
57
+     * Définit un bouton
58
+     *
59
+     * @param string $icone
60
+     *    L'icone à mettre dans le bouton
61
+     * @param string $libelle
62
+     *    Le nom de l'entrée i18n associé
63
+     * @param null|string $url
64
+     *    L'URL de la page
65
+     * @param null|string|array $urlArg
66
+     *    Arguments supplémentaires de l'URL
67
+     * @param null|string $url2
68
+     *    URL du javascript
69
+     * @param null|mixed $target
70
+     *    Pour ouvrir une fenêtre à part
71
+     */
72
+    public function __construct($icone, $libelle, $url = null, $urlArg = null, $url2 = null, $target = null) {
73
+        $this->icone = $icone;
74
+        $this->libelle = $libelle;
75
+        $this->url = $url;
76
+        $this->urlArg = $urlArg;
77
+        $this->url2 = $url2;
78
+        $this->target = $target;
79
+    }
80 80
 }
81 81
 
82 82
 
@@ -93,35 +93,35 @@  discard block
 block discarded – undo
93 93
  */
94 94
 function definir_barre_onglets($script) {
95 95
 
96
-	$onglets = [];
97
-	$liste_onglets = [];
98
-
99
-	// ajouter les onglets issus des plugin via paquet.xml
100
-	if (function_exists('onglets_plugins')) {
101
-		$liste_onglets = onglets_plugins();
102
-	}
103
-
104
-
105
-	foreach ($liste_onglets as $id => $infos) {
106
-		if (
107
-			($parent = $infos['parent'])
108
-			&& $parent == $script
109
-			&& autoriser('onglet', "_$id")
110
-		) {
111
-			$onglets[$id] = new Bouton(
112
-				isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
113
-				$infos['titre'],  // titre
114
-				(isset($infos['action']) and $infos['action'])
115
-					? generer_url_ecrire(
116
-						$infos['action'],
117
-						(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : ''
118
-					)
119
-					: null
120
-			);
121
-		}
122
-	}
123
-
124
-	return pipeline('ajouter_onglets', ['data' => $onglets, 'args' => $script]);
96
+    $onglets = [];
97
+    $liste_onglets = [];
98
+
99
+    // ajouter les onglets issus des plugin via paquet.xml
100
+    if (function_exists('onglets_plugins')) {
101
+        $liste_onglets = onglets_plugins();
102
+    }
103
+
104
+
105
+    foreach ($liste_onglets as $id => $infos) {
106
+        if (
107
+            ($parent = $infos['parent'])
108
+            && $parent == $script
109
+            && autoriser('onglet', "_$id")
110
+        ) {
111
+            $onglets[$id] = new Bouton(
112
+                isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
113
+                $infos['titre'],  // titre
114
+                (isset($infos['action']) and $infos['action'])
115
+                    ? generer_url_ecrire(
116
+                        $infos['action'],
117
+                        (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : ''
118
+                    )
119
+                    : null
120
+            );
121
+        }
122
+    }
123
+
124
+    return pipeline('ajouter_onglets', ['data' => $onglets, 'args' => $script]);
125 125
 }
126 126
 
127 127
 
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
  * @return string
141 141
  */
142 142
 function barre_onglets($rubrique, $ongletCourant, $class = 'barre_onglet') {
143
-	include_spip('inc/presentation');
143
+    include_spip('inc/presentation');
144 144
 
145
-	$res = '';
145
+    $res = '';
146 146
 
147
-	foreach (definir_barre_onglets($rubrique) as $exec => $onglet) {
148
-		$url = $onglet->url ?: generer_url_ecrire($exec);
149
-		$res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
150
-	}
147
+    foreach (definir_barre_onglets($rubrique) as $exec => $onglet) {
148
+        $url = $onglet->url ?: generer_url_ecrire($exec);
149
+        $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
150
+    }
151 151
 
152
-	return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
152
+    return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
153 153
 }
Please login to merge, or discard this patch.
ecrire/inc/pipelines.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		}
66 66
 	}
67 67
 
68
-	$texte = $x . $texte;
68
+	$texte = $x.$texte;
69 69
 
70 70
 	return $texte;
71 71
 }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	|| ($pos = 0);
180 180
 
181 181
 	if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
182
-		$insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
+		$insert = "\n".pipeline('insert_head', '<!-- f_insert_head -->')."\n";
183 183
 		$texte = substr_replace($texte, $insert, $pos, 0);
184 184
 	}
185 185
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		}
212 212
 		$texte = substr_replace($texte, $x, $pos, 0);
213 213
 		// pas de preview en fenetre enfant
214
-		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
+		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='".addslashes($GLOBALS['meta']['adresse_site'])."';}</script>";
215 215
 		if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
216 216
 			$pos = -1;
217 217
 		}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 	// inserer avant le </body> fermant si on peut, a la fin de la page sinon
284 284
 	if (($p = strpos($texte, '</body>')) !== false) {
285
-		$texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
+		$texte = substr($texte, 0, $p).$code.substr($texte, $p);
286 286
 	} else {
287 287
 		$texte .= $code;
288 288
 	}
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Pipelines
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 if (test_espace_prive()) {
22
-	include_spip('inc/pipelines_ecrire');
22
+    include_spip('inc/pipelines_ecrire');
23 23
 }
24 24
 
25 25
 
@@ -45,28 +45,28 @@  discard block
 block discarded – undo
45 45
  * @return string          Contenu qui sera inséré dans le head HTML
46 46
  **/
47 47
 function f_jQuery($texte) {
48
-	$x = '';
49
-	$jquery_plugins = pipeline(
50
-		'jquery_plugins',
51
-		[
52
-			'javascript/jquery.js',
53
-			'javascript/jquery.form.js',
54
-			'javascript/jquery.autosave.js',
55
-			'javascript/jquery.placeholder-label.js',
56
-			'javascript/ajaxCallback.js',
57
-			'javascript/js.cookie.js',
58
-		]
59
-	);
60
-	foreach (array_unique($jquery_plugins) as $script) {
61
-		if ($script = find_in_path(supprimer_timestamp($script))) {
62
-			$script = timestamp($script);
63
-			$x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
64
-		}
65
-	}
48
+    $x = '';
49
+    $jquery_plugins = pipeline(
50
+        'jquery_plugins',
51
+        [
52
+            'javascript/jquery.js',
53
+            'javascript/jquery.form.js',
54
+            'javascript/jquery.autosave.js',
55
+            'javascript/jquery.placeholder-label.js',
56
+            'javascript/ajaxCallback.js',
57
+            'javascript/js.cookie.js',
58
+        ]
59
+    );
60
+    foreach (array_unique($jquery_plugins) as $script) {
61
+        if ($script = find_in_path(supprimer_timestamp($script))) {
62
+            $script = timestamp($script);
63
+            $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
64
+        }
65
+    }
66 66
 
67
-	$texte = $x . $texte;
67
+    $texte = $x . $texte;
68 68
 
69
-	return $texte;
69
+    return $texte;
70 70
 }
71 71
 
72 72
 
@@ -85,28 +85,28 @@  discard block
 block discarded – undo
85 85
  * @return string         Contenu de la page envoyée au navigateur
86 86
  **/
87 87
 function f_surligne($texte) {
88
-	if (!$GLOBALS['html']) {
89
-		return $texte;
90
-	}
91
-	$rech = _request('var_recherche');
92
-	if (
93
-		!$rech
94
-		and (!defined('_SURLIGNE_RECHERCHE_REFERERS')
95
-			or !_SURLIGNE_RECHERCHE_REFERERS
96
-			or !isset($_SERVER['HTTP_REFERER']))
97
-	) {
98
-		return $texte;
99
-	}
100
-	include_spip('inc/surligne');
88
+    if (!$GLOBALS['html']) {
89
+        return $texte;
90
+    }
91
+    $rech = _request('var_recherche');
92
+    if (
93
+        !$rech
94
+        and (!defined('_SURLIGNE_RECHERCHE_REFERERS')
95
+            or !_SURLIGNE_RECHERCHE_REFERERS
96
+            or !isset($_SERVER['HTTP_REFERER']))
97
+    ) {
98
+        return $texte;
99
+    }
100
+    include_spip('inc/surligne');
101 101
 
102
-	if (isset($_SERVER['HTTP_REFERER'])) {
103
-		$_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']);
104
-	}
105
-	if ($rech) {
106
-		$rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech);
107
-	}
102
+    if (isset($_SERVER['HTTP_REFERER'])) {
103
+        $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']);
104
+    }
105
+    if ($rech) {
106
+        $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech);
107
+    }
108 108
 
109
-	return surligner_mots($texte, $rech);
109
+    return surligner_mots($texte, $rech);
110 110
 }
111 111
 
112 112
 /**
@@ -123,33 +123,33 @@  discard block
 block discarded – undo
123 123
  * @return string         Contenu de la page envoyée au navigateur
124 124
  **/
125 125
 function f_tidy($texte) {
126
-	/**
127
-	 * Indentation à faire ?
128
-	 *
129
-	 * - true : actif.
130
-	 * - false par défaut.
131
-	 */
126
+    /**
127
+     * Indentation à faire ?
128
+     *
129
+     * - true : actif.
130
+     * - false par défaut.
131
+     */
132 132
 
133
-	if (
134
-		$GLOBALS['xhtml'] # tidy demande
135
-		and $GLOBALS['html'] # verifie que la page avait l'entete text/html
136
-		and strlen($texte)
137
-		and !headers_sent()
138
-	) {
139
-		# Compatibilite ascendante
140
-		if (!is_string($GLOBALS['xhtml'])) {
141
-			$GLOBALS['xhtml'] = 'tidy';
142
-		}
133
+    if (
134
+        $GLOBALS['xhtml'] # tidy demande
135
+        and $GLOBALS['html'] # verifie que la page avait l'entete text/html
136
+        and strlen($texte)
137
+        and !headers_sent()
138
+    ) {
139
+        # Compatibilite ascendante
140
+        if (!is_string($GLOBALS['xhtml'])) {
141
+            $GLOBALS['xhtml'] = 'tidy';
142
+        }
143 143
 
144
-		if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
145
-			spip_log("tidy absent, l'indenteur SPIP le remplace");
146
-			$f = charger_fonction('sax', 'xml');
147
-		}
144
+        if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) {
145
+            spip_log("tidy absent, l'indenteur SPIP le remplace");
146
+            $f = charger_fonction('sax', 'xml');
147
+        }
148 148
 
149
-		return $f($texte);
150
-	}
149
+        return $f($texte);
150
+    }
151 151
 
152
-	return $texte;
152
+    return $texte;
153 153
 }
154 154
 
155 155
 
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
  * @return string         Contenu de la page envoyée au navigateur
169 169
  **/
170 170
 function f_insert_head($texte) {
171
-	if (!$GLOBALS['html']) {
172
-		return $texte;
173
-	}
174
-	include_spip('public/admin'); // pour strripos
171
+    if (!$GLOBALS['html']) {
172
+        return $texte;
173
+    }
174
+    include_spip('public/admin'); // pour strripos
175 175
 
176
-	($pos = stripos($texte, '</head>'))
177
-	|| ($pos = stripos($texte, '<body>'))
178
-	|| ($pos = 0);
176
+    ($pos = stripos($texte, '</head>'))
177
+    || ($pos = stripos($texte, '<body>'))
178
+    || ($pos = 0);
179 179
 
180
-	if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
181
-		$insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
-		$texte = substr_replace($texte, $insert, $pos, 0);
183
-	}
180
+    if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) {
181
+        $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n";
182
+        $texte = substr_replace($texte, $insert, $pos, 0);
183
+    }
184 184
 
185
-	return $texte;
185
+    return $texte;
186 186
 }
187 187
 
188 188
 
@@ -198,34 +198,34 @@  discard block
 block discarded – undo
198 198
  * @return string         Contenu de la page envoyée au navigateur
199 199
  **/
200 200
 function f_admin($texte) {
201
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) {
202
-		include_spip('inc/filtres'); // pour http_img_pack
203
-		$x = "<div class='spip-previsu' "
204
-			. http_style_background('preview-32.png', '', 32)
205
-			. '>'
206
-			. _T('previsualisation')
207
-			. '</div>';
208
-		if (!$pos = stripos($texte, '</body>')) {
209
-			$pos = strlen($texte);
210
-		}
211
-		$texte = substr_replace($texte, $x, $pos, 0);
212
-		// pas de preview en fenetre enfant
213
-		$x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
-		if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
215
-			$pos = -1;
216
-		}
217
-		$texte = substr_replace($texte, $x, $pos + 1, 0);
218
-	}
201
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) {
202
+        include_spip('inc/filtres'); // pour http_img_pack
203
+        $x = "<div class='spip-previsu' "
204
+            . http_style_background('preview-32.png', '', 32)
205
+            . '>'
206
+            . _T('previsualisation')
207
+            . '</div>';
208
+        if (!$pos = stripos($texte, '</body>')) {
209
+            $pos = strlen($texte);
210
+        }
211
+        $texte = substr_replace($texte, $x, $pos, 0);
212
+        // pas de preview en fenetre enfant
213
+        $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>";
214
+        if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) {
215
+            $pos = -1;
216
+        }
217
+        $texte = substr_replace($texte, $x, $pos + 1, 0);
218
+    }
219 219
 
220
-	if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) {
221
-		include_spip('public/admin');
222
-		$texte = affiche_boutons_admin($texte);
223
-	}
224
-	if (_request('var_mode') == 'noajax') {
225
-		$texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
226
-	}
220
+    if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) {
221
+        include_spip('public/admin');
222
+        $texte = affiche_boutons_admin($texte);
223
+    }
224
+    if (_request('var_mode') == 'noajax') {
225
+        $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte);
226
+    }
227 227
 
228
-	return $texte;
228
+    return $texte;
229 229
 }
230 230
 
231 231
 /**
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
  * @return array $flux  Description et contenu de l'inclusion
244 244
  **/
245 245
 function f_recuperer_fond($flux) {
246
-	if (!test_espace_prive()) {
247
-		return $flux;
248
-	}
246
+    if (!test_espace_prive()) {
247
+        return $flux;
248
+    }
249 249
 
250
-	return f_afficher_blocs_ecrire($flux);
250
+    return f_afficher_blocs_ecrire($flux);
251 251
 }
252 252
 
253 253
 /**
@@ -261,30 +261,30 @@  discard block
 block discarded – undo
261 261
  * @return string         Contenu de la page envoyée au navigateur
262 262
  */
263 263
 function f_queue($texte) {
264
-	// eviter une inclusion si rien a faire
265
-	if (
266
-		_request('action') == 'cron'
267
-		or queue_sleep_time_to_next_job() > 0
268
-		or defined('_DEBUG_BLOCK_QUEUE')
269
-	) {
270
-		return $texte;
271
-	}
264
+    // eviter une inclusion si rien a faire
265
+    if (
266
+        _request('action') == 'cron'
267
+        or queue_sleep_time_to_next_job() > 0
268
+        or defined('_DEBUG_BLOCK_QUEUE')
269
+    ) {
270
+        return $texte;
271
+    }
272 272
 
273
-	include_spip('inc/queue');
274
-	$code = queue_affichage_cron();
273
+    include_spip('inc/queue');
274
+    $code = queue_affichage_cron();
275 275
 
276
-	// si rien a afficher
277
-	// ou si on est pas dans une page html, on ne sait rien faire de mieux
278
-	if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) {
279
-		return $texte;
280
-	}
276
+    // si rien a afficher
277
+    // ou si on est pas dans une page html, on ne sait rien faire de mieux
278
+    if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) {
279
+        return $texte;
280
+    }
281 281
 
282
-	// inserer avant le </body> fermant si on peut, a la fin de la page sinon
283
-	if (($p = strpos($texte, '</body>')) !== false) {
284
-		$texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
-	} else {
286
-		$texte .= $code;
287
-	}
282
+    // inserer avant le </body> fermant si on peut, a la fin de la page sinon
283
+    if (($p = strpos($texte, '</body>')) !== false) {
284
+        $texte = substr($texte, 0, $p) . $code . substr($texte, $p);
285
+    } else {
286
+        $texte .= $code;
287
+    }
288 288
 
289
-	return $texte;
289
+    return $texte;
290 290
 }
Please login to merge, or discard this patch.
ecrire/inc/recherche_to_array.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$_id_table = reset($_id_table);
68 68
 	}
69 69
 
70
-	$requete['SELECT'][] = 't.' . $_id_table;
70
+	$requete['SELECT'][] = 't.'.$_id_table;
71 71
 	$a = [];
72 72
 	// Recherche fulltext
73 73
 	foreach ($champs as $champ => $poids) {
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 				$champ = "t.$champ";
79 79
 			}
80 80
 			$requete['SELECT'][] = $champ;
81
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
81
+			$a[] = $champ.' '.$methode.' '.$q;
82 82
 		}
83 83
 	}
84 84
 	if ($a) {
85 85
 		$requete['WHERE'][] = join(' OR ', $a);
86 86
 	}
87
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
87
+	$requete['FROM'][] = table_objet_sql($table).' AS t';
88 88
 
89 89
 	$results = [];
90 90
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 					);
253 253
 				} // cas table de liaison generique spip_xxx_yyy
254 254
 				elseif (
255
-					$t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
-					or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
255
+					$t = $trouver_table($table_arrivee.'_'.$table_depart, $serveur)
256
+					or $t = $trouver_table($table_depart.'_'.$table_arrivee, $serveur)
257 257
 				) {
258 258
 					$s = sql_select(
259 259
 						"$cle_depart,$cle_arrivee",
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
 				}
293 293
 				if (isset($joint['champs']) and $joint['champs']) {
294 294
 					foreach ($joint['champs'] as $c => $val) {
295
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
295
+						$results[$id]['champs'][$table_liee.'.'.$c] = $val;
296 296
 					}
297 297
 				}
298 298
 				if (isset($joint['matches']) and $joint['matches']) {
299 299
 					foreach ($joint['matches'] as $c => $val) {
300
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
300
+						$results[$id]['matches'][$table_liee.'.'.$c] = $val;
301 301
 					}
302 302
 				}
303 303
 			}
Please login to merge, or discard this patch.
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -11,298 +11,298 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 
18 18
 // methodes sql
19 19
 function inc_recherche_to_array_dist($recherche, $options = []) {
20 20
 
21
-	// options par defaut
22
-	$options = array_merge(
23
-		[
24
-			'score' => true,
25
-			'champs' => false,
26
-			'toutvoir' => false,
27
-			'matches' => false,
28
-			'jointures' => false
29
-		],
30
-		$options
31
-	);
21
+    // options par defaut
22
+    $options = array_merge(
23
+        [
24
+            'score' => true,
25
+            'champs' => false,
26
+            'toutvoir' => false,
27
+            'matches' => false,
28
+            'jointures' => false
29
+        ],
30
+        $options
31
+    );
32 32
 
33
-	include_spip('inc/rechercher');
34
-	include_spip('inc/autoriser');
33
+    include_spip('inc/rechercher');
34
+    include_spip('inc/autoriser');
35 35
 
36
-	$requete = [
37
-		'SELECT' => [],
38
-		'FROM' => [],
39
-		'WHERE' => [],
40
-		'GROUPBY' => [],
41
-		'ORDERBY' => [],
42
-		'LIMIT' => '',
43
-		'HAVING' => []
44
-	];
36
+    $requete = [
37
+        'SELECT' => [],
38
+        'FROM' => [],
39
+        'WHERE' => [],
40
+        'GROUPBY' => [],
41
+        'ORDERBY' => [],
42
+        'LIMIT' => '',
43
+        'HAVING' => []
44
+    ];
45 45
 
46
-	$table = sinon($options['table'], 'article');
47
-	if ($options['champs']) {
48
-		$champs = $options['champs'];
49
-	} else {
50
-		$l = liste_des_champs();
51
-		$champs = $l['article'];
52
-	}
53
-	$serveur = $options['serveur'];
46
+    $table = sinon($options['table'], 'article');
47
+    if ($options['champs']) {
48
+        $champs = $options['champs'];
49
+    } else {
50
+        $l = liste_des_champs();
51
+        $champs = $l['article'];
52
+    }
53
+    $serveur = $options['serveur'];
54 54
 
55
-	[$methode, $q, $preg] = expression_recherche($recherche, $options);
55
+    [$methode, $q, $preg] = expression_recherche($recherche, $options);
56 56
 
57
-	$jointures = $options['jointures']
58
-		? liste_des_jointures()
59
-		: [];
57
+    $jointures = $options['jointures']
58
+        ? liste_des_jointures()
59
+        : [];
60 60
 
61
-	$_id_table = id_table_objet($table);
61
+    $_id_table = id_table_objet($table);
62 62
 
63
-	// c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
64
-	// (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
65
-	if (strpos($_id_table, ',') !== false) {
66
-		$_id_table = explode(',', $_id_table);
67
-		$_id_table = reset($_id_table);
68
-	}
63
+    // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
64
+    // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
65
+    if (strpos($_id_table, ',') !== false) {
66
+        $_id_table = explode(',', $_id_table);
67
+        $_id_table = reset($_id_table);
68
+    }
69 69
 
70
-	$requete['SELECT'][] = 't.' . $_id_table;
71
-	$a = [];
72
-	// Recherche fulltext
73
-	foreach ($champs as $champ => $poids) {
74
-		if (is_array($champ)) {
75
-			spip_log('requetes imbriquees interdites');
76
-		} else {
77
-			if (strpos($champ, '.') === false) {
78
-				$champ = "t.$champ";
79
-			}
80
-			$requete['SELECT'][] = $champ;
81
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
82
-		}
83
-	}
84
-	if ($a) {
85
-		$requete['WHERE'][] = join(' OR ', $a);
86
-	}
87
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
70
+    $requete['SELECT'][] = 't.' . $_id_table;
71
+    $a = [];
72
+    // Recherche fulltext
73
+    foreach ($champs as $champ => $poids) {
74
+        if (is_array($champ)) {
75
+            spip_log('requetes imbriquees interdites');
76
+        } else {
77
+            if (strpos($champ, '.') === false) {
78
+                $champ = "t.$champ";
79
+            }
80
+            $requete['SELECT'][] = $champ;
81
+            $a[] = $champ . ' ' . $methode . ' ' . $q;
82
+        }
83
+    }
84
+    if ($a) {
85
+        $requete['WHERE'][] = join(' OR ', $a);
86
+    }
87
+    $requete['FROM'][] = table_objet_sql($table) . ' AS t';
88 88
 
89
-	$results = [];
89
+    $results = [];
90 90
 
91
-	$s = sql_select(
92
-		$requete['SELECT'],
93
-		$requete['FROM'],
94
-		$requete['WHERE'],
95
-		implode(' ', $requete['GROUPBY']),
96
-		$requete['ORDERBY'],
97
-		$requete['LIMIT'],
98
-		$requete['HAVING'],
99
-		$serveur
100
-	);
91
+    $s = sql_select(
92
+        $requete['SELECT'],
93
+        $requete['FROM'],
94
+        $requete['WHERE'],
95
+        implode(' ', $requete['GROUPBY']),
96
+        $requete['ORDERBY'],
97
+        $requete['LIMIT'],
98
+        $requete['HAVING'],
99
+        $serveur
100
+    );
101 101
 
102
-	while (
103
-		$t = sql_fetch($s, $serveur)
104
-		and (!isset($t['score']) or $t['score'] > 0)
105
-	) {
106
-		$id = intval($t[$_id_table]);
102
+    while (
103
+        $t = sql_fetch($s, $serveur)
104
+        and (!isset($t['score']) or $t['score'] > 0)
105
+    ) {
106
+        $id = intval($t[$_id_table]);
107 107
 
108
-		if (
109
-			$options['toutvoir']
110
-			or autoriser('voir', $table, $id)
111
-		) {
112
-			// indiquer les champs concernes
113
-			$champs_vus = [];
114
-			$score = 0;
115
-			$matches = [];
108
+        if (
109
+            $options['toutvoir']
110
+            or autoriser('voir', $table, $id)
111
+        ) {
112
+            // indiquer les champs concernes
113
+            $champs_vus = [];
114
+            $score = 0;
115
+            $matches = [];
116 116
 
117
-			$vu = false;
118
-			foreach ($champs as $champ => $poids) {
119
-				$champ = explode('.', $champ);
120
-				$champ = end($champ);
121
-				// translitteration_rapide uniquement si on est deja en utf-8
122
-				$value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
123
-				if (
124
-					$n =
125
-					($options['score'] || $options['matches'])
126
-						? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
127
-						: preg_match($preg, $value)
128
-				) {
129
-					$vu = true;
117
+            $vu = false;
118
+            foreach ($champs as $champ => $poids) {
119
+                $champ = explode('.', $champ);
120
+                $champ = end($champ);
121
+                // translitteration_rapide uniquement si on est deja en utf-8
122
+                $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
123
+                if (
124
+                    $n =
125
+                    ($options['score'] || $options['matches'])
126
+                        ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
127
+                        : preg_match($preg, $value)
128
+                ) {
129
+                    $vu = true;
130 130
 
131
-					if ($options['champs']) {
132
-						$champs_vus[$champ] = $t[$champ];
133
-					}
134
-					if ($options['score']) {
135
-						// compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
136
-						$score += $poids * strlen(implode('', array_column($regs, 0)));
137
-					}
131
+                    if ($options['champs']) {
132
+                        $champs_vus[$champ] = $t[$champ];
133
+                    }
134
+                    if ($options['score']) {
135
+                        // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
136
+                        $score += $poids * strlen(implode('', array_column($regs, 0)));
137
+                    }
138 138
 
139
-					if ($options['matches']) {
140
-						$matches[$champ] = $regs;
141
-					}
139
+                    if ($options['matches']) {
140
+                        $matches[$champ] = $regs;
141
+                    }
142 142
 
143
-					if (
144
-						!$options['champs']
145
-						and !$options['score']
146
-						and !$options['matches']
147
-					) {
148
-						break;
149
-					}
150
-				}
151
-			}
143
+                    if (
144
+                        !$options['champs']
145
+                        and !$options['score']
146
+                        and !$options['matches']
147
+                    ) {
148
+                        break;
149
+                    }
150
+                }
151
+            }
152 152
 
153
-			if ($vu) {
154
-				if (!isset($results)) {
155
-					$results = [];
156
-				}
157
-				$results[$id] = [];
158
-				if ($champs_vus) {
159
-					$results[$id]['champs'] = $champs_vus;
160
-				}
161
-				if ($score) {
162
-					$results[$id]['score'] = $score;
163
-				}
164
-				if ($matches) {
165
-					$results[$id]['matches'] = $matches;
166
-				}
167
-			}
168
-		}
169
-	}
153
+            if ($vu) {
154
+                if (!isset($results)) {
155
+                    $results = [];
156
+                }
157
+                $results[$id] = [];
158
+                if ($champs_vus) {
159
+                    $results[$id]['champs'] = $champs_vus;
160
+                }
161
+                if ($score) {
162
+                    $results[$id]['score'] = $score;
163
+                }
164
+                if ($matches) {
165
+                    $results[$id]['matches'] = $matches;
166
+                }
167
+            }
168
+        }
169
+    }
170 170
 
171 171
 
172
-	// Gerer les donnees associees
173
-	// ici on est un peu naze : pas capables de reconstruire une jointure complexe
174
-	// on ne sait passer que par table de laison en 1 coup
175
-	if (
176
-		isset($jointures[$table])
177
-		and $joints = recherche_en_base(
178
-			$recherche,
179
-			$jointures[$table],
180
-			array_merge($options, ['jointures' => false])
181
-		)
182
-	) {
183
-		include_spip('action/editer_liens');
184
-		$trouver_table = charger_fonction('trouver_table', 'base');
185
-		$cle_depart = id_table_objet($table);
186
-		$table_depart = table_objet($table, $serveur);
187
-		$desc_depart = $trouver_table($table_depart, $serveur);
188
-		$depart_associable = objet_associable($table);
189
-		foreach ($joints as $table_liee => $ids_trouves) {
190
-			// on peut definir une fonction de recherche jointe pour regler les cas particuliers
191
-			if (
192
-				!(
193
-				$rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true)
194
-				or $rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true)
195
-				or $rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true)
196
-				)
197
-			) {
198
-				$cle_arrivee = id_table_objet($table_liee);
199
-				$table_arrivee = table_objet($table_liee, $serveur);
200
-				$desc_arrivee = $trouver_table($table_arrivee, $serveur);
201
-				// cas simple : $cle_depart dans la table_liee
202
-				if (isset($desc_arrivee['field'][$cle_depart])) {
203
-					$s = sql_select(
204
-						"$cle_depart, $cle_arrivee",
205
-						$desc_arrivee['table_sql'],
206
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
207
-						'',
208
-						'',
209
-						'',
210
-						'',
211
-						$serveur
212
-					);
213
-				} // cas simple : $cle_arrivee dans la table
214
-				elseif (isset($desc_depart['field'][$cle_arrivee])) {
215
-					$s = sql_select(
216
-						"$cle_depart, $cle_arrivee",
217
-						$desc_depart['table_sql'],
218
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
219
-						'',
220
-						'',
221
-						'',
222
-						'',
223
-						$serveur
224
-					);
225
-				}
226
-				// sinon cherchons une table de liaison
227
-				// cas recherche principale article, objet lie document : passer par spip_documents_liens
228
-				elseif ($l = objet_associable($table_liee)) {
229
-					[$primary, $table_liens] = $l;
230
-					$s = sql_select(
231
-						"id_objet as $cle_depart, $primary as $cle_arrivee",
232
-						$table_liens,
233
-						["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
234
-						'',
235
-						'',
236
-						'',
237
-						'',
238
-						$serveur
239
-					);
240
-				} // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
241
-				elseif ($l = $depart_associable) {
242
-					[$primary, $table_liens] = $l;
243
-					$s = sql_select(
244
-						"$primary as $cle_depart, id_objet as $cle_arrivee",
245
-						$table_liens,
246
-						["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
247
-						'',
248
-						'',
249
-						'',
250
-						'',
251
-						$serveur
252
-					);
253
-				} // cas table de liaison generique spip_xxx_yyy
254
-				elseif (
255
-					$t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
-					or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
257
-				) {
258
-					$s = sql_select(
259
-						"$cle_depart,$cle_arrivee",
260
-						$t['table_sql'],
261
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
262
-						'',
263
-						'',
264
-						'',
265
-						'',
266
-						$serveur
267
-					);
268
-				}
269
-			} else {
270
-				[$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
271
-					$table,
272
-					$table_liee,
273
-					array_keys($ids_trouves),
274
-					$serveur
275
-				);
276
-			}
172
+    // Gerer les donnees associees
173
+    // ici on est un peu naze : pas capables de reconstruire une jointure complexe
174
+    // on ne sait passer que par table de laison en 1 coup
175
+    if (
176
+        isset($jointures[$table])
177
+        and $joints = recherche_en_base(
178
+            $recherche,
179
+            $jointures[$table],
180
+            array_merge($options, ['jointures' => false])
181
+        )
182
+    ) {
183
+        include_spip('action/editer_liens');
184
+        $trouver_table = charger_fonction('trouver_table', 'base');
185
+        $cle_depart = id_table_objet($table);
186
+        $table_depart = table_objet($table, $serveur);
187
+        $desc_depart = $trouver_table($table_depart, $serveur);
188
+        $depart_associable = objet_associable($table);
189
+        foreach ($joints as $table_liee => $ids_trouves) {
190
+            // on peut definir une fonction de recherche jointe pour regler les cas particuliers
191
+            if (
192
+                !(
193
+                $rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true)
194
+                or $rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true)
195
+                or $rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true)
196
+                )
197
+            ) {
198
+                $cle_arrivee = id_table_objet($table_liee);
199
+                $table_arrivee = table_objet($table_liee, $serveur);
200
+                $desc_arrivee = $trouver_table($table_arrivee, $serveur);
201
+                // cas simple : $cle_depart dans la table_liee
202
+                if (isset($desc_arrivee['field'][$cle_depart])) {
203
+                    $s = sql_select(
204
+                        "$cle_depart, $cle_arrivee",
205
+                        $desc_arrivee['table_sql'],
206
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
207
+                        '',
208
+                        '',
209
+                        '',
210
+                        '',
211
+                        $serveur
212
+                    );
213
+                } // cas simple : $cle_arrivee dans la table
214
+                elseif (isset($desc_depart['field'][$cle_arrivee])) {
215
+                    $s = sql_select(
216
+                        "$cle_depart, $cle_arrivee",
217
+                        $desc_depart['table_sql'],
218
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
219
+                        '',
220
+                        '',
221
+                        '',
222
+                        '',
223
+                        $serveur
224
+                    );
225
+                }
226
+                // sinon cherchons une table de liaison
227
+                // cas recherche principale article, objet lie document : passer par spip_documents_liens
228
+                elseif ($l = objet_associable($table_liee)) {
229
+                    [$primary, $table_liens] = $l;
230
+                    $s = sql_select(
231
+                        "id_objet as $cle_depart, $primary as $cle_arrivee",
232
+                        $table_liens,
233
+                        ["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
234
+                        '',
235
+                        '',
236
+                        '',
237
+                        '',
238
+                        $serveur
239
+                    );
240
+                } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
241
+                elseif ($l = $depart_associable) {
242
+                    [$primary, $table_liens] = $l;
243
+                    $s = sql_select(
244
+                        "$primary as $cle_depart, id_objet as $cle_arrivee",
245
+                        $table_liens,
246
+                        ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
247
+                        '',
248
+                        '',
249
+                        '',
250
+                        '',
251
+                        $serveur
252
+                    );
253
+                } // cas table de liaison generique spip_xxx_yyy
254
+                elseif (
255
+                    $t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
+                    or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
257
+                ) {
258
+                    $s = sql_select(
259
+                        "$cle_depart,$cle_arrivee",
260
+                        $t['table_sql'],
261
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
262
+                        '',
263
+                        '',
264
+                        '',
265
+                        '',
266
+                        $serveur
267
+                    );
268
+                }
269
+            } else {
270
+                [$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
271
+                    $table,
272
+                    $table_liee,
273
+                    array_keys($ids_trouves),
274
+                    $serveur
275
+                );
276
+            }
277 277
 
278
-			while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
279
-				$id = $t[$cle_depart];
280
-				$joint = $ids_trouves[$t[$cle_arrivee]];
281
-				if (!isset($results)) {
282
-					$results = [];
283
-				}
284
-				if (!isset($results[$id])) {
285
-					$results[$id] = [];
286
-				}
287
-				if (isset($joint['score']) and $joint['score']) {
288
-					if (!isset($results[$id]['score'])) {
289
-						$results[$id]['score'] = 0;
290
-					}
291
-					$results[$id]['score'] += $joint['score'];
292
-				}
293
-				if (isset($joint['champs']) and $joint['champs']) {
294
-					foreach ($joint['champs'] as $c => $val) {
295
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
296
-					}
297
-				}
298
-				if (isset($joint['matches']) and $joint['matches']) {
299
-					foreach ($joint['matches'] as $c => $val) {
300
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
301
-					}
302
-				}
303
-			}
304
-		}
305
-	}
278
+            while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
279
+                $id = $t[$cle_depart];
280
+                $joint = $ids_trouves[$t[$cle_arrivee]];
281
+                if (!isset($results)) {
282
+                    $results = [];
283
+                }
284
+                if (!isset($results[$id])) {
285
+                    $results[$id] = [];
286
+                }
287
+                if (isset($joint['score']) and $joint['score']) {
288
+                    if (!isset($results[$id]['score'])) {
289
+                        $results[$id]['score'] = 0;
290
+                    }
291
+                    $results[$id]['score'] += $joint['score'];
292
+                }
293
+                if (isset($joint['champs']) and $joint['champs']) {
294
+                    foreach ($joint['champs'] as $c => $val) {
295
+                        $results[$id]['champs'][$table_liee . '.' . $c] = $val;
296
+                    }
297
+                }
298
+                if (isset($joint['matches']) and $joint['matches']) {
299
+                    foreach ($joint['matches'] as $c => $val) {
300
+                        $results[$id]['matches'][$table_liee . '.' . $c] = $val;
301
+                    }
302
+                }
303
+            }
304
+        }
305
+    }
306 306
 
307
-	return $results;
307
+    return $results;
308 308
 }
Please login to merge, or discard this patch.
ecrire/inc/icone_renommer.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -11,71 +11,71 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/boutons');
18 18
 include_spip('base/objets');
19 19
 
20 20
 function inc_icone_renommer_dist($fond, $fonction) {
21
-	$size = 24;
22
-	if (
23
-		preg_match('/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
24
-		and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1]))
25
-	) {
26
-		if (isset($match[1]) and $match[1]) {
27
-			$size = $match[1];
28
-		}
29
-		$type = substr($fond, 0, -strlen($match[0]));
30
-		if (!isset($match[2]) or !$match[2]) {
31
-			$fond .= '.png';
32
-		}
33
-	} else {
34
-		$type = $fond;
35
-		$fond .= '.png';
36
-	}
21
+    $size = 24;
22
+    if (
23
+        preg_match('/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
24
+        and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1]))
25
+    ) {
26
+        if (isset($match[1]) and $match[1]) {
27
+            $size = $match[1];
28
+        }
29
+        $type = substr($fond, 0, -strlen($match[0]));
30
+        if (!isset($match[2]) or !$match[2]) {
31
+            $fond .= '.png';
32
+        }
33
+    } else {
34
+        $type = $fond;
35
+        $fond .= '.png';
36
+    }
37 37
 
38
-	$rtl = false;
39
-	if (preg_match(',[-_]rtl$,i', $type, $match)) {
40
-		$rtl = true;
41
-		$type = substr($type, 0, -strlen($match[0]));
42
-	}
38
+    $rtl = false;
39
+    if (preg_match(',[-_]rtl$,i', $type, $match)) {
40
+        $rtl = true;
41
+        $type = substr($type, 0, -strlen($match[0]));
42
+    }
43 43
 
44
-	// objet_type garde invariant tout ce qui ne commence par par id_, spip_
45
-	// et ne finit pas par un s, sauf si c'est une exception declaree
46
-	$type = objet_type($type, false);
44
+    // objet_type garde invariant tout ce qui ne commence par par id_, spip_
45
+    // et ne finit pas par un s, sauf si c'est une exception declaree
46
+    $type = objet_type($type, false);
47 47
 
48
-	$dir = 'images/';
49
-	$f = "$type-$size.png";
50
-	if ($icone = find_in_theme($dir . $f)) {
51
-		$dir = dirname($icone);
52
-		$fond = $icone;
48
+    $dir = 'images/';
49
+    $f = "$type-$size.png";
50
+    if ($icone = find_in_theme($dir . $f)) {
51
+        $dir = dirname($icone);
52
+        $fond = $icone;
53 53
 
54
-		if (
55
-			$rtl
56
-			and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
57
-			and file_exists($fr)
58
-		) {
59
-			$fond = $fr;
60
-		}
54
+        if (
55
+            $rtl
56
+            and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
57
+            and file_exists($fr)
58
+        ) {
59
+            $fond = $fr;
60
+        }
61 61
 
62
-		$action = $fonction;
63
-		if ($action == 'supprimer.gif') {
64
-			$action = 'del';
65
-		} elseif ($action == 'creer.gif') {
66
-			$action = 'new';
67
-		} elseif ($action == 'edit.gif') {
68
-			$action = 'edit';
69
-		}
62
+        $action = $fonction;
63
+        if ($action == 'supprimer.gif') {
64
+            $action = 'del';
65
+        } elseif ($action == 'creer.gif') {
66
+            $action = 'new';
67
+        } elseif ($action == 'edit.gif') {
68
+            $action = 'edit';
69
+        }
70 70
 
71
-		$fonction = '';
72
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
73
-			$fonction = $action;
74
-		}
71
+        $fonction = '';
72
+        if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
73
+            $fonction = $action;
74
+        }
75 75
 
76
-		// c'est bon !
77
-		return [$fond, $fonction];
78
-	}
76
+        // c'est bon !
77
+        return [$fond, $fonction];
78
+    }
79 79
 
80
-	return [$fond, $fonction];
80
+    return [$fond, $fonction];
81 81
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 
48 48
 	$dir = 'images/';
49 49
 	$f = "$type-$size.png";
50
-	if ($icone = find_in_theme($dir . $f)) {
50
+	if ($icone = find_in_theme($dir.$f)) {
51 51
 		$dir = dirname($icone);
52 52
 		$fond = $icone;
53 53
 
54 54
 		if (
55 55
 			$rtl
56
-			and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
56
+			and $fr = $dir.'/'.str_replace("$type-", "$type-rtl-", basename($icone))
57 57
 			and file_exists($fr)
58 58
 		) {
59 59
 			$fond = $fr;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		}
70 70
 
71 71
 		$fonction = '';
72
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
+		if (in_array($action, ['add', 'del', 'new', 'edit', 'config'])) {
73 73
 			$fonction = $action;
74 74
 		}
75 75
 
Please login to merge, or discard this patch.