Completed
Push — master ( 8bdd42...ce9a8f )
by cam
05:11
created
prive/themes/spip/vars.css_fonctions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
  * Génère les variables CSS d'une couleur pour l'espace privé
29 29
  *
30 30
  * @param string $couleur Couleur hex
31
- * @return string
31
+ * @return Spip_Css_Vars_Collection
32 32
  */
33 33
 function spip_couleur_theme_generer_variables_css($couleur) : \Spip_Css_Vars_Collection {
34 34
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -45,19 +45,19 @@
 block discarded – undo
45 45
     $vars->add("--spip-color-theme--b", couleur_hex_to_rgb($couleur, "b")); // utile ?
46 46
 
47 47
     // un joli dégradé de presque blanc à presque noir…
48
-    $vars->add("--spip-color-theme--100", '#' . couleur_eclaircir($couleur, .99));
49
-    $vars->add("--spip-color-theme--98", '#' . couleur_eclaircir($couleur, .95));
50
-    $vars->add("--spip-color-theme--95", '#' . couleur_eclaircir($couleur, .90));
51
-    $vars->add("--spip-color-theme--90", '#' . couleur_eclaircir($couleur, .75));
52
-    $vars->add("--spip-color-theme--80", '#' . couleur_eclaircir($couleur, .50));
53
-    $vars->add("--spip-color-theme--70", '#' . couleur_eclaircir($couleur, .25));
48
+    $vars->add("--spip-color-theme--100", '#'.couleur_eclaircir($couleur, .99));
49
+    $vars->add("--spip-color-theme--98", '#'.couleur_eclaircir($couleur, .95));
50
+    $vars->add("--spip-color-theme--95", '#'.couleur_eclaircir($couleur, .90));
51
+    $vars->add("--spip-color-theme--90", '#'.couleur_eclaircir($couleur, .75));
52
+    $vars->add("--spip-color-theme--80", '#'.couleur_eclaircir($couleur, .50));
53
+    $vars->add("--spip-color-theme--70", '#'.couleur_eclaircir($couleur, .25));
54 54
     $vars->add("--spip-color-theme--60", $couleur);
55
-    $vars->add("--spip-color-theme--50", '#' . couleur_foncer($couleur, .125));
56
-    $vars->add("--spip-color-theme--40", '#' . couleur_foncer($couleur, .25));
57
-    $vars->add("--spip-color-theme--30", '#' . couleur_foncer($couleur, .375));
58
-    $vars->add("--spip-color-theme--20", '#' . couleur_foncer($couleur, .50));
59
-    $vars->add("--spip-color-theme--10", '#' . couleur_foncer($couleur, .75));
60
-    $vars->add("--spip-color-theme--00", '#' . couleur_foncer($couleur, .98));
55
+    $vars->add("--spip-color-theme--50", '#'.couleur_foncer($couleur, .125));
56
+    $vars->add("--spip-color-theme--40", '#'.couleur_foncer($couleur, .25));
57
+    $vars->add("--spip-color-theme--30", '#'.couleur_foncer($couleur, .375));
58
+    $vars->add("--spip-color-theme--20", '#'.couleur_foncer($couleur, .50));
59
+    $vars->add("--spip-color-theme--10", '#'.couleur_foncer($couleur, .75));
60
+    $vars->add("--spip-color-theme--00", '#'.couleur_foncer($couleur, .98));
61 61
 
62 62
     // nos déclinaisons (basées sur le dégradé précedent, où 60 est là couleur du thème)
63 63
     $vars->add("--spip-color-theme-white", "var(--spip-color-theme--100)");
Please login to merge, or discard this patch.
prive/formulaires/configurer_preferences.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  **/
22 22
 
23 23
 if (!defined('_ECRIRE_INC_VERSION')) {
24
-	return;
24
+    return;
25 25
 }
26 26
 
27 27
 /**
@@ -31,28 +31,28 @@  discard block
 block discarded – undo
31 31
  *     Environnement du formulaire
32 32
  **/
33 33
 function formulaires_configurer_preferences_charger_dist() {
34
-	// travailler sur des meta fraiches
35
-	include_spip('inc/meta');
36
-	lire_metas();
34
+    // travailler sur des meta fraiches
35
+    include_spip('inc/meta');
36
+    lire_metas();
37 37
 
38
-	$valeurs = array();
39
-	$valeurs['display_navigation'] = isset($GLOBALS['visiteur_session']['prefs']['display_navigation']) ? $GLOBALS['visiteur_session']['prefs']['display_navigation'] : 'navigation_avec_icones';
40
-	$valeurs['display_outils'] = isset($GLOBALS['visiteur_session']['prefs']['display_outils']) ? $GLOBALS['visiteur_session']['prefs']['display_outils'] : 'oui';
41
-	$valeurs['display'] = (isset($GLOBALS['visiteur_session']['prefs']['display']) and $GLOBALS['visiteur_session']['prefs']['display'] > 0) ? $GLOBALS['visiteur_session']['prefs']['display'] : 2;
42
-	$valeurs['couleur'] = (isset($GLOBALS['visiteur_session']['prefs']['couleur']) and $GLOBALS['visiteur_session']['prefs']['couleur'] > 0) ? $GLOBALS['visiteur_session']['prefs']['couleur'] : 1;
38
+    $valeurs = array();
39
+    $valeurs['display_navigation'] = isset($GLOBALS['visiteur_session']['prefs']['display_navigation']) ? $GLOBALS['visiteur_session']['prefs']['display_navigation'] : 'navigation_avec_icones';
40
+    $valeurs['display_outils'] = isset($GLOBALS['visiteur_session']['prefs']['display_outils']) ? $GLOBALS['visiteur_session']['prefs']['display_outils'] : 'oui';
41
+    $valeurs['display'] = (isset($GLOBALS['visiteur_session']['prefs']['display']) and $GLOBALS['visiteur_session']['prefs']['display'] > 0) ? $GLOBALS['visiteur_session']['prefs']['display'] : 2;
42
+    $valeurs['couleur'] = (isset($GLOBALS['visiteur_session']['prefs']['couleur']) and $GLOBALS['visiteur_session']['prefs']['couleur'] > 0) ? $GLOBALS['visiteur_session']['prefs']['couleur'] : 1;
43 43
 
44
-	$couleurs = charger_fonction('couleurs', 'inc');
45
-	$les_couleurs = $couleurs();
46
-	foreach ($les_couleurs as $k => $c) {
47
-		$valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr='
48
-			. $GLOBALS['spip_lang_left'] . '&'
49
-			. $couleurs($k));
50
-		$valeurs['couleurs'][$k] = $c;
51
-	}
44
+    $couleurs = charger_fonction('couleurs', 'inc');
45
+    $les_couleurs = $couleurs();
46
+    foreach ($les_couleurs as $k => $c) {
47
+        $valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr='
48
+            . $GLOBALS['spip_lang_left'] . '&'
49
+            . $couleurs($k));
50
+        $valeurs['couleurs'][$k] = $c;
51
+    }
52 52
 
53
-	$valeurs['imessage'] = $GLOBALS['visiteur_session']['imessage'];
53
+    $valeurs['imessage'] = $GLOBALS['visiteur_session']['imessage'];
54 54
 
55
-	return $valeurs;
55
+    return $valeurs;
56 56
 }
57 57
 
58 58
 /**
@@ -63,34 +63,34 @@  discard block
 block discarded – undo
63 63
  **/
64 64
 function formulaires_configurer_preferences_traiter_dist() {
65 65
 
66
-	if ($couleur = _request('couleur')) {
67
-		$couleurs = charger_fonction('couleurs', 'inc');
68
-		$les_couleurs = $couleurs(array(), true);
69
-		if (isset($les_couleurs[$couleur])) {
70
-			$GLOBALS['visiteur_session']['prefs']['couleur'] = $couleur;
71
-		}
72
-	}
73
-	if ($display = intval(_request('display'))) {
74
-		$GLOBALS['visiteur_session']['prefs']['display'] = $display;
75
-	}
76
-	if ($display_navigation = _request('display_navigation')
77
-		and in_array($display_navigation, ['navigation_sans_icone', 'navigation_avec_icones'])) {
78
-		$GLOBALS['visiteur_session']['prefs']['display_navigation'] = $display_navigation;
79
-	}
80
-	if (!is_null($display_outils = _request('display_outils'))) {
81
-		$GLOBALS['visiteur_session']['prefs']['display_outils'] = ($display_outils ? 'oui' : '');
82
-	}
66
+    if ($couleur = _request('couleur')) {
67
+        $couleurs = charger_fonction('couleurs', 'inc');
68
+        $les_couleurs = $couleurs(array(), true);
69
+        if (isset($les_couleurs[$couleur])) {
70
+            $GLOBALS['visiteur_session']['prefs']['couleur'] = $couleur;
71
+        }
72
+    }
73
+    if ($display = intval(_request('display'))) {
74
+        $GLOBALS['visiteur_session']['prefs']['display'] = $display;
75
+    }
76
+    if ($display_navigation = _request('display_navigation')
77
+        and in_array($display_navigation, ['navigation_sans_icone', 'navigation_avec_icones'])) {
78
+        $GLOBALS['visiteur_session']['prefs']['display_navigation'] = $display_navigation;
79
+    }
80
+    if (!is_null($display_outils = _request('display_outils'))) {
81
+        $GLOBALS['visiteur_session']['prefs']['display_outils'] = ($display_outils ? 'oui' : '');
82
+    }
83 83
 
84
-	if (intval($GLOBALS['visiteur_session']['id_auteur'])) {
85
-		include_spip('action/editer_auteur');
86
-		$c = array('prefs' => serialize($GLOBALS['visiteur_session']['prefs']));
84
+    if (intval($GLOBALS['visiteur_session']['id_auteur'])) {
85
+        include_spip('action/editer_auteur');
86
+        $c = array('prefs' => serialize($GLOBALS['visiteur_session']['prefs']));
87 87
 
88
-		if ($imessage = _request('imessage') and in_array($imessage, ['oui', 'non'])) {
89
-			$c['imessage'] = $imessage;
90
-		}
88
+        if ($imessage = _request('imessage') and in_array($imessage, ['oui', 'non'])) {
89
+            $c['imessage'] = $imessage;
90
+        }
91 91
 
92
-		auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c);
93
-	}
92
+        auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c);
93
+    }
94 94
 
95
-	return array('message_ok' => _T('config_info_enregistree'), 'editable' => true);
95
+    return array('message_ok' => _T('config_info_enregistree'), 'editable' => true);
96 96
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
 	$les_couleurs = $couleurs();
46 46
 	foreach ($les_couleurs as $k => $c) {
47 47
 		$valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr='
48
-			. $GLOBALS['spip_lang_left'] . '&'
48
+			. $GLOBALS['spip_lang_left'].'&'
49 49
 			. $couleurs($k));
50 50
 		$valeurs['couleurs'][$k] = $c;
51 51
 	}
Please login to merge, or discard this patch.
ecrire/inc/filtres_images_lib_mini.php 2 patches
Indentation   +1306 added lines, -1306 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 include_spip('inc/filtres'); // par precaution
25 25
 include_spip('inc/filtres_images_mini'); // par precaution
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
  *     Le code de la couleur en hexadécimal.
40 40
  */
41 41
 function _couleur_dec_to_hex($red, $green, $blue) {
42
-	$red = dechex($red);
43
-	$green = dechex($green);
44
-	$blue = dechex($blue);
45
-
46
-	if (strlen($red) == 1) {
47
-		$red = "0" . $red;
48
-	}
49
-	if (strlen($green) == 1) {
50
-		$green = "0" . $green;
51
-	}
52
-	if (strlen($blue) == 1) {
53
-		$blue = "0" . $blue;
54
-	}
55
-
56
-	return "$red$green$blue";
42
+    $red = dechex($red);
43
+    $green = dechex($green);
44
+    $blue = dechex($blue);
45
+
46
+    if (strlen($red) == 1) {
47
+        $red = "0" . $red;
48
+    }
49
+    if (strlen($green) == 1) {
50
+        $green = "0" . $green;
51
+    }
52
+    if (strlen($blue) == 1) {
53
+        $blue = "0" . $blue;
54
+    }
55
+
56
+    return "$red$green$blue";
57 57
 }
58 58
 
59 59
 /**
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
  *     Un tableau des 3 éléments : rouge, vert, bleu.
66 66
  */
67 67
 function _couleur_hex_to_dec($couleur) {
68
-	$couleur = couleur_html_to_hex($couleur);
69
-	$couleur = ltrim($couleur, '#');
70
-	if (strlen($couleur) === 3) {
71
-		$couleur = $couleur[0] . $couleur[0] . $couleur[1] . $couleur[1] . $couleur[2] . $couleur[2];
72
-	}
73
-	$retour = [];
74
-	$retour["red"] = hexdec(substr($couleur, 0, 2));
75
-	$retour["green"] = hexdec(substr($couleur, 2, 2));
76
-	$retour["blue"] = hexdec(substr($couleur, 4, 2));
77
-
78
-	return $retour;
68
+    $couleur = couleur_html_to_hex($couleur);
69
+    $couleur = ltrim($couleur, '#');
70
+    if (strlen($couleur) === 3) {
71
+        $couleur = $couleur[0] . $couleur[0] . $couleur[1] . $couleur[1] . $couleur[2] . $couleur[2];
72
+    }
73
+    $retour = [];
74
+    $retour["red"] = hexdec(substr($couleur, 0, 2));
75
+    $retour["green"] = hexdec(substr($couleur, 2, 2));
76
+    $retour["blue"] = hexdec(substr($couleur, 4, 2));
77
+
78
+    return $retour;
79 79
 }
80 80
 
81 81
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
  *     Le code de la couleur en hexadécimal.
93 93
  */
94 94
 function _couleur_hsl_to_hex($hue, $saturation, $lightness) {
95
-	$rgb = _couleur_hsl_to_rgb($hue, $saturation, $lightness);
96
-	return _couleur_dec_to_hex($rgb['r'], $rgb['g'], $rgb['b']);
95
+    $rgb = _couleur_hsl_to_rgb($hue, $saturation, $lightness);
96
+    return _couleur_dec_to_hex($rgb['r'], $rgb['g'], $rgb['b']);
97 97
 }
98 98
 
99 99
 /**
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
  *     Un tableau des 3 éléments : teinte, saturation, luminosité.
106 106
  */
107 107
 function _couleur_hex_to_hsl($couleur) {
108
-	$rgb = _couleur_hex_to_dec($couleur);
109
-	return _couleur_rgb_to_hsl($rgb['red'], $rgb['green'], $rgb['blue']);
108
+    $rgb = _couleur_hex_to_dec($couleur);
109
+    return _couleur_rgb_to_hsl($rgb['red'], $rgb['green'], $rgb['blue']);
110 110
 }
111 111
 
112 112
 /**
@@ -121,58 +121,58 @@  discard block
 block discarded – undo
121 121
  * @return array
122 122
  */
123 123
 function _couleur_rgb_to_hsl($R, $G, $B) {
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;
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
-		}
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 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;
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
 /**
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
  *     true si il faut supprimer le fichier temporaire ; false sinon.
251 251
  */
252 252
 function statut_effacer_images_temporaires($stat) {
253
-	static $statut = false; // par defaut on grave toute les images
254
-	if ($stat === 'get') {
255
-		return $statut;
256
-	}
257
-	$statut = $stat ? true : false;
253
+    static $statut = false; // par defaut on grave toute les images
254
+    if ($stat === 'get') {
255
+        return $statut;
256
+    }
257
+    $statut = $stat ? true : false;
258 258
 }
259 259
 
260 260
 
@@ -307,224 +307,224 @@  discard block
 block discarded – undo
307 307
  *     - array : tableau décrivant de l'image
308 308
  */
309 309
 function _image_valeurs_trans($img, $effet, $forcer_format = false, $fonction_creation = null, $find_in_path = false, $support_svg = false) {
310
-	static $images_recalcul = array();
311
-	if (strlen($img) == 0) {
312
-		return false;
313
-	}
314
-
315
-	$source = trim(extraire_attribut($img, 'src'));
316
-	if (strlen($source) < 1) {
317
-		$source = $img;
318
-		$img = "<img src='$source' />";
319
-	} # gerer img src="data:....base64"
320
-	elseif (preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
321
-	  and $extension = _image_trouver_extension_depuis_mime("image/".$regs[1])
322
-		and in_array($extension, _image_extensions_acceptees_en_entree())
323
-	) {
324
-		$local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
325
-		if (!file_exists($local)) {
326
-			ecrire_fichier($local, base64_decode($regs[2]));
327
-		}
328
-		$source = $local;
329
-		$img = inserer_attribut($img, 'src', $source);
330
-		# eviter les mauvaises surprises lors de conversions de format
331
-		$img = inserer_attribut($img, 'width', '');
332
-		$img = inserer_attribut($img, 'height', '');
333
-	}
334
-
335
-	// les protocoles web prennent au moins 3 lettres
336
-	if (tester_url_absolue($source)) {
337
-		include_spip('inc/distant');
338
-		$fichier = _DIR_RACINE . copie_locale($source);
339
-		if (!$fichier) {
340
-			return "";
341
-		}
342
-	} else {
343
-		// enlever le timestamp eventuel
344
-		if (strpos($source, "?") !== false) {
345
-			$source = preg_replace(',[?][0-9]+$,', '', $source);
346
-		}
347
-		if (strpos($source, "?") !== false
348
-			and strncmp($source, _DIR_IMG, strlen(_DIR_IMG)) == 0
349
-			and file_exists($f = preg_replace(',[?].*$,', '', $source))
350
-		) {
351
-			$source = $f;
352
-		}
353
-		$fichier = $source;
354
-	}
355
-
356
-	$terminaison_dest = "";
357
-	if ($terminaison = _image_trouver_extension($fichier)) {
358
-		$terminaison_dest = ($terminaison == 'gif') ? 'png' : $terminaison;
359
-	}
360
-
361
-	if ($forcer_format !== false
362
-		// 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
363
-		and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format,_image_extensions_acceptees_en_sortie()))) {
364
-		$terminaison_dest = $forcer_format;
365
-	}
366
-
367
-	if (!$terminaison_dest) {
368
-		return false;
369
-	}
370
-
371
-	$nom_fichier = substr($fichier, 0, strlen($fichier) - (strlen($terminaison) + 1));
372
-	$fichier_dest = $nom_fichier;
373
-	if (($find_in_path and $f = find_in_path($fichier) and $fichier = $f)
374
-		or @file_exists($f = $fichier)
375
-	) {
376
-		// on passe la balise img a taille image qui exraira les attributs si possible
377
-		// au lieu de faire un acces disque sur le fichier
378
-		list($ret["hauteur"], $ret["largeur"]) = taille_image($find_in_path ? $f : $img);
379
-		$date_src = @filemtime($f);
380
-	} elseif (@file_exists($f = "$fichier.src")
381
-		and lire_fichier($f, $valeurs)
382
-		and $valeurs = unserialize($valeurs)
383
-		and isset($valeurs["hauteur_dest"])
384
-		and isset($valeurs["largeur_dest"])
385
-	) {
386
-		$ret["hauteur"] = $valeurs["hauteur_dest"];
387
-		$ret["largeur"] = $valeurs["largeur_dest"];
388
-		$date_src = $valeurs["date"];
389
-	} // pas de fichier source par la
390
-	else {
391
-		return false;
392
-	}
393
-
394
-	// pas de taille mesurable
395
-	if (!($ret["hauteur"] or $ret["largeur"])) {
396
-		return false;
397
-	}
398
-
399
-	// les images calculees dependent du chemin du fichier source
400
-	// 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
401
-	// ce n'est pas totalement optimal en terme de stockage, mais chaque image est associee a un fichier .src
402
-	// qui contient la methode de reconstrucion (le filtre + les arguments d'appel) et les arguments different entre prive et public
403
-	// la mise en commun du fichier image cree donc un bug et des problemes qui necessiteraient beaucoup de complexite de code
404
-	// alors que ca concerne peu de site au final
405
-	// la release de r23632+r23633+r23634 a provoque peu de remontee de bug attestant du peu de sites impactes
406
-	$identifiant = $fichier;
407
-
408
-	// cas general :
409
-	// on a un dossier cache commun et un nom de fichier qui varie avec l'effet
410
-	// cas particulier de reduire :
411
-	// un cache par dimension, et le nom de fichier est conserve, suffixe par la dimension aussi
412
-	$cache = "cache-gd2";
413
-	if (substr($effet, 0, 7) == 'reduire') {
414
-		list(, $maxWidth, $maxHeight) = explode('-', $effet);
415
-		list($destWidth, $destHeight) = _image_ratio($ret['largeur'], $ret['hauteur'], $maxWidth, $maxHeight);
416
-		$ret['largeur_dest'] = $destWidth;
417
-		$ret['hauteur_dest'] = $destHeight;
418
-		$effet = "L{$destWidth}xH$destHeight";
419
-		$cache = "cache-vignettes";
420
-		$fichier_dest = basename($fichier_dest);
421
-		if (($ret['largeur'] <= $maxWidth) && ($ret['hauteur'] <= $maxHeight)) {
422
-			// on garde la terminaison initiale car image simplement copiee
423
-			// et on postfixe son nom avec un md5 du path
424
-			$terminaison_dest = $terminaison;
425
-			$fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
426
-		} else {
427
-			$fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
428
-		}
429
-		$cache = sous_repertoire(_DIR_VAR, $cache);
430
-		$cache = sous_repertoire($cache, $effet);
431
-	} else {
432
-		$fichier_dest = md5("$identifiant-$effet");
433
-		$cache = sous_repertoire(_DIR_VAR, $cache);
434
-		$cache = sous_repertoire($cache, substr($fichier_dest, 0, 2));
435
-		$fichier_dest = substr($fichier_dest, 2);
436
-	}
437
-
438
-	$fichier_dest = $cache . $fichier_dest . "." . $terminaison_dest;
439
-
440
-	$GLOBALS["images_calculees"][] = $fichier_dest;
441
-
442
-	$creer = true;
443
-	// si recalcul des images demande, recalculer chaque image une fois
444
-	if (defined('_VAR_IMAGES') and _VAR_IMAGES and !isset($images_recalcul[$fichier_dest])) {
445
-		$images_recalcul[$fichier_dest] = true;
446
-	} else {
447
-		if (@file_exists($f = $fichier_dest)) {
448
-			if (filemtime($f) >= $date_src) {
449
-				$creer = false;
450
-			}
451
-		} else {
452
-			if (@file_exists($f = "$fichier_dest.src")
453
-				and lire_fichier($f, $valeurs)
454
-				and $valeurs = unserialize($valeurs)
455
-				and $valeurs["date"] >= $date_src
456
-			) {
457
-				$creer = false;
458
-			}
459
-		}
460
-	}
461
-	if ($creer) {
462
-		if (!@file_exists($fichier)) {
463
-			if (!@file_exists("$fichier.src")) {
464
-				spip_log("Image absente : $fichier");
465
-
466
-				return false;
467
-			}
468
-			# on reconstruit l'image source absente a partir de la chaine des .src
469
-			reconstruire_image_intermediaire($fichier);
470
-		}
471
-	}
472
-
473
-	if ($creer) {
474
-		spip_log("filtre image " . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
475
-			"images" . _LOG_DEBUG);
476
-	}
477
-
478
-	$term_fonction = _image_trouver_extension_pertinente($fichier);
479
-	$ret["fonction_imagecreatefrom"] = "_imagecreatefrom" . $term_fonction;
480
-	$ret["fichier"] = $fichier;
481
-	$ret["fonction_image"] = "_image_image" . $terminaison_dest;
482
-	$ret["fichier_dest"] = $fichier_dest;
483
-	$ret["format_source"] = _image_extension_normalisee($terminaison);
484
-	$ret["format_dest"] = $terminaison_dest;
485
-	$ret["date_src"] = $date_src;
486
-	$ret["creer"] = $creer;
487
-	$ret["class"] = extraire_attribut($img, 'class');
488
-	$ret["alt"] = extraire_attribut($img, 'alt');
489
-	$ret["style"] = extraire_attribut($img, 'style');
490
-	$ret["tag"] = $img;
491
-	if ($fonction_creation) {
492
-		$ret["reconstruction"] = $fonction_creation;
493
-		# ecrire ici comment creer le fichier, car il est pas sur qu'on l'ecrira reelement 
494
-		# cas de image_reduire qui finalement ne reduit pas l'image source
495
-		# ca evite d'essayer de le creer au prochain hit si il n'est pas la
496
-		#ecrire_fichier($ret['fichier_dest'].'.src',serialize($ret),true);
497
-	}
498
-
499
-	$ret = pipeline('image_preparer_filtre', array(
500
-			'args' => array(
501
-				'img' => $img,
502
-				'effet' => $effet,
503
-				'forcer_format' => $forcer_format,
504
-				'fonction_creation' => $fonction_creation,
505
-				'find_in_path' => $find_in_path,
506
-			),
507
-			'data' => $ret
508
-		)
509
-	);
510
-
511
-	// une globale pour le debug en cas de crash memoire
512
-	$GLOBALS["derniere_image_calculee"] = $ret;
513
-
514
-	// traiter le cas particulier des SVG : si le filtre n'a pas annonce explicitement qu'il savait faire, on delegue
515
-	if ($term_fonction === 'svg') {
516
-		if ($creer and !$support_svg) {
517
-			process_image_svg_identite($ret);
518
-			$ret['creer'] = false;
519
-		}
520
-	}
521
-	else {
522
-		if (!function_exists($ret["fonction_imagecreatefrom"])) {
523
-			return false;
524
-		}
525
-	}
526
-
527
-	return $ret;
310
+    static $images_recalcul = array();
311
+    if (strlen($img) == 0) {
312
+        return false;
313
+    }
314
+
315
+    $source = trim(extraire_attribut($img, 'src'));
316
+    if (strlen($source) < 1) {
317
+        $source = $img;
318
+        $img = "<img src='$source' />";
319
+    } # gerer img src="data:....base64"
320
+    elseif (preg_match('@^data:image/([^;]*);base64,(.*)$@isS', $source, $regs)
321
+      and $extension = _image_trouver_extension_depuis_mime("image/".$regs[1])
322
+        and in_array($extension, _image_extensions_acceptees_en_entree())
323
+    ) {
324
+        $local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
325
+        if (!file_exists($local)) {
326
+            ecrire_fichier($local, base64_decode($regs[2]));
327
+        }
328
+        $source = $local;
329
+        $img = inserer_attribut($img, 'src', $source);
330
+        # eviter les mauvaises surprises lors de conversions de format
331
+        $img = inserer_attribut($img, 'width', '');
332
+        $img = inserer_attribut($img, 'height', '');
333
+    }
334
+
335
+    // les protocoles web prennent au moins 3 lettres
336
+    if (tester_url_absolue($source)) {
337
+        include_spip('inc/distant');
338
+        $fichier = _DIR_RACINE . copie_locale($source);
339
+        if (!$fichier) {
340
+            return "";
341
+        }
342
+    } else {
343
+        // enlever le timestamp eventuel
344
+        if (strpos($source, "?") !== false) {
345
+            $source = preg_replace(',[?][0-9]+$,', '', $source);
346
+        }
347
+        if (strpos($source, "?") !== false
348
+            and strncmp($source, _DIR_IMG, strlen(_DIR_IMG)) == 0
349
+            and file_exists($f = preg_replace(',[?].*$,', '', $source))
350
+        ) {
351
+            $source = $f;
352
+        }
353
+        $fichier = $source;
354
+    }
355
+
356
+    $terminaison_dest = "";
357
+    if ($terminaison = _image_trouver_extension($fichier)) {
358
+        $terminaison_dest = ($terminaison == 'gif') ? 'png' : $terminaison;
359
+    }
360
+
361
+    if ($forcer_format !== false
362
+        // 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
363
+        and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format,_image_extensions_acceptees_en_sortie()))) {
364
+        $terminaison_dest = $forcer_format;
365
+    }
366
+
367
+    if (!$terminaison_dest) {
368
+        return false;
369
+    }
370
+
371
+    $nom_fichier = substr($fichier, 0, strlen($fichier) - (strlen($terminaison) + 1));
372
+    $fichier_dest = $nom_fichier;
373
+    if (($find_in_path and $f = find_in_path($fichier) and $fichier = $f)
374
+        or @file_exists($f = $fichier)
375
+    ) {
376
+        // on passe la balise img a taille image qui exraira les attributs si possible
377
+        // au lieu de faire un acces disque sur le fichier
378
+        list($ret["hauteur"], $ret["largeur"]) = taille_image($find_in_path ? $f : $img);
379
+        $date_src = @filemtime($f);
380
+    } elseif (@file_exists($f = "$fichier.src")
381
+        and lire_fichier($f, $valeurs)
382
+        and $valeurs = unserialize($valeurs)
383
+        and isset($valeurs["hauteur_dest"])
384
+        and isset($valeurs["largeur_dest"])
385
+    ) {
386
+        $ret["hauteur"] = $valeurs["hauteur_dest"];
387
+        $ret["largeur"] = $valeurs["largeur_dest"];
388
+        $date_src = $valeurs["date"];
389
+    } // pas de fichier source par la
390
+    else {
391
+        return false;
392
+    }
393
+
394
+    // pas de taille mesurable
395
+    if (!($ret["hauteur"] or $ret["largeur"])) {
396
+        return false;
397
+    }
398
+
399
+    // les images calculees dependent du chemin du fichier source
400
+    // 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
401
+    // ce n'est pas totalement optimal en terme de stockage, mais chaque image est associee a un fichier .src
402
+    // qui contient la methode de reconstrucion (le filtre + les arguments d'appel) et les arguments different entre prive et public
403
+    // la mise en commun du fichier image cree donc un bug et des problemes qui necessiteraient beaucoup de complexite de code
404
+    // alors que ca concerne peu de site au final
405
+    // la release de r23632+r23633+r23634 a provoque peu de remontee de bug attestant du peu de sites impactes
406
+    $identifiant = $fichier;
407
+
408
+    // cas general :
409
+    // on a un dossier cache commun et un nom de fichier qui varie avec l'effet
410
+    // cas particulier de reduire :
411
+    // un cache par dimension, et le nom de fichier est conserve, suffixe par la dimension aussi
412
+    $cache = "cache-gd2";
413
+    if (substr($effet, 0, 7) == 'reduire') {
414
+        list(, $maxWidth, $maxHeight) = explode('-', $effet);
415
+        list($destWidth, $destHeight) = _image_ratio($ret['largeur'], $ret['hauteur'], $maxWidth, $maxHeight);
416
+        $ret['largeur_dest'] = $destWidth;
417
+        $ret['hauteur_dest'] = $destHeight;
418
+        $effet = "L{$destWidth}xH$destHeight";
419
+        $cache = "cache-vignettes";
420
+        $fichier_dest = basename($fichier_dest);
421
+        if (($ret['largeur'] <= $maxWidth) && ($ret['hauteur'] <= $maxHeight)) {
422
+            // on garde la terminaison initiale car image simplement copiee
423
+            // et on postfixe son nom avec un md5 du path
424
+            $terminaison_dest = $terminaison;
425
+            $fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
426
+        } else {
427
+            $fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
428
+        }
429
+        $cache = sous_repertoire(_DIR_VAR, $cache);
430
+        $cache = sous_repertoire($cache, $effet);
431
+    } else {
432
+        $fichier_dest = md5("$identifiant-$effet");
433
+        $cache = sous_repertoire(_DIR_VAR, $cache);
434
+        $cache = sous_repertoire($cache, substr($fichier_dest, 0, 2));
435
+        $fichier_dest = substr($fichier_dest, 2);
436
+    }
437
+
438
+    $fichier_dest = $cache . $fichier_dest . "." . $terminaison_dest;
439
+
440
+    $GLOBALS["images_calculees"][] = $fichier_dest;
441
+
442
+    $creer = true;
443
+    // si recalcul des images demande, recalculer chaque image une fois
444
+    if (defined('_VAR_IMAGES') and _VAR_IMAGES and !isset($images_recalcul[$fichier_dest])) {
445
+        $images_recalcul[$fichier_dest] = true;
446
+    } else {
447
+        if (@file_exists($f = $fichier_dest)) {
448
+            if (filemtime($f) >= $date_src) {
449
+                $creer = false;
450
+            }
451
+        } else {
452
+            if (@file_exists($f = "$fichier_dest.src")
453
+                and lire_fichier($f, $valeurs)
454
+                and $valeurs = unserialize($valeurs)
455
+                and $valeurs["date"] >= $date_src
456
+            ) {
457
+                $creer = false;
458
+            }
459
+        }
460
+    }
461
+    if ($creer) {
462
+        if (!@file_exists($fichier)) {
463
+            if (!@file_exists("$fichier.src")) {
464
+                spip_log("Image absente : $fichier");
465
+
466
+                return false;
467
+            }
468
+            # on reconstruit l'image source absente a partir de la chaine des .src
469
+            reconstruire_image_intermediaire($fichier);
470
+        }
471
+    }
472
+
473
+    if ($creer) {
474
+        spip_log("filtre image " . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
475
+            "images" . _LOG_DEBUG);
476
+    }
477
+
478
+    $term_fonction = _image_trouver_extension_pertinente($fichier);
479
+    $ret["fonction_imagecreatefrom"] = "_imagecreatefrom" . $term_fonction;
480
+    $ret["fichier"] = $fichier;
481
+    $ret["fonction_image"] = "_image_image" . $terminaison_dest;
482
+    $ret["fichier_dest"] = $fichier_dest;
483
+    $ret["format_source"] = _image_extension_normalisee($terminaison);
484
+    $ret["format_dest"] = $terminaison_dest;
485
+    $ret["date_src"] = $date_src;
486
+    $ret["creer"] = $creer;
487
+    $ret["class"] = extraire_attribut($img, 'class');
488
+    $ret["alt"] = extraire_attribut($img, 'alt');
489
+    $ret["style"] = extraire_attribut($img, 'style');
490
+    $ret["tag"] = $img;
491
+    if ($fonction_creation) {
492
+        $ret["reconstruction"] = $fonction_creation;
493
+        # ecrire ici comment creer le fichier, car il est pas sur qu'on l'ecrira reelement 
494
+        # cas de image_reduire qui finalement ne reduit pas l'image source
495
+        # ca evite d'essayer de le creer au prochain hit si il n'est pas la
496
+        #ecrire_fichier($ret['fichier_dest'].'.src',serialize($ret),true);
497
+    }
498
+
499
+    $ret = pipeline('image_preparer_filtre', array(
500
+            'args' => array(
501
+                'img' => $img,
502
+                'effet' => $effet,
503
+                'forcer_format' => $forcer_format,
504
+                'fonction_creation' => $fonction_creation,
505
+                'find_in_path' => $find_in_path,
506
+            ),
507
+            'data' => $ret
508
+        )
509
+    );
510
+
511
+    // une globale pour le debug en cas de crash memoire
512
+    $GLOBALS["derniere_image_calculee"] = $ret;
513
+
514
+    // traiter le cas particulier des SVG : si le filtre n'a pas annonce explicitement qu'il savait faire, on delegue
515
+    if ($term_fonction === 'svg') {
516
+        if ($creer and !$support_svg) {
517
+            process_image_svg_identite($ret);
518
+            $ret['creer'] = false;
519
+        }
520
+    }
521
+    else {
522
+        if (!function_exists($ret["fonction_imagecreatefrom"])) {
523
+            return false;
524
+        }
525
+    }
526
+
527
+    return $ret;
528 528
 }
529 529
 
530 530
 
@@ -533,51 +533,51 @@  discard block
 block discarded – undo
533 533
  * @return array
534 534
  */
535 535
 function _image_extensions_acceptees_en_entree() {
536
-	static $extensions = null;
537
-	if (empty($extensions)) {
538
-		$extensions = ['png', 'gif', 'jpg', 'jpeg'];
539
-		if (!empty($GLOBALS['meta']['gd_formats'])) {
540
-			// action=tester renseigne gd_formats et detecte le support de webp
541
-			$extensions = array_merge(explode(',', $GLOBALS['meta']['gd_formats']));
542
-			$extensions = array_map('trim', $extensions);
543
-			$extensions = array_filter($extensions);
544
-			$extensions = array_unique($extensions);
545
-		}
546
-		$extensions[] = 'svg'; // on le supporte toujours avec des fonctions specifiques
547
-	}
548
-
549
-	return $extensions;
536
+    static $extensions = null;
537
+    if (empty($extensions)) {
538
+        $extensions = ['png', 'gif', 'jpg', 'jpeg'];
539
+        if (!empty($GLOBALS['meta']['gd_formats'])) {
540
+            // action=tester renseigne gd_formats et detecte le support de webp
541
+            $extensions = array_merge(explode(',', $GLOBALS['meta']['gd_formats']));
542
+            $extensions = array_map('trim', $extensions);
543
+            $extensions = array_filter($extensions);
544
+            $extensions = array_unique($extensions);
545
+        }
546
+        $extensions[] = 'svg'; // on le supporte toujours avec des fonctions specifiques
547
+    }
548
+
549
+    return $extensions;
550 550
 }
551 551
 
552 552
 /**
553 553
  * @return array|string[]|null
554 554
  */
555 555
 function _image_extensions_acceptees_en_sortie(){
556
-	static $extensions = null;
557
-	if (empty($extensions)){
558
-		$extensions = _image_extensions_acceptees_en_entree();
559
-		$extensions = array_diff($extensions, ['jpeg']);
560
-		if (in_array('gif', $extensions) and !function_exists('imagegif')) {
561
-			$extensions = array_diff($extensions, ['gif']);
562
-		}
563
-		if (in_array('webp', $extensions) and !function_exists('imagewebp')) {
564
-			$extensions = array_diff($extensions, ['webp']);
565
-		}
566
-	}
567
-
568
-	return $extensions;
556
+    static $extensions = null;
557
+    if (empty($extensions)){
558
+        $extensions = _image_extensions_acceptees_en_entree();
559
+        $extensions = array_diff($extensions, ['jpeg']);
560
+        if (in_array('gif', $extensions) and !function_exists('imagegif')) {
561
+            $extensions = array_diff($extensions, ['gif']);
562
+        }
563
+        if (in_array('webp', $extensions) and !function_exists('imagewebp')) {
564
+            $extensions = array_diff($extensions, ['webp']);
565
+        }
566
+    }
567
+
568
+    return $extensions;
569 569
 }
570 570
 
571 571
 function _image_extension_normalisee($extension){
572
-	$extension = strtolower($extension);
573
-	if ($extension === 'jpeg') {
574
-		$extension = 'jpg';
575
-	}
576
-	return $extension;
572
+    $extension = strtolower($extension);
573
+    if ($extension === 'jpeg') {
574
+        $extension = 'jpg';
575
+    }
576
+    return $extension;
577 577
 }
578 578
 
579 579
 function _image_extensions_conservent_transparence(){
580
-	return ['png', 'webp'];
580
+    return ['png', 'webp'];
581 581
 }
582 582
 
583 583
 
@@ -587,12 +587,12 @@  discard block
 block discarded – undo
587 587
  * @return string
588 588
  */
589 589
 function _image_trouver_extension($path) {
590
-	$preg_extensions = implode('|', _image_extensions_acceptees_en_entree());
591
-	if (preg_match(",\.($preg_extensions)($|[?]),i", $path, $regs)) {
592
-		$terminaison = strtolower($regs[1]);
593
-		return $terminaison;
594
-	}
595
-	return '';
590
+    $preg_extensions = implode('|', _image_extensions_acceptees_en_entree());
591
+    if (preg_match(",\.($preg_extensions)($|[?]),i", $path, $regs)) {
592
+        $terminaison = strtolower($regs[1]);
593
+        return $terminaison;
594
+    }
595
+    return '';
596 596
 }
597 597
 
598 598
 /**
@@ -603,33 +603,33 @@  discard block
 block discarded – undo
603 603
  * @return string Extension, dans le format attendu par les fonctions 'gd' ('jpeg' pour les .jpg par exemple)
604 604
  */
605 605
 function _image_trouver_extension_pertinente($path) {
606
-	$path = supprimer_timestamp($path);
607
-	$terminaison = _image_trouver_extension($path);
608
-	if ($terminaison == 'jpg') {
609
-		$terminaison = 'jpeg';
610
-	}
611
-
612
-	if (!file_exists($path)) {
613
-		return $terminaison;
614
-	}
615
-
616
-	if (!$info = @spip_getimagesize($path)) {
617
-		return $terminaison;
618
-	}
619
-
620
-	if (isset($info['mime'])) {
621
-		$mime = $info['mime'];
622
-	}
623
-	else {
624
-		$mime = image_type_to_mime_type($info[2]);
625
-	}
626
-
627
-	$_terminaison = _image_trouver_extension_depuis_mime($mime);
628
-	if ($_terminaison and $_terminaison !== $terminaison) {
629
-		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", "images." . _LOG_INFO_IMPORTANTE);
630
-		$terminaison = $_terminaison;
631
-	}
632
-	return $terminaison;
606
+    $path = supprimer_timestamp($path);
607
+    $terminaison = _image_trouver_extension($path);
608
+    if ($terminaison == 'jpg') {
609
+        $terminaison = 'jpeg';
610
+    }
611
+
612
+    if (!file_exists($path)) {
613
+        return $terminaison;
614
+    }
615
+
616
+    if (!$info = @spip_getimagesize($path)) {
617
+        return $terminaison;
618
+    }
619
+
620
+    if (isset($info['mime'])) {
621
+        $mime = $info['mime'];
622
+    }
623
+    else {
624
+        $mime = image_type_to_mime_type($info[2]);
625
+    }
626
+
627
+    $_terminaison = _image_trouver_extension_depuis_mime($mime);
628
+    if ($_terminaison and $_terminaison !== $terminaison) {
629
+        spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", "images." . _LOG_INFO_IMPORTANTE);
630
+        $terminaison = $_terminaison;
631
+    }
632
+    return $terminaison;
633 633
 }
634 634
 
635 635
 /**
@@ -637,36 +637,36 @@  discard block
 block discarded – undo
637 637
  * @return string
638 638
  */
639 639
 function _image_trouver_extension_depuis_mime($mime) {
640
-	switch (strtolower($mime)) {
641
-		case 'image/png':
642
-		case 'image/x-png':
643
-			$terminaison = 'png';
644
-			break;
645
-
646
-		case 'image/jpg':
647
-		case 'image/jpeg':
648
-		case 'image/pjpeg':
649
-			$terminaison = 'jpeg';
650
-			break;
651
-
652
-		case 'image/gif':
653
-			$terminaison = 'gif';
654
-			break;
655
-
656
-		case 'image/webp':
657
-		case 'image/x-webp':
658
-			$terminaison = 'webp';
659
-			break;
660
-
661
-		case 'image/svg+xml':
662
-			$terminaison = 'svg';
663
-			break;
664
-
665
-		default:
666
-			$terminaison = '';
667
-	}
668
-
669
-	return $terminaison;
640
+    switch (strtolower($mime)) {
641
+        case 'image/png':
642
+        case 'image/x-png':
643
+            $terminaison = 'png';
644
+            break;
645
+
646
+        case 'image/jpg':
647
+        case 'image/jpeg':
648
+        case 'image/pjpeg':
649
+            $terminaison = 'jpeg';
650
+            break;
651
+
652
+        case 'image/gif':
653
+            $terminaison = 'gif';
654
+            break;
655
+
656
+        case 'image/webp':
657
+        case 'image/x-webp':
658
+            $terminaison = 'webp';
659
+            break;
660
+
661
+        case 'image/svg+xml':
662
+            $terminaison = 'svg';
663
+            break;
664
+
665
+        default:
666
+            $terminaison = '';
667
+    }
668
+
669
+    return $terminaison;
670 670
 }
671 671
 
672 672
 
@@ -686,18 +686,18 @@  discard block
 block discarded – undo
686 686
  *     Une ressource de type Image GD.
687 687
  */
688 688
 function _imagecreatefrom_func(string $func, string $filename) {
689
-	if (!function_exists($func)) {
690
-		spip_log("GD indisponible : $func inexistante. Traitement $filename impossible.", _LOG_CRITIQUE);
691
-		erreur_squelette("GD indisponible : $func inexistante. Traitement $filename impossible.");
692
-		return null;
693
-	}
694
-	$img = @$func($filename);
695
-	if (!$img) {
696
-		spip_log("Erreur lecture imagecreatefromjpeg $filename", _LOG_CRITIQUE);
697
-		erreur_squelette("Erreur lecture imagecreatefromjpeg $filename");
698
-		$img = imagecreate(10, 10);
699
-	}
700
-	return $img;
689
+    if (!function_exists($func)) {
690
+        spip_log("GD indisponible : $func inexistante. Traitement $filename impossible.", _LOG_CRITIQUE);
691
+        erreur_squelette("GD indisponible : $func inexistante. Traitement $filename impossible.");
692
+        return null;
693
+    }
694
+    $img = @$func($filename);
695
+    if (!$img) {
696
+        spip_log("Erreur lecture imagecreatefromjpeg $filename", _LOG_CRITIQUE);
697
+        erreur_squelette("Erreur lecture imagecreatefromjpeg $filename");
698
+        $img = imagecreate(10, 10);
699
+    }
700
+    return $img;
701 701
 }
702 702
 
703 703
 /**
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
  *     Une ressource de type Image GD.
714 714
  */
715 715
 function _imagecreatefromjpeg($filename) {
716
-	return _imagecreatefrom_func('imagecreatefromjpeg', $filename);
716
+    return _imagecreatefrom_func('imagecreatefromjpeg', $filename);
717 717
 }
718 718
 
719 719
 /**
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
  *     Une ressource de type Image GD.
730 730
  */
731 731
 function _imagecreatefrompng($filename) {
732
-	return _imagecreatefrom_func('imagecreatefrompng', $filename);
732
+    return _imagecreatefrom_func('imagecreatefrompng', $filename);
733 733
 }
734 734
 
735 735
 /**
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
  *     Une ressource de type Image GD.
746 746
  */
747 747
 function _imagecreatefromgif($filename) {
748
-	return _imagecreatefrom_func('imagecreatefromgif', $filename);
748
+    return _imagecreatefrom_func('imagecreatefromgif', $filename);
749 749
 }
750 750
 
751 751
 
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
  *     Une ressource de type Image GD.
763 763
  */
764 764
 function _imagecreatefromwebp($filename) {
765
-	return _imagecreatefrom_func('imagecreatefromwebp', $filename);
765
+    return _imagecreatefrom_func('imagecreatefromwebp', $filename);
766 766
 }
767 767
 
768 768
 /**
@@ -780,24 +780,24 @@  discard block
 block discarded – undo
780 780
  *     - true si une image est bien retournée.
781 781
  */
782 782
 function _image_imagepng($img, $fichier) {
783
-	if (!function_exists('imagepng')) {
784
-		return false;
785
-	}
786
-	$tmp = $fichier . ".tmp";
787
-	$ret = imagepng($img, $tmp);
788
-	if (file_exists($tmp)) {
789
-		$taille_test = getimagesize($tmp);
790
-		if ($taille_test[0] < 1) {
791
-			return false;
792
-		}
793
-
794
-		spip_unlink($fichier); // le fichier peut deja exister
795
-		@rename($tmp, $fichier);
796
-
797
-		return $ret;
798
-	}
799
-
800
-	return false;
783
+    if (!function_exists('imagepng')) {
784
+        return false;
785
+    }
786
+    $tmp = $fichier . ".tmp";
787
+    $ret = imagepng($img, $tmp);
788
+    if (file_exists($tmp)) {
789
+        $taille_test = getimagesize($tmp);
790
+        if ($taille_test[0] < 1) {
791
+            return false;
792
+        }
793
+
794
+        spip_unlink($fichier); // le fichier peut deja exister
795
+        @rename($tmp, $fichier);
796
+
797
+        return $ret;
798
+    }
799
+
800
+    return false;
801 801
 }
802 802
 
803 803
 /**
@@ -815,24 +815,24 @@  discard block
 block discarded – undo
815 815
  *     - true si une image est bien retournée.
816 816
  */
817 817
 function _image_imagegif($img, $fichier) {
818
-	if (!function_exists('imagegif')) {
819
-		return false;
820
-	}
821
-	$tmp = $fichier . ".tmp";
822
-	$ret = imagegif($img, $tmp);
823
-	if (file_exists($tmp)) {
824
-		$taille_test = getimagesize($tmp);
825
-		if ($taille_test[0] < 1) {
826
-			return false;
827
-		}
828
-
829
-		spip_unlink($fichier); // le fichier peut deja exister
830
-		@rename($tmp, $fichier);
831
-
832
-		return $ret;
833
-	}
834
-
835
-	return false;
818
+    if (!function_exists('imagegif')) {
819
+        return false;
820
+    }
821
+    $tmp = $fichier . ".tmp";
822
+    $ret = imagegif($img, $tmp);
823
+    if (file_exists($tmp)) {
824
+        $taille_test = getimagesize($tmp);
825
+        if ($taille_test[0] < 1) {
826
+            return false;
827
+        }
828
+
829
+        spip_unlink($fichier); // le fichier peut deja exister
830
+        @rename($tmp, $fichier);
831
+
832
+        return $ret;
833
+    }
834
+
835
+    return false;
836 836
 }
837 837
 
838 838
 /**
@@ -855,29 +855,29 @@  discard block
 block discarded – undo
855 855
  *     - true si une image est bien retournée.
856 856
  */
857 857
 function _image_imagejpg($img, $fichier, $qualite = _IMG_GD_QUALITE) {
858
-	if (!function_exists('imagejpeg')) {
859
-		return false;
860
-	}
861
-	$tmp = $fichier . ".tmp";
858
+    if (!function_exists('imagejpeg')) {
859
+        return false;
860
+    }
861
+    $tmp = $fichier . ".tmp";
862 862
 
863
-	// Enable interlancing
864
-	imageinterlace($img, true);
863
+    // Enable interlancing
864
+    imageinterlace($img, true);
865 865
 
866
-	$ret = imagejpeg($img, $tmp, $qualite);
866
+    $ret = imagejpeg($img, $tmp, $qualite);
867 867
 
868
-	if (file_exists($tmp)) {
869
-		$taille_test = getimagesize($tmp);
870
-		if ($taille_test[0] < 1) {
871
-			return false;
872
-		}
868
+    if (file_exists($tmp)) {
869
+        $taille_test = getimagesize($tmp);
870
+        if ($taille_test[0] < 1) {
871
+            return false;
872
+        }
873 873
 
874
-		spip_unlink($fichier); // le fichier peut deja exister
875
-		@rename($tmp, $fichier);
874
+        spip_unlink($fichier); // le fichier peut deja exister
875
+        @rename($tmp, $fichier);
876 876
 
877
-		return $ret;
878
-	}
877
+        return $ret;
878
+    }
879 879
 
880
-	return false;
880
+    return false;
881 881
 }
882 882
 
883 883
 /**
@@ -895,9 +895,9 @@  discard block
 block discarded – undo
895 895
  *     true si le fichier a bien été créé ; false sinon.
896 896
  */
897 897
 function _image_imageico($img, $fichier) {
898
-	$gd_image_array = array($img);
898
+    $gd_image_array = array($img);
899 899
 
900
-	return ecrire_fichier($fichier, phpthumb_functions::GD2ICOstring($gd_image_array));
900
+    return ecrire_fichier($fichier, phpthumb_functions::GD2ICOstring($gd_image_array));
901 901
 }
902 902
 
903 903
 
@@ -916,24 +916,24 @@  discard block
 block discarded – undo
916 916
  *     - true si une image est bien retournée.
917 917
  */
918 918
 function _image_imagewebp($img, $fichier, $qualite = _IMG_GD_QUALITE) {
919
-	if (!function_exists('imagewebp')) {
920
-		return false;
921
-	}
922
-	$tmp = $fichier . ".tmp";
923
-	$ret = imagewebp($img, $tmp, $qualite);
924
-	if (file_exists($tmp)) {
925
-		$taille_test = getimagesize($tmp);
926
-		if ($taille_test[0] < 1) {
927
-			return false;
928
-		}
929
-
930
-		spip_unlink($fichier); // le fichier peut deja exister
931
-		@rename($tmp, $fichier);
932
-
933
-		return $ret;
934
-	}
935
-
936
-	return false;
919
+    if (!function_exists('imagewebp')) {
920
+        return false;
921
+    }
922
+    $tmp = $fichier . ".tmp";
923
+    $ret = imagewebp($img, $tmp, $qualite);
924
+    if (file_exists($tmp)) {
925
+        $taille_test = getimagesize($tmp);
926
+        if ($taille_test[0] < 1) {
927
+            return false;
928
+        }
929
+
930
+        spip_unlink($fichier); // le fichier peut deja exister
931
+        @rename($tmp, $fichier);
932
+
933
+        return $ret;
934
+    }
935
+
936
+    return false;
937 937
 }
938 938
 
939 939
 /**
@@ -953,35 +953,35 @@  discard block
 block discarded – undo
953 953
  */
954 954
 function _image_imagesvg($img, $fichier) {
955 955
 
956
-	$tmp = $fichier . ".tmp";
957
-	if (strpos($img, "<") === false) {
958
-		$img = supprimer_timestamp($img);
959
-		if (!file_exists($img)) {
960
-			return false;
961
-		}
962
-		@copy($img, $tmp);
963
-		if (filesize($tmp) == filesize($img)) {
964
-			spip_unlink($fichier); // le fichier peut deja exister
965
-			@rename($tmp, $fichier);
966
-			return true;
967
-		}
968
-		return false;
969
-	}
970
-
971
-	file_put_contents($tmp, $img);
972
-	if (file_exists($tmp)) {
973
-		$taille_test = spip_getimagesize($tmp);
974
-		if ($taille_test[0] < 1) {
975
-			return false;
976
-		}
977
-
978
-		spip_unlink($fichier); // le fichier peut deja exister
979
-		@rename($tmp, $fichier);
980
-
981
-		return true;
982
-	}
983
-
984
-	return false;
956
+    $tmp = $fichier . ".tmp";
957
+    if (strpos($img, "<") === false) {
958
+        $img = supprimer_timestamp($img);
959
+        if (!file_exists($img)) {
960
+            return false;
961
+        }
962
+        @copy($img, $tmp);
963
+        if (filesize($tmp) == filesize($img)) {
964
+            spip_unlink($fichier); // le fichier peut deja exister
965
+            @rename($tmp, $fichier);
966
+            return true;
967
+        }
968
+        return false;
969
+    }
970
+
971
+    file_put_contents($tmp, $img);
972
+    if (file_exists($tmp)) {
973
+        $taille_test = spip_getimagesize($tmp);
974
+        if ($taille_test[0] < 1) {
975
+            return false;
976
+        }
977
+
978
+        spip_unlink($fichier); // le fichier peut deja exister
979
+        @rename($tmp, $fichier);
980
+
981
+        return true;
982
+    }
983
+
984
+    return false;
985 985
 }
986 986
 
987 987
 
@@ -1009,29 +1009,29 @@  discard block
 block discarded – undo
1009 1009
  *     - false sinon.
1010 1010
  */
1011 1011
 function _image_gd_output($img, $valeurs, $qualite = _IMG_GD_QUALITE, $fonction = null) {
1012
-	if (is_null($fonction)) {
1013
-		$fonction = "_image_image" . $valeurs['format_dest'];
1014
-	}
1015
-	$ret = false;
1016
-	#un flag pour reperer les images gravees
1017
-	$lock =
1018
-		!statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1019
-	or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'));
1020
-	if (
1021
-		function_exists($fonction)
1022
-		&& ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
1023
-		&& isset($valeurs['reconstruction']) # et on sait comment la resonctruire le cas echeant
1024
-		&& !$lock
1025
-	) {
1026
-		if (@file_exists($valeurs['fichier_dest'])) {
1027
-			// dans tous les cas mettre a jour la taille de l'image finale
1028
-			list($valeurs["hauteur_dest"], $valeurs["largeur_dest"]) = taille_image($valeurs['fichier_dest']);
1029
-			$valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1030
-			ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1031
-		}
1032
-	}
1033
-
1034
-	return $ret;
1012
+    if (is_null($fonction)) {
1013
+        $fonction = "_image_image" . $valeurs['format_dest'];
1014
+    }
1015
+    $ret = false;
1016
+    #un flag pour reperer les images gravees
1017
+    $lock =
1018
+        !statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1019
+    or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'));
1020
+    if (
1021
+        function_exists($fonction)
1022
+        && ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
1023
+        && isset($valeurs['reconstruction']) # et on sait comment la resonctruire le cas echeant
1024
+        && !$lock
1025
+    ) {
1026
+        if (@file_exists($valeurs['fichier_dest'])) {
1027
+            // dans tous les cas mettre a jour la taille de l'image finale
1028
+            list($valeurs["hauteur_dest"], $valeurs["largeur_dest"]) = taille_image($valeurs['fichier_dest']);
1029
+            $valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1030
+            ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1031
+        }
1032
+    }
1033
+
1034
+    return $ret;
1035 1035
 }
1036 1036
 
1037 1037
 /**
@@ -1044,26 +1044,26 @@  discard block
 block discarded – undo
1044 1044
  *     Chemin vers le fichier manquant
1045 1045
  **/
1046 1046
 function reconstruire_image_intermediaire($fichier_manquant) {
1047
-	$reconstruire = array();
1048
-	$fichier = $fichier_manquant;
1049
-	while (strpos($fichier,"://")===false
1050
-		and !@file_exists($fichier)
1051
-		and lire_fichier($src = "$fichier.src", $source)
1052
-		and $valeurs = unserialize($source)
1053
-		and ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1054
-	) {
1055
-		spip_unlink($src); // si jamais on a un timeout pendant la reconstruction, elle se fera naturellement au hit suivant
1056
-		$reconstruire[] = $valeurs['reconstruction'];
1057
-	}
1058
-	while (count($reconstruire)) {
1059
-		$r = array_pop($reconstruire);
1060
-		$fonction = $r[0];
1061
-		$args = $r[1];
1062
-		call_user_func_array($fonction, $args);
1063
-	}
1064
-	// cette image intermediaire est commune a plusieurs series de filtre, il faut la conserver
1065
-	// mais l'on peut nettoyer les miettes de sa creation
1066
-	ramasse_miettes($fichier_manquant);
1047
+    $reconstruire = array();
1048
+    $fichier = $fichier_manquant;
1049
+    while (strpos($fichier,"://")===false
1050
+        and !@file_exists($fichier)
1051
+        and lire_fichier($src = "$fichier.src", $source)
1052
+        and $valeurs = unserialize($source)
1053
+        and ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1054
+    ) {
1055
+        spip_unlink($src); // si jamais on a un timeout pendant la reconstruction, elle se fera naturellement au hit suivant
1056
+        $reconstruire[] = $valeurs['reconstruction'];
1057
+    }
1058
+    while (count($reconstruire)) {
1059
+        $r = array_pop($reconstruire);
1060
+        $fonction = $r[0];
1061
+        $args = $r[1];
1062
+        call_user_func_array($fonction, $args);
1063
+    }
1064
+    // cette image intermediaire est commune a plusieurs series de filtre, il faut la conserver
1065
+    // mais l'on peut nettoyer les miettes de sa creation
1066
+    ramasse_miettes($fichier_manquant);
1067 1067
 }
1068 1068
 
1069 1069
 /**
@@ -1083,25 +1083,25 @@  discard block
 block discarded – undo
1083 1083
  *     Chemin du fichier d'image calculé
1084 1084
  **/
1085 1085
 function ramasse_miettes($fichier) {
1086
-	if (strpos($fichier,"://")!==false
1087
-		or !lire_fichier($src = "$fichier.src", $source)
1088
-		or !$valeurs = unserialize($source)
1089
-	) {
1090
-		return;
1091
-	}
1092
-	spip_unlink($src); # on supprime la reference a sa source pour marquer cette image comme non intermediaire
1093
-	while (
1094
-		($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1095
-		and (substr($fichier, 0, strlen(_DIR_VAR)) == _DIR_VAR) # et est dans local
1096
-		and (lire_fichier($src = "$fichier.src",
1097
-			$source)) # le fichier a une source connue (c'est donc une image calculee intermediaire)
1098
-		and ($valeurs = unserialize($source))  # et valide
1099
-	) {
1100
-		# on efface le fichier
1101
-		spip_unlink($fichier);
1102
-		# mais laisse le .src qui permet de savoir comment reconstruire l'image si besoin
1103
-		#spip_unlink($src);
1104
-	}
1086
+    if (strpos($fichier,"://")!==false
1087
+        or !lire_fichier($src = "$fichier.src", $source)
1088
+        or !$valeurs = unserialize($source)
1089
+    ) {
1090
+        return;
1091
+    }
1092
+    spip_unlink($src); # on supprime la reference a sa source pour marquer cette image comme non intermediaire
1093
+    while (
1094
+        ($fichier = $valeurs['fichier']) # l'origine est connue (on ne verifie pas son existence, qu'importe ...)
1095
+        and (substr($fichier, 0, strlen(_DIR_VAR)) == _DIR_VAR) # et est dans local
1096
+        and (lire_fichier($src = "$fichier.src",
1097
+            $source)) # le fichier a une source connue (c'est donc une image calculee intermediaire)
1098
+        and ($valeurs = unserialize($source))  # et valide
1099
+    ) {
1100
+        # on efface le fichier
1101
+        spip_unlink($fichier);
1102
+        # mais laisse le .src qui permet de savoir comment reconstruire l'image si besoin
1103
+        #spip_unlink($src);
1104
+    }
1105 1105
 }
1106 1106
 
1107 1107
 
@@ -1126,71 +1126,71 @@  discard block
 block discarded – undo
1126 1126
  *     Code HTML de l'image
1127 1127
  **/
1128 1128
 function image_graver($img) {
1129
-	// appeler le filtre post_image_filtrer qui permet de faire
1130
-	// des traitements auto a la fin d'une serie de filtres
1131
-	$img = pipeline('post_image_filtrer', $img);
1132
-
1133
-	$fichier_ori = $fichier = extraire_attribut($img, 'src');
1134
-	if (($p = strpos($fichier, '?')) !== false) {
1135
-		$fichier = substr($fichier, 0, $p);
1136
-	}
1137
-	if (strlen($fichier) < 1) {
1138
-		$fichier = $img;
1139
-	}
1140
-	# si jamais le fichier final n'a pas ete calcule car suppose temporaire
1141
-	# et qu'il ne s'agit pas d'une URL
1142
-	if (strpos($fichier,"://")===false and !@file_exists($fichier)) {
1143
-		reconstruire_image_intermediaire($fichier);
1144
-	}
1145
-	ramasse_miettes($fichier);
1146
-
1147
-	// ajouter le timestamp si besoin
1148
-	if (strpos($fichier_ori, "?") === false) {
1149
-		// on utilise str_replace pour attraper le onmouseover des logo si besoin
1150
-		$img = str_replace($fichier_ori, timestamp($fichier_ori), $img);
1151
-	}
1152
-
1153
-	return $img;
1129
+    // appeler le filtre post_image_filtrer qui permet de faire
1130
+    // des traitements auto a la fin d'une serie de filtres
1131
+    $img = pipeline('post_image_filtrer', $img);
1132
+
1133
+    $fichier_ori = $fichier = extraire_attribut($img, 'src');
1134
+    if (($p = strpos($fichier, '?')) !== false) {
1135
+        $fichier = substr($fichier, 0, $p);
1136
+    }
1137
+    if (strlen($fichier) < 1) {
1138
+        $fichier = $img;
1139
+    }
1140
+    # si jamais le fichier final n'a pas ete calcule car suppose temporaire
1141
+    # et qu'il ne s'agit pas d'une URL
1142
+    if (strpos($fichier,"://")===false and !@file_exists($fichier)) {
1143
+        reconstruire_image_intermediaire($fichier);
1144
+    }
1145
+    ramasse_miettes($fichier);
1146
+
1147
+    // ajouter le timestamp si besoin
1148
+    if (strpos($fichier_ori, "?") === false) {
1149
+        // on utilise str_replace pour attraper le onmouseover des logo si besoin
1150
+        $img = str_replace($fichier_ori, timestamp($fichier_ori), $img);
1151
+    }
1152
+
1153
+    return $img;
1154 1154
 }
1155 1155
 
1156 1156
 
1157 1157
 if (!function_exists("imagepalettetotruecolor")) {
1158
-	/**
1159
-	 * Transforme une image à palette indexée (256 couleurs max) en "vraies" couleurs RGB
1160
-	 *
1161
-	 * @note Pour compatibilité avec PHP < 5.5
1162
-	 *
1163
-	 * @link http://php.net/manual/fr/function.imagepalettetotruecolor.php
1164
-	 *
1165
-	 * @param ressource $img
1166
-	 * @return bool
1167
-	 *     - true si l'image est déjà en vrai RGB ou peut être transformée
1168
-	 *     - false si la transformation ne peut être faite.
1169
-	 **/
1170
-	function imagepalettetotruecolor(&$img) {
1171
-		if (!$img or !function_exists('imagecreatetruecolor')) {
1172
-			return false;
1173
-		} elseif (!imageistruecolor($img)) {
1174
-			$w = imagesx($img);
1175
-			$h = imagesy($img);
1176
-			$img1 = imagecreatetruecolor($w, $h);
1177
-			//Conserver la transparence si possible
1178
-			if (function_exists('ImageCopyResampled')) {
1179
-				if (function_exists("imageAntiAlias")) {
1180
-					imageAntiAlias($img1, true);
1181
-				}
1182
-				@imagealphablending($img1, false);
1183
-				@imagesavealpha($img1, true);
1184
-				@ImageCopyResampled($img1, $img, 0, 0, 0, 0, $w, $h, $w, $h);
1185
-			} else {
1186
-				imagecopy($img1, $img, 0, 0, 0, 0, $w, $h);
1187
-			}
1188
-
1189
-			$img = $img1;
1190
-		}
1191
-
1192
-		return true;
1193
-	}
1158
+    /**
1159
+     * Transforme une image à palette indexée (256 couleurs max) en "vraies" couleurs RGB
1160
+     *
1161
+     * @note Pour compatibilité avec PHP < 5.5
1162
+     *
1163
+     * @link http://php.net/manual/fr/function.imagepalettetotruecolor.php
1164
+     *
1165
+     * @param ressource $img
1166
+     * @return bool
1167
+     *     - true si l'image est déjà en vrai RGB ou peut être transformée
1168
+     *     - false si la transformation ne peut être faite.
1169
+     **/
1170
+    function imagepalettetotruecolor(&$img) {
1171
+        if (!$img or !function_exists('imagecreatetruecolor')) {
1172
+            return false;
1173
+        } elseif (!imageistruecolor($img)) {
1174
+            $w = imagesx($img);
1175
+            $h = imagesy($img);
1176
+            $img1 = imagecreatetruecolor($w, $h);
1177
+            //Conserver la transparence si possible
1178
+            if (function_exists('ImageCopyResampled')) {
1179
+                if (function_exists("imageAntiAlias")) {
1180
+                    imageAntiAlias($img1, true);
1181
+                }
1182
+                @imagealphablending($img1, false);
1183
+                @imagesavealpha($img1, true);
1184
+                @ImageCopyResampled($img1, $img, 0, 0, 0, 0, $w, $h, $w, $h);
1185
+            } else {
1186
+                imagecopy($img1, $img, 0, 0, 0, 0, $w, $h);
1187
+            }
1188
+
1189
+            $img = $img1;
1190
+        }
1191
+
1192
+        return true;
1193
+    }
1194 1194
 }
1195 1195
 
1196 1196
 /**
@@ -1217,32 +1217,32 @@  discard block
 block discarded – undo
1217 1217
  *     Code html modifié de la balise.
1218 1218
  **/
1219 1219
 function _image_tag_changer_taille($tag, $width, $height, $style = false) {
1220
-	if ($style === false) {
1221
-		$style = extraire_attribut($tag, 'style');
1222
-	}
1223
-
1224
-	// enlever le width et height du style
1225
-	$style = preg_replace(",(^|;)\s*(width|height)\s*:\s*[^;]+,ims", "", $style);
1226
-	if ($style and $style[0] == ';') {
1227
-		$style = substr($style, 1);
1228
-	}
1229
-
1230
-	// mettre des attributs de width et height sur les images, 
1231
-	// ca accelere le rendu du navigateur
1232
-	// ca permet aux navigateurs de reserver la bonne taille 
1233
-	// quand on a desactive l'affichage des images.
1234
-	$tag = inserer_attribut($tag, 'width', round($width));
1235
-	$tag = inserer_attribut($tag, 'height', round($height));
1236
-
1237
-	// attributs deprecies. Transformer en CSS
1238
-	if ($espace = extraire_attribut($tag, 'hspace')) {
1239
-		$style = "margin:${espace}px;" . $style;
1240
-		$tag = inserer_attribut($tag, 'hspace', '');
1241
-	}
1242
-
1243
-	$tag = inserer_attribut($tag, 'style', $style, true, $style ? false : true);
1244
-
1245
-	return $tag;
1220
+    if ($style === false) {
1221
+        $style = extraire_attribut($tag, 'style');
1222
+    }
1223
+
1224
+    // enlever le width et height du style
1225
+    $style = preg_replace(",(^|;)\s*(width|height)\s*:\s*[^;]+,ims", "", $style);
1226
+    if ($style and $style[0] == ';') {
1227
+        $style = substr($style, 1);
1228
+    }
1229
+
1230
+    // mettre des attributs de width et height sur les images, 
1231
+    // ca accelere le rendu du navigateur
1232
+    // ca permet aux navigateurs de reserver la bonne taille 
1233
+    // quand on a desactive l'affichage des images.
1234
+    $tag = inserer_attribut($tag, 'width', round($width));
1235
+    $tag = inserer_attribut($tag, 'height', round($height));
1236
+
1237
+    // attributs deprecies. Transformer en CSS
1238
+    if ($espace = extraire_attribut($tag, 'hspace')) {
1239
+        $style = "margin:${espace}px;" . $style;
1240
+        $tag = inserer_attribut($tag, 'hspace', '');
1241
+    }
1242
+
1243
+    $tag = inserer_attribut($tag, 'style', $style, true, $style ? false : true);
1244
+
1245
+    return $tag;
1246 1246
 }
1247 1247
 
1248 1248
 
@@ -1268,71 +1268,71 @@  discard block
 block discarded – undo
1268 1268
  *     Retourne le code HTML de l'image
1269 1269
  **/
1270 1270
 function _image_ecrire_tag($valeurs, $surcharge = array()) {
1271
-	$valeurs = pipeline('image_ecrire_tag_preparer', $valeurs);
1272
-
1273
-	// fermer les tags img pas bien fermes;
1274
-	$tag = str_replace(">", "/>", str_replace("/>", ">", $valeurs['tag']));
1275
-
1276
-	// le style
1277
-	$style = $valeurs['style'];
1278
-	if (isset($surcharge['style'])) {
1279
-		$style = $surcharge['style'];
1280
-		unset($surcharge['style']);
1281
-	}
1282
-
1283
-	// traiter specifiquement la largeur et la hauteur
1284
-	$width = $valeurs['largeur'];
1285
-	if (isset($surcharge['width'])) {
1286
-		$width = $surcharge['width'];
1287
-		unset($surcharge['width']);
1288
-	}
1289
-	$height = $valeurs['hauteur'];
1290
-	if (isset($surcharge['height'])) {
1291
-		$height = $surcharge['height'];
1292
-		unset($surcharge['height']);
1293
-	}
1294
-
1295
-	$tag = _image_tag_changer_taille($tag, $width, $height, $style);
1296
-	// traiter specifiquement le src qui peut etre repris dans un onmouseout
1297
-	// on remplace toute les ref a src dans le tag
1298
-	$src = extraire_attribut($tag, 'src');
1299
-	if (isset($surcharge['src'])) {
1300
-		$tag = str_replace($src, $surcharge['src'], $tag);
1301
-		// si il y a des & dans src, alors ils peuvent provenir d'un &amp
1302
-		// pas garanti comme methode, mais mieux que rien
1303
-		if (strpos($src, '&') !== false) {
1304
-			$tag = str_replace(str_replace("&", "&amp;", $src), $surcharge['src'], $tag);
1305
-		}
1306
-		$src = $surcharge['src'];
1307
-		unset($surcharge['src']);
1308
-	}
1309
-
1310
-	$class = $valeurs['class'];
1311
-	if (isset($surcharge['class'])) {
1312
-		$class = $surcharge['class'];
1313
-		unset($surcharge['class']);
1314
-	}
1315
-	if (strlen($class)) {
1316
-		$tag = inserer_attribut($tag, 'class', $class);
1317
-	}
1318
-
1319
-	if (count($surcharge)) {
1320
-		foreach ($surcharge as $attribut => $valeur) {
1321
-			$tag = inserer_attribut($tag, $attribut, $valeur);
1322
-		}
1323
-	}
1324
-
1325
-	$tag = pipeline('image_ecrire_tag_finir',
1326
-		array(
1327
-			'args' => array(
1328
-				'valeurs' => $valeurs,
1329
-				'surcharge' => $surcharge,
1330
-			),
1331
-			'data' => $tag
1332
-		)
1333
-	);
1334
-
1335
-	return $tag;
1271
+    $valeurs = pipeline('image_ecrire_tag_preparer', $valeurs);
1272
+
1273
+    // fermer les tags img pas bien fermes;
1274
+    $tag = str_replace(">", "/>", str_replace("/>", ">", $valeurs['tag']));
1275
+
1276
+    // le style
1277
+    $style = $valeurs['style'];
1278
+    if (isset($surcharge['style'])) {
1279
+        $style = $surcharge['style'];
1280
+        unset($surcharge['style']);
1281
+    }
1282
+
1283
+    // traiter specifiquement la largeur et la hauteur
1284
+    $width = $valeurs['largeur'];
1285
+    if (isset($surcharge['width'])) {
1286
+        $width = $surcharge['width'];
1287
+        unset($surcharge['width']);
1288
+    }
1289
+    $height = $valeurs['hauteur'];
1290
+    if (isset($surcharge['height'])) {
1291
+        $height = $surcharge['height'];
1292
+        unset($surcharge['height']);
1293
+    }
1294
+
1295
+    $tag = _image_tag_changer_taille($tag, $width, $height, $style);
1296
+    // traiter specifiquement le src qui peut etre repris dans un onmouseout
1297
+    // on remplace toute les ref a src dans le tag
1298
+    $src = extraire_attribut($tag, 'src');
1299
+    if (isset($surcharge['src'])) {
1300
+        $tag = str_replace($src, $surcharge['src'], $tag);
1301
+        // si il y a des & dans src, alors ils peuvent provenir d'un &amp
1302
+        // pas garanti comme methode, mais mieux que rien
1303
+        if (strpos($src, '&') !== false) {
1304
+            $tag = str_replace(str_replace("&", "&amp;", $src), $surcharge['src'], $tag);
1305
+        }
1306
+        $src = $surcharge['src'];
1307
+        unset($surcharge['src']);
1308
+    }
1309
+
1310
+    $class = $valeurs['class'];
1311
+    if (isset($surcharge['class'])) {
1312
+        $class = $surcharge['class'];
1313
+        unset($surcharge['class']);
1314
+    }
1315
+    if (strlen($class)) {
1316
+        $tag = inserer_attribut($tag, 'class', $class);
1317
+    }
1318
+
1319
+    if (count($surcharge)) {
1320
+        foreach ($surcharge as $attribut => $valeur) {
1321
+            $tag = inserer_attribut($tag, $attribut, $valeur);
1322
+        }
1323
+    }
1324
+
1325
+    $tag = pipeline('image_ecrire_tag_finir',
1326
+        array(
1327
+            'args' => array(
1328
+                'valeurs' => $valeurs,
1329
+                'surcharge' => $surcharge,
1330
+            ),
1331
+            'data' => $tag
1332
+        )
1333
+    );
1334
+
1335
+    return $tag;
1336 1336
 }
1337 1337
 
1338 1338
 /**
@@ -1355,253 +1355,253 @@  discard block
 block discarded – undo
1355 1355
  *     Description de l'image, sinon null.
1356 1356
  **/
1357 1357
 function _image_creer_vignette($valeurs, $maxWidth, $maxHeight, $process = 'AUTO', $force = false) {
1358
-	// ordre de preference des formats graphiques pour creer les vignettes
1359
-	// le premier format disponible, selon la methode demandee, est utilise
1360
-	$image = $valeurs['fichier'];
1361
-	$format = $valeurs['format_source'];
1362
-	$destdir = dirname($valeurs['fichier_dest']);
1363
-	$destfile = basename($valeurs['fichier_dest'], "." . $valeurs["format_dest"]);
1364
-
1365
-	$format_sortie = $valeurs['format_dest'];
1366
-
1367
-	if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1368
-		$process = $GLOBALS['meta']['image_process'];
1369
-	}
1370
-
1371
-	// si le doc n'est pas une image dans un format accetpable, refuser
1372
-	if (!$force and !in_array($format, formats_image_acceptables(in_array($process, ['gd1', 'gd2'])))) {
1373
-		return;
1374
-	}
1375
-	$destination = "$destdir/$destfile";
1376
-
1377
-	// calculer la taille
1378
-	if (($srcWidth = $valeurs['largeur']) && ($srcHeight = $valeurs['hauteur'])) {
1379
-		if (!($destWidth = $valeurs['largeur_dest']) || !($destHeight = $valeurs['hauteur_dest'])) {
1380
-			list($destWidth, $destHeight) = _image_ratio($valeurs['largeur'], $valeurs['hauteur'], $maxWidth, $maxHeight);
1381
-		}
1382
-	} elseif ($process == 'convert' or $process == 'imagick') {
1383
-		$destWidth = $maxWidth;
1384
-		$destHeight = $maxHeight;
1385
-	} else {
1386
-		spip_log("echec $process sur $image");
1387
-
1388
-		return;
1389
-	}
1390
-
1391
-	$vignette = '';
1392
-
1393
-	// Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1394
-	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1395
-		$vignette = $destination . '.' . $format;
1396
-		@copy($image, $vignette);
1397
-	}
1398
-
1399
-	elseif ($valeurs["format_source"] === 'svg') {
1400
-		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)){
1401
-			$format_sortie = 'svg';
1402
-			$vignette = $destination . "." . $format_sortie;
1403
-			$valeurs['fichier_dest'] = $vignette;
1404
-			_image_gd_output($svg, $valeurs);
1405
-		}
1406
-	}
1407
-
1408
-	// imagemagick en ligne de commande
1409
-	elseif ($process == 'convert') {
1410
-		if (!defined('_CONVERT_COMMAND')) {
1411
-			define('_CONVERT_COMMAND', 'convert');
1412
-		} // Securite : mes_options.php peut preciser le chemin absolu
1413
-		if (!defined('_RESIZE_COMMAND')) {
1414
-			define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1415
-		}
1416
-		$vignette = $destination . "." . $format_sortie;
1417
-		$commande = str_replace(
1418
-			array('%x', '%y', '%src', '%dest'),
1419
-			array(
1420
-				$destWidth,
1421
-				$destHeight,
1422
-				escapeshellcmd($image),
1423
-				escapeshellcmd($vignette)
1424
-			),
1425
-			_RESIZE_COMMAND);
1426
-		spip_log($commande);
1427
-		exec($commande);
1428
-		if (!@file_exists($vignette)) {
1429
-			spip_log("echec convert sur $vignette");
1430
-
1431
-			return;  // echec commande
1432
-		}
1433
-	}
1434
-
1435
-	// php5 imagemagick
1436
-	elseif ($process == 'imagick') {
1437
-		$vignette = "$destination." . $format_sortie;
1438
-
1439
-		if (!class_exists('Imagick')) {
1440
-			spip_log("Classe Imagick absente !", _LOG_ERREUR);
1441
-
1442
-			return;
1443
-		}
1444
-		$imagick = new Imagick();
1445
-		$imagick->readImage($image);
1446
-		$imagick->resizeImage($destWidth, $destHeight, Imagick::FILTER_LANCZOS,
1447
-			1);//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1448
-		$imagick->writeImage($vignette);
1449
-
1450
-		if (!@file_exists($vignette)) {
1451
-			spip_log("echec imagick sur $vignette");
1452
-
1453
-			return;
1454
-		}
1455
-	}
1456
-
1457
-	// netpbm
1458
-	elseif ($process == "netpbm") {
1459
-		if (!defined('_PNMSCALE_COMMAND')) {
1460
-			define('_PNMSCALE_COMMAND', 'pnmscale');
1461
-		} // Securite : mes_options.php peut preciser le chemin absolu
1462
-		if (_PNMSCALE_COMMAND == '') {
1463
-			return;
1464
-		}
1465
-		$vignette = $destination . "." . $format_sortie;
1466
-		$pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND);
1467
-		if ($format == "jpg") {
1468
-
1469
-			$jpegtopnm_command = str_replace("pnmscale", "jpegtopnm", _PNMSCALE_COMMAND);
1470
-			exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1471
-			if (!($s = @filesize($vignette))) {
1472
-				spip_unlink($vignette);
1473
-			}
1474
-			if (!@file_exists($vignette)) {
1475
-				spip_log("echec netpbm-jpg sur $vignette");
1476
-
1477
-				return;
1478
-			}
1479
-		} else {
1480
-			if ($format == "gif") {
1481
-				$giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND);
1482
-				exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1483
-				if (!($s = @filesize($vignette))) {
1484
-					spip_unlink($vignette);
1485
-				}
1486
-				if (!@file_exists($vignette)) {
1487
-					spip_log("echec netpbm-gif sur $vignette");
1488
-
1489
-					return;
1490
-				}
1491
-			} else {
1492
-				if ($format == "png") {
1493
-					$pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND);
1494
-					exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1495
-					if (!($s = @filesize($vignette))) {
1496
-						spip_unlink($vignette);
1497
-					}
1498
-					if (!@file_exists($vignette)) {
1499
-						spip_log("echec netpbm-png sur $vignette");
1500
-
1501
-						return;
1502
-					}
1503
-				}
1504
-			}
1505
-		}
1506
-	}
1507
-
1508
-	// gd ou gd2
1509
-	elseif ($process == 'gd1' or $process == 'gd2') {
1510
-		if (!function_exists('gd_info')) {
1511
-			spip_log("Librairie GD absente !", _LOG_ERREUR);
1512
-
1513
-			return;
1514
-		}
1515
-		if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1516
-			spip_log("vignette gd1/gd2 impossible : " . $srcWidth * $srcHeight . "pixels");
1517
-
1518
-			return;
1519
-		}
1520
-		$destFormat = $format_sortie;
1521
-		if (!$destFormat) {
1522
-			spip_log("pas de format pour $image");
1523
-
1524
-			return;
1525
-		}
1526
-
1527
-		$fonction_imagecreatefrom = $valeurs['fonction_imagecreatefrom'];
1528
-		if (!function_exists($fonction_imagecreatefrom)) {
1529
-			return '';
1530
-		}
1531
-		$srcImage = @$fonction_imagecreatefrom($image);
1532
-		if (!$srcImage) {
1533
-			spip_log("echec gd1/gd2");
1534
-
1535
-			return;
1536
-		}
1537
-
1538
-		// Initialisation de l'image destination
1539
-		$destImage = null;
1540
-		if ($process == 'gd2' and $destFormat != "gif") {
1541
-			$destImage = ImageCreateTrueColor($destWidth, $destHeight);
1542
-		}
1543
-		if (!$destImage) {
1544
-			$destImage = ImageCreate($destWidth, $destHeight);
1545
-		}
1546
-
1547
-		// Recopie de l'image d'origine avec adaptation de la taille 
1548
-		$ok = false;
1549
-		if (($process == 'gd2') and function_exists('ImageCopyResampled')) {
1550
-			if ($format == "gif") {
1551
-				// Si un GIF est transparent, 
1552
-				// fabriquer un PNG transparent  
1553
-				$transp = imagecolortransparent($srcImage);
1554
-				if ($transp > 0) {
1555
-					$destFormat = "png";
1556
-				}
1557
-			}
1558
-			if (in_array($destFormat, _image_extensions_conservent_transparence())) {
1559
-				// Conserver la transparence 
1560
-				if (function_exists("imageAntiAlias")) {
1561
-					imageAntiAlias($destImage, true);
1562
-				}
1563
-				@imagealphablending($destImage, false);
1564
-				@imagesavealpha($destImage, true);
1565
-			}
1566
-			$ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1567
-		}
1568
-		if (!$ok) {
1569
-			$ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1570
-		}
1571
-
1572
-		// Sauvegarde de l'image destination
1573
-		$valeurs['fichier_dest'] = $vignette = "$destination.$destFormat";
1574
-		$valeurs['format_dest'] = $format = $destFormat;
1575
-		_image_gd_output($destImage, $valeurs);
1576
-
1577
-		if ($srcImage) {
1578
-			ImageDestroy($srcImage);
1579
-		}
1580
-		ImageDestroy($destImage);
1581
-	}
1582
-
1583
-	if (!$vignette or !$size = @spip_getimagesize($vignette)) {
1584
-		$size = array($destWidth, $destHeight);
1585
-	}
1586
-
1587
-	// Gaffe: en safe mode, pas d'acces a la vignette,
1588
-	// donc risque de balancer "width='0'", ce qui masque l'image sous MSIE
1589
-	if ($size[0] < 1) {
1590
-		$size[0] = $destWidth;
1591
-	}
1592
-	if ($size[1] < 1) {
1593
-		$size[1] = $destHeight;
1594
-	}
1595
-
1596
-	$retour['width'] = $largeur = $size[0];
1597
-	$retour['height'] = $hauteur = $size[1];
1598
-
1599
-	$retour['fichier'] = $vignette;
1600
-	$retour['format'] = $format;
1601
-	$retour['date'] = @filemtime($vignette);
1602
-
1603
-	// renvoyer l'image
1604
-	return $retour;
1358
+    // ordre de preference des formats graphiques pour creer les vignettes
1359
+    // le premier format disponible, selon la methode demandee, est utilise
1360
+    $image = $valeurs['fichier'];
1361
+    $format = $valeurs['format_source'];
1362
+    $destdir = dirname($valeurs['fichier_dest']);
1363
+    $destfile = basename($valeurs['fichier_dest'], "." . $valeurs["format_dest"]);
1364
+
1365
+    $format_sortie = $valeurs['format_dest'];
1366
+
1367
+    if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1368
+        $process = $GLOBALS['meta']['image_process'];
1369
+    }
1370
+
1371
+    // si le doc n'est pas une image dans un format accetpable, refuser
1372
+    if (!$force and !in_array($format, formats_image_acceptables(in_array($process, ['gd1', 'gd2'])))) {
1373
+        return;
1374
+    }
1375
+    $destination = "$destdir/$destfile";
1376
+
1377
+    // calculer la taille
1378
+    if (($srcWidth = $valeurs['largeur']) && ($srcHeight = $valeurs['hauteur'])) {
1379
+        if (!($destWidth = $valeurs['largeur_dest']) || !($destHeight = $valeurs['hauteur_dest'])) {
1380
+            list($destWidth, $destHeight) = _image_ratio($valeurs['largeur'], $valeurs['hauteur'], $maxWidth, $maxHeight);
1381
+        }
1382
+    } elseif ($process == 'convert' or $process == 'imagick') {
1383
+        $destWidth = $maxWidth;
1384
+        $destHeight = $maxHeight;
1385
+    } else {
1386
+        spip_log("echec $process sur $image");
1387
+
1388
+        return;
1389
+    }
1390
+
1391
+    $vignette = '';
1392
+
1393
+    // Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1394
+    if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1395
+        $vignette = $destination . '.' . $format;
1396
+        @copy($image, $vignette);
1397
+    }
1398
+
1399
+    elseif ($valeurs["format_source"] === 'svg') {
1400
+        if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)){
1401
+            $format_sortie = 'svg';
1402
+            $vignette = $destination . "." . $format_sortie;
1403
+            $valeurs['fichier_dest'] = $vignette;
1404
+            _image_gd_output($svg, $valeurs);
1405
+        }
1406
+    }
1407
+
1408
+    // imagemagick en ligne de commande
1409
+    elseif ($process == 'convert') {
1410
+        if (!defined('_CONVERT_COMMAND')) {
1411
+            define('_CONVERT_COMMAND', 'convert');
1412
+        } // Securite : mes_options.php peut preciser le chemin absolu
1413
+        if (!defined('_RESIZE_COMMAND')) {
1414
+            define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1415
+        }
1416
+        $vignette = $destination . "." . $format_sortie;
1417
+        $commande = str_replace(
1418
+            array('%x', '%y', '%src', '%dest'),
1419
+            array(
1420
+                $destWidth,
1421
+                $destHeight,
1422
+                escapeshellcmd($image),
1423
+                escapeshellcmd($vignette)
1424
+            ),
1425
+            _RESIZE_COMMAND);
1426
+        spip_log($commande);
1427
+        exec($commande);
1428
+        if (!@file_exists($vignette)) {
1429
+            spip_log("echec convert sur $vignette");
1430
+
1431
+            return;  // echec commande
1432
+        }
1433
+    }
1434
+
1435
+    // php5 imagemagick
1436
+    elseif ($process == 'imagick') {
1437
+        $vignette = "$destination." . $format_sortie;
1438
+
1439
+        if (!class_exists('Imagick')) {
1440
+            spip_log("Classe Imagick absente !", _LOG_ERREUR);
1441
+
1442
+            return;
1443
+        }
1444
+        $imagick = new Imagick();
1445
+        $imagick->readImage($image);
1446
+        $imagick->resizeImage($destWidth, $destHeight, Imagick::FILTER_LANCZOS,
1447
+            1);//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1448
+        $imagick->writeImage($vignette);
1449
+
1450
+        if (!@file_exists($vignette)) {
1451
+            spip_log("echec imagick sur $vignette");
1452
+
1453
+            return;
1454
+        }
1455
+    }
1456
+
1457
+    // netpbm
1458
+    elseif ($process == "netpbm") {
1459
+        if (!defined('_PNMSCALE_COMMAND')) {
1460
+            define('_PNMSCALE_COMMAND', 'pnmscale');
1461
+        } // Securite : mes_options.php peut preciser le chemin absolu
1462
+        if (_PNMSCALE_COMMAND == '') {
1463
+            return;
1464
+        }
1465
+        $vignette = $destination . "." . $format_sortie;
1466
+        $pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND);
1467
+        if ($format == "jpg") {
1468
+
1469
+            $jpegtopnm_command = str_replace("pnmscale", "jpegtopnm", _PNMSCALE_COMMAND);
1470
+            exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1471
+            if (!($s = @filesize($vignette))) {
1472
+                spip_unlink($vignette);
1473
+            }
1474
+            if (!@file_exists($vignette)) {
1475
+                spip_log("echec netpbm-jpg sur $vignette");
1476
+
1477
+                return;
1478
+            }
1479
+        } else {
1480
+            if ($format == "gif") {
1481
+                $giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND);
1482
+                exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1483
+                if (!($s = @filesize($vignette))) {
1484
+                    spip_unlink($vignette);
1485
+                }
1486
+                if (!@file_exists($vignette)) {
1487
+                    spip_log("echec netpbm-gif sur $vignette");
1488
+
1489
+                    return;
1490
+                }
1491
+            } else {
1492
+                if ($format == "png") {
1493
+                    $pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND);
1494
+                    exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1495
+                    if (!($s = @filesize($vignette))) {
1496
+                        spip_unlink($vignette);
1497
+                    }
1498
+                    if (!@file_exists($vignette)) {
1499
+                        spip_log("echec netpbm-png sur $vignette");
1500
+
1501
+                        return;
1502
+                    }
1503
+                }
1504
+            }
1505
+        }
1506
+    }
1507
+
1508
+    // gd ou gd2
1509
+    elseif ($process == 'gd1' or $process == 'gd2') {
1510
+        if (!function_exists('gd_info')) {
1511
+            spip_log("Librairie GD absente !", _LOG_ERREUR);
1512
+
1513
+            return;
1514
+        }
1515
+        if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1516
+            spip_log("vignette gd1/gd2 impossible : " . $srcWidth * $srcHeight . "pixels");
1517
+
1518
+            return;
1519
+        }
1520
+        $destFormat = $format_sortie;
1521
+        if (!$destFormat) {
1522
+            spip_log("pas de format pour $image");
1523
+
1524
+            return;
1525
+        }
1526
+
1527
+        $fonction_imagecreatefrom = $valeurs['fonction_imagecreatefrom'];
1528
+        if (!function_exists($fonction_imagecreatefrom)) {
1529
+            return '';
1530
+        }
1531
+        $srcImage = @$fonction_imagecreatefrom($image);
1532
+        if (!$srcImage) {
1533
+            spip_log("echec gd1/gd2");
1534
+
1535
+            return;
1536
+        }
1537
+
1538
+        // Initialisation de l'image destination
1539
+        $destImage = null;
1540
+        if ($process == 'gd2' and $destFormat != "gif") {
1541
+            $destImage = ImageCreateTrueColor($destWidth, $destHeight);
1542
+        }
1543
+        if (!$destImage) {
1544
+            $destImage = ImageCreate($destWidth, $destHeight);
1545
+        }
1546
+
1547
+        // Recopie de l'image d'origine avec adaptation de la taille 
1548
+        $ok = false;
1549
+        if (($process == 'gd2') and function_exists('ImageCopyResampled')) {
1550
+            if ($format == "gif") {
1551
+                // Si un GIF est transparent, 
1552
+                // fabriquer un PNG transparent  
1553
+                $transp = imagecolortransparent($srcImage);
1554
+                if ($transp > 0) {
1555
+                    $destFormat = "png";
1556
+                }
1557
+            }
1558
+            if (in_array($destFormat, _image_extensions_conservent_transparence())) {
1559
+                // Conserver la transparence 
1560
+                if (function_exists("imageAntiAlias")) {
1561
+                    imageAntiAlias($destImage, true);
1562
+                }
1563
+                @imagealphablending($destImage, false);
1564
+                @imagesavealpha($destImage, true);
1565
+            }
1566
+            $ok = @ImageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1567
+        }
1568
+        if (!$ok) {
1569
+            $ok = ImageCopyResized($destImage, $srcImage, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight);
1570
+        }
1571
+
1572
+        // Sauvegarde de l'image destination
1573
+        $valeurs['fichier_dest'] = $vignette = "$destination.$destFormat";
1574
+        $valeurs['format_dest'] = $format = $destFormat;
1575
+        _image_gd_output($destImage, $valeurs);
1576
+
1577
+        if ($srcImage) {
1578
+            ImageDestroy($srcImage);
1579
+        }
1580
+        ImageDestroy($destImage);
1581
+    }
1582
+
1583
+    if (!$vignette or !$size = @spip_getimagesize($vignette)) {
1584
+        $size = array($destWidth, $destHeight);
1585
+    }
1586
+
1587
+    // Gaffe: en safe mode, pas d'acces a la vignette,
1588
+    // donc risque de balancer "width='0'", ce qui masque l'image sous MSIE
1589
+    if ($size[0] < 1) {
1590
+        $size[0] = $destWidth;
1591
+    }
1592
+    if ($size[1] < 1) {
1593
+        $size[1] = $destHeight;
1594
+    }
1595
+
1596
+    $retour['width'] = $largeur = $size[0];
1597
+    $retour['height'] = $hauteur = $size[1];
1598
+
1599
+    $retour['fichier'] = $vignette;
1600
+    $retour['format'] = $format;
1601
+    $retour['date'] = @filemtime($vignette);
1602
+
1603
+    // renvoyer l'image
1604
+    return $retour;
1605 1605
 }
1606 1606
 
1607 1607
 /**
@@ -1621,25 +1621,25 @@  discard block
 block discarded – undo
1621 1621
  * @return array Liste [ largeur, hauteur, ratio de réduction ]
1622 1622
  **/
1623 1623
 function _image_ratio($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1624
-	$ratioWidth = $srcWidth / $maxWidth;
1625
-	$ratioHeight = $srcHeight / $maxHeight;
1626
-
1627
-	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1628
-		$destWidth = $srcWidth;
1629
-		$destHeight = $srcHeight;
1630
-	} elseif ($ratioWidth < $ratioHeight) {
1631
-		$destWidth = $srcWidth / $ratioHeight;
1632
-		$destHeight = $maxHeight;
1633
-	} else {
1634
-		$destWidth = $maxWidth;
1635
-		$destHeight = $srcHeight / $ratioWidth;
1636
-	}
1637
-
1638
-	return array(
1639
-		intval(round($destWidth)),
1640
-		intval(round($destHeight)),
1641
-		max($ratioWidth, $ratioHeight)
1642
-	);
1624
+    $ratioWidth = $srcWidth / $maxWidth;
1625
+    $ratioHeight = $srcHeight / $maxHeight;
1626
+
1627
+    if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1628
+        $destWidth = $srcWidth;
1629
+        $destHeight = $srcHeight;
1630
+    } elseif ($ratioWidth < $ratioHeight) {
1631
+        $destWidth = $srcWidth / $ratioHeight;
1632
+        $destHeight = $maxHeight;
1633
+    } else {
1634
+        $destWidth = $maxWidth;
1635
+        $destHeight = $srcHeight / $ratioWidth;
1636
+    }
1637
+
1638
+    return array(
1639
+        intval(round($destWidth)),
1640
+        intval(round($destHeight)),
1641
+        max($ratioWidth, $ratioHeight)
1642
+    );
1643 1643
 }
1644 1644
 
1645 1645
 /**
@@ -1659,25 +1659,25 @@  discard block
 block discarded – undo
1659 1659
  * @return array Liste [ largeur, hauteur, ratio de réduction ]
1660 1660
  **/
1661 1661
 function ratio_passe_partout($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
1662
-	$ratioWidth = $srcWidth / $maxWidth;
1663
-	$ratioHeight = $srcHeight / $maxHeight;
1664
-
1665
-	if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1666
-		$destWidth = $srcWidth;
1667
-		$destHeight = $srcHeight;
1668
-	} elseif ($ratioWidth > $ratioHeight) {
1669
-		$destWidth = $srcWidth / $ratioHeight;
1670
-		$destHeight = $maxHeight;
1671
-	} else {
1672
-		$destWidth = $maxWidth;
1673
-		$destHeight = $srcHeight / $ratioWidth;
1674
-	}
1675
-
1676
-	return array(
1677
-		intval(round($destWidth)),
1678
-		intval(round($destHeight)),
1679
-		min($ratioWidth, $ratioHeight)
1680
-	);
1662
+    $ratioWidth = $srcWidth / $maxWidth;
1663
+    $ratioHeight = $srcHeight / $maxHeight;
1664
+
1665
+    if ($srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1666
+        $destWidth = $srcWidth;
1667
+        $destHeight = $srcHeight;
1668
+    } elseif ($ratioWidth > $ratioHeight) {
1669
+        $destWidth = $srcWidth / $ratioHeight;
1670
+        $destHeight = $maxHeight;
1671
+    } else {
1672
+        $destWidth = $maxWidth;
1673
+        $destHeight = $srcHeight / $ratioWidth;
1674
+    }
1675
+
1676
+    return array(
1677
+        intval(round($destWidth)),
1678
+        intval(round($destHeight)),
1679
+        min($ratioWidth, $ratioHeight)
1680
+    );
1681 1681
 }
1682 1682
 
1683 1683
 
@@ -1690,12 +1690,12 @@  discard block
 block discarded – undo
1690 1690
  * @return string
1691 1691
  */
1692 1692
 function process_image_svg_identite($image) {
1693
-	if ($image['creer']) {
1694
-		$source = $image['fichier'];
1695
-		_image_gd_output($source, $image);
1696
-	}
1693
+    if ($image['creer']) {
1694
+        $source = $image['fichier'];
1695
+        _image_gd_output($source, $image);
1696
+    }
1697 1697
 
1698
-	return _image_ecrire_tag($image, array('src' => $image['fichier_dest']));
1698
+    return _image_ecrire_tag($image, array('src' => $image['fichier_dest']));
1699 1699
 }
1700 1700
 
1701 1701
 
@@ -1728,104 +1728,104 @@  discard block
 block discarded – undo
1728 1728
  *     Code HTML de la balise img produite
1729 1729
  **/
1730 1730
 function process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process = 'AUTO') {
1731
-	$image = false;
1732
-	if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1733
-		$process = $GLOBALS['meta']['image_process'];
1734
-	}
1735
-	# determiner le format de sortie
1736
-	$format_sortie = false; // le choix par defaut sera bon
1737
-	if ($process == "netpbm") {
1738
-		$format_sortie = "jpg";
1739
-	} elseif ($process == 'gd1' or $process == 'gd2') {
1740
-		$image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1741
-		// on verifie que l'extension choisie est bonne (en principe oui)
1742
-		$gd_formats = formats_image_acceptables(true);
1743
-		if (is_array($image)
1744
-			and (!in_array($image['format_dest'], $gd_formats)
1745
-				or (!in_array($image['format_dest'], _image_extensions_acceptees_en_sortie()))
1746
-			)
1747
-		) {
1748
-			if ($image['format_source'] == 'jpg') {
1749
-				$formats_sortie = array('jpg', 'png', 'gif');
1750
-			} else // les gif sont passes en png preferentiellement pour etre homogene aux autres filtres images
1751
-			{
1752
-				$formats_sortie = array('png', 'jpg', 'gif');
1753
-			}
1754
-			// Choisir le format destination
1755
-			// - on sauve de preference en JPEG (meilleure compression)
1756
-			// - pour le GIF : les GD recentes peuvent le lire mais pas l'ecrire
1757
-			# bug : gd_formats contient la liste des fichiers qu'on sait *lire*,
1758
-			# pas *ecrire*
1759
-			$format_sortie = "";
1760
-			foreach ($formats_sortie as $fmt) {
1761
-				if (in_array($fmt, $gd_formats) and in_array($fmt, _image_extensions_acceptees_en_sortie())) {
1762
-					$format_sortie = $fmt;
1763
-					break;
1764
-				}
1765
-			}
1766
-			$image = false;
1767
-		}
1768
-	}
1769
-
1770
-	if (!is_array($image)) {
1771
-		$image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1772
-	}
1773
-
1774
-	if (!is_array($image) or !$image['largeur'] or !$image['hauteur']) {
1775
-		spip_log("image_reduire_src:pas de version locale de $img");
1776
-		// on peut resizer en mode html si on dispose des elements
1777
-		if ($srcw = extraire_attribut($img, 'width')
1778
-			and $srch = extraire_attribut($img, 'height')
1779
-		) {
1780
-			list($w, $h) = _image_ratio($srcw, $srch, $taille, $taille_y);
1781
-
1782
-			return _image_tag_changer_taille($img, $w, $h);
1783
-		}
1784
-		// la on n'a pas d'infos sur l'image source... on refile le truc a css
1785
-		// sous la forme style='max-width: NNpx;'
1786
-		return inserer_attribut($img, 'style',
1787
-			"max-width: ${taille}px; max-height: ${taille_y}px");
1788
-	}
1789
-
1790
-	// si l'image est plus petite que la cible retourner une copie cachee de l'image
1791
-	if (($image['largeur'] <= $taille) && ($image['hauteur'] <= $taille_y)) {
1792
-		if ($image['creer']) {
1793
-			@copy($image['fichier'], $image['fichier_dest']);
1794
-		}
1795
-
1796
-		return _image_ecrire_tag($image, array('src' => $image['fichier_dest']));
1797
-	}
1798
-
1799
-	if ($image['creer'] == false && !$force) {
1800
-		return _image_ecrire_tag($image,
1801
-			array('src' => $image['fichier_dest'], 'width' => $image['largeur_dest'], 'height' => $image['hauteur_dest']));
1802
-	}
1803
-
1804
-	if (in_array($image["format_source"], _image_extensions_acceptees_en_entree())) {
1805
-		$destWidth = $image['largeur_dest'];
1806
-		$destHeight = $image['hauteur_dest'];
1807
-		$logo = $image['fichier'];
1808
-		$date = $image["date_src"];
1809
-		$preview = _image_creer_vignette($image, $taille, $taille_y, $process, $force);
1810
-
1811
-		if ($preview && $preview['fichier']) {
1812
-			$logo = $preview['fichier'];
1813
-			$destWidth = $preview['width'];
1814
-			$destHeight = $preview['height'];
1815
-			$date = $preview['date'];
1816
-		}
1817
-		// dans l'espace prive mettre un timestamp sur l'adresse 
1818
-		// de l'image, de facon a tromper le cache du navigateur
1819
-		// quand on fait supprimer/reuploader un logo
1820
-		// (pas de filemtime si SAFE MODE)
1821
-		$date = test_espace_prive() ? ('?' . $date) : '';
1822
-
1823
-		return _image_ecrire_tag($image, array('src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight));
1824
-	}
1825
-	else {
1826
-		# BMP, tiff ... les redacteurs osent tout!
1827
-		return $img;
1828
-	}
1731
+    $image = false;
1732
+    if (($process == 'AUTO') and isset($GLOBALS['meta']['image_process'])) {
1733
+        $process = $GLOBALS['meta']['image_process'];
1734
+    }
1735
+    # determiner le format de sortie
1736
+    $format_sortie = false; // le choix par defaut sera bon
1737
+    if ($process == "netpbm") {
1738
+        $format_sortie = "jpg";
1739
+    } elseif ($process == 'gd1' or $process == 'gd2') {
1740
+        $image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1741
+        // on verifie que l'extension choisie est bonne (en principe oui)
1742
+        $gd_formats = formats_image_acceptables(true);
1743
+        if (is_array($image)
1744
+            and (!in_array($image['format_dest'], $gd_formats)
1745
+                or (!in_array($image['format_dest'], _image_extensions_acceptees_en_sortie()))
1746
+            )
1747
+        ) {
1748
+            if ($image['format_source'] == 'jpg') {
1749
+                $formats_sortie = array('jpg', 'png', 'gif');
1750
+            } else // les gif sont passes en png preferentiellement pour etre homogene aux autres filtres images
1751
+            {
1752
+                $formats_sortie = array('png', 'jpg', 'gif');
1753
+            }
1754
+            // Choisir le format destination
1755
+            // - on sauve de preference en JPEG (meilleure compression)
1756
+            // - pour le GIF : les GD recentes peuvent le lire mais pas l'ecrire
1757
+            # bug : gd_formats contient la liste des fichiers qu'on sait *lire*,
1758
+            # pas *ecrire*
1759
+            $format_sortie = "";
1760
+            foreach ($formats_sortie as $fmt) {
1761
+                if (in_array($fmt, $gd_formats) and in_array($fmt, _image_extensions_acceptees_en_sortie())) {
1762
+                    $format_sortie = $fmt;
1763
+                    break;
1764
+                }
1765
+            }
1766
+            $image = false;
1767
+        }
1768
+    }
1769
+
1770
+    if (!is_array($image)) {
1771
+        $image = _image_valeurs_trans($img, "reduire-{$taille}-{$taille_y}", $format_sortie, $fonction, false, _SVG_SUPPORTED);
1772
+    }
1773
+
1774
+    if (!is_array($image) or !$image['largeur'] or !$image['hauteur']) {
1775
+        spip_log("image_reduire_src:pas de version locale de $img");
1776
+        // on peut resizer en mode html si on dispose des elements
1777
+        if ($srcw = extraire_attribut($img, 'width')
1778
+            and $srch = extraire_attribut($img, 'height')
1779
+        ) {
1780
+            list($w, $h) = _image_ratio($srcw, $srch, $taille, $taille_y);
1781
+
1782
+            return _image_tag_changer_taille($img, $w, $h);
1783
+        }
1784
+        // la on n'a pas d'infos sur l'image source... on refile le truc a css
1785
+        // sous la forme style='max-width: NNpx;'
1786
+        return inserer_attribut($img, 'style',
1787
+            "max-width: ${taille}px; max-height: ${taille_y}px");
1788
+    }
1789
+
1790
+    // si l'image est plus petite que la cible retourner une copie cachee de l'image
1791
+    if (($image['largeur'] <= $taille) && ($image['hauteur'] <= $taille_y)) {
1792
+        if ($image['creer']) {
1793
+            @copy($image['fichier'], $image['fichier_dest']);
1794
+        }
1795
+
1796
+        return _image_ecrire_tag($image, array('src' => $image['fichier_dest']));
1797
+    }
1798
+
1799
+    if ($image['creer'] == false && !$force) {
1800
+        return _image_ecrire_tag($image,
1801
+            array('src' => $image['fichier_dest'], 'width' => $image['largeur_dest'], 'height' => $image['hauteur_dest']));
1802
+    }
1803
+
1804
+    if (in_array($image["format_source"], _image_extensions_acceptees_en_entree())) {
1805
+        $destWidth = $image['largeur_dest'];
1806
+        $destHeight = $image['hauteur_dest'];
1807
+        $logo = $image['fichier'];
1808
+        $date = $image["date_src"];
1809
+        $preview = _image_creer_vignette($image, $taille, $taille_y, $process, $force);
1810
+
1811
+        if ($preview && $preview['fichier']) {
1812
+            $logo = $preview['fichier'];
1813
+            $destWidth = $preview['width'];
1814
+            $destHeight = $preview['height'];
1815
+            $date = $preview['date'];
1816
+        }
1817
+        // dans l'espace prive mettre un timestamp sur l'adresse 
1818
+        // de l'image, de facon a tromper le cache du navigateur
1819
+        // quand on fait supprimer/reuploader un logo
1820
+        // (pas de filemtime si SAFE MODE)
1821
+        $date = test_espace_prive() ? ('?' . $date) : '';
1822
+
1823
+        return _image_ecrire_tag($image, array('src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight));
1824
+    }
1825
+    else {
1826
+        # BMP, tiff ... les redacteurs osent tout!
1827
+        return $img;
1828
+    }
1829 1829
 }
1830 1830
 
1831 1831
 /**
@@ -1840,144 +1840,144 @@  discard block
 block discarded – undo
1840 1840
  */
1841 1841
 class phpthumb_functions {
1842 1842
 
1843
-	/**
1844
-	 * Retourne la couleur d'un pixel dans une image
1845
-	 *
1846
-	 * @param ressource $img
1847
-	 * @param int $x
1848
-	 * @param int $y
1849
-	 * @return array|bool
1850
-	 */
1851
-	public static function GetPixelColor(&$img, $x, $y) {
1852
-		if (is_resource($img) || (is_object($img) && $img instanceof \GdImage)) {
1853
-			return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
1854
-		}
1855
-		return false;
1856
-	}
1857
-
1858
-	/**
1859
-	 * Retourne un nombre dans une représentation en Little Endian
1860
-	 *
1861
-	 * @param int $number
1862
-	 * @param int $minbytes
1863
-	 * @return string
1864
-	 */
1865
-	public static function LittleEndian2String($number, $minbytes = 1) {
1866
-		$intstring = '';
1867
-		while ($number > 0) {
1868
-			$intstring = $intstring . chr($number & 255);
1869
-			$number >>= 8;
1870
-		}
1871
-
1872
-		return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
1873
-	}
1874
-
1875
-	/**
1876
-	 * Transforme une ressource GD en image au format ICO
1877
-	 *
1878
-	 * @param array $gd_image_array
1879
-	 *     Tableau de ressources d'images GD
1880
-	 * @return string
1881
-	 *     Image au format ICO
1882
-	 */
1883
-	public static function GD2ICOstring(&$gd_image_array) {
1884
-		foreach ($gd_image_array as $key => $gd_image) {
1885
-
1886
-			$ImageWidths[$key] = ImageSX($gd_image);
1887
-			$ImageHeights[$key] = ImageSY($gd_image);
1888
-			$bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
1889
-			$totalcolors[$key] = ImageColorsTotal($gd_image);
1890
-
1891
-			$icXOR[$key] = '';
1892
-			for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
1893
-				for ($x = 0; $x < $ImageWidths[$key]; $x++) {
1894
-					$argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
1895
-					$a = round(255 * ((127 - $argb['alpha']) / 127));
1896
-					$r = $argb['red'];
1897
-					$g = $argb['green'];
1898
-					$b = $argb['blue'];
1899
-
1900
-					if ($bpp[$key] == 32) {
1901
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1902
-					} elseif ($bpp[$key] == 24) {
1903
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r);
1904
-					}
1905
-
1906
-					if ($a < 128) {
1907
-						@$icANDmask[$key][$y] .= '1';
1908
-					} else {
1909
-						@$icANDmask[$key][$y] .= '0';
1910
-					}
1911
-				}
1912
-				// mask bits are 32-bit aligned per scanline
1913
-				while (strlen($icANDmask[$key][$y]) % 32) {
1914
-					$icANDmask[$key][$y] .= '0';
1915
-				}
1916
-			}
1917
-			$icAND[$key] = '';
1918
-			foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
1919
-				for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
1920
-					$icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
1921
-				}
1922
-			}
1923
-
1924
-		}
1925
-
1926
-		foreach ($gd_image_array as $key => $gd_image) {
1927
-			$biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
1928
-
1929
-			// BITMAPINFOHEADER - 40 bytes
1930
-			$BitmapInfoHeader[$key] = '';
1931
-			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1932
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1933
-			// The biHeight member specifies the combined
1934
-			// height of the XOR and AND masks.
1935
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1936
-			$BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1937
-			$BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1938
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1939
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1940
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1941
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1942
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1943
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1944
-		}
1945
-
1946
-
1947
-		$icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1948
-		$icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1949
-		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1950
-
1951
-		$dwImageOffset = 6 + (count($gd_image_array) * 16);
1952
-		foreach ($gd_image_array as $key => $gd_image) {
1953
-			// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1954
-
1955
-			$icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1956
-			$icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1957
-			$icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1958
-			$icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1959
-
1960
-			$icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
1961
-			$icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1962
-
1963
-			$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
1964
-			$icondata .= phpthumb_functions::LittleEndian2String($dwBytesInRes,
1965
-				4);     // dwBytesInRes;	// How many bytes in this resource?
1966
-
1967
-			$icondata .= phpthumb_functions::LittleEndian2String($dwImageOffset,
1968
-				4);    // dwImageOffset;   // Where in the file is this image?
1969
-			$dwImageOffset += strlen($BitmapInfoHeader[$key]);
1970
-			$dwImageOffset += strlen($icXOR[$key]);
1971
-			$dwImageOffset += strlen($icAND[$key]);
1972
-		}
1973
-
1974
-		foreach ($gd_image_array as $key => $gd_image) {
1975
-			$icondata .= $BitmapInfoHeader[$key];
1976
-			$icondata .= $icXOR[$key];
1977
-			$icondata .= $icAND[$key];
1978
-		}
1979
-
1980
-		return $icondata;
1981
-	}
1843
+    /**
1844
+     * Retourne la couleur d'un pixel dans une image
1845
+     *
1846
+     * @param ressource $img
1847
+     * @param int $x
1848
+     * @param int $y
1849
+     * @return array|bool
1850
+     */
1851
+    public static function GetPixelColor(&$img, $x, $y) {
1852
+        if (is_resource($img) || (is_object($img) && $img instanceof \GdImage)) {
1853
+            return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
1854
+        }
1855
+        return false;
1856
+    }
1857
+
1858
+    /**
1859
+     * Retourne un nombre dans une représentation en Little Endian
1860
+     *
1861
+     * @param int $number
1862
+     * @param int $minbytes
1863
+     * @return string
1864
+     */
1865
+    public static function LittleEndian2String($number, $minbytes = 1) {
1866
+        $intstring = '';
1867
+        while ($number > 0) {
1868
+            $intstring = $intstring . chr($number & 255);
1869
+            $number >>= 8;
1870
+        }
1871
+
1872
+        return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
1873
+    }
1874
+
1875
+    /**
1876
+     * Transforme une ressource GD en image au format ICO
1877
+     *
1878
+     * @param array $gd_image_array
1879
+     *     Tableau de ressources d'images GD
1880
+     * @return string
1881
+     *     Image au format ICO
1882
+     */
1883
+    public static function GD2ICOstring(&$gd_image_array) {
1884
+        foreach ($gd_image_array as $key => $gd_image) {
1885
+
1886
+            $ImageWidths[$key] = ImageSX($gd_image);
1887
+            $ImageHeights[$key] = ImageSY($gd_image);
1888
+            $bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
1889
+            $totalcolors[$key] = ImageColorsTotal($gd_image);
1890
+
1891
+            $icXOR[$key] = '';
1892
+            for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
1893
+                for ($x = 0; $x < $ImageWidths[$key]; $x++) {
1894
+                    $argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
1895
+                    $a = round(255 * ((127 - $argb['alpha']) / 127));
1896
+                    $r = $argb['red'];
1897
+                    $g = $argb['green'];
1898
+                    $b = $argb['blue'];
1899
+
1900
+                    if ($bpp[$key] == 32) {
1901
+                        $icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1902
+                    } elseif ($bpp[$key] == 24) {
1903
+                        $icXOR[$key] .= chr($b) . chr($g) . chr($r);
1904
+                    }
1905
+
1906
+                    if ($a < 128) {
1907
+                        @$icANDmask[$key][$y] .= '1';
1908
+                    } else {
1909
+                        @$icANDmask[$key][$y] .= '0';
1910
+                    }
1911
+                }
1912
+                // mask bits are 32-bit aligned per scanline
1913
+                while (strlen($icANDmask[$key][$y]) % 32) {
1914
+                    $icANDmask[$key][$y] .= '0';
1915
+                }
1916
+            }
1917
+            $icAND[$key] = '';
1918
+            foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
1919
+                for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
1920
+                    $icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
1921
+                }
1922
+            }
1923
+
1924
+        }
1925
+
1926
+        foreach ($gd_image_array as $key => $gd_image) {
1927
+            $biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
1928
+
1929
+            // BITMAPINFOHEADER - 40 bytes
1930
+            $BitmapInfoHeader[$key] = '';
1931
+            $BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1932
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1933
+            // The biHeight member specifies the combined
1934
+            // height of the XOR and AND masks.
1935
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1936
+            $BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1937
+            $BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1938
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1939
+            $BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1940
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1941
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1942
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1943
+            $BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1944
+        }
1945
+
1946
+
1947
+        $icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1948
+        $icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1949
+        $icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1950
+
1951
+        $dwImageOffset = 6 + (count($gd_image_array) * 16);
1952
+        foreach ($gd_image_array as $key => $gd_image) {
1953
+            // ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1954
+
1955
+            $icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1956
+            $icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1957
+            $icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1958
+            $icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1959
+
1960
+            $icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
1961
+            $icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1962
+
1963
+            $dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
1964
+            $icondata .= phpthumb_functions::LittleEndian2String($dwBytesInRes,
1965
+                4);     // dwBytesInRes;	// How many bytes in this resource?
1966
+
1967
+            $icondata .= phpthumb_functions::LittleEndian2String($dwImageOffset,
1968
+                4);    // dwImageOffset;   // Where in the file is this image?
1969
+            $dwImageOffset += strlen($BitmapInfoHeader[$key]);
1970
+            $dwImageOffset += strlen($icXOR[$key]);
1971
+            $dwImageOffset += strlen($icAND[$key]);
1972
+        }
1973
+
1974
+        foreach ($gd_image_array as $key => $gd_image) {
1975
+            $icondata .= $BitmapInfoHeader[$key];
1976
+            $icondata .= $icXOR[$key];
1977
+            $icondata .= $icAND[$key];
1978
+        }
1979
+
1980
+        return $icondata;
1981
+    }
1982 1982
 
1983 1983
 }
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	$blue = dechex($blue);
45 45
 
46 46
 	if (strlen($red) == 1) {
47
-		$red = "0" . $red;
47
+		$red = "0".$red;
48 48
 	}
49 49
 	if (strlen($green) == 1) {
50
-		$green = "0" . $green;
50
+		$green = "0".$green;
51 51
 	}
52 52
 	if (strlen($blue) == 1) {
53
-		$blue = "0" . $blue;
53
+		$blue = "0".$blue;
54 54
 	}
55 55
 
56 56
 	return "$red$green$blue";
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	$couleur = couleur_html_to_hex($couleur);
69 69
 	$couleur = ltrim($couleur, '#');
70 70
 	if (strlen($couleur) === 3) {
71
-		$couleur = $couleur[0] . $couleur[0] . $couleur[1] . $couleur[1] . $couleur[2] . $couleur[2];
71
+		$couleur = $couleur[0].$couleur[0].$couleur[1].$couleur[1].$couleur[2].$couleur[2];
72 72
 	}
73 73
 	$retour = [];
74 74
 	$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
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 	  and $extension = _image_trouver_extension_depuis_mime("image/".$regs[1])
322 322
 		and in_array($extension, _image_extensions_acceptees_en_entree())
323 323
 	) {
324
-		$local = sous_repertoire(_DIR_VAR, 'image-data') . md5($regs[2]) . '.' . _image_extension_normalisee($extension);
324
+		$local = sous_repertoire(_DIR_VAR, 'image-data').md5($regs[2]).'.'._image_extension_normalisee($extension);
325 325
 		if (!file_exists($local)) {
326 326
 			ecrire_fichier($local, base64_decode($regs[2]));
327 327
 		}
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	// les protocoles web prennent au moins 3 lettres
336 336
 	if (tester_url_absolue($source)) {
337 337
 		include_spip('inc/distant');
338
-		$fichier = _DIR_RACINE . copie_locale($source);
338
+		$fichier = _DIR_RACINE.copie_locale($source);
339 339
 		if (!$fichier) {
340 340
 			return "";
341 341
 		}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
 	if ($forcer_format !== false
362 362
 		// 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
363
-		and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format,_image_extensions_acceptees_en_sortie()))) {
363
+		and ($terminaison_dest !== 'svg' or $support_svg or !in_array($forcer_format, _image_extensions_acceptees_en_sortie()))) {
364 364
 		$terminaison_dest = $forcer_format;
365 365
 	}
366 366
 
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
 			// on garde la terminaison initiale car image simplement copiee
423 423
 			// et on postfixe son nom avec un md5 du path
424 424
 			$terminaison_dest = $terminaison;
425
-			$fichier_dest .= '-' . substr(md5("$identifiant"), 0, 5);
425
+			$fichier_dest .= '-'.substr(md5("$identifiant"), 0, 5);
426 426
 		} else {
427
-			$fichier_dest .= '-' . substr(md5("$identifiant-$effet"), 0, 5);
427
+			$fichier_dest .= '-'.substr(md5("$identifiant-$effet"), 0, 5);
428 428
 		}
429 429
 		$cache = sous_repertoire(_DIR_VAR, $cache);
430 430
 		$cache = sous_repertoire($cache, $effet);
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		$fichier_dest = substr($fichier_dest, 2);
436 436
 	}
437 437
 
438
-	$fichier_dest = $cache . $fichier_dest . "." . $terminaison_dest;
438
+	$fichier_dest = $cache.$fichier_dest.".".$terminaison_dest;
439 439
 
440 440
 	$GLOBALS["images_calculees"][] = $fichier_dest;
441 441
 
@@ -471,14 +471,14 @@  discard block
 block discarded – undo
471 471
 	}
472 472
 
473 473
 	if ($creer) {
474
-		spip_log("filtre image " . ($fonction_creation ? reset($fonction_creation) : '') . "[$effet] sur $fichier",
475
-			"images" . _LOG_DEBUG);
474
+		spip_log("filtre image ".($fonction_creation ? reset($fonction_creation) : '')."[$effet] sur $fichier",
475
+			"images"._LOG_DEBUG);
476 476
 	}
477 477
 
478 478
 	$term_fonction = _image_trouver_extension_pertinente($fichier);
479
-	$ret["fonction_imagecreatefrom"] = "_imagecreatefrom" . $term_fonction;
479
+	$ret["fonction_imagecreatefrom"] = "_imagecreatefrom".$term_fonction;
480 480
 	$ret["fichier"] = $fichier;
481
-	$ret["fonction_image"] = "_image_image" . $terminaison_dest;
481
+	$ret["fonction_image"] = "_image_image".$terminaison_dest;
482 482
 	$ret["fichier_dest"] = $fichier_dest;
483 483
 	$ret["format_source"] = _image_extension_normalisee($terminaison);
484 484
 	$ret["format_dest"] = $terminaison_dest;
@@ -552,9 +552,9 @@  discard block
 block discarded – undo
552 552
 /**
553 553
  * @return array|string[]|null
554 554
  */
555
-function _image_extensions_acceptees_en_sortie(){
555
+function _image_extensions_acceptees_en_sortie() {
556 556
 	static $extensions = null;
557
-	if (empty($extensions)){
557
+	if (empty($extensions)) {
558 558
 		$extensions = _image_extensions_acceptees_en_entree();
559 559
 		$extensions = array_diff($extensions, ['jpeg']);
560 560
 		if (in_array('gif', $extensions) and !function_exists('imagegif')) {
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	return $extensions;
569 569
 }
570 570
 
571
-function _image_extension_normalisee($extension){
571
+function _image_extension_normalisee($extension) {
572 572
 	$extension = strtolower($extension);
573 573
 	if ($extension === 'jpeg') {
574 574
 		$extension = 'jpg';
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	return $extension;
577 577
 }
578 578
 
579
-function _image_extensions_conservent_transparence(){
579
+function _image_extensions_conservent_transparence() {
580 580
 	return ['png', 'webp'];
581 581
 }
582 582
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 
627 627
 	$_terminaison = _image_trouver_extension_depuis_mime($mime);
628 628
 	if ($_terminaison and $_terminaison !== $terminaison) {
629
-		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", "images." . _LOG_INFO_IMPORTANTE);
629
+		spip_log("Mauvaise extension du fichier : $path . Son type mime est : $mime", "images."._LOG_INFO_IMPORTANTE);
630 630
 		$terminaison = $_terminaison;
631 631
 	}
632 632
 	return $terminaison;
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	if (!function_exists('imagepng')) {
784 784
 		return false;
785 785
 	}
786
-	$tmp = $fichier . ".tmp";
786
+	$tmp = $fichier.".tmp";
787 787
 	$ret = imagepng($img, $tmp);
788 788
 	if (file_exists($tmp)) {
789 789
 		$taille_test = getimagesize($tmp);
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 	if (!function_exists('imagegif')) {
819 819
 		return false;
820 820
 	}
821
-	$tmp = $fichier . ".tmp";
821
+	$tmp = $fichier.".tmp";
822 822
 	$ret = imagegif($img, $tmp);
823 823
 	if (file_exists($tmp)) {
824 824
 		$taille_test = getimagesize($tmp);
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 	if (!function_exists('imagejpeg')) {
859 859
 		return false;
860 860
 	}
861
-	$tmp = $fichier . ".tmp";
861
+	$tmp = $fichier.".tmp";
862 862
 
863 863
 	// Enable interlancing
864 864
 	imageinterlace($img, true);
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 	if (!function_exists('imagewebp')) {
920 920
 		return false;
921 921
 	}
922
-	$tmp = $fichier . ".tmp";
922
+	$tmp = $fichier.".tmp";
923 923
 	$ret = imagewebp($img, $tmp, $qualite);
924 924
 	if (file_exists($tmp)) {
925 925
 		$taille_test = getimagesize($tmp);
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
  */
954 954
 function _image_imagesvg($img, $fichier) {
955 955
 
956
-	$tmp = $fichier . ".tmp";
956
+	$tmp = $fichier.".tmp";
957 957
 	if (strpos($img, "<") === false) {
958 958
 		$img = supprimer_timestamp($img);
959 959
 		if (!file_exists($img)) {
@@ -1010,13 +1010,13 @@  discard block
 block discarded – undo
1010 1010
  */
1011 1011
 function _image_gd_output($img, $valeurs, $qualite = _IMG_GD_QUALITE, $fonction = null) {
1012 1012
 	if (is_null($fonction)) {
1013
-		$fonction = "_image_image" . $valeurs['format_dest'];
1013
+		$fonction = "_image_image".$valeurs['format_dest'];
1014 1014
 	}
1015 1015
 	$ret = false;
1016 1016
 	#un flag pour reperer les images gravees
1017 1017
 	$lock =
1018 1018
 		!statut_effacer_images_temporaires('get') // si la fonction n'a pas ete activee, on grave tout
1019
-	or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'] . '.src'));
1019
+	or (@file_exists($valeurs['fichier_dest']) and !@file_exists($valeurs['fichier_dest'].'.src'));
1020 1020
 	if (
1021 1021
 		function_exists($fonction)
1022 1022
 		&& ($ret = $fonction($img, $valeurs['fichier_dest'], $qualite)) # on a reussi a creer l'image
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			// dans tous les cas mettre a jour la taille de l'image finale
1028 1028
 			list($valeurs["hauteur_dest"], $valeurs["largeur_dest"]) = taille_image($valeurs['fichier_dest']);
1029 1029
 			$valeurs['date'] = @filemtime($valeurs['fichier_dest']); // pour la retrouver apres disparition
1030
-			ecrire_fichier($valeurs['fichier_dest'] . '.src', serialize($valeurs), true);
1030
+			ecrire_fichier($valeurs['fichier_dest'].'.src', serialize($valeurs), true);
1031 1031
 		}
1032 1032
 	}
1033 1033
 
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 function reconstruire_image_intermediaire($fichier_manquant) {
1047 1047
 	$reconstruire = array();
1048 1048
 	$fichier = $fichier_manquant;
1049
-	while (strpos($fichier,"://")===false
1049
+	while (strpos($fichier, "://") === false
1050 1050
 		and !@file_exists($fichier)
1051 1051
 		and lire_fichier($src = "$fichier.src", $source)
1052 1052
 		and $valeurs = unserialize($source)
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
  *     Chemin du fichier d'image calculé
1084 1084
  **/
1085 1085
 function ramasse_miettes($fichier) {
1086
-	if (strpos($fichier,"://")!==false
1086
+	if (strpos($fichier, "://") !== false
1087 1087
 		or !lire_fichier($src = "$fichier.src", $source)
1088 1088
 		or !$valeurs = unserialize($source)
1089 1089
 	) {
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 	}
1140 1140
 	# si jamais le fichier final n'a pas ete calcule car suppose temporaire
1141 1141
 	# et qu'il ne s'agit pas d'une URL
1142
-	if (strpos($fichier,"://")===false and !@file_exists($fichier)) {
1142
+	if (strpos($fichier, "://") === false and !@file_exists($fichier)) {
1143 1143
 		reconstruire_image_intermediaire($fichier);
1144 1144
 	}
1145 1145
 	ramasse_miettes($fichier);
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 
1237 1237
 	// attributs deprecies. Transformer en CSS
1238 1238
 	if ($espace = extraire_attribut($tag, 'hspace')) {
1239
-		$style = "margin:${espace}px;" . $style;
1239
+		$style = "margin:${espace}px;".$style;
1240 1240
 		$tag = inserer_attribut($tag, 'hspace', '');
1241 1241
 	}
1242 1242
 
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 	$image = $valeurs['fichier'];
1361 1361
 	$format = $valeurs['format_source'];
1362 1362
 	$destdir = dirname($valeurs['fichier_dest']);
1363
-	$destfile = basename($valeurs['fichier_dest'], "." . $valeurs["format_dest"]);
1363
+	$destfile = basename($valeurs['fichier_dest'], ".".$valeurs["format_dest"]);
1364 1364
 
1365 1365
 	$format_sortie = $valeurs['format_dest'];
1366 1366
 
@@ -1392,14 +1392,14 @@  discard block
 block discarded – undo
1392 1392
 
1393 1393
 	// Si l'image est de la taille demandee (ou plus petite), simplement la retourner
1394 1394
 	if ($srcWidth and $srcWidth <= $maxWidth and $srcHeight <= $maxHeight) {
1395
-		$vignette = $destination . '.' . $format;
1395
+		$vignette = $destination.'.'.$format;
1396 1396
 		@copy($image, $vignette);
1397 1397
 	}
1398 1398
 
1399 1399
 	elseif ($valeurs["format_source"] === 'svg') {
1400
-		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)){
1400
+		if ($svg = svg_redimensionner($valeurs['fichier'], $destWidth, $destHeight)) {
1401 1401
 			$format_sortie = 'svg';
1402
-			$vignette = $destination . "." . $format_sortie;
1402
+			$vignette = $destination.".".$format_sortie;
1403 1403
 			$valeurs['fichier_dest'] = $vignette;
1404 1404
 			_image_gd_output($svg, $valeurs);
1405 1405
 		}
@@ -1411,9 +1411,9 @@  discard block
 block discarded – undo
1411 1411
 			define('_CONVERT_COMMAND', 'convert');
1412 1412
 		} // Securite : mes_options.php peut preciser le chemin absolu
1413 1413
 		if (!defined('_RESIZE_COMMAND')) {
1414
-			define('_RESIZE_COMMAND', _CONVERT_COMMAND . ' -quality ' . _IMG_CONVERT_QUALITE . ' -resize %xx%y! %src %dest');
1414
+			define('_RESIZE_COMMAND', _CONVERT_COMMAND.' -quality '._IMG_CONVERT_QUALITE.' -resize %xx%y! %src %dest');
1415 1415
 		}
1416
-		$vignette = $destination . "." . $format_sortie;
1416
+		$vignette = $destination.".".$format_sortie;
1417 1417
 		$commande = str_replace(
1418 1418
 			array('%x', '%y', '%src', '%dest'),
1419 1419
 			array(
@@ -1428,13 +1428,13 @@  discard block
 block discarded – undo
1428 1428
 		if (!@file_exists($vignette)) {
1429 1429
 			spip_log("echec convert sur $vignette");
1430 1430
 
1431
-			return;  // echec commande
1431
+			return; // echec commande
1432 1432
 		}
1433 1433
 	}
1434 1434
 
1435 1435
 	// php5 imagemagick
1436 1436
 	elseif ($process == 'imagick') {
1437
-		$vignette = "$destination." . $format_sortie;
1437
+		$vignette = "$destination.".$format_sortie;
1438 1438
 
1439 1439
 		if (!class_exists('Imagick')) {
1440 1440
 			spip_log("Classe Imagick absente !", _LOG_ERREUR);
@@ -1444,7 +1444,7 @@  discard block
 block discarded – undo
1444 1444
 		$imagick = new Imagick();
1445 1445
 		$imagick->readImage($image);
1446 1446
 		$imagick->resizeImage($destWidth, $destHeight, Imagick::FILTER_LANCZOS,
1447
-			1);//, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1447
+			1); //, IMAGICK_FILTER_LANCZOS, _IMG_IMAGICK_QUALITE / 100);
1448 1448
 		$imagick->writeImage($vignette);
1449 1449
 
1450 1450
 		if (!@file_exists($vignette)) {
@@ -1462,12 +1462,12 @@  discard block
 block discarded – undo
1462 1462
 		if (_PNMSCALE_COMMAND == '') {
1463 1463
 			return;
1464 1464
 		}
1465
-		$vignette = $destination . "." . $format_sortie;
1465
+		$vignette = $destination.".".$format_sortie;
1466 1466
 		$pnmtojpeg_command = str_replace("pnmscale", "pnmtojpeg", _PNMSCALE_COMMAND);
1467 1467
 		if ($format == "jpg") {
1468 1468
 
1469 1469
 			$jpegtopnm_command = str_replace("pnmscale", "jpegtopnm", _PNMSCALE_COMMAND);
1470
-			exec("$jpegtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1470
+			exec("$jpegtopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1471 1471
 			if (!($s = @filesize($vignette))) {
1472 1472
 				spip_unlink($vignette);
1473 1473
 			}
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
 		} else {
1480 1480
 			if ($format == "gif") {
1481 1481
 				$giftopnm_command = str_replace("pnmscale", "giftopnm", _PNMSCALE_COMMAND);
1482
-				exec("$giftopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1482
+				exec("$giftopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1483 1483
 				if (!($s = @filesize($vignette))) {
1484 1484
 					spip_unlink($vignette);
1485 1485
 				}
@@ -1491,7 +1491,7 @@  discard block
 block discarded – undo
1491 1491
 			} else {
1492 1492
 				if ($format == "png") {
1493 1493
 					$pngtopnm_command = str_replace("pnmscale", "pngtopnm", _PNMSCALE_COMMAND);
1494
-					exec("$pngtopnm_command $image | " . _PNMSCALE_COMMAND . " -width $destWidth | $pnmtojpeg_command > $vignette");
1494
+					exec("$pngtopnm_command $image | "._PNMSCALE_COMMAND." -width $destWidth | $pnmtojpeg_command > $vignette");
1495 1495
 					if (!($s = @filesize($vignette))) {
1496 1496
 						spip_unlink($vignette);
1497 1497
 					}
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
 			return;
1514 1514
 		}
1515 1515
 		if (_IMG_GD_MAX_PIXELS && $srcWidth * $srcHeight > _IMG_GD_MAX_PIXELS) {
1516
-			spip_log("vignette gd1/gd2 impossible : " . $srcWidth * $srcHeight . "pixels");
1516
+			spip_log("vignette gd1/gd2 impossible : ".$srcWidth * $srcHeight."pixels");
1517 1517
 
1518 1518
 			return;
1519 1519
 		}
@@ -1818,7 +1818,7 @@  discard block
 block discarded – undo
1818 1818
 		// de l'image, de facon a tromper le cache du navigateur
1819 1819
 		// quand on fait supprimer/reuploader un logo
1820 1820
 		// (pas de filemtime si SAFE MODE)
1821
-		$date = test_espace_prive() ? ('?' . $date) : '';
1821
+		$date = test_espace_prive() ? ('?'.$date) : '';
1822 1822
 
1823 1823
 		return _image_ecrire_tag($image, array('src' => "$logo$date", 'width' => $destWidth, 'height' => $destHeight));
1824 1824
 	}
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 	public static function LittleEndian2String($number, $minbytes = 1) {
1866 1866
 		$intstring = '';
1867 1867
 		while ($number > 0) {
1868
-			$intstring = $intstring . chr($number & 255);
1868
+			$intstring = $intstring.chr($number & 255);
1869 1869
 			$number >>= 8;
1870 1870
 		}
1871 1871
 
@@ -1898,9 +1898,9 @@  discard block
 block discarded – undo
1898 1898
 					$b = $argb['blue'];
1899 1899
 
1900 1900
 					if ($bpp[$key] == 32) {
1901
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r) . chr($a);
1901
+						$icXOR[$key] .= chr($b).chr($g).chr($r).chr($a);
1902 1902
 					} elseif ($bpp[$key] == 24) {
1903
-						$icXOR[$key] .= chr($b) . chr($g) . chr($r);
1903
+						$icXOR[$key] .= chr($b).chr($g).chr($r);
1904 1904
 					}
1905 1905
 
1906 1906
 					if ($a < 128) {
@@ -1928,44 +1928,44 @@  discard block
 block discarded – undo
1928 1928
 
1929 1929
 			// BITMAPINFOHEADER - 40 bytes
1930 1930
 			$BitmapInfoHeader[$key] = '';
1931
-			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00";                // DWORD  biSize;
1932
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4);    // LONG   biWidth;
1931
+			$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00"; // DWORD  biSize;
1932
+			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4); // LONG   biWidth;
1933 1933
 			// The biHeight member specifies the combined
1934 1934
 			// height of the XOR and AND masks.
1935 1935
 			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG   biHeight;
1936
-			$BitmapInfoHeader[$key] .= "\x01\x00";                    // WORD   biPlanes;
1937
-			$BitmapInfoHeader[$key] .= chr($bpp[$key]) . "\x00";              // wBitCount;
1938
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biCompression;
1939
-			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4);      // DWORD  biSizeImage;
1940
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biXPelsPerMeter;
1941
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // LONG   biYPelsPerMeter;
1942
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrUsed;
1943
-			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00";                // DWORD  biClrImportant;
1936
+			$BitmapInfoHeader[$key] .= "\x01\x00"; // WORD   biPlanes;
1937
+			$BitmapInfoHeader[$key] .= chr($bpp[$key])."\x00"; // wBitCount;
1938
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biCompression;
1939
+			$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4); // DWORD  biSizeImage;
1940
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG   biXPelsPerMeter;
1941
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG   biYPelsPerMeter;
1942
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biClrUsed;
1943
+			$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD  biClrImportant;
1944 1944
 		}
1945 1945
 
1946 1946
 
1947
-		$icondata = "\x00\x00";                    // idReserved;   // Reserved (must be 0)
1948
-		$icondata .= "\x01\x00";                    // idType;	   // Resource Type (1 for icons)
1949
-		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2);  // idCount;	  // How many images?
1947
+		$icondata = "\x00\x00"; // idReserved;   // Reserved (must be 0)
1948
+		$icondata .= "\x01\x00"; // idType;	   // Resource Type (1 for icons)
1949
+		$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2); // idCount;	  // How many images?
1950 1950
 
1951 1951
 		$dwImageOffset = 6 + (count($gd_image_array) * 16);
1952 1952
 		foreach ($gd_image_array as $key => $gd_image) {
1953 1953
 			// ICONDIRENTRY   idEntries[1]; // An entry for each image (idCount of 'em)
1954 1954
 
1955
-			$icondata .= chr($ImageWidths[$key]);           // bWidth;		  // Width, in pixels, of the image
1956
-			$icondata .= chr($ImageHeights[$key]);          // bHeight;		 // Height, in pixels, of the image
1957
-			$icondata .= chr($totalcolors[$key]);           // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1958
-			$icondata .= "\x00";                    // bReserved;	   // Reserved ( must be 0)
1955
+			$icondata .= chr($ImageWidths[$key]); // bWidth;		  // Width, in pixels, of the image
1956
+			$icondata .= chr($ImageHeights[$key]); // bHeight;		 // Height, in pixels, of the image
1957
+			$icondata .= chr($totalcolors[$key]); // bColorCount;	 // Number of colors in image (0 if >=8bpp)
1958
+			$icondata .= "\x00"; // bReserved;	   // Reserved ( must be 0)
1959 1959
 
1960
-			$icondata .= "\x01\x00";                  // wPlanes;		 // Color Planes
1961
-			$icondata .= chr($bpp[$key]) . "\x00";            // wBitCount;	   // Bits per pixel
1960
+			$icondata .= "\x01\x00"; // wPlanes;		 // Color Planes
1961
+			$icondata .= chr($bpp[$key])."\x00"; // wBitCount;	   // Bits per pixel
1962 1962
 
1963 1963
 			$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
1964 1964
 			$icondata .= phpthumb_functions::LittleEndian2String($dwBytesInRes,
1965
-				4);     // dwBytesInRes;	// How many bytes in this resource?
1965
+				4); // dwBytesInRes;	// How many bytes in this resource?
1966 1966
 
1967 1967
 			$icondata .= phpthumb_functions::LittleEndian2String($dwImageOffset,
1968
-				4);    // dwImageOffset;   // Where in the file is this image?
1968
+				4); // dwImageOffset;   // Where in the file is this image?
1969 1969
 			$dwImageOffset += strlen($BitmapInfoHeader[$key]);
1970 1970
 			$dwImageOffset += strlen($icXOR[$key]);
1971 1971
 			$dwImageOffset += strlen($icAND[$key]);
Please login to merge, or discard this patch.
ecrire/inc/filtres_images_mini.php 2 patches
Indentation   +307 added lines, -307 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_images_lib_mini'); // par precaution
24 24
 
@@ -31,161 +31,161 @@  discard block
 block discarded – undo
31 31
  *    Le code hexadécimal de la couleur (sans le #) ou le code couleur textuel si non trouvé
32 32
  */
33 33
 function couleur_html_to_hex($couleur) {
34
-	$couleurs_html = array(
35
-		'aliceblue' => 'F0F8FF',
36
-		'antiquewhite' => 'FAEBD7',
37
-		'aqua' => '00FFFF',
38
-		'aquamarine' => '7FFFD4',
39
-		'azure' => 'F0FFFF',
40
-		'beige' => 'F5F5DC',
41
-		'bisque' => 'FFE4C4',
42
-		'black' => '000000',
43
-		'blanchedalmond' => 'FFEBCD',
44
-		'blue' => '0000FF',
45
-		'blueviolet' => '8A2BE2',
46
-		'brown' => 'A52A2A',
47
-		'burlywood' => 'DEB887',
48
-		'cadetblue' => '5F9EA0',
49
-		'chartreuse' => '7FFF00',
50
-		'chocolate' => 'D2691E',
51
-		'coral' => 'FF7F50',
52
-		'cornflowerblue' => '6495ED',
53
-		'cornsilk' => 'FFF8DC',
54
-		'crimson' => 'DC143C',
55
-		'cyan' => '00FFFF',
56
-		'darkblue' => '00008B',
57
-		'darkcyan' => '008B8B',
58
-		'darkgoldenrod' => 'B8860B',
59
-		'darkgray' => 'A9A9A9',
60
-		'darkgreen' => '006400',
61
-		'darkgrey' => 'A9A9A9',
62
-		'darkkhaki' => 'BDB76B',
63
-		'darkmagenta' => '8B008B',
64
-		'darkolivegreen' => '556B2F',
65
-		'darkorange' => 'FF8C00',
66
-		'darkorchid' => '9932CC',
67
-		'darkred' => '8B0000',
68
-		'darksalmon' => 'E9967A',
69
-		'darkseagreen' => '8FBC8F',
70
-		'darkslateblue' => '483D8B',
71
-		'darkslategray' => '2F4F4F',
72
-		'darkslategrey' => '2F4F4F',
73
-		'darkturquoise' => '00CED1',
74
-		'darkviolet' => '9400D3',
75
-		'deeppink' => 'FF1493',
76
-		'deepskyblue' => '00BFFF',
77
-		'dimgray' => '696969',
78
-		'dimgrey' => '696969',
79
-		'dodgerblue' => '1E90FF',
80
-		'firebrick' => 'B22222',
81
-		'floralwhite' => 'FFFAF0',
82
-		'forestgreen' => '228B22',
83
-		'fuchsia' => 'FF00FF',
84
-		'gainsboro' => 'DCDCDC',
85
-		'ghostwhite' => 'F8F8FF',
86
-		'gold' => 'FFD700',
87
-		'goldenrod' => 'DAA520',
88
-		'gray' => '808080',
89
-		'green' => '008000',
90
-		'greenyellow' => 'ADFF2F',
91
-		'grey' => '808080',
92
-		'honeydew' => 'F0FFF0',
93
-		'hotpink' => 'FF69B4',
94
-		'indianred' => 'CD5C5C',
95
-		'indigo' => '4B0082',
96
-		'ivory' => 'FFFFF0',
97
-		'khaki' => 'F0E68C',
98
-		'lavender' => 'E6E6FA',
99
-		'lavenderblush' => 'FFF0F5',
100
-		'lawngreen' => '7CFC00',
101
-		'lemonchiffon' => 'FFFACD',
102
-		'lightblue' => 'ADD8E6',
103
-		'lightcoral' => 'F08080',
104
-		'lightcyan' => 'E0FFFF',
105
-		'lightgoldenrodyellow' => 'FAFAD2',
106
-		'lightgray' => 'D3D3D3',
107
-		'lightgreen' => '90EE90',
108
-		'lightgrey' => 'D3D3D3',
109
-		'lightpink' => 'FFB6C1',
110
-		'lightsalmon' => 'FFA07A',
111
-		'lightseagreen' => '20B2AA',
112
-		'lightskyblue' => '87CEFA',
113
-		'lightslategray' => '778899',
114
-		'lightslategrey' => '778899',
115
-		'lightsteelblue' => 'B0C4DE',
116
-		'lightyellow' => 'FFFFE0',
117
-		'lime' => '00FF00',
118
-		'limegreen' => '32CD32',
119
-		'linen' => 'FAF0E6',
120
-		'magenta' => 'FF00FF',
121
-		'maroon' => '800000',
122
-		'mediumaquamarine' => '66CDAA',
123
-		'mediumblue' => '0000CD',
124
-		'mediumorchid' => 'BA55D3',
125
-		'mediumpurple' => '9370DB',
126
-		'mediumseagreen' => '3CB371',
127
-		'mediumslateblue' => '7B68EE',
128
-		'mediumspringgreen' => '00FA9A',
129
-		'mediumturquoise' => '48D1CC',
130
-		'mediumvioletred' => 'C71585',
131
-		'midnightblue' => '191970',
132
-		'mintcream' => 'F5FFFA',
133
-		'mistyrose' => 'FFE4E1',
134
-		'moccasin' => 'FFE4B5',
135
-		'navajowhite' => 'FFDEAD',
136
-		'navy' => '000080',
137
-		'oldlace' => 'FDF5E6',
138
-		'olive' => '808000',
139
-		'olivedrab' => '6B8E23',
140
-		'orange' => 'FFA500',
141
-		'orangered' => 'FF4500',
142
-		'orchid' => 'DA70D6',
143
-		'palegoldenrod' => 'EEE8AA',
144
-		'palegreen' => '98FB98',
145
-		'paleturquoise' => 'AFEEEE',
146
-		'palevioletred' => 'DB7093',
147
-		'papayawhip' => 'FFEFD5',
148
-		'peachpuff' => 'FFDAB9',
149
-		'peru' => 'CD853F',
150
-		'pink' => 'FFC0CB',
151
-		'plum' => 'DDA0DD',
152
-		'powderblue' => 'B0E0E6',
153
-		'purple' => '800080',
154
-		'rebeccapurple' => '663399',
155
-		'red' => 'FF0000',
156
-		'rosybrown' => 'BC8F8F',
157
-		'royalblue' => '4169E1',
158
-		'saddlebrown' => '8B4513',
159
-		'salmon' => 'FA8072',
160
-		'sandybrown' => 'F4A460',
161
-		'seagreen' => '2E8B57',
162
-		'seashell' => 'FFF5EE',
163
-		'sienna' => 'A0522D',
164
-		'silver' => 'C0C0C0',
165
-		'skyblue' => '87CEEB',
166
-		'slateblue' => '6A5ACD',
167
-		'slategray' => '708090',
168
-		'slategrey' => '708090',
169
-		'snow' => 'FFFAFA',
170
-		'springgreen' => '00FF7F',
171
-		'steelblue' => '4682B4',
172
-		'tan' => 'D2B48C',
173
-		'teal' => '008080',
174
-		'thistle' => 'D8BFD8',
175
-		'tomato' => 'FF6347',
176
-		'turquoise' => '40E0D0',
177
-		'violet' => 'EE82EE',
178
-		'wheat' => 'F5DEB3',
179
-		'white' => 'FFFFFF',
180
-		'whitesmoke' => 'F5F5F5',
181
-		'yellow' => 'FFFF00',
182
-		'yellowgreen' => '9ACD32',
183
-	);
184
-	if (isset($couleurs_html[$lc = strtolower($couleur)])) {
185
-		return $couleurs_html[$lc];
186
-	}
187
-
188
-	return $couleur;
34
+    $couleurs_html = array(
35
+        'aliceblue' => 'F0F8FF',
36
+        'antiquewhite' => 'FAEBD7',
37
+        'aqua' => '00FFFF',
38
+        'aquamarine' => '7FFFD4',
39
+        'azure' => 'F0FFFF',
40
+        'beige' => 'F5F5DC',
41
+        'bisque' => 'FFE4C4',
42
+        'black' => '000000',
43
+        'blanchedalmond' => 'FFEBCD',
44
+        'blue' => '0000FF',
45
+        'blueviolet' => '8A2BE2',
46
+        'brown' => 'A52A2A',
47
+        'burlywood' => 'DEB887',
48
+        'cadetblue' => '5F9EA0',
49
+        'chartreuse' => '7FFF00',
50
+        'chocolate' => 'D2691E',
51
+        'coral' => 'FF7F50',
52
+        'cornflowerblue' => '6495ED',
53
+        'cornsilk' => 'FFF8DC',
54
+        'crimson' => 'DC143C',
55
+        'cyan' => '00FFFF',
56
+        'darkblue' => '00008B',
57
+        'darkcyan' => '008B8B',
58
+        'darkgoldenrod' => 'B8860B',
59
+        'darkgray' => 'A9A9A9',
60
+        'darkgreen' => '006400',
61
+        'darkgrey' => 'A9A9A9',
62
+        'darkkhaki' => 'BDB76B',
63
+        'darkmagenta' => '8B008B',
64
+        'darkolivegreen' => '556B2F',
65
+        'darkorange' => 'FF8C00',
66
+        'darkorchid' => '9932CC',
67
+        'darkred' => '8B0000',
68
+        'darksalmon' => 'E9967A',
69
+        'darkseagreen' => '8FBC8F',
70
+        'darkslateblue' => '483D8B',
71
+        'darkslategray' => '2F4F4F',
72
+        'darkslategrey' => '2F4F4F',
73
+        'darkturquoise' => '00CED1',
74
+        'darkviolet' => '9400D3',
75
+        'deeppink' => 'FF1493',
76
+        'deepskyblue' => '00BFFF',
77
+        'dimgray' => '696969',
78
+        'dimgrey' => '696969',
79
+        'dodgerblue' => '1E90FF',
80
+        'firebrick' => 'B22222',
81
+        'floralwhite' => 'FFFAF0',
82
+        'forestgreen' => '228B22',
83
+        'fuchsia' => 'FF00FF',
84
+        'gainsboro' => 'DCDCDC',
85
+        'ghostwhite' => 'F8F8FF',
86
+        'gold' => 'FFD700',
87
+        'goldenrod' => 'DAA520',
88
+        'gray' => '808080',
89
+        'green' => '008000',
90
+        'greenyellow' => 'ADFF2F',
91
+        'grey' => '808080',
92
+        'honeydew' => 'F0FFF0',
93
+        'hotpink' => 'FF69B4',
94
+        'indianred' => 'CD5C5C',
95
+        'indigo' => '4B0082',
96
+        'ivory' => 'FFFFF0',
97
+        'khaki' => 'F0E68C',
98
+        'lavender' => 'E6E6FA',
99
+        'lavenderblush' => 'FFF0F5',
100
+        'lawngreen' => '7CFC00',
101
+        'lemonchiffon' => 'FFFACD',
102
+        'lightblue' => 'ADD8E6',
103
+        'lightcoral' => 'F08080',
104
+        'lightcyan' => 'E0FFFF',
105
+        'lightgoldenrodyellow' => 'FAFAD2',
106
+        'lightgray' => 'D3D3D3',
107
+        'lightgreen' => '90EE90',
108
+        'lightgrey' => 'D3D3D3',
109
+        'lightpink' => 'FFB6C1',
110
+        'lightsalmon' => 'FFA07A',
111
+        'lightseagreen' => '20B2AA',
112
+        'lightskyblue' => '87CEFA',
113
+        'lightslategray' => '778899',
114
+        'lightslategrey' => '778899',
115
+        'lightsteelblue' => 'B0C4DE',
116
+        'lightyellow' => 'FFFFE0',
117
+        'lime' => '00FF00',
118
+        'limegreen' => '32CD32',
119
+        'linen' => 'FAF0E6',
120
+        'magenta' => 'FF00FF',
121
+        'maroon' => '800000',
122
+        'mediumaquamarine' => '66CDAA',
123
+        'mediumblue' => '0000CD',
124
+        'mediumorchid' => 'BA55D3',
125
+        'mediumpurple' => '9370DB',
126
+        'mediumseagreen' => '3CB371',
127
+        'mediumslateblue' => '7B68EE',
128
+        'mediumspringgreen' => '00FA9A',
129
+        'mediumturquoise' => '48D1CC',
130
+        'mediumvioletred' => 'C71585',
131
+        'midnightblue' => '191970',
132
+        'mintcream' => 'F5FFFA',
133
+        'mistyrose' => 'FFE4E1',
134
+        'moccasin' => 'FFE4B5',
135
+        'navajowhite' => 'FFDEAD',
136
+        'navy' => '000080',
137
+        'oldlace' => 'FDF5E6',
138
+        'olive' => '808000',
139
+        'olivedrab' => '6B8E23',
140
+        'orange' => 'FFA500',
141
+        'orangered' => 'FF4500',
142
+        'orchid' => 'DA70D6',
143
+        'palegoldenrod' => 'EEE8AA',
144
+        'palegreen' => '98FB98',
145
+        'paleturquoise' => 'AFEEEE',
146
+        'palevioletred' => 'DB7093',
147
+        'papayawhip' => 'FFEFD5',
148
+        'peachpuff' => 'FFDAB9',
149
+        'peru' => 'CD853F',
150
+        'pink' => 'FFC0CB',
151
+        'plum' => 'DDA0DD',
152
+        'powderblue' => 'B0E0E6',
153
+        'purple' => '800080',
154
+        'rebeccapurple' => '663399',
155
+        'red' => 'FF0000',
156
+        'rosybrown' => 'BC8F8F',
157
+        'royalblue' => '4169E1',
158
+        'saddlebrown' => '8B4513',
159
+        'salmon' => 'FA8072',
160
+        'sandybrown' => 'F4A460',
161
+        'seagreen' => '2E8B57',
162
+        'seashell' => 'FFF5EE',
163
+        'sienna' => 'A0522D',
164
+        'silver' => 'C0C0C0',
165
+        'skyblue' => '87CEEB',
166
+        'slateblue' => '6A5ACD',
167
+        'slategray' => '708090',
168
+        'slategrey' => '708090',
169
+        'snow' => 'FFFAFA',
170
+        'springgreen' => '00FF7F',
171
+        'steelblue' => '4682B4',
172
+        'tan' => 'D2B48C',
173
+        'teal' => '008080',
174
+        'thistle' => 'D8BFD8',
175
+        'tomato' => 'FF6347',
176
+        'turquoise' => '40E0D0',
177
+        'violet' => 'EE82EE',
178
+        'wheat' => 'F5DEB3',
179
+        'white' => 'FFFFFF',
180
+        'whitesmoke' => 'F5F5F5',
181
+        'yellow' => 'FFFF00',
182
+        'yellowgreen' => '9ACD32',
183
+    );
184
+    if (isset($couleurs_html[$lc = strtolower($couleur)])) {
185
+        return $couleurs_html[$lc];
186
+    }
187
+
188
+    return $couleur;
189 189
 }
190 190
 
191 191
 /**
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
  * @return string Couleur tel que "hsl(200, 40%, 34%)" ou valeur formattée
202 202
  */
203 203
 function couleur_hex_to_hsl($couleur, $format = null) {
204
-	$hsl = _couleur_hex_to_hsl($couleur);
205
-	$hsl = [
206
-		'h' => round($hsl['h'] * 360), 
207
-		's' => round($hsl['s'] * 100) . '%', 
208
-		'l' => round($hsl['l'] * 100) . '%'
209
-	];
210
-	if ($format === null) {
211
-		return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})";
212
-	}
213
-	return str_replace(array_keys($hsl), $hsl, $format);
204
+    $hsl = _couleur_hex_to_hsl($couleur);
205
+    $hsl = [
206
+        'h' => round($hsl['h'] * 360), 
207
+        's' => round($hsl['s'] * 100) . '%', 
208
+        'l' => round($hsl['l'] * 100) . '%'
209
+    ];
210
+    if ($format === null) {
211
+        return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})";
212
+    }
213
+    return str_replace(array_keys($hsl), $hsl, $format);
214 214
 }
215 215
 
216 216
 
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
  * @return string Couleur tel que "rgb(200, 40, 84)" ou valeur formattée
228 228
  */
229 229
 function couleur_hex_to_rgb($couleur, $format = null) {
230
-	$rgb = _couleur_hex_to_dec($couleur);
231
-	$rgb = [
232
-		'r' => $rgb['red'], 
233
-		'g' => $rgb['green'], 
234
-		'b' => $rgb['blue'],
235
-	];
236
-	if ($format === null) {
237
-		return "rgb({$rgb['r']}, {$rgb['g']}, {$rgb['b']})";
238
-	}
239
-	return str_replace(array_keys($rgb), $rgb, $format);
230
+    $rgb = _couleur_hex_to_dec($couleur);
231
+    $rgb = [
232
+        'r' => $rgb['red'], 
233
+        'g' => $rgb['green'], 
234
+        'b' => $rgb['blue'],
235
+    ];
236
+    if ($format === null) {
237
+        return "rgb({$rgb['r']}, {$rgb['g']}, {$rgb['b']})";
238
+    }
239
+    return str_replace(array_keys($rgb), $rgb, $format);
240 240
 }
241 241
 
242 242
 /**
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
  *    Code hexadécimal de la couleur plus foncée
253 253
  */
254 254
 function couleur_foncer($couleur, $coeff = 0.5) {
255
-	$couleurs = _couleur_hex_to_dec($couleur);
255
+    $couleurs = _couleur_hex_to_dec($couleur);
256 256
 
257
-	$red = $couleurs['red'] - round(($couleurs['red']) * $coeff);
258
-	$green = $couleurs['green'] - round(($couleurs['green']) * $coeff);
259
-	$blue = $couleurs['blue'] - round(($couleurs['blue']) * $coeff);
257
+    $red = $couleurs['red'] - round(($couleurs['red']) * $coeff);
258
+    $green = $couleurs['green'] - round(($couleurs['green']) * $coeff);
259
+    $blue = $couleurs['blue'] - round(($couleurs['blue']) * $coeff);
260 260
 
261
-	$couleur = _couleur_dec_to_hex($red, $green, $blue);
261
+    $couleur = _couleur_dec_to_hex($red, $green, $blue);
262 262
 
263
-	return $couleur;
263
+    return $couleur;
264 264
 }
265 265
 
266 266
 /**
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
  *    Code hexadécimal de la couleur éclaircie
277 277
  */
278 278
 function couleur_eclaircir($couleur, $coeff = 0.5) {
279
-	$couleurs = _couleur_hex_to_dec($couleur);
279
+    $couleurs = _couleur_hex_to_dec($couleur);
280 280
 
281
-	$red = $couleurs['red'] + round((255 - $couleurs['red']) * $coeff);
282
-	$green = $couleurs['green'] + round((255 - $couleurs['green']) * $coeff);
283
-	$blue = $couleurs['blue'] + round((255 - $couleurs['blue']) * $coeff);
281
+    $red = $couleurs['red'] + round((255 - $couleurs['red']) * $coeff);
282
+    $green = $couleurs['green'] + round((255 - $couleurs['green']) * $coeff);
283
+    $blue = $couleurs['blue'] + round((255 - $couleurs['blue']) * $coeff);
284 284
 
285
-	$couleur = _couleur_dec_to_hex($red, $green, $blue);
285
+    $couleur = _couleur_dec_to_hex($red, $green, $blue);
286 286
 
287
-	return $couleur;
287
+    return $couleur;
288 288
 }
289 289
 
290 290
 /**
@@ -307,28 +307,28 @@  discard block
 block discarded – undo
307 307
  *    Le tag html `<img src=... />` avec une class `filtre_inactif` ou pas
308 308
  */
309 309
 function image_select($img, $width_min = 0, $height_min = 0, $width_max = 10000, $height_max = 1000) {
310
-	if (!$img) {
311
-		return $img;
312
-	}
313
-	list($h, $l) = taille_image($img);
314
-	$select = true;
315
-	if ($l < $width_min or $l > $width_max or $h < $height_min or $h > $height_max) {
316
-		$select = false;
317
-	}
318
-
319
-	$class = extraire_attribut($img, 'class');
320
-	$p = strpos($class, 'filtre_inactif');
321
-	if (($select == false) and ($p === false)) {
322
-		$class .= ' filtre_inactif';
323
-		$img = inserer_attribut($img, 'class', $class);
324
-	}
325
-	if (($select == true) and ($p !== false)) {
326
-		// no_image_filtrer : historique, a virer
327
-		$class = preg_replace(',\s*(filtre_inactif|no_image_filtrer),', '', $class);
328
-		$img = inserer_attribut($img, 'class', $class);
329
-	}
330
-
331
-	return $img;
310
+    if (!$img) {
311
+        return $img;
312
+    }
313
+    list($h, $l) = taille_image($img);
314
+    $select = true;
315
+    if ($l < $width_min or $l > $width_max or $h < $height_min or $h > $height_max) {
316
+        $select = false;
317
+    }
318
+
319
+    $class = extraire_attribut($img, 'class');
320
+    $p = strpos($class, 'filtre_inactif');
321
+    if (($select == false) and ($p === false)) {
322
+        $class .= ' filtre_inactif';
323
+        $img = inserer_attribut($img, 'class', $class);
324
+    }
325
+    if (($select == true) and ($p !== false)) {
326
+        // no_image_filtrer : historique, a virer
327
+        $class = preg_replace(',\s*(filtre_inactif|no_image_filtrer),', '', $class);
328
+        $img = inserer_attribut($img, 'class', $class);
329
+    }
330
+
331
+    return $img;
332 332
 }
333 333
 
334 334
 /**
@@ -376,45 +376,45 @@  discard block
 block discarded – undo
376 376
  *     Code HTML de l'image ou du texte.
377 377
  **/
378 378
 function image_passe_partout(
379
-	$img,
380
-	$taille_x = -1,
381
-	$taille_y = -1,
382
-	$force = false,
383
-	$cherche_image = false,
384
-	$process = 'AUTO'
379
+    $img,
380
+    $taille_x = -1,
381
+    $taille_y = -1,
382
+    $force = false,
383
+    $cherche_image = false,
384
+    $process = 'AUTO'
385 385
 ) {
386
-	// PHP 7+ type hint
387
-	$img = (string)$img;
388
-	$taille_x = (int)$taille_x;
389
-	$taille_y = (int)$taille_y;
390
-	$force = (bool)$force;
391
-	$process = (string)$process;
392
-
393
-	if (!$img) {
394
-		return '';
395
-	}
396
-	list($hauteur, $largeur) = taille_image($img);
397
-	if ($taille_x === -1) {
398
-		$taille_x = isset($GLOBALS['meta']['taille_preview']) ? $GLOBALS['meta']['taille_preview'] : 150;
399
-	}
400
-	if ($taille_y === -1) {
401
-		$taille_y = $taille_x;
402
-	}
403
-
404
-	if ($taille_x === 0 and $taille_y > 0) {
405
-		$taille_x = 1;
406
-	} # {0,300} -> c'est 300 qui compte
407
-	elseif ($taille_x > 0 and $taille_y === 0) {
408
-		$taille_y = 1;
409
-	} # {300,0} -> c'est 300 qui compte
410
-	elseif ($taille_x == 0 and $taille_y === 0) {
411
-		return '';
412
-	}
413
-
414
-	list($destWidth, $destHeight, $ratio) = ratio_passe_partout($largeur, $hauteur, $taille_x, $taille_y);
415
-	$fonction = array('image_passe_partout', func_get_args());
416
-
417
-	return process_image_reduire($fonction, $img, $destWidth, $destHeight, $force, $process);
386
+    // PHP 7+ type hint
387
+    $img = (string)$img;
388
+    $taille_x = (int)$taille_x;
389
+    $taille_y = (int)$taille_y;
390
+    $force = (bool)$force;
391
+    $process = (string)$process;
392
+
393
+    if (!$img) {
394
+        return '';
395
+    }
396
+    list($hauteur, $largeur) = taille_image($img);
397
+    if ($taille_x === -1) {
398
+        $taille_x = isset($GLOBALS['meta']['taille_preview']) ? $GLOBALS['meta']['taille_preview'] : 150;
399
+    }
400
+    if ($taille_y === -1) {
401
+        $taille_y = $taille_x;
402
+    }
403
+
404
+    if ($taille_x === 0 and $taille_y > 0) {
405
+        $taille_x = 1;
406
+    } # {0,300} -> c'est 300 qui compte
407
+    elseif ($taille_x > 0 and $taille_y === 0) {
408
+        $taille_y = 1;
409
+    } # {300,0} -> c'est 300 qui compte
410
+    elseif ($taille_x == 0 and $taille_y === 0) {
411
+        return '';
412
+    }
413
+
414
+    list($destWidth, $destHeight, $ratio) = ratio_passe_partout($largeur, $hauteur, $taille_x, $taille_y);
415
+    $fonction = array('image_passe_partout', func_get_args());
416
+
417
+    return process_image_reduire($fonction, $img, $destWidth, $destHeight, $force, $process);
418 418
 }
419 419
 
420 420
 /**
@@ -457,44 +457,44 @@  discard block
 block discarded – undo
457 457
  *     Code HTML de l'image ou du texte.
458 458
  **/
459 459
 function image_reduire(
460
-	$img,
461
-	$taille = -1,
462
-	$taille_y = -1,
463
-	$force = false,
464
-	$cherche_image = false,
465
-	$process = 'AUTO'
460
+    $img,
461
+    $taille = -1,
462
+    $taille_y = -1,
463
+    $force = false,
464
+    $cherche_image = false,
465
+    $process = 'AUTO'
466 466
 ) {
467
-	// PHP 7+ type hint
468
-	$img = (string)$img;
469
-	$taille = (int)$taille;
470
-	$taille_y = (int)$taille_y;
471
-	$force = (bool)$force;
472
-	$process = (string)$process;
473
-
474
-	// Determiner la taille x,y maxi
475
-	// prendre le reglage de previsu par defaut
476
-	if ($taille === -1) {
477
-		$taille = (isset($GLOBALS['meta']['taille_preview']) and intval($GLOBALS['meta']['taille_preview']))
478
-			? intval($GLOBALS['meta']['taille_preview'])
479
-			: 150;
480
-	}
481
-	if ($taille_y === -1) {
482
-		$taille_y = $taille;
483
-	}
484
-
485
-	if ($taille === 0 and $taille_y > 0) {
486
-		$taille = 10000;
487
-	} # {0,300} -> c'est 300 qui compte
488
-	elseif ($taille > 0 and $taille_y === 0) {
489
-		$taille_y = 10000;
490
-	} # {300,0} -> c'est 300 qui compte
491
-	elseif ($taille == 0 and $taille_y === 0) {
492
-		return '';
493
-	}
494
-
495
-	$fonction = array('image_reduire', func_get_args());
496
-
497
-	return process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process);
467
+    // PHP 7+ type hint
468
+    $img = (string)$img;
469
+    $taille = (int)$taille;
470
+    $taille_y = (int)$taille_y;
471
+    $force = (bool)$force;
472
+    $process = (string)$process;
473
+
474
+    // Determiner la taille x,y maxi
475
+    // prendre le reglage de previsu par defaut
476
+    if ($taille === -1) {
477
+        $taille = (isset($GLOBALS['meta']['taille_preview']) and intval($GLOBALS['meta']['taille_preview']))
478
+            ? intval($GLOBALS['meta']['taille_preview'])
479
+            : 150;
480
+    }
481
+    if ($taille_y === -1) {
482
+        $taille_y = $taille;
483
+    }
484
+
485
+    if ($taille === 0 and $taille_y > 0) {
486
+        $taille = 10000;
487
+    } # {0,300} -> c'est 300 qui compte
488
+    elseif ($taille > 0 and $taille_y === 0) {
489
+        $taille_y = 10000;
490
+    } # {300,0} -> c'est 300 qui compte
491
+    elseif ($taille == 0 and $taille_y === 0) {
492
+        return '';
493
+    }
494
+
495
+    $fonction = array('image_reduire', func_get_args());
496
+
497
+    return process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process);
498 498
 }
499 499
 
500 500
 
@@ -513,25 +513,25 @@  discard block
 block discarded – undo
513 513
  *     Code HTML de l'image ou du texte.
514 514
  **/
515 515
 function image_reduire_par($img, $val = 1, $force = false) {
516
-	// PHP 7+ type hint
517
-	$img = (string)$img;
518
-	$val = (int)$val;
519
-	$force = (bool)$force;
516
+    // PHP 7+ type hint
517
+    $img = (string)$img;
518
+    $val = (int)$val;
519
+    $force = (bool)$force;
520 520
 
521
-	list($hauteur, $largeur) = taille_image($img);
521
+    list($hauteur, $largeur) = taille_image($img);
522 522
 
523
-	$l = round($largeur / $val);
524
-	$h = round($hauteur / $val);
523
+    $l = round($largeur / $val);
524
+    $h = round($hauteur / $val);
525 525
 
526
-	if ($l > $h) {
527
-		$h = 0;
528
-	} else {
529
-		$l = 0;
530
-	}
526
+    if ($l > $h) {
527
+        $h = 0;
528
+    } else {
529
+        $l = 0;
530
+    }
531 531
 
532
-	$img = image_reduire($img, $l, $h, $force);
532
+    $img = image_reduire($img, $l, $h, $force);
533 533
 
534
-	return $img;
534
+    return $img;
535 535
 }
536 536
 
537 537
 /**
@@ -554,10 +554,10 @@  discard block
 block discarded – undo
554 554
  *      Couleur en écriture hexadécimale.
555 555
 **/
556 556
 function filtre_couleur_saturation_dist($couleur, $val, $strict = false) {
557
-	if (function_exists('couleur_saturation')) {
558
-		return couleur_saturation($couleur, $val, $strict);
559
-	}
560
-	return $couleur;
557
+    if (function_exists('couleur_saturation')) {
558
+        return couleur_saturation($couleur, $val, $strict);
559
+    }
560
+    return $couleur;
561 561
 }
562 562
 
563 563
 /**
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
  *      Couleur en écriture hexadécimale.
579 579
 **/
580 580
 function filtre_couleur_luminance_dist($couleur, $val) {
581
-	if (function_exists('couleur_luminance')) {
582
-		return couleur_luminance($couleur, $val);
583
-	}
584
-	return $couleur;
581
+    if (function_exists('couleur_luminance')) {
582
+        return couleur_luminance($couleur, $val);
583
+    }
584
+    return $couleur;
585 585
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 	$hsl = _couleur_hex_to_hsl($couleur);
205 205
 	$hsl = [
206 206
 		'h' => round($hsl['h'] * 360), 
207
-		's' => round($hsl['s'] * 100) . '%', 
208
-		'l' => round($hsl['l'] * 100) . '%'
207
+		's' => round($hsl['s'] * 100).'%', 
208
+		'l' => round($hsl['l'] * 100).'%'
209 209
 	];
210 210
 	if ($format === null) {
211 211
 		return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})";
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 	$process = 'AUTO'
385 385
 ) {
386 386
 	// PHP 7+ type hint
387
-	$img = (string)$img;
388
-	$taille_x = (int)$taille_x;
389
-	$taille_y = (int)$taille_y;
390
-	$force = (bool)$force;
391
-	$process = (string)$process;
387
+	$img = (string) $img;
388
+	$taille_x = (int) $taille_x;
389
+	$taille_y = (int) $taille_y;
390
+	$force = (bool) $force;
391
+	$process = (string) $process;
392 392
 
393 393
 	if (!$img) {
394 394
 		return '';
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 	$process = 'AUTO'
466 466
 ) {
467 467
 	// PHP 7+ type hint
468
-	$img = (string)$img;
469
-	$taille = (int)$taille;
470
-	$taille_y = (int)$taille_y;
471
-	$force = (bool)$force;
472
-	$process = (string)$process;
468
+	$img = (string) $img;
469
+	$taille = (int) $taille;
470
+	$taille_y = (int) $taille_y;
471
+	$force = (bool) $force;
472
+	$process = (string) $process;
473 473
 
474 474
 	// Determiner la taille x,y maxi
475 475
 	// prendre le reglage de previsu par defaut
@@ -514,9 +514,9 @@  discard block
 block discarded – undo
514 514
  **/
515 515
 function image_reduire_par($img, $val = 1, $force = false) {
516 516
 	// PHP 7+ type hint
517
-	$img = (string)$img;
518
-	$val = (int)$val;
519
-	$force = (bool)$force;
517
+	$img = (string) $img;
518
+	$val = (int) $val;
519
+	$force = (bool) $force;
520 520
 
521 521
 	list($hauteur, $largeur) = taille_image($img);
522 522
 
Please login to merge, or discard this patch.
ecrire/inc/couleurs.php 2 patches
Indentation   +59 added lines, -59 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
 /**
@@ -38,66 +38,66 @@  discard block
 block discarded – undo
38 38
  * @return array|string
39 39
  */
40 40
 function inc_couleurs_dist($choix = null, $ajouter = false) {
41
-	static $couleurs_spip = array(
42
-		// Saumon
43
-		4 => ["couleur_theme" => "#cda261"], 
44
-		// Orange
45
-		3 => ["couleur_theme" => "#fa9a00"],
46
-		// Rouge
47
-		8 => ["couleur_theme" => "#df4543"],
48
-		// Framboise
49
-		2 => ["couleur_theme" =>  "#d51b60"],
50
-		// Vert de gris
51
-		7 => ["couleur_theme" => "#999966"],
52
-		// Vert
53
-		1 => ["couleur_theme" => "#9dba00"],
54
-		//  Bleu pastel
55
-		5 => ["couleur_theme" => "#5da7c5"],
56
-		// Violet
57
-		9 => ["couleur_theme" => "#8f8fbd"],
58
-		//  Gris
59
-		6 => ["couleur_theme" => "#85909a"],
60
-		//  Gris
61
-		10 => ["couleur_theme" => "#909090"],
62
-	);
41
+    static $couleurs_spip = array(
42
+        // Saumon
43
+        4 => ["couleur_theme" => "#cda261"], 
44
+        // Orange
45
+        3 => ["couleur_theme" => "#fa9a00"],
46
+        // Rouge
47
+        8 => ["couleur_theme" => "#df4543"],
48
+        // Framboise
49
+        2 => ["couleur_theme" =>  "#d51b60"],
50
+        // Vert de gris
51
+        7 => ["couleur_theme" => "#999966"],
52
+        // Vert
53
+        1 => ["couleur_theme" => "#9dba00"],
54
+        //  Bleu pastel
55
+        5 => ["couleur_theme" => "#5da7c5"],
56
+        // Violet
57
+        9 => ["couleur_theme" => "#8f8fbd"],
58
+        //  Gris
59
+        6 => ["couleur_theme" => "#85909a"],
60
+        //  Gris
61
+        10 => ["couleur_theme" => "#909090"],
62
+    );
63 63
 
64
-	if (is_numeric($choix)) {
65
-		$c = $couleurs_spip[$choix];
66
-		// compat < SPIP 3.3
67
-		include_spip('inc/filtres_images_mini');
68
-		$c["couleur_foncee"] = $c["couleur_theme"];
69
-		$c["couleur_claire"] = '#' . couleur_eclaircir($c["couleur_theme"], .5);
64
+    if (is_numeric($choix)) {
65
+        $c = $couleurs_spip[$choix];
66
+        // compat < SPIP 3.3
67
+        include_spip('inc/filtres_images_mini');
68
+        $c["couleur_foncee"] = $c["couleur_theme"];
69
+        $c["couleur_claire"] = '#' . couleur_eclaircir($c["couleur_theme"], .5);
70 70
 
71
-		return
72
-			'couleur_theme=' . substr($c['couleur_theme'], 1)
73
-			// compat < SPIP 3.3
74
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
75
-			. '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
76
-	} else {
77
-		if (is_array($choix)) {
78
-			// compat < SPIP 3.3
79
-			$compat_spip_33 = function($c) {
80
-				if (!isset($c["couleur_theme"])) {
81
-					$c["couleur_theme"] = $c["couleur_foncee"];
82
-					unset($c["couleur_foncee"]);
83
-					unset($c["couleur_claire"]);
84
-					unset($c["couleur_lien"]);
85
-					unset($c["couleur_lien_off"]);
86
-				}
87
-				return $c;
88
-			};
89
-			if ($ajouter) {
90
-				foreach ($choix as $c) {
91
-					$couleurs_spip[] = $compat_spip_33($c);
92
-				}
71
+        return
72
+            'couleur_theme=' . substr($c['couleur_theme'], 1)
73
+            // compat < SPIP 3.3
74
+            . '&couleur_claire=' . substr($c['couleur_claire'], 1)
75
+            . '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
76
+    } else {
77
+        if (is_array($choix)) {
78
+            // compat < SPIP 3.3
79
+            $compat_spip_33 = function($c) {
80
+                if (!isset($c["couleur_theme"])) {
81
+                    $c["couleur_theme"] = $c["couleur_foncee"];
82
+                    unset($c["couleur_foncee"]);
83
+                    unset($c["couleur_claire"]);
84
+                    unset($c["couleur_lien"]);
85
+                    unset($c["couleur_lien_off"]);
86
+                }
87
+                return $c;
88
+            };
89
+            if ($ajouter) {
90
+                foreach ($choix as $c) {
91
+                    $couleurs_spip[] = $compat_spip_33($c);
92
+                }
93 93
 
94
-				return $couleurs_spip;
95
-			} else {
96
-				$choix = array_map($compat_spip_33, $choix);
97
-				return $couleurs_spip = $choix;
98
-			}
99
-		}
100
-	}
94
+                return $couleurs_spip;
95
+            } else {
96
+                $choix = array_map($compat_spip_33, $choix);
97
+                return $couleurs_spip = $choix;
98
+            }
99
+        }
100
+    }
101 101
 
102
-	return $couleurs_spip;
102
+    return $couleurs_spip;
103 103
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,13 +66,13 @@
 block discarded – undo
66 66
 		// compat < SPIP 3.3
67 67
 		include_spip('inc/filtres_images_mini');
68 68
 		$c["couleur_foncee"] = $c["couleur_theme"];
69
-		$c["couleur_claire"] = '#' . couleur_eclaircir($c["couleur_theme"], .5);
69
+		$c["couleur_claire"] = '#'.couleur_eclaircir($c["couleur_theme"], .5);
70 70
 
71 71
 		return
72
-			'couleur_theme=' . substr($c['couleur_theme'], 1)
72
+			'couleur_theme='.substr($c['couleur_theme'], 1)
73 73
 			// compat < SPIP 3.3
74
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
75
-			. '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
74
+			. '&couleur_claire='.substr($c['couleur_claire'], 1)
75
+			. '&couleur_foncee='.substr($c['couleur_foncee'], 1);
76 76
 	} else {
77 77
 		if (is_array($choix)) {
78 78
 			// compat < SPIP 3.3
Please login to merge, or discard this patch.
ecrire/inc/commencer_page.php 2 patches
Indentation   +64 added lines, -64 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
 /**
@@ -43,25 +43,25 @@  discard block
 block discarded – undo
43 43
  * @return string Code HTML
44 44
  **/
45 45
 function inc_commencer_page_dist(
46
-	$titre = "",
47
-	$rubrique = "accueil",
48
-	$sous_rubrique = "accueil",
49
-	$id_rubrique = "",
50
-	$menu = true,
51
-	$minipres = false,
52
-	$alertes = true
46
+    $titre = "",
47
+    $rubrique = "accueil",
48
+    $sous_rubrique = "accueil",
49
+    $id_rubrique = "",
50
+    $menu = true,
51
+    $minipres = false,
52
+    $alertes = true
53 53
 ) {
54 54
 
55
-	include_spip('inc/headers');
55
+    include_spip('inc/headers');
56 56
 
57
-	http_no_cache();
57
+    http_no_cache();
58 58
 
59
-	return init_entete($titre, $id_rubrique, $minipres)
60
-	. init_body($rubrique, $sous_rubrique, $id_rubrique, $menu)
61
-	. "<div id='page'>"
62
-	. auteurs_recemment_connectes($GLOBALS['connect_id_auteur'])
63
-	. ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '')
64
-	. '<div class="largeur">';
59
+    return init_entete($titre, $id_rubrique, $minipres)
60
+    . init_body($rubrique, $sous_rubrique, $id_rubrique, $menu)
61
+    . "<div id='page'>"
62
+    . auteurs_recemment_connectes($GLOBALS['connect_id_auteur'])
63
+    . ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '')
64
+    . '<div class="largeur">';
65 65
 }
66 66
 
67 67
 /**
@@ -82,21 +82,21 @@  discard block
 block discarded – undo
82 82
  *     Entête du fichier HTML avec le DOCTYPE
83 83
  */
84 84
 function init_entete($titre = '', $dummy = 0, $minipres = false) {
85
-	include_spip('inc/texte');
86
-	if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']["nom_site"]))) {
87
-		$nom_site_spip = _T('info_mon_site_spip');
88
-	}
89
-
90
-	$titre = "["
91
-		. $nom_site_spip
92
-		. "]"
93
-		. ($titre ? " " . textebrut(typo($titre)) : "");
94
-
95
-	return _DOCTYPE_ECRIRE
96
-	. html_lang_attributes()
97
-	. "<head>\n"
98
-	. init_head($titre, $dummy, $minipres)
99
-	. "</head>\n";
85
+    include_spip('inc/texte');
86
+    if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']["nom_site"]))) {
87
+        $nom_site_spip = _T('info_mon_site_spip');
88
+    }
89
+
90
+    $titre = "["
91
+        . $nom_site_spip
92
+        . "]"
93
+        . ($titre ? " " . textebrut(typo($titre)) : "");
94
+
95
+    return _DOCTYPE_ECRIRE
96
+    . html_lang_attributes()
97
+    . "<head>\n"
98
+    . init_head($titre, $dummy, $minipres)
99
+    . "</head>\n";
100 100
 }
101 101
 
102 102
 /**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
  * @return string
111 111
  */
112 112
 function init_head($titre = '', $dummy = 0, $minipres = false) {
113
-	return recuperer_fond("prive/squelettes/head/dist", array('titre' => $titre, 'minipres' => $minipres ? ' ' : ''));
113
+    return recuperer_fond("prive/squelettes/head/dist", array('titre' => $titre, 'minipres' => $minipres ? ' ' : ''));
114 114
 }
115 115
 
116 116
 /**
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
  */
133 133
 function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) {
134 134
 
135
-	$res = pipeline('body_prive', "<body class='"
136
-		. init_body_class() . " " . _request('exec') . "'"
137
-		. ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : "")
138
-		. '>');
135
+    $res = pipeline('body_prive', "<body class='"
136
+        . init_body_class() . " " . _request('exec') . "'"
137
+        . ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : "")
138
+        . '>');
139 139
 
140
-	if (!$menu) {
141
-		return $res;
142
-	}
140
+    if (!$menu) {
141
+        return $res;
142
+    }
143 143
 
144 144
 
145
-	$bandeau = charger_fonction('bandeau', 'inc');
145
+    $bandeau = charger_fonction('bandeau', 'inc');
146 146
 
147
-	return $res
148
-	. $bandeau();
147
+    return $res
148
+    . $bandeau();
149 149
 }
150 150
 
151 151
 /**
@@ -157,27 +157,27 @@  discard block
 block discarded – undo
157 157
  * @return string Classes CSS (séparées par des espaces)
158 158
  */
159 159
 function init_body_class() {
160
-	$prefs = isset($GLOBALS['visiteur_session']['prefs']) ? $GLOBALS['visiteur_session']['prefs'] : array();
161
-
162
-	$GLOBALS['spip_display'] = isset($prefs['display']) ? (int) $prefs['display'] : 2;
163
-	$spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones';
164
-	$spip_display_outils = isset($prefs['display_outils'])
165
-		? ($prefs['display_outils'] ? 'navigation_avec_outils' : 'navigation_sans_outils')
166
-		: 'navigation_avec_outils';
167
-	$GLOBALS['spip_ecran'] = isset($_COOKIE['spip_ecran']) ? spip_sanitize_classname($_COOKIE['spip_ecran']) : "etroit";
168
-
169
-	$display_class = array(
170
-		0 => 'icones_img_texte'
171
-		/*init*/,
172
-		1 => 'icones_texte',
173
-		2 => 'icones_img_texte',
174
-		3 => 'icones_img'
175
-	);
176
-
177
-	$couleur = isset($prefs['couleur']) ? (int) $prefs['couleur'] : 9;
178
-
179
-	$classes = $GLOBALS['spip_ecran'] . " spip-theme-colors-$couleur $spip_display_navigation $spip_display_outils " . $display_class[$GLOBALS['spip_display']];
180
-	return spip_sanitize_classname($classes);
160
+    $prefs = isset($GLOBALS['visiteur_session']['prefs']) ? $GLOBALS['visiteur_session']['prefs'] : array();
161
+
162
+    $GLOBALS['spip_display'] = isset($prefs['display']) ? (int) $prefs['display'] : 2;
163
+    $spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones';
164
+    $spip_display_outils = isset($prefs['display_outils'])
165
+        ? ($prefs['display_outils'] ? 'navigation_avec_outils' : 'navigation_sans_outils')
166
+        : 'navigation_avec_outils';
167
+    $GLOBALS['spip_ecran'] = isset($_COOKIE['spip_ecran']) ? spip_sanitize_classname($_COOKIE['spip_ecran']) : "etroit";
168
+
169
+    $display_class = array(
170
+        0 => 'icones_img_texte'
171
+        /*init*/,
172
+        1 => 'icones_texte',
173
+        2 => 'icones_img_texte',
174
+        3 => 'icones_img'
175
+    );
176
+
177
+    $couleur = isset($prefs['couleur']) ? (int) $prefs['couleur'] : 9;
178
+
179
+    $classes = $GLOBALS['spip_ecran'] . " spip-theme-colors-$couleur $spip_display_navigation $spip_display_outils " . $display_class[$GLOBALS['spip_display']];
180
+    return spip_sanitize_classname($classes);
181 181
 }
182 182
 
183 183
 
@@ -188,5 +188,5 @@  discard block
 block discarded – undo
188 188
  * @return string
189 189
  */
190 190
 function auteurs_recemment_connectes($id_auteur) {
191
-	return recuperer_fond('prive/objets/liste/auteurs_enligne');
191
+    return recuperer_fond('prive/objets/liste/auteurs_enligne');
192 192
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	$titre = "["
91 91
 		. $nom_site_spip
92 92
 		. "]"
93
-		. ($titre ? " " . textebrut(typo($titre)) : "");
93
+		. ($titre ? " ".textebrut(typo($titre)) : "");
94 94
 
95 95
 	return _DOCTYPE_ECRIRE
96 96
 	. html_lang_attributes()
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) {
134 134
 
135 135
 	$res = pipeline('body_prive', "<body class='"
136
-		. init_body_class() . " " . _request('exec') . "'"
136
+		. init_body_class()." "._request('exec')."'"
137 137
 		. ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : "")
138 138
 		. '>');
139 139
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 	$couleur = isset($prefs['couleur']) ? (int) $prefs['couleur'] : 9;
178 178
 
179
-	$classes = $GLOBALS['spip_ecran'] . " spip-theme-colors-$couleur $spip_display_navigation $spip_display_outils " . $display_class[$GLOBALS['spip_display']];
179
+	$classes = $GLOBALS['spip_ecran']." spip-theme-colors-$couleur $spip_display_navigation $spip_display_outils ".$display_class[$GLOBALS['spip_display']];
180 180
 	return spip_sanitize_classname($classes);
181 181
 }
182 182
 
Please login to merge, or discard this patch.
ecrire/inc/filtres.php 1 patch
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	}
95 95
 
96 96
 	include_fichiers_fonctions();
97
-	foreach (array('filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc) as $f) {
97
+	foreach (array('filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc) as $f) {
98 98
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
99 99
 		// fonction ou name\space\fonction
100 100
 		if (is_callable($f)) {
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	// affichage "GIT [master: abcdef]"
222 222
 	$commit = isset($desc['commit_short']) ? $desc['commit_short'] : $desc['commit'];
223 223
 	if ($desc['branch']) {
224
-		$commit = $desc['branch'] . ': ' . $commit;
224
+		$commit = $desc['branch'].': '.$commit;
225 225
 	}
226 226
 	return "{$desc['vcs']} [$commit]";
227 227
 }
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 
242 242
 	// version installee par GIT
243
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
243
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
244 244
 		$currentHead = trim(substr($c, 4));
245
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
245
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
246 246
 			return [
247 247
 				'vcs' => 'GIT',
248 248
 				'branch' => basename($currentHead),
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 		$dir = '.';
270 270
 	}
271 271
 	// version installee par SVN
272
-	if (file_exists($dir . '/.svn/wc.db') && class_exists('SQLite3')) {
273
-		$db = new SQLite3($dir . '/.svn/wc.db');
272
+	if (file_exists($dir.'/.svn/wc.db') && class_exists('SQLite3')) {
273
+		$db = new SQLite3($dir.'/.svn/wc.db');
274 274
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
275 275
 		if ($result) {
276 276
 			$row = $result->fetchArray();
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 
310 310
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
311 311
 // et laisser passer les fonctions personnelles baptisees image_...
312
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
313
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
314
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
315
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
316
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
312
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
313
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
314
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
315
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
316
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
317 317
 
318 318
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
319 319
 $GLOBALS['spip_matrice']['couleur_hex_to_hsl'] = 'inc/filtres_images_mini.php';
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
  */
473 473
 function filtre_debug($val, $key = null) {
474 474
 	$debug = (
475
-		is_null($key) ? '' : (var_export($key, true) . " = ")
476
-		) . var_export($val, true);
475
+		is_null($key) ? '' : (var_export($key, true)." = ")
476
+		).var_export($val, true);
477 477
 
478 478
 	include_spip('inc/autoriser');
479 479
 	if (autoriser('webmestre')) {
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
573 573
 							$srcover = $match[1];
574 574
 							array_shift($args);
575
-							array_unshift($args, "<img src='" . $match[1] . "' />");
575
+							array_unshift($args, "<img src='".$match[1]."' />");
576 576
 							$srcover_filter = call_user_func_array($filtre, $args);
577 577
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
578 578
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -643,14 +643,14 @@  discard block
 block discarded – undo
643 643
 				$hauteur_img[$src] = $srcHeight = $srcsize[1];
644 644
 			}
645 645
 		}
646
-		elseif(strpos($src, "<svg") !== false) {
646
+		elseif (strpos($src, "<svg") !== false) {
647 647
 			include_spip('inc/svg');
648
-			if ($attrs = svg_lire_attributs($src)){
648
+			if ($attrs = svg_lire_attributs($src)) {
649 649
 				list($width, $height, $viewbox) = svg_getimagesize_from_attr($attrs);
650
-				if (!$srcWidth){
650
+				if (!$srcWidth) {
651 651
 					$largeur_img[$src] = $srcWidth = $width;
652 652
 				}
653
-				if (!$srcHeight){
653
+				if (!$srcHeight) {
654 654
 					$hauteur_img[$src] = $srcHeight = $height;
655 655
 				}
656 656
 			}
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 	// " -> &quot; et tout ce genre de choses
935 935
 	$u = $GLOBALS['meta']['pcre_u'];
936 936
 	$texte = str_replace("&nbsp;", " ", $texte);
937
-	$texte = preg_replace('/\s{2,}/S' . $u, " ", $texte);
937
+	$texte = preg_replace('/\s{2,}/S'.$u, " ", $texte);
938 938
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
939 939
 	$texte = entites_html($texte, false, false);
940 940
 	// mais bien echapper les double quotes !
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
  **/
995 995
 function supprimer_numero($texte) {
996 996
 	return preg_replace(
997
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
997
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
998 998
 		"", $texte);
999 999
 }
1000 1000
 
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
  **/
1020 1020
 function recuperer_numero($texte) {
1021 1021
 	if (preg_match(
1022
-		",^[[:space:]]*([0-9]+)([.)]|" . chr(194) . '?' . chr(176) . ")[[:space:]]+,S",
1022
+		",^[[:space:]]*([0-9]+)([.)]|".chr(194).'?'.chr(176).")[[:space:]]+,S",
1023 1023
 		$texte, $regs)) {
1024 1024
 		return strval($regs[1]);
1025 1025
 	} else {
@@ -1104,8 +1104,8 @@  discard block
 block discarded – undo
1104 1104
  **/
1105 1105
 function textebrut($texte) {
1106 1106
 	$u = $GLOBALS['meta']['pcre_u'];
1107
-	$texte = preg_replace('/\s+/S' . $u, " ", $texte);
1108
-	$texte = preg_replace("/<(p|br)( [^>]*)?" . ">/iS", "\n\n", $texte);
1107
+	$texte = preg_replace('/\s+/S'.$u, " ", $texte);
1108
+	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
1109 1109
 	$texte = preg_replace("/^\n+/", "", $texte);
1110 1110
 	$texte = preg_replace("/\n+$/", "", $texte);
1111 1111
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 	if (preg_match_all(",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1134 1134
 		$texte, $liens, PREG_PATTERN_ORDER)) {
1135 1135
 		foreach ($liens[0] as $a) {
1136
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1136
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1137 1137
 			$ablank = inserer_attribut($a, 'rel', $rel);
1138 1138
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1139 1139
 			$texte = str_replace($a, $ablank, $texte);
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 		foreach ($regs[0] as $a) {
1159 1159
 			$rel = extraire_attribut($a, "rel");
1160 1160
 			if (strpos($rel, "nofollow") === false) {
1161
-				$rel = "nofollow" . ($rel ? " $rel" : "");
1161
+				$rel = "nofollow".($rel ? " $rel" : "");
1162 1162
 				$anofollow = inserer_attribut($a, "rel", $rel);
1163 1163
 				$texte = str_replace($a, $anofollow, $texte);
1164 1164
 			}
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 	$u = $GLOBALS['meta']['pcre_u'];
1188 1188
 	$texte = preg_replace("@</p>@iS", "\n", $texte);
1189 1189
 	$texte = preg_replace("@<p\b.*>@UiS", "<br />", $texte);
1190
-	$texte = preg_replace("@^\s*<br />@S" . $u, "", $texte);
1190
+	$texte = preg_replace("@^\s*<br />@S".$u, "", $texte);
1191 1191
 
1192 1192
 	return $texte;
1193 1193
 }
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 		return $texte;
1218 1218
 	}
1219 1219
 	include_spip('inc/texte');
1220
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1220
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1221 1221
 		'div' : 'span';
1222 1222
 
1223 1223
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 function attribut_html($texte, $textebrut = true) {
1327 1327
 	$u = $GLOBALS['meta']['pcre_u'];
1328 1328
 	if ($textebrut) {
1329
-		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS" . $u), array(" ", ""), textebrut($texte));
1329
+		$texte = preg_replace(array(",\n,", ",\s(?=\s),msS".$u), array(" ", ""), textebrut($texte));
1330 1330
 	}
1331 1331
 	$texte = texte_backend($texte);
1332 1332
 	$texte = str_replace(array("'", '"'), array('&#039;', '&#034;'), $texte);
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 	# un message pour abs_url
1356 1356
 	$GLOBALS['mode_abs_url'] = 'url';
1357 1357
 	$url = trim($url);
1358
-	$r = ",^(?:" . _PROTOCOLES_STD . '):?/?/?$,iS';
1358
+	$r = ",^(?:"._PROTOCOLES_STD.'):?/?/?$,iS';
1359 1359
 
1360 1360
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1361 1361
 }
@@ -1557,14 +1557,14 @@  discard block
 block discarded – undo
1557 1557
 	if (strpos($texte, "<") !== false) {
1558 1558
 		include_spip('inc/lien');
1559 1559
 		if (defined('_PREG_MODELE')) {
1560
-			$preg_modeles = "@" . _PREG_MODELE . "@imsS";
1560
+			$preg_modeles = "@"._PREG_MODELE."@imsS";
1561 1561
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1562 1562
 		}
1563 1563
 	}
1564 1564
 
1565 1565
 	$debut = '';
1566 1566
 	$suite = $texte;
1567
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1567
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1568 1568
 		$debut .= substr($suite, 0, $t - 1);
1569 1569
 		$suite = substr($suite, $t);
1570 1570
 		$car = substr($suite, 0, 1);
@@ -1581,11 +1581,11 @@  discard block
 block discarded – undo
1581 1581
 			$suite = substr($suite, strlen($regs[0]));
1582 1582
 		}
1583 1583
 	}
1584
-	$texte = $debut . $suite;
1584
+	$texte = $debut.$suite;
1585 1585
 
1586 1586
 	$texte = echappe_retour($texte);
1587 1587
 
1588
-	return $texte . $fin;
1588
+	return $texte.$fin;
1589 1589
 }
1590 1590
 
1591 1591
 
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
 		}
1647 1647
 
1648 1648
 		foreach ($regs as $reg) {
1649
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1649
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1650 1650
 			$desc = $traduire($cle, $lang, true);
1651 1651
 			$l = $desc->langue;
1652 1652
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1759,9 +1759,9 @@  discard block
 block discarded – undo
1759 1759
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1760 1760
 					include_spip('inc/texte');
1761 1761
 					$trad_propre = preg_replace(",(^<p[^>]*>|</p>$),Uims", "", propre($trad));
1762
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1762
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1763 1763
 					if ($mode === 'div') {
1764
-						$trad = rtrim($trad) . "\n\n";
1764
+						$trad = rtrim($trad)."\n\n";
1765 1765
 					}
1766 1766
 					$trad = code_echappement($trad, 'multi', false, $mode);
1767 1767
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
 	if (is_array($balise)) {
1956 1956
 		array_walk(
1957 1957
 			$balise,
1958
-			function(&$a, $key, $t){
1958
+			function(&$a, $key, $t) {
1959 1959
 				$a = extraire_attribut($a, $t);
1960 1960
 			},
1961 1961
 			$attribut
@@ -2042,14 +2042,14 @@  discard block
 block discarded – undo
2042 2042
 
2043 2043
 	if ($old !== null) {
2044 2044
 		// Remplacer l'ancien attribut du meme nom
2045
-		$balise = $r[1] . $insert . $r[5];
2045
+		$balise = $r[1].$insert.$r[5];
2046 2046
 	} else {
2047 2047
 		// preferer une balise " />" (comme <img />)
2048 2048
 		if (preg_match(',/>,', $balise)) {
2049
-			$balise = preg_replace(",\s?/>,S", $insert . " />", $balise, 1);
2049
+			$balise = preg_replace(",\s?/>,S", $insert." />", $balise, 1);
2050 2050
 		} // sinon une balise <a ...> ... </a>
2051 2051
 		else {
2052
-			$balise = preg_replace(",\s?>,S", $insert . ">", $balise, 1);
2052
+			$balise = preg_replace(",\s?>,S", $insert.">", $balise, 1);
2053 2053
 		}
2054 2054
 	}
2055 2055
 
@@ -2082,7 +2082,7 @@  discard block
 block discarded – undo
2082 2082
  * @param string $operation
2083 2083
  * @return string
2084 2084
  */
2085
-function modifier_class($balise, $class, $operation='ajouter') {
2085
+function modifier_class($balise, $class, $operation = 'ajouter') {
2086 2086
 	if (is_string($class)) {
2087 2087
 		$class = explode(' ', trim($class));
2088 2088
 	}
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
 				}
2108 2108
 				if (in_array($operation, ['ajouter', 'commuter'])
2109 2109
 					and !$is_class_presente) {
2110
-					$class_new = rtrim($class_new) . " " . $c;
2110
+					$class_new = rtrim($class_new)." ".$c;
2111 2111
 				}
2112 2112
 				elseif (in_array($operation, ['supprimer', 'commuter'])
2113 2113
 					and $is_class_presente) {
@@ -2135,7 +2135,7 @@  discard block
 block discarded – undo
2135 2135
  * @param string|array $class
2136 2136
  * @return string
2137 2137
  */
2138
-function ajouter_class($balise, $class){
2138
+function ajouter_class($balise, $class) {
2139 2139
 	return modifier_class($balise, $class, 'ajouter');
2140 2140
 }
2141 2141
 
@@ -2145,7 +2145,7 @@  discard block
 block discarded – undo
2145 2145
  * @param string|array $class
2146 2146
  * @return string
2147 2147
  */
2148
-function supprimer_class($balise, $class){
2148
+function supprimer_class($balise, $class) {
2149 2149
 	return modifier_class($balise, $class, 'supprimer');
2150 2150
 }
2151 2151
 
@@ -2156,7 +2156,7 @@  discard block
 block discarded – undo
2156 2156
  * @param string|array $class
2157 2157
  * @return string
2158 2158
  */
2159
-function commuter_class($balise, $class){
2159
+function commuter_class($balise, $class) {
2160 2160
 	return modifier_class($balise, $class, 'commuter');
2161 2161
 }
2162 2162
 
@@ -2176,8 +2176,8 @@  discard block
 block discarded – undo
2176 2176
 //
2177 2177
 // Quelques fonctions de calcul arithmetique
2178 2178
 //
2179
-function floatstr($a) { return str_replace(',','.',(string)floatval($a)); }
2180
-function strize($f, $a, $b) { return floatstr($f(floatstr($a),floatstr($b))); }
2179
+function floatstr($a) { return str_replace(',', '.', (string) floatval($a)); }
2180
+function strize($f, $a, $b) { return floatstr($f(floatstr($a), floatstr($b))); }
2181 2181
 
2182 2182
 /**
2183 2183
  * Additionne 2 nombres
@@ -2197,7 +2197,7 @@  discard block
 block discarded – undo
2197 2197
 function plus($a, $b) {
2198 2198
 	return $a + $b;
2199 2199
 }
2200
-function strplus($a, $b) {return strize('plus', $a, $b);}
2200
+function strplus($a, $b) {return strize('plus', $a, $b); }
2201 2201
 /**
2202 2202
  * Soustrait 2 nombres
2203 2203
  *
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 function moins($a, $b) {
2217 2217
 	return $a - $b;
2218 2218
 }
2219
-function strmoins($a, $b) {return strize('moins', $a, $b);}
2219
+function strmoins($a, $b) {return strize('moins', $a, $b); }
2220 2220
 
2221 2221
 /**
2222 2222
  * Multiplie 2 nombres
@@ -2237,7 +2237,7 @@  discard block
 block discarded – undo
2237 2237
 function mult($a, $b) {
2238 2238
 	return $a * $b;
2239 2239
 }
2240
-function strmult($a, $b) {return strize('mult', $a, $b);}
2240
+function strmult($a, $b) {return strize('mult', $a, $b); }
2241 2241
 
2242 2242
 /**
2243 2243
  * Divise 2 nombres
@@ -2258,7 +2258,7 @@  discard block
 block discarded – undo
2258 2258
 function div($a, $b) {
2259 2259
 	return $b ? $a / $b : 0;
2260 2260
 }
2261
-function strdiv($a, $b) {return strize('div', $a, $b);}
2261
+function strdiv($a, $b) {return strize('div', $a, $b); }
2262 2262
 
2263 2263
 /**
2264 2264
  * Retourne le modulo 2 nombres
@@ -2299,13 +2299,13 @@  discard block
 block discarded – undo
2299 2299
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2300 2300
 		define('_TAGS_NOM_AUTEUR', '');
2301 2301
 	}
2302
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2302
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2303 2303
 	foreach ($tags_acceptes as $tag) {
2304 2304
 		if (strlen($tag)) {
2305
-			$remp1[] = '<' . trim($tag) . '>';
2306
-			$remp1[] = '</' . trim($tag) . '>';
2307
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2308
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2305
+			$remp1[] = '<'.trim($tag).'>';
2306
+			$remp1[] = '</'.trim($tag).'>';
2307
+			$remp2[] = '\x60'.trim($tag).'\x61';
2308
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2309 2309
 		}
2310 2310
 	}
2311 2311
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2355,7 +2355,7 @@  discard block
 block discarded – undo
2355 2355
 			$s[] = preg_replace(',>[^<]+</a>,S',
2356 2356
 				'>'
2357 2357
 				. http_img_pack('attachment-16.png', $t,
2358
-					'title="' . attribut_html($t) . '"')
2358
+					'title="'.attribut_html($t).'"')
2359 2359
 				. '</a>', $tag);
2360 2360
 		}
2361 2361
 	}
@@ -2416,10 +2416,10 @@  discard block
 block discarded – undo
2416 2416
 	$fichier = basename($url);
2417 2417
 
2418 2418
 	return '<a rel="enclosure"'
2419
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2420
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2421
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2422
-	. '>' . $fichier . '</a>';
2419
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2420
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2421
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2422
+	. '>'.$fichier.'</a>';
2423 2423
 }
2424 2424
 
2425 2425
 /**
@@ -2447,9 +2447,9 @@  discard block
 block discarded – undo
2447 2447
 			} # vieux data
2448 2448
 			$fichier = basename($url);
2449 2449
 			$enclosures[] = '<enclosure'
2450
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2451
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2452
-				. ($length ? ' length="' . $length . '"' : '')
2450
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2451
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2452
+				. ($length ? ' length="'.$length.'"' : '')
2453 2453
 				. ' />';
2454 2454
 		}
2455 2455
 	}
@@ -2475,7 +2475,7 @@  discard block
 block discarded – undo
2475 2475
 		if (extraire_attribut($e, rel) == 'tag') {
2476 2476
 			$subjects .= '<dc:subject>'
2477 2477
 				. texte_backend(textebrut($e))
2478
-				. '</dc:subject>' . "\n";
2478
+				. '</dc:subject>'."\n";
2479 2479
 		}
2480 2480
 	}
2481 2481
 
@@ -2511,7 +2511,7 @@  discard block
 block discarded – undo
2511 2511
 	if (is_array($texte)) {
2512 2512
 		array_walk(
2513 2513
 			$texte,
2514
-			function(&$a, $key, $t){
2514
+			function(&$a, $key, $t) {
2515 2515
 				$a = extraire_balise($a, $t);
2516 2516
 			},
2517 2517
 			$tag
@@ -2555,7 +2555,7 @@  discard block
 block discarded – undo
2555 2555
 	if (is_array($texte)) {
2556 2556
 		array_walk(
2557 2557
 			$texte,
2558
-			function(&$a, $key, $t){
2558
+			function(&$a, $key, $t) {
2559 2559
 				$a = extraire_balises($a, $t);
2560 2560
 			},
2561 2561
 			$tag
@@ -2681,7 +2681,7 @@  discard block
 block discarded – undo
2681 2681
 		if ($fond != '404') {
2682 2682
 			$contexte = array_shift($p);
2683 2683
 			$contexte['page'] = $fond;
2684
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2684
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2685 2685
 		}
2686 2686
 	}
2687 2687
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2736,9 +2736,9 @@  discard block
 block discarded – undo
2736 2736
 			. '"'
2737 2737
 			. (is_null($val)
2738 2738
 				? ''
2739
-				: ' value="' . entites_html($val) . '"'
2739
+				: ' value="'.entites_html($val).'"'
2740 2740
 			)
2741
-			. ' type="hidden"' . "\n/>";
2741
+			. ' type="hidden"'."\n/>";
2742 2742
 	}
2743 2743
 
2744 2744
 	return join("", $hidden);
@@ -2875,7 +2875,7 @@  discard block
 block discarded – undo
2875 2875
 	return preg_replace_callback(
2876 2876
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2877 2877
 		function($x) use ($path) {
2878
-			return "url('" . suivre_lien($path, $x[1]) . "')";
2878
+			return "url('".suivre_lien($path, $x[1])."')";
2879 2879
 		},
2880 2880
 		$contenu
2881 2881
 	);
@@ -2937,14 +2937,14 @@  discard block
 block discarded – undo
2937 2937
 	) {
2938 2938
 		$distant = true;
2939 2939
 		$cssf = parse_url($css);
2940
-		$cssf = $cssf['path'] . ($cssf['query'] ? "?" . $cssf['query'] : "");
2940
+		$cssf = $cssf['path'].($cssf['query'] ? "?".$cssf['query'] : "");
2941 2941
 		$cssf = preg_replace(',[?:&=],', "_", $cssf);
2942 2942
 	} else {
2943 2943
 		$distant = false;
2944 2944
 		$cssf = $css;
2945 2945
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2946 2946
 		//propose (rien a faire dans ce cas)
2947
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2947
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2948 2948
 		if (@file_exists($f)) {
2949 2949
 			return $f;
2950 2950
 		}
@@ -2954,7 +2954,7 @@  discard block
 block discarded – undo
2954 2954
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2955 2955
 	$f = $dir_var
2956 2956
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2957
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2957
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2958 2958
 
2959 2959
 	// la css peut etre distante (url absolue !)
2960 2960
 	if ($distant) {
@@ -2999,8 +2999,8 @@  discard block
 block discarded – undo
2999 2999
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
3000 3000
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3001 3001
 			$css_direction = substr($css_direction, strlen($dir_var));
3002
-			$src_faux_abs["/@@@@@@/" . $css_direction] = $css_direction;
3003
-			$css_direction = "/@@@@@@/" . $css_direction;
3002
+			$src_faux_abs["/@@@@@@/".$css_direction] = $css_direction;
3003
+			$css_direction = "/@@@@@@/".$css_direction;
3004 3004
 		}
3005 3005
 		$src[] = $regs[0][$k];
3006 3006
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -3049,7 +3049,7 @@  discard block
 block discarded – undo
3049 3049
 
3050 3050
 	$f = basename($css, '.css');
3051 3051
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3052
-		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3052
+		. preg_replace(",(.*?)(_rtl|_ltr)?$,", "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3053 3053
 		. '.css';
3054 3054
 
3055 3055
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3058,7 +3058,7 @@  discard block
 block discarded – undo
3058 3058
 
3059 3059
 	if ($url_absolue_css == $css) {
3060 3060
 		if (strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3061
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3061
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3062 3062
 		) {
3063 3063
 			include_spip('inc/distant');
3064 3064
 			if (!$contenu = recuperer_page($css)) {
@@ -3168,7 +3168,7 @@  discard block
 block discarded – undo
3168 3168
 	$expression = str_replace("\/", "/", $expression);
3169 3169
 	$expression = str_replace("/", "\/", $expression);
3170 3170
 
3171
-	if (preg_match('/' . $expression . '/' . $modif, $texte, $r)) {
3171
+	if (preg_match('/'.$expression.'/'.$modif, $texte, $r)) {
3172 3172
 		if (isset($r[$capte])) {
3173 3173
 			return $r[$capte];
3174 3174
 		} else {
@@ -3206,7 +3206,7 @@  discard block
 block discarded – undo
3206 3206
 	$expression = str_replace("\/", "/", $expression);
3207 3207
 	$expression = str_replace("/", "\/", $expression);
3208 3208
 
3209
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3209
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3210 3210
 }
3211 3211
 
3212 3212
 
@@ -3225,7 +3225,7 @@  discard block
 block discarded – undo
3225 3225
 function traiter_doublons_documents(&$doublons, $letexte) {
3226 3226
 
3227 3227
 	// Verifier dans le texte & les notes (pas beau, helas)
3228
-	$t = $letexte . $GLOBALS['les_notes'];
3228
+	$t = $letexte.$GLOBALS['les_notes'];
3229 3229
 
3230 3230
 	if (strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3231 3231
 		and preg_match_all(
@@ -3235,7 +3235,7 @@  discard block
 block discarded – undo
3235 3235
 		if (!isset($doublons['documents'])) {
3236 3236
 			$doublons['documents'] = "";
3237 3237
 		}
3238
-		$doublons['documents'] .= "," . join(',', $matches[1]);
3238
+		$doublons['documents'] .= ",".join(',', $matches[1]);
3239 3239
 	}
3240 3240
 
3241 3241
 	return $letexte;
@@ -3292,7 +3292,7 @@  discard block
 block discarded – undo
3292 3292
 	if ($env) {
3293 3293
 		foreach ($env as $i => $j) {
3294 3294
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3295
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3295
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3296 3296
 			}
3297 3297
 		}
3298 3298
 	}
@@ -3331,7 +3331,7 @@  discard block
 block discarded – undo
3331 3331
 	if ($env) {
3332 3332
 		foreach ($env as $i => $j) {
3333 3333
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3334
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3334
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3335 3335
 			}
3336 3336
 		}
3337 3337
 	}
@@ -3415,19 +3415,19 @@  discard block
 block discarded – undo
3415 3415
 
3416 3416
 	$img_file = $img;
3417 3417
 	if ($p = strpos($img_file, '?')) {
3418
-		$img_file = substr($img_file,0, $p);
3418
+		$img_file = substr($img_file, 0, $p);
3419 3419
 	}
3420 3420
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3421 3421
 		$img_file = chemin_image($img);
3422 3422
 	}
3423 3423
 	else {
3424
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true){
3424
+		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3425 3425
 			// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3426 3426
 			// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3427 3427
 			if (preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3428
-			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . "-xx.svg"
3428
+			  and $variante_svg_generique = substr($img_file, 0, -strlen($m[0]))."-xx.svg"
3429 3429
 			  and file_exists($variante_svg_generique)) {
3430
-				if ($variante_svg_size = substr($variante_svg_generique,0,-6) . $m[1] . ".svg" and file_exists($variante_svg_size)) {
3430
+				if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].".svg" and file_exists($variante_svg_size)) {
3431 3431
 					$img_file = $variante_svg_size;
3432 3432
 				}
3433 3433
 				else {
@@ -3452,7 +3452,7 @@  discard block
 block discarded – undo
3452 3452
 				return "";
3453 3453
 			}
3454 3454
 		}
3455
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3455
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3456 3456
 	}
3457 3457
 
3458 3458
 	if (file_exists($img_file)) {
@@ -3461,15 +3461,15 @@  discard block
 block discarded – undo
3461 3461
 	if ($alt === false) {
3462 3462
 		$alt = '';
3463 3463
 	}
3464
-	elseif($alt or $alt==='') {
3464
+	elseif ($alt or $alt === '') {
3465 3465
 		$alt = " alt='".attribut_html($alt)."'";
3466 3466
 	}
3467 3467
 	else {
3468 3468
 		$alt = " alt='".attribut_html($title)."'";
3469 3469
 	}
3470 3470
 	return "<img src='$img_file'$alt"
3471
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3472
-	. " " . ltrim($atts)
3471
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3472
+	. " ".ltrim($atts)
3473 3473
 	. " />";
3474 3474
 }
3475 3475
 
@@ -3481,12 +3481,12 @@  discard block
 block discarded – undo
3481 3481
  * @param string $size
3482 3482
  * @return string
3483 3483
  */
3484
-function http_style_background($img, $att = '', $size=null) {
3485
-	if ($size and is_numeric($size)){
3486
-		$size = trim($size) . "px";
3484
+function http_style_background($img, $att = '', $size = null) {
3485
+	if ($size and is_numeric($size)) {
3486
+		$size = trim($size)."px";
3487 3487
 	}
3488
-	return " style='background" .
3489
-		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
3488
+	return " style='background".
3489
+		($att ? "" : "-image").": url(\"".chemin_image($img)."\")".($att ? (' '.$att) : '').";"
3490 3490
 		. ($size ? "background-size:{$size};" : '')
3491 3491
 		. "'";
3492 3492
 }
@@ -3512,7 +3512,7 @@  discard block
 block discarded – undo
3512 3512
 			$args[] = $maybe_size;
3513 3513
 			$maybe_size = null;
3514 3514
 		}
3515
-		while (count($args)<2) {
3515
+		while (count($args) < 2) {
3516 3516
 			$args[] = null; // default alt or class
3517 3517
 		}
3518 3518
 		$args[] = $maybe_size;
@@ -3522,7 +3522,7 @@  discard block
 block discarded – undo
3522 3522
 
3523 3523
 function helper_filtre_balise_img_svg_size($img, $size) {
3524 3524
 	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3525
-	if (strpos($size, '@') === 0 and substr($size,-1) === 'x') {
3525
+	if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3526 3526
 		$coef = floatval(substr($size, 1, -1));
3527 3527
 		list($h, $w) = taille_image($img);
3528 3528
 		$height = intval(round($h / $coef));
@@ -3577,7 +3577,7 @@  discard block
 block discarded – undo
3577 3577
  * @return string
3578 3578
  *     Code HTML de la balise IMG
3579 3579
  */
3580
-function filtre_balise_img_dist($img, $alt = '', $class = null, $size=null) {
3580
+function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) {
3581 3581
 
3582 3582
 	list($alt, $class, $size) = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3583 3583
 
@@ -3596,7 +3596,7 @@  discard block
 block discarded – undo
3596 3596
 		}
3597 3597
 	}
3598 3598
 	else {
3599
-		$img = http_img_pack($img, $alt, $class ? " class='" . attribut_html($class) . "'" : '', '',
3599
+		$img = http_img_pack($img, $alt, $class ? " class='".attribut_html($class)."'" : '', '',
3600 3600
 				array('chemin_image' => false, 'utiliser_suffixe_size' => false));
3601 3601
 		if (is_null($alt)) {
3602 3602
 			$img = vider_attribut($img, 'alt');
@@ -3642,16 +3642,16 @@  discard block
 block discarded – undo
3642 3642
  * @return string
3643 3643
  *     Code HTML de la balise SVG
3644 3644
  */
3645
-function filtre_balise_svg_dist($img, $alt = '', $class = null, $size=null) {
3645
+function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) {
3646 3646
 
3647 3647
 	$img = trim($img);
3648 3648
 	$img_file = $img;
3649
-	if (strpos($img, '<svg') === false){
3650
-		if ($p = strpos($img_file, '?')){
3649
+	if (strpos($img, '<svg') === false) {
3650
+		if ($p = strpos($img_file, '?')) {
3651 3651
 			$img_file = substr($img_file, 0, $p);
3652 3652
 		}
3653 3653
 
3654
-		if (!$img_file or !$svg = file_get_contents($img_file)){
3654
+		if (!$img_file or !$svg = file_get_contents($img_file)) {
3655 3655
 			return '';
3656 3656
 		}
3657 3657
 	}
@@ -3666,7 +3666,7 @@  discard block
 block discarded – undo
3666 3666
 	$balise_svg_source = $balise_svg;
3667 3667
 
3668 3668
 	// entete XML à supprimer
3669
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3669
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3670 3670
 
3671 3671
 	// IE est toujours mon ami
3672 3672
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
@@ -3682,11 +3682,11 @@  discard block
 block discarded – undo
3682 3682
 	}
3683 3683
 
3684 3684
 	// regler le alt
3685
-	if ($alt){
3685
+	if ($alt) {
3686 3686
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3687
-		$id = "img-svg-title-" . substr(md5("$img_file:$svg:$alt"),0,4);
3687
+		$id = "img-svg-title-".substr(md5("$img_file:$svg:$alt"), 0, 4);
3688 3688
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3689
-		$title = "<title id=\"$id\">" . entites_html($alt)."</title>\n";
3689
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3690 3690
 		$balise_svg .= $title;
3691 3691
 	}
3692 3692
 	else {
@@ -3730,7 +3730,7 @@  discard block
 block discarded – undo
3730 3730
 	$texte = '';
3731 3731
 	if (is_array($tableau)) {
3732 3732
 		foreach ($tableau as $k => $v) {
3733
-			$res = recuperer_fond('modeles/' . $modele,
3733
+			$res = recuperer_fond('modeles/'.$modele,
3734 3734
 				array_merge(array('cle' => $k), (is_array($v) ? $v : array('valeur' => $v)))
3735 3735
 			);
3736 3736
 			$texte .= $res;
@@ -3907,7 +3907,7 @@  discard block
 block discarded – undo
3907 3907
 	}
3908 3908
 
3909 3909
 	$c = serialize($c);
3910
-	$cle = calculer_cle_action($form . $c);
3910
+	$cle = calculer_cle_action($form.$c);
3911 3911
 	$c = "$cle:$c";
3912 3912
 
3913 3913
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3964,15 +3964,15 @@  discard block
 block discarded – undo
3964 3964
 	}
3965 3965
 	// toujours encoder l'url source dans le bloc ajax
3966 3966
 	$r = self();
3967
-	$r = ' data-origin="' . $r . '"';
3967
+	$r = ' data-origin="'.$r.'"';
3968 3968
 	$class = 'ajaxbloc';
3969 3969
 	if ($ajaxid and is_string($ajaxid)) {
3970 3970
 		// ajaxid est normalement conforme a un nom de classe css
3971 3971
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3972
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3972
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3973 3973
 	}
3974 3974
 
3975
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3975
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3976 3976
 }
3977 3977
 
3978 3978
 /**
@@ -4011,11 +4011,11 @@  discard block
 block discarded – undo
4011 4011
 	// extraire la signature en debut de contexte
4012 4012
 	// et la verifier avant de deserializer
4013 4013
 	// format : signature:donneesserializees
4014
-	if ($p = strpos($c,":")){
4015
-		$cle = substr($c,0,$p);
4016
-		$c = substr($c,$p+1);
4014
+	if ($p = strpos($c, ":")) {
4015
+		$cle = substr($c, 0, $p);
4016
+		$c = substr($c, $p + 1);
4017 4017
 
4018
-		if ($cle == calculer_cle_action($form . $c)) {
4018
+		if ($cle == calculer_cle_action($form.$c)) {
4019 4019
 			$env = @unserialize($c);
4020 4020
 			return $env;
4021 4021
 		}
@@ -4121,24 +4121,24 @@  discard block
 block discarded – undo
4121 4121
 		$att = "";
4122 4122
 		// si $on passe la balise et optionnelement une ou ++classe
4123 4123
 		// a.active span.selected.active etc....
4124
-		if (is_string($on) and (strncmp($on, 'a', 1)==0 or strncmp($on, 'span', 4)==0 or strncmp($on, 'strong', 6)==0)){
4124
+		if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4125 4125
 			$on = explode(".", $on);
4126 4126
 			// on verifie que c'est exactement une des 3 balises a, span ou strong
4127
-			if (in_array(reset($on), array('a', 'span', 'strong'))){
4127
+			if (in_array(reset($on), array('a', 'span', 'strong'))) {
4128 4128
 				$bal = array_shift($on);
4129 4129
 				$class = implode(" ", $on);
4130
-				if ($bal=="a"){
4130
+				if ($bal == "a") {
4131 4131
 					$att = 'href="#" ';
4132 4132
 				}
4133 4133
 			}
4134 4134
 		}
4135
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4135
+		$att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"';
4136 4136
 	} else {
4137 4137
 		$bal = 'a';
4138 4138
 		$att = "href='$url'"
4139
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4140
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4141
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4139
+			. ($title ? " title='".attribut_html($title)."'" : '')
4140
+			. ($class ? " class='".attribut_html($class)."'" : '')
4141
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
4142 4142
 			. $evt;
4143 4143
 	}
4144 4144
 	if ($libelle === null) {
@@ -4232,7 +4232,7 @@  discard block
 block discarded – undo
4232 4232
 	}
4233 4233
 
4234 4234
 	// ajouter le type d'objet dans la class de l'icone
4235
-	$class .= " " . substr(basename($fond), 0, -4);
4235
+	$class .= " ".substr(basename($fond), 0, -4);
4236 4236
 
4237 4237
 	$alt = attribut_html($texte);
4238 4238
 	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
@@ -4256,7 +4256,7 @@  discard block
 block discarded – undo
4256 4256
 	}
4257 4257
 
4258 4258
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4259
-	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "") . "\">$icone</span>";
4259
+	$icone = "<span class=\"icone-image".($fonction ? " icone-fonction icone-fonction-$fonction" : "")."\">$icone</span>";
4260 4260
 
4261 4261
 	if ($type == 'lien') {
4262 4262
 		return "<span class='icone s$size $class'>"
@@ -4486,13 +4486,13 @@  discard block
 block discarded – undo
4486 4486
 	$res = "";
4487 4487
 	foreach ($boutons as $page => $detail) {
4488 4488
 		if ($detail->icone and strlen(trim($detail->icone))) {
4489
-			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(" . $detail->icone . ");}";
4489
+			$res .= "\n.navigation_avec_icones #bando1_$page {background-image:url(".$detail->icone.");}";
4490 4490
 		}
4491 4491
 		$selecteur = (in_array($page, array('outils_rapides', 'outils_collaboratifs')) ? "" : ".navigation_avec_icones ");
4492 4492
 		if (is_array($detail->sousmenu)) {
4493 4493
 			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4494 4494
 				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4495
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url(" . $sousdetail->icone . ");}";
4495
+					$res .= "\n$selecteur.bando2_$souspage {background-image:url(".$sousdetail->icone.");}";
4496 4496
 				}
4497 4497
 			}
4498 4498
 		}
@@ -4518,17 +4518,17 @@  discard block
 block discarded – undo
4518 4518
  */
4519 4519
 function bouton_action($libelle, $url, $class = "", $confirm = "", $title = "", $callback = "") {
4520 4520
 	if ($confirm) {
4521
-		$confirm = "confirm(\"" . attribut_html($confirm) . "\")";
4521
+		$confirm = "confirm(\"".attribut_html($confirm)."\")";
4522 4522
 		if ($callback) {
4523 4523
 			$callback = "$confirm?($callback):false";
4524 4524
 		} else {
4525 4525
 			$callback = $confirm;
4526 4526
 		}
4527 4527
 	}
4528
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : "";
4528
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : "";
4529 4529
 	$title = $title ? " title='$title'" : "";
4530 4530
 
4531
-	return "<form class='bouton_action_post $class' method='post' action='$url'><div>" . form_hidden($url)
4531
+	return "<form class='bouton_action_post $class' method='post' action='$url'><div>".form_hidden($url)
4532 4532
 	. "<button type='submit' class='submit'$title$onclick>$libelle</button></div></form>";
4533 4533
 }
4534 4534
 
@@ -4589,14 +4589,14 @@  discard block
 block discarded – undo
4589 4589
 		$champ_titre = "";
4590 4590
 		if ($demande_titre) {
4591 4591
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4592
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4592
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4593 4593
 		}
4594 4594
 		include_spip('base/abstract_sql');
4595 4595
 		include_spip('base/connect_sql');
4596 4596
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4597
-			'*' . $champ_titre,
4597
+			'*'.$champ_titre,
4598 4598
 			$desc['table_sql'],
4599
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4599
+			id_table_objet($type_objet).' = '.intval($id_objet)
4600 4600
 		);
4601 4601
 	}
4602 4602
 
@@ -4666,7 +4666,7 @@  discard block
 block discarded – undo
4666 4666
 		return $texte;
4667 4667
 	}
4668 4668
 
4669
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4669
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4670 4670
 
4671 4671
 	// Fournir $connect et $Pile[0] au traitement si besoin
4672 4672
 	$Pile = array(0 => $env);
@@ -4700,7 +4700,7 @@  discard block
 block discarded – undo
4700 4700
 	}
4701 4701
 	$url = generer_url_entite($id_objet, $objet, '', '', $connect);
4702 4702
 
4703
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . "</a>";
4703
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur)."</a>";
4704 4704
 }
4705 4705
 
4706 4706
 
@@ -4719,10 +4719,10 @@  discard block
 block discarded – undo
4719 4719
 function wrap($texte, $wrap) {
4720 4720
 	$balises = extraire_balises($wrap);
4721 4721
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4722
-		$texte = $wrap . $texte;
4722
+		$texte = $wrap.$texte;
4723 4723
 		$regs = array_reverse($regs[1]);
4724
-		$wrap = "</" . implode("></", $regs) . ">";
4725
-		$texte = $texte . $wrap;
4724
+		$wrap = "</".implode("></", $regs).">";
4725
+		$texte = $texte.$wrap;
4726 4726
 	}
4727 4727
 
4728 4728
 	return $texte;
@@ -4753,7 +4753,7 @@  discard block
 block discarded – undo
4753 4753
 
4754 4754
 	// caster $u en array si besoin
4755 4755
 	if (is_object($u)) {
4756
-		$u = (array)$u;
4756
+		$u = (array) $u;
4757 4757
 	}
4758 4758
 
4759 4759
 	if (is_array($u)) {
@@ -4774,7 +4774,7 @@  discard block
 block discarded – undo
4774 4774
 		// sinon on passe a la ligne et on indente
4775 4775
 		$i_str = str_pad("", $indent, " ");
4776 4776
 		foreach ($u as $k => $v) {
4777
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4777
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4778 4778
 		}
4779 4779
 
4780 4780
 		return $out;
@@ -4827,8 +4827,8 @@  discard block
 block discarded – undo
4827 4827
  * @param string $class
4828 4828
  * @return string
4829 4829
  */
4830
-function objet_icone($objet, $taille = 24, $class='') {
4831
-	$icone = objet_info($objet, 'icone_objet') . "-" . $taille . ".png";
4830
+function objet_icone($objet, $taille = 24, $class = '') {
4831
+	$icone = objet_info($objet, 'icone_objet')."-".$taille.".png";
4832 4832
 	$icone = chemin_image($icone);
4833 4833
 	$balise_img = charger_filtre('balise_img');
4834 4834
 
@@ -4852,12 +4852,12 @@  discard block
 block discarded – undo
4852 4852
  * @param array $options
4853 4853
  * @return string
4854 4854
  */
4855
-function objet_T($objet, $chaine, $args = array(), $options = array()){
4856
-	$chaine = explode(':',$chaine);
4857
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, array('force'=>false)))) {
4855
+function objet_T($objet, $chaine, $args = array(), $options = array()) {
4856
+	$chaine = explode(':', $chaine);
4857
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, array('force'=>false)))) {
4858 4858
 		return $t;
4859 4859
 	}
4860
-	$chaine = implode(':',$chaine);
4860
+	$chaine = implode(':', $chaine);
4861 4861
 	return _T($chaine, $args, $options);
4862 4862
 }
4863 4863
 
@@ -4917,7 +4917,7 @@  discard block
 block discarded – undo
4917 4917
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4918 4918
 
4919 4919
 	// calculer le nom de la css
4920
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4920
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4921 4921
 	$nom_safe = preg_replace(",\W,", '_', str_replace('.', '_', $fond));
4922 4922
 	$contexte_implicite = calculer_contexte_implicite();
4923 4923
 
@@ -4925,22 +4925,22 @@  discard block
 block discarded – undo
4925 4925
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4926 4926
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4927 4927
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
4928
-		$hash = md5($contexte_implicite['host'] . '::'. $cache);
4928
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
4929 4929
 	}
4930 4930
 	else {
4931 4931
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4932 4932
 		ksort($contexte);
4933
-		$hash = md5($fond . json_encode($contexte_implicite) . json_encode($contexte) . $connect);
4933
+		$hash = md5($fond.json_encode($contexte_implicite).json_encode($contexte).$connect);
4934 4934
 	}
4935
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4935
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4936 4936
 
4937 4937
 	// mettre a jour le fichier si il n'existe pas
4938 4938
 	// ou trop ancien
4939 4939
 	// le dernier fichier produit est toujours suffixe par .last
4940 4940
 	// et recopie sur le fichier cible uniquement si il change
4941 4941
 	if (!file_exists($filename)
4942
-		or !file_exists($filename . ".last")
4943
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . ".last") < $cache['lastmodified'])
4942
+		or !file_exists($filename.".last")
4943
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.".last") < $cache['lastmodified'])
4944 4944
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
4945 4945
 	) {
4946 4946
 		$contenu = $cache['texte'];
@@ -4959,10 +4959,10 @@  discard block
 block discarded – undo
4959 4959
 			}
4960 4960
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
4961 4961
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
4962
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
4962
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
4963 4963
 		}
4964 4964
 		// et ecrire le fichier si il change
4965
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
4965
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
4966 4966
 	}
4967 4967
 
4968 4968
 	return timestamp($filename);
@@ -5157,11 +5157,11 @@  discard block
 block discarded – undo
5157 5157
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
5158 5158
 	$l = strlen($passe);
5159 5159
 
5160
-	if ($l<=8 or !$afficher_partiellement){
5160
+	if ($l <= 8 or !$afficher_partiellement) {
5161 5161
 		if (!$l) {
5162 5162
 			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5163 5163
 		}
5164
-		return str_pad('',$afficher_partiellement ? $l : 16,'*');
5164
+		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5165 5165
 	}
5166 5166
 
5167 5167
 	if (is_null($portion_pourcent)) {
@@ -5175,11 +5175,11 @@  discard block
 block discarded – undo
5175 5175
 	}
5176 5176
 	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
5177 5177
 	$e = max($e, 0);
5178
-	$mid = str_pad('',$l-2*$e,'*');
5179
-	if ($e>0 and strlen($mid)>8){
5178
+	$mid = str_pad('', $l - 2 * $e, '*');
5179
+	if ($e > 0 and strlen($mid) > 8) {
5180 5180
 		$mid = '***...***';
5181 5181
 	}
5182
-	return substr($passe,0,$e) . $mid . ($e > 0 ? substr($passe,-$e) : '');
5182
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5183 5183
 }
5184 5184
 
5185 5185
 
@@ -5201,9 +5201,9 @@  discard block
 block discarded – undo
5201 5201
 function identifiant_slug($texte, $type = '', $options = array()) {
5202 5202
 
5203 5203
 	$original = $texte;
5204
-	$separateur = (isset($options['separateur'])?$options['separateur']:'_');
5205
-	$longueur_maxi = (isset($options['longueur_maxi'])?$options['longueur_maxi']:60);
5206
-	$longueur_mini = (isset($options['longueur_mini'])?$options['longueur_mini']:0);
5204
+	$separateur = (isset($options['separateur']) ? $options['separateur'] : '_');
5205
+	$longueur_maxi = (isset($options['longueur_maxi']) ? $options['longueur_maxi'] : 60);
5206
+	$longueur_mini = (isset($options['longueur_mini']) ? $options['longueur_mini'] : 0);
5207 5207
 
5208 5208
 	if (!function_exists('translitteration')) {
5209 5209
 		include_spip('inc/charsets');
@@ -5245,15 +5245,15 @@  discard block
 block discarded – undo
5245 5245
 			}
5246 5246
 	}
5247 5247
 
5248
-	if (strlen($texte)>$longueur_maxi) {
5248
+	if (strlen($texte) > $longueur_maxi) {
5249 5249
 		$texte = substr($texte, 0, $longueur_maxi);
5250 5250
 	}
5251 5251
 
5252 5252
 	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5253 5253
 		if (preg_match(',^\d,', $texte)) {
5254
-			$texte = ($type ? substr($type,0,1) : "s") . $texte;
5254
+			$texte = ($type ? substr($type, 0, 1) : "s").$texte;
5255 5255
 		}
5256
-		$texte .= $separateur . md5($original);
5256
+		$texte .= $separateur.md5($original);
5257 5257
 		$texte = substr($texte, 0, $longueur_mini);
5258 5258
 	}
5259 5259
 
Please login to merge, or discard this patch.