Completed
Push — master ( a5da4e...51674a )
by cam
01:27
created
ecrire/inc/traduire.php 2 patches
Indentation   +192 added lines, -192 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
 
24 24
 /**
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
  *     Liste des fichiers de langue trouvés, dans l'ordre des chemins
40 40
  */
41 41
 function find_langs_in_path($file, $dirname = 'lang') {
42
-	static $dirs = [];
43
-	$liste = [];
44
-	foreach (creer_chemin() as $dir) {
45
-		if (!isset($dirs[$a = $dir . $dirname])) {
46
-			$dirs[$a] = (is_dir($a) || !$a);
47
-		}
48
-		if ($dirs[$a] && is_readable($a .= $file)) {
49
-			$liste[] = $a;
50
-		}
51
-	}
42
+    static $dirs = [];
43
+    $liste = [];
44
+    foreach (creer_chemin() as $dir) {
45
+        if (!isset($dirs[$a = $dir . $dirname])) {
46
+            $dirs[$a] = (is_dir($a) || !$a);
47
+        }
48
+        if ($dirs[$a] && is_readable($a .= $file)) {
49
+            $liste[] = $a;
50
+        }
51
+    }
52 52
 
53
-	return array_reverse($liste);
53
+    return array_reverse($liste);
54 54
 }
55 55
 
56 56
 /**
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
  *     Liste des fichiers touvés pour ce module et cette langue.
66 66
  **/
67 67
 function chercher_module_lang($module, $lang = '') {
68
-	if ($lang) {
69
-		$lang = '_' . $lang;
70
-	}
68
+    if ($lang) {
69
+        $lang = '_' . $lang;
70
+    }
71 71
 
72
-	// 1) dans un repertoire nomme lang/ se trouvant sur le chemin
73
-	if (
74
-		$f = ($module == 'local'
75
-		? find_in_path($module . $lang . '.php', 'lang/')
76
-		: find_langs_in_path($module . $lang . '.php', 'lang/'))
77
-	) {
78
-		return is_array($f) ? $f : [$f];
79
-	}
72
+    // 1) dans un repertoire nomme lang/ se trouvant sur le chemin
73
+    if (
74
+        $f = ($module == 'local'
75
+        ? find_in_path($module . $lang . '.php', 'lang/')
76
+        : find_langs_in_path($module . $lang . '.php', 'lang/'))
77
+    ) {
78
+        return is_array($f) ? $f : [$f];
79
+    }
80 80
 
81
-	// 2) directement dans le chemin (old style, uniquement pour local)
82
-	return ($module == 'local' || strpos($module, '/'))
83
-		? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false)
84
-		: false;
81
+    // 2) directement dans le chemin (old style, uniquement pour local)
82
+    return ($module == 'local' || strpos($module, '/'))
83
+        ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false)
84
+        : false;
85 85
 }
86 86
 
87 87
 /**
@@ -103,33 +103,33 @@  discard block
 block discarded – undo
103 103
  * @return void
104 104
  **/
105 105
 function charger_langue($lang, $module = 'spip') {
106
-	static $langs = [];
107
-	$var = 'i18n_' . $module . '_' . $lang;
108
-	if (!isset($langs[$lang])) {
109
-		$langs[$lang] = [];
110
-		if ($lang) {
111
-			$langs[$lang][] = $lang;
112
-			if (str_contains($lang, '_')) {
113
-				$l = explode('_', $lang);
114
-				$langs[$lang][] = reset($l);
115
-			}
116
-		}
117
-		$langs[$lang][] = $GLOBALS['meta']['langue_site'];
118
-		$langs[$lang][] = _LANGUE_PAR_DEFAUT;
119
-	}
120
-	foreach ($langs[$lang] as $l) {
121
-		if ($fichiers_lang = chercher_module_lang($module, $l)) {
122
-			$GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l;
123
-			$GLOBALS[$GLOBALS['idx_lang']] = lire_fichier_langue(array_shift($fichiers_lang));
124
-			surcharger_langue($fichiers_lang);
125
-			if ($l !== $lang) {
126
-				$GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l];
127
-			}
128
-			$GLOBALS['lang_' . $var] = $l;
129
-			#spip_log("module de langue : {$module}_$l.php", 'traduire');
130
-			break;
131
-		}
132
-	}
106
+    static $langs = [];
107
+    $var = 'i18n_' . $module . '_' . $lang;
108
+    if (!isset($langs[$lang])) {
109
+        $langs[$lang] = [];
110
+        if ($lang) {
111
+            $langs[$lang][] = $lang;
112
+            if (str_contains($lang, '_')) {
113
+                $l = explode('_', $lang);
114
+                $langs[$lang][] = reset($l);
115
+            }
116
+        }
117
+        $langs[$lang][] = $GLOBALS['meta']['langue_site'];
118
+        $langs[$lang][] = _LANGUE_PAR_DEFAUT;
119
+    }
120
+    foreach ($langs[$lang] as $l) {
121
+        if ($fichiers_lang = chercher_module_lang($module, $l)) {
122
+            $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l;
123
+            $GLOBALS[$GLOBALS['idx_lang']] = lire_fichier_langue(array_shift($fichiers_lang));
124
+            surcharger_langue($fichiers_lang);
125
+            if ($l !== $lang) {
126
+                $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l];
127
+            }
128
+            $GLOBALS['lang_' . $var] = $l;
129
+            #spip_log("module de langue : {$module}_$l.php", 'traduire');
130
+            break;
131
+        }
132
+    }
133 133
 }
134 134
 
135 135
 /**
@@ -142,21 +142,21 @@  discard block
 block discarded – undo
142 142
  * @return array<string, string>
143 143
  */
144 144
 function lire_fichier_langue(string $fichier): array {
145
-	$idx_lang_before = $GLOBALS['idx_lang'] ?? null;
146
-	$idx_lang_tmp = ($GLOBALS['idx_lang'] ?? 'lang') . '@temporaire';
147
-	$GLOBALS['idx_lang'] = $idx_lang_tmp;
148
-	$idx_lang = include $fichier;
149
-	$GLOBALS['idx_lang'] = $idx_lang_before;
150
-	if (!is_array($idx_lang)) {
151
-		if (isset($GLOBALS[$idx_lang_tmp]) && is_array($GLOBALS[$idx_lang_tmp])) {
152
-			$idx_lang = $GLOBALS[$idx_lang_tmp];
153
-		} else {
154
-			$idx_lang = [];
155
-			spip_log(sprintf('Fichier de langue incorrect : %s', $fichier), _LOG_ERREUR);
156
-		}
157
-		unset($GLOBALS[$idx_lang_tmp]);
158
-	}
159
-	return $idx_lang;
145
+    $idx_lang_before = $GLOBALS['idx_lang'] ?? null;
146
+    $idx_lang_tmp = ($GLOBALS['idx_lang'] ?? 'lang') . '@temporaire';
147
+    $GLOBALS['idx_lang'] = $idx_lang_tmp;
148
+    $idx_lang = include $fichier;
149
+    $GLOBALS['idx_lang'] = $idx_lang_before;
150
+    if (!is_array($idx_lang)) {
151
+        if (isset($GLOBALS[$idx_lang_tmp]) && is_array($GLOBALS[$idx_lang_tmp])) {
152
+            $idx_lang = $GLOBALS[$idx_lang_tmp];
153
+        } else {
154
+            $idx_lang = [];
155
+            spip_log(sprintf('Fichier de langue incorrect : %s', $fichier), _LOG_ERREUR);
156
+        }
157
+        unset($GLOBALS[$idx_lang_tmp]);
158
+    }
159
+    return $idx_lang;
160 160
 }
161 161
 
162 162
 /**
@@ -176,29 +176,29 @@  discard block
 block discarded – undo
176 176
  *    Liste des chemins de fichiers de langue à surcharger.
177 177
  **/
178 178
 function surcharger_langue($fichiers) {
179
-	static $surcharges = [];
180
-	if (!isset($GLOBALS['idx_lang'])) {
181
-		return;
182
-	}
179
+    static $surcharges = [];
180
+    if (!isset($GLOBALS['idx_lang'])) {
181
+        return;
182
+    }
183 183
 
184
-	if (!is_array($fichiers)) {
185
-		$fichiers = [$fichiers];
186
-	}
187
-	if ($fichiers === []) {
188
-		return;
189
-	}
190
-	foreach ($fichiers as $fichier) {
191
-		if (!isset($surcharges[$fichier])) {
192
-			$surcharges[$fichier] = lire_fichier_langue($fichier);
193
-		}
194
-		if (is_array($surcharges[$fichier])) {
195
-			$GLOBALS[$GLOBALS['idx_lang']] ??= [];
196
-			$GLOBALS[$GLOBALS['idx_lang']] = array_merge(
197
-				$GLOBALS[$GLOBALS['idx_lang']],
198
-				$surcharges[$fichier]
199
-			);
200
-		}
201
-	}
184
+    if (!is_array($fichiers)) {
185
+        $fichiers = [$fichiers];
186
+    }
187
+    if ($fichiers === []) {
188
+        return;
189
+    }
190
+    foreach ($fichiers as $fichier) {
191
+        if (!isset($surcharges[$fichier])) {
192
+            $surcharges[$fichier] = lire_fichier_langue($fichier);
193
+        }
194
+        if (is_array($surcharges[$fichier])) {
195
+            $GLOBALS[$GLOBALS['idx_lang']] ??= [];
196
+            $GLOBALS[$GLOBALS['idx_lang']] = array_merge(
197
+                $GLOBALS[$GLOBALS['idx_lang']],
198
+                $surcharges[$fichier]
199
+            );
200
+        }
201
+    }
202 202
 }
203 203
 
204 204
 /**
@@ -239,99 +239,99 @@  discard block
 block discarded – undo
239 239
  *     - Description : traduction et description (texte, module, langue)
240 240
  **/
241 241
 function inc_traduire_dist($ori, $lang, $raw = false) {
242
-	static $deja_vu = [];
243
-	static $local = [];
242
+    static $deja_vu = [];
243
+    static $local = [];
244 244
 
245
-	if (isset($deja_vu[$lang][$ori]) && _request('var_mode') != 'traduction') {
246
-		return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte;
247
-	}
245
+    if (isset($deja_vu[$lang][$ori]) && _request('var_mode') != 'traduction') {
246
+        return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte;
247
+    }
248 248
 
249
-	// modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES
250
-	if (strpos($ori, ':')) {
251
-		[$modules, $code] = explode(':', $ori, 2);
252
-		$modules = explode('|', $modules);
253
-		$ori_complet = $ori;
254
-	} else {
255
-		$modules = ['spip', 'ecrire'];
256
-		$code = $ori;
257
-		$ori_complet = implode('|', $modules) . ':' . $ori;
258
-	}
249
+    // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES
250
+    if (strpos($ori, ':')) {
251
+        [$modules, $code] = explode(':', $ori, 2);
252
+        $modules = explode('|', $modules);
253
+        $ori_complet = $ori;
254
+    } else {
255
+        $modules = ['spip', 'ecrire'];
256
+        $code = $ori;
257
+        $ori_complet = implode('|', $modules) . ':' . $ori;
258
+    }
259 259
 
260
-	$desc = new Description();
260
+    $desc = new Description();
261 261
 
262
-	// parcourir tous les modules jusqu'a ce qu'on trouve
263
-	foreach ($modules as $module) {
264
-		$var = 'i18n_' . $module . '_' . $lang;
262
+    // parcourir tous les modules jusqu'a ce qu'on trouve
263
+    foreach ($modules as $module) {
264
+        $var = 'i18n_' . $module . '_' . $lang;
265 265
 
266
-		if (empty($GLOBALS[$var])) {
267
-			charger_langue($lang, $module);
268
-			// surcharges persos -- on cherche
269
-			// (lang/)local_xx.php et/ou (lang/)local.php ...
270
-			if (!isset($local['local_' . $lang])) {
271
-				// redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer)
272
-				$GLOBALS['idx_lang'] = $var;
273
-				// ... (lang/)local_xx.php
274
-				$local['local_' . $lang] = chercher_module_lang('local', $lang);
275
-			}
276
-			if ($local['local_' . $lang]) {
277
-				surcharger_langue($local['local_' . $lang]);
278
-			}
279
-			// ... puis (lang/)local.php
280
-			if (!isset($local['local'])) {
281
-				$local['local'] = chercher_module_lang('local');
282
-			}
283
-			if ($local['local']) {
284
-				surcharger_langue($local['local']);
285
-			}
286
-		}
266
+        if (empty($GLOBALS[$var])) {
267
+            charger_langue($lang, $module);
268
+            // surcharges persos -- on cherche
269
+            // (lang/)local_xx.php et/ou (lang/)local.php ...
270
+            if (!isset($local['local_' . $lang])) {
271
+                // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer)
272
+                $GLOBALS['idx_lang'] = $var;
273
+                // ... (lang/)local_xx.php
274
+                $local['local_' . $lang] = chercher_module_lang('local', $lang);
275
+            }
276
+            if ($local['local_' . $lang]) {
277
+                surcharger_langue($local['local_' . $lang]);
278
+            }
279
+            // ... puis (lang/)local.php
280
+            if (!isset($local['local'])) {
281
+                $local['local'] = chercher_module_lang('local');
282
+            }
283
+            if ($local['local']) {
284
+                surcharger_langue($local['local']);
285
+            }
286
+        }
287 287
 
288
-		if (isset($GLOBALS[$var][$code])) {
289
-			$desc->code = $code;
290
-			$desc->module = $module;
291
-			$desc->langue = $GLOBALS['lang_' . $var] ?? $lang;
292
-			$desc->texte = $GLOBALS[$var][$code];
293
-			break;
294
-		}
295
-	}
288
+        if (isset($GLOBALS[$var][$code])) {
289
+            $desc->code = $code;
290
+            $desc->module = $module;
291
+            $desc->langue = $GLOBALS['lang_' . $var] ?? $lang;
292
+            $desc->texte = $GLOBALS[$var][$code];
293
+            break;
294
+        }
295
+    }
296 296
 
297
-	if (!$desc->corrections) {
298
-		$desc->corrections = true;
299
-		// Retour aux sources si la chaine est absente dans la langue cible ;
300
-		// on essaie d'abord la langue du site, puis a defaut la langue fr
301
-		if (
302
-			($desc->texte === null || !strlen($desc->texte))
303
-			&& $lang !== _LANGUE_PAR_DEFAUT
304
-		) {
305
-			if ($lang !== $GLOBALS['meta']['langue_site']) {
306
-				$desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true);
307
-			} else {
308
-				$desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true);
309
-			}
310
-		}
297
+    if (!$desc->corrections) {
298
+        $desc->corrections = true;
299
+        // Retour aux sources si la chaine est absente dans la langue cible ;
300
+        // on essaie d'abord la langue du site, puis a defaut la langue fr
301
+        if (
302
+            ($desc->texte === null || !strlen($desc->texte))
303
+            && $lang !== _LANGUE_PAR_DEFAUT
304
+        ) {
305
+            if ($lang !== $GLOBALS['meta']['langue_site']) {
306
+                $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true);
307
+            } else {
308
+                $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true);
309
+            }
310
+        }
311 311
 
312
-		// Supprimer la mention <NEW> ou <MODIF>
313
-		if ($desc->texte && str_starts_with($desc->texte, '<')) {
314
-			$desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte);
315
-		}
312
+        // Supprimer la mention <NEW> ou <MODIF>
313
+        if ($desc->texte && str_starts_with($desc->texte, '<')) {
314
+            $desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte);
315
+        }
316 316
 
317
-		// Si on n'est pas en utf-8, la chaine peut l'etre...
318
-		// le cas echeant on la convertit en entites html &#xxx;
319
-		if (
320
-			(!isset($GLOBALS['meta']['charset']) || $GLOBALS['meta']['charset'] !== 'utf-8')
321
-			&& preg_match(',[\x7f-\xff],S', $desc->texte)
322
-		) {
323
-			include_spip('inc/charsets');
324
-			$desc->texte = charset2unicode($desc->texte, 'utf-8');
325
-		}
326
-	}
317
+        // Si on n'est pas en utf-8, la chaine peut l'etre...
318
+        // le cas echeant on la convertit en entites html &#xxx;
319
+        if (
320
+            (!isset($GLOBALS['meta']['charset']) || $GLOBALS['meta']['charset'] !== 'utf-8')
321
+            && preg_match(',[\x7f-\xff],S', $desc->texte)
322
+        ) {
323
+            include_spip('inc/charsets');
324
+            $desc->texte = charset2unicode($desc->texte, 'utf-8');
325
+        }
326
+    }
327 327
 
328
-	if (_request('var_mode') == 'traduction') {
329
-		$desc = definir_details_traduction($desc, $ori_complet);
330
-	} else {
331
-		$deja_vu[$lang][$ori] = $desc;
332
-	}
328
+    if (_request('var_mode') == 'traduction') {
329
+        $desc = definir_details_traduction($desc, $ori_complet);
330
+    } else {
331
+        $deja_vu[$lang][$ori] = $desc;
332
+    }
333 333
 
334
-	return $raw ? $desc : $desc->texte;
334
+    return $raw ? $desc : $desc->texte;
335 335
 }
336 336
 
337 337
 /**
@@ -343,23 +343,23 @@  discard block
 block discarded – undo
343 343
  * @return Description
344 344
  */
345 345
 function definir_details_traduction($desc, $modules) {
346
-	if (!$desc->mode && $desc->texte) {
347
-		// ne pas modifier 2 fois l'affichage
348
-		$desc->mode = 'traduction';
349
-		$classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : '');
350
-		$desc->texte = '<span '
351
-			. 'lang=' . $desc->langue
352
-			. ' class=' . $classe
353
-			. ' data-module=' . $desc->module
354
-			. ' data-code=' . $desc->code
355
-			. ' title=' . $modules . '(' . $desc->langue . ')>'
356
-			. $desc->texte
357
-			. '</span>';
358
-		$desc->texte = str_replace(
359
-			["$desc->module:", "$desc->module|"],
360
-			["*$desc->module*:", "*$desc->module*|"],
361
-			$desc->texte
362
-		);
363
-	}
364
-	return $desc;
346
+    if (!$desc->mode && $desc->texte) {
347
+        // ne pas modifier 2 fois l'affichage
348
+        $desc->mode = 'traduction';
349
+        $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : '');
350
+        $desc->texte = '<span '
351
+            . 'lang=' . $desc->langue
352
+            . ' class=' . $classe
353
+            . ' data-module=' . $desc->module
354
+            . ' data-code=' . $desc->code
355
+            . ' title=' . $modules . '(' . $desc->langue . ')>'
356
+            . $desc->texte
357
+            . '</span>';
358
+        $desc->texte = str_replace(
359
+            ["$desc->module:", "$desc->module|"],
360
+            ["*$desc->module*:", "*$desc->module*|"],
361
+            $desc->texte
362
+        );
363
+    }
364
+    return $desc;
365 365
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	static $dirs = [];
43 43
 	$liste = [];
44 44
 	foreach (creer_chemin() as $dir) {
45
-		if (!isset($dirs[$a = $dir . $dirname])) {
45
+		if (!isset($dirs[$a = $dir.$dirname])) {
46 46
 			$dirs[$a] = (is_dir($a) || !$a);
47 47
 		}
48 48
 		if ($dirs[$a] && is_readable($a .= $file)) {
@@ -66,21 +66,21 @@  discard block
 block discarded – undo
66 66
  **/
67 67
 function chercher_module_lang($module, $lang = '') {
68 68
 	if ($lang) {
69
-		$lang = '_' . $lang;
69
+		$lang = '_'.$lang;
70 70
 	}
71 71
 
72 72
 	// 1) dans un repertoire nomme lang/ se trouvant sur le chemin
73 73
 	if (
74 74
 		$f = ($module == 'local'
75
-		? find_in_path($module . $lang . '.php', 'lang/')
76
-		: find_langs_in_path($module . $lang . '.php', 'lang/'))
75
+		? find_in_path($module.$lang.'.php', 'lang/')
76
+		: find_langs_in_path($module.$lang.'.php', 'lang/'))
77 77
 	) {
78 78
 		return is_array($f) ? $f : [$f];
79 79
 	}
80 80
 
81 81
 	// 2) directement dans le chemin (old style, uniquement pour local)
82 82
 	return ($module == 'local' || strpos($module, '/'))
83
-		? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false)
83
+		? (($f = find_in_path($module.$lang.'.php')) ? [$f] : false)
84 84
 		: false;
85 85
 }
86 86
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
  **/
105 105
 function charger_langue($lang, $module = 'spip') {
106 106
 	static $langs = [];
107
-	$var = 'i18n_' . $module . '_' . $lang;
107
+	$var = 'i18n_'.$module.'_'.$lang;
108 108
 	if (!isset($langs[$lang])) {
109 109
 		$langs[$lang] = [];
110 110
 		if ($lang) {
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 	}
120 120
 	foreach ($langs[$lang] as $l) {
121 121
 		if ($fichiers_lang = chercher_module_lang($module, $l)) {
122
-			$GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l;
122
+			$GLOBALS['idx_lang'] = 'i18n_'.$module.'_'.$l;
123 123
 			$GLOBALS[$GLOBALS['idx_lang']] = lire_fichier_langue(array_shift($fichiers_lang));
124 124
 			surcharger_langue($fichiers_lang);
125 125
 			if ($l !== $lang) {
126
-				$GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l];
126
+				$GLOBALS[$var] = &$GLOBALS['i18n_'.$module.'_'.$l];
127 127
 			}
128
-			$GLOBALS['lang_' . $var] = $l;
128
+			$GLOBALS['lang_'.$var] = $l;
129 129
 			#spip_log("module de langue : {$module}_$l.php", 'traduire');
130 130
 			break;
131 131
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
  */
144 144
 function lire_fichier_langue(string $fichier): array {
145 145
 	$idx_lang_before = $GLOBALS['idx_lang'] ?? null;
146
-	$idx_lang_tmp = ($GLOBALS['idx_lang'] ?? 'lang') . '@temporaire';
146
+	$idx_lang_tmp = ($GLOBALS['idx_lang'] ?? 'lang').'@temporaire';
147 147
 	$GLOBALS['idx_lang'] = $idx_lang_tmp;
148 148
 	$idx_lang = include $fichier;
149 149
 	$GLOBALS['idx_lang'] = $idx_lang_before;
@@ -254,27 +254,27 @@  discard block
 block discarded – undo
254 254
 	} else {
255 255
 		$modules = ['spip', 'ecrire'];
256 256
 		$code = $ori;
257
-		$ori_complet = implode('|', $modules) . ':' . $ori;
257
+		$ori_complet = implode('|', $modules).':'.$ori;
258 258
 	}
259 259
 
260 260
 	$desc = new Description();
261 261
 
262 262
 	// parcourir tous les modules jusqu'a ce qu'on trouve
263 263
 	foreach ($modules as $module) {
264
-		$var = 'i18n_' . $module . '_' . $lang;
264
+		$var = 'i18n_'.$module.'_'.$lang;
265 265
 
266 266
 		if (empty($GLOBALS[$var])) {
267 267
 			charger_langue($lang, $module);
268 268
 			// surcharges persos -- on cherche
269 269
 			// (lang/)local_xx.php et/ou (lang/)local.php ...
270
-			if (!isset($local['local_' . $lang])) {
270
+			if (!isset($local['local_'.$lang])) {
271 271
 				// redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer)
272 272
 				$GLOBALS['idx_lang'] = $var;
273 273
 				// ... (lang/)local_xx.php
274
-				$local['local_' . $lang] = chercher_module_lang('local', $lang);
274
+				$local['local_'.$lang] = chercher_module_lang('local', $lang);
275 275
 			}
276
-			if ($local['local_' . $lang]) {
277
-				surcharger_langue($local['local_' . $lang]);
276
+			if ($local['local_'.$lang]) {
277
+				surcharger_langue($local['local_'.$lang]);
278 278
 			}
279 279
 			// ... puis (lang/)local.php
280 280
 			if (!isset($local['local'])) {
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 		if (isset($GLOBALS[$var][$code])) {
289 289
 			$desc->code = $code;
290 290
 			$desc->module = $module;
291
-			$desc->langue = $GLOBALS['lang_' . $var] ?? $lang;
291
+			$desc->langue = $GLOBALS['lang_'.$var] ?? $lang;
292 292
 			$desc->texte = $GLOBALS[$var][$code];
293 293
 			break;
294 294
 		}
@@ -346,13 +346,13 @@  discard block
 block discarded – undo
346 346
 	if (!$desc->mode && $desc->texte) {
347 347
 		// ne pas modifier 2 fois l'affichage
348 348
 		$desc->mode = 'traduction';
349
-		$classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : '');
349
+		$classe = 'debug-traduction'.($desc->module == 'ecrire' ? '-prive' : '');
350 350
 		$desc->texte = '<span '
351
-			. 'lang=' . $desc->langue
352
-			. ' class=' . $classe
353
-			. ' data-module=' . $desc->module
354
-			. ' data-code=' . $desc->code
355
-			. ' title=' . $modules . '(' . $desc->langue . ')>'
351
+			. 'lang='.$desc->langue
352
+			. ' class='.$classe
353
+			. ' data-module='.$desc->module
354
+			. ' data-code='.$desc->code
355
+			. ' title='.$modules.'('.$desc->langue.')>'
356 356
 			. $desc->texte
357 357
 			. '</span>';
358 358
 		$desc->texte = str_replace(
Please login to merge, or discard this patch.
ecrire/inc/bandeau.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			$_id = $e['id_table_objet'];
52 52
 			if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) {
53 53
 				$table = $e['table_objet_sql'];
54
-				$row = sql_fetsel('*', $table, "$_id=" . (int) $id);
54
+				$row = sql_fetsel('*', $table, "$_id=".(int) $id);
55 55
 				if (isset($row['id_rubrique'])) {
56 56
 					$contexte['id_rubrique'] = $row['id_rubrique'];
57 57
 					if (isset($row['id_secteur'])) {
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 				$boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
116 116
 					+ [
117 117
 						$id => new Bouton(
118
-							($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
119
-							$infos['titre'],  // titre
118
+							($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone
119
+							$infos['titre'], // titre
120 120
 							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
121 121
 							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
122 122
 						)
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 				$boutons_admin = array_slice($boutons_admin, 0, $position)
134 134
 					+ [
135 135
 						$id => new Bouton(
136
-							($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
137
-							$infos['titre'],  // titre
136
+							($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone
137
+							$infos['titre'], // titre
138 138
 							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
139 139
 							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
140 140
 						)
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		$url = str_replace('&amp;', '&', $url);
222 222
 		while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
223 223
 			if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) {
224
-				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']);
224
+				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.(int) $contexte['id_rubrique']);
225 225
 			}
226 226
 			$val = _request($matches[2], $contexte);
227 227
 			$url = parametre_url($url, $matches[1], $val ?: '', '&');
Please login to merge, or discard this patch.
Indentation   +149 added lines, -149 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
 
24 24
 include_spip('inc/boutons');
@@ -38,33 +38,33 @@  discard block
 block discarded – undo
38 38
  *     contexte
39 39
  **/
40 40
 function definir_barre_contexte($contexte = null) {
41
-	if (is_null($contexte)) {
42
-		$contexte = $_GET;
43
-	} elseif (is_string($contexte)) {
44
-		$contexte = unserialize($contexte);
45
-	}
46
-	if (!isset($contexte['id_rubrique']) && isset($contexte['exec'])) {
47
-		if (!function_exists('trouver_objet_exec')) {
48
-			include_spip('inc/pipelines_ecrire');
49
-		}
50
-		if ($e = trouver_objet_exec($contexte['exec'])) {
51
-			$_id = $e['id_table_objet'];
52
-			if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) {
53
-				$table = $e['table_objet_sql'];
54
-				$row = sql_fetsel('*', $table, "$_id=" . (int) $id);
55
-				if (isset($row['id_rubrique'])) {
56
-					$contexte['id_rubrique'] = $row['id_rubrique'];
57
-					if (isset($row['id_secteur'])) {
58
-						$contexte['id_secteur'] = $row['id_secteur'];
59
-					}
60
-				} elseif (isset($row['id_groupe'])) {
61
-					// TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
62
-					$contexte['id_groupe'] = $row['id_groupe'];
63
-				}
64
-			}
65
-		}
66
-	}
67
-	return $contexte;
41
+    if (is_null($contexte)) {
42
+        $contexte = $_GET;
43
+    } elseif (is_string($contexte)) {
44
+        $contexte = unserialize($contexte);
45
+    }
46
+    if (!isset($contexte['id_rubrique']) && isset($contexte['exec'])) {
47
+        if (!function_exists('trouver_objet_exec')) {
48
+            include_spip('inc/pipelines_ecrire');
49
+        }
50
+        if ($e = trouver_objet_exec($contexte['exec'])) {
51
+            $_id = $e['id_table_objet'];
52
+            if (isset($contexte[$_id]) && ($id = (int) $contexte[$_id])) {
53
+                $table = $e['table_objet_sql'];
54
+                $row = sql_fetsel('*', $table, "$_id=" . (int) $id);
55
+                if (isset($row['id_rubrique'])) {
56
+                    $contexte['id_rubrique'] = $row['id_rubrique'];
57
+                    if (isset($row['id_secteur'])) {
58
+                        $contexte['id_secteur'] = $row['id_secteur'];
59
+                    }
60
+                } elseif (isset($row['id_groupe'])) {
61
+                    // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
62
+                    $contexte['id_groupe'] = $row['id_groupe'];
63
+                }
64
+            }
65
+        }
66
+    }
67
+    return $contexte;
68 68
 }
69 69
 
70 70
 /**
@@ -80,89 +80,89 @@  discard block
 block discarded – undo
80 80
  * @return array
81 81
  */
82 82
 function definir_barre_boutons($contexte = [], $icones = true, $autorise = true) {
83
-	include_spip('inc/autoriser');
84
-	$boutons_admin = [];
83
+    include_spip('inc/autoriser');
84
+    $boutons_admin = [];
85 85
 
86
-	// les boutons du core, issus de ecrire/paquet.xml
87
-	$liste_boutons = [];
86
+    // les boutons du core, issus de ecrire/paquet.xml
87
+    $liste_boutons = [];
88 88
 
89
-	// ajouter les boutons issus des plugin via paquet.xml
90
-	if (
91
-		function_exists('boutons_plugins')
92
-		&& is_array($liste_boutons_plugins = boutons_plugins())
93
-	) {
94
-		$liste_boutons = &$liste_boutons_plugins;
95
-	}
89
+    // ajouter les boutons issus des plugin via paquet.xml
90
+    if (
91
+        function_exists('boutons_plugins')
92
+        && is_array($liste_boutons_plugins = boutons_plugins())
93
+    ) {
94
+        $liste_boutons = &$liste_boutons_plugins;
95
+    }
96 96
 
97
-	foreach ($liste_boutons as $id => $infos) {
98
-		$parent = '';
99
-		// les boutons principaux ne sont pas soumis a autorisation
100
-		if (
101
-			!isset($infos['parent'])
102
-			|| !($parent = $infos['parent'])
103
-			|| !$autorise
104
-			|| autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
105
-		) {
106
-			if (
107
-				$parent
108
-				&& ($parent = preg_replace(',^bando_,', 'menu_', (string) $parent))
109
-				&& isset($boutons_admin[$parent])
110
-			) {
111
-				$position = (isset($infos['position']) && strlen((string) $infos['position'])) ? (int) $infos['position'] : count($boutons_admin[$parent]->sousmenu);
112
-				if ($position < 0) {
113
-					$position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
114
-				}
115
-				$boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
116
-					+ [
117
-						$id => new Bouton(
118
-							($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
119
-							$infos['titre'],  // titre
120
-							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
121
-							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
122
-						)
123
-					]
124
-					+ array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
125
-			}
126
-			if (
127
-				!$parent
128
-				// provisoire, eviter les vieux boutons
129
-				&& !in_array($id, ['forum', 'statistiques_visites'])
130
-				&& (!$autorise || autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
131
-			) {
132
-				$position = (isset($infos['position']) && $infos['position']) ? $infos['position'] : count($boutons_admin);
133
-				$boutons_admin = array_slice($boutons_admin, 0, $position)
134
-					+ [
135
-						$id => new Bouton(
136
-							($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
137
-							$infos['titre'],  // titre
138
-							(isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
139
-							(isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
140
-						)
141
-					]
142
-					+ array_slice($boutons_admin, $position, 100);
143
-			}
144
-		}
145
-	}
146
-	$boutons_admin = pipeline('ajouter_menus', $boutons_admin);
97
+    foreach ($liste_boutons as $id => $infos) {
98
+        $parent = '';
99
+        // les boutons principaux ne sont pas soumis a autorisation
100
+        if (
101
+            !isset($infos['parent'])
102
+            || !($parent = $infos['parent'])
103
+            || !$autorise
104
+            || autoriser('menu', "_$id", 0, null, ['contexte' => $contexte])
105
+        ) {
106
+            if (
107
+                $parent
108
+                && ($parent = preg_replace(',^bando_,', 'menu_', (string) $parent))
109
+                && isset($boutons_admin[$parent])
110
+            ) {
111
+                $position = (isset($infos['position']) && strlen((string) $infos['position'])) ? (int) $infos['position'] : count($boutons_admin[$parent]->sousmenu);
112
+                if ($position < 0) {
113
+                    $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
114
+                }
115
+                $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
116
+                    + [
117
+                        $id => new Bouton(
118
+                            ($icones && !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
119
+                            $infos['titre'],  // titre
120
+                            (isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
121
+                            (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
122
+                        )
123
+                    ]
124
+                    + array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
125
+            }
126
+            if (
127
+                !$parent
128
+                // provisoire, eviter les vieux boutons
129
+                && !in_array($id, ['forum', 'statistiques_visites'])
130
+                && (!$autorise || autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte]))
131
+            ) {
132
+                $position = (isset($infos['position']) && $infos['position']) ? $infos['position'] : count($boutons_admin);
133
+                $boutons_admin = array_slice($boutons_admin, 0, $position)
134
+                    + [
135
+                        $id => new Bouton(
136
+                            ($icones && isset($infos['icone']) && $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
137
+                            $infos['titre'],  // titre
138
+                            (isset($infos['action']) && $infos['action']) ? $infos['action'] : null,
139
+                            (isset($infos['parametres']) && $infos['parametres']) ? $infos['parametres'] : null
140
+                        )
141
+                    ]
142
+                    + array_slice($boutons_admin, $position, 100);
143
+            }
144
+        }
145
+    }
146
+    $boutons_admin = pipeline('ajouter_menus', $boutons_admin);
147 147
 
148
-	// définir les favoris et positions d’origine
149
-	if ($boutons_admin) {
150
-		$menus_favoris = obtenir_menus_favoris();
151
-		$i = 1;
152
-		foreach ($boutons_admin as $key => $menu) {
153
-			$menu->favori = (int) table_valeur($menus_favoris, $key, false);
154
-			$menu->position = $i++;
155
-			if ($menu->sousmenu) {
156
-				$j = 1;
157
-				foreach ($menu->sousmenu as $key => $bouton) {
158
-					$bouton->favori = (int) table_valeur($menus_favoris, $key, false);
159
-					$bouton->position = $j++;
160
-				}
161
-			}
162
-		}
163
-	}
148
+    // définir les favoris et positions d’origine
149
+    if ($boutons_admin) {
150
+        $menus_favoris = obtenir_menus_favoris();
151
+        $i = 1;
152
+        foreach ($boutons_admin as $key => $menu) {
153
+            $menu->favori = (int) table_valeur($menus_favoris, $key, false);
154
+            $menu->position = $i++;
155
+            if ($menu->sousmenu) {
156
+                $j = 1;
157
+                foreach ($menu->sousmenu as $key => $bouton) {
158
+                    $bouton->favori = (int) table_valeur($menus_favoris, $key, false);
159
+                    $bouton->position = $j++;
160
+                }
161
+            }
162
+        }
163
+    }
164 164
 
165
-	return $boutons_admin;
165
+    return $boutons_admin;
166 166
 }
167 167
 
168 168
 /**
@@ -174,22 +174,22 @@  discard block
 block discarded – undo
174 174
  * @return Bouton[]
175 175
  */
176 176
 function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) {
177
-	foreach ($menus as $menu) {
178
-		if ($menu->sousmenu) {
179
-			$libelles = $isfavoris = $favoris = [];
180
-			foreach ($menu->sousmenu as $key => $item) {
181
-				$libelles[$key] = strtolower(translitteration(_T($item->libelle)));
182
-				$isfavoris[$key] = (bool) $item->favori;
183
-				$favoris[$key] = $item->favori;
184
-			}
185
-			if ($avec_favoris) {
186
-				array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
187
-			} else {
188
-				array_multisort($libelles, SORT_ASC, $menu->sousmenu);
189
-			}
190
-		}
191
-	}
192
-	return $menus;
177
+    foreach ($menus as $menu) {
178
+        if ($menu->sousmenu) {
179
+            $libelles = $isfavoris = $favoris = [];
180
+            foreach ($menu->sousmenu as $key => $item) {
181
+                $libelles[$key] = strtolower(translitteration(_T($item->libelle)));
182
+                $isfavoris[$key] = (bool) $item->favori;
183
+                $favoris[$key] = $item->favori;
184
+            }
185
+            if ($avec_favoris) {
186
+                array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
187
+            } else {
188
+                array_multisort($libelles, SORT_ASC, $menu->sousmenu);
189
+            }
190
+        }
191
+    }
192
+    return $menus;
193 193
 }
194 194
 
195 195
 /**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
  * @return Bouton[]
201 201
  */
202 202
 function trier_boutons_enfants_par_favoris_alpha($menus) {
203
-	return trier_boutons_enfants_par_alpha($menus, true);
203
+    return trier_boutons_enfants_par_alpha($menus, true);
204 204
 }
205 205
 
206 206
 
@@ -213,23 +213,23 @@  discard block
 block discarded – undo
213 213
  * @return string
214 214
  */
215 215
 function bandeau_creer_url($url, $args = '', $contexte = null) {
216
-	if (!preg_match(',[\/\?],', $url)) {
217
-		$url = generer_url_ecrire($url, $args, true);
218
-		// recuperer les parametres du contexte demande par l'url sous la forme
219
-		// &truc=@machin@
220
-		// @machin@ etant remplace par _request('machin')
221
-		$url = str_replace('&amp;', '&', $url);
222
-		while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
223
-			if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) {
224
-				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']);
225
-			}
226
-			$val = _request($matches[2], $contexte);
227
-			$url = parametre_url($url, $matches[1], $val ?: '', '&');
228
-		}
229
-		$url = str_replace('&', '&amp;', $url);
230
-	}
216
+    if (!preg_match(',[\/\?],', $url)) {
217
+        $url = generer_url_ecrire($url, $args, true);
218
+        // recuperer les parametres du contexte demande par l'url sous la forme
219
+        // &truc=@machin@
220
+        // @machin@ etant remplace par _request('machin')
221
+        $url = str_replace('&amp;', '&', $url);
222
+        while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
223
+            if ($matches[2] == 'id_secteur' && !isset($contexte['id_secteur']) && isset($contexte['id_rubrique'])) {
224
+                $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $contexte['id_rubrique']);
225
+            }
226
+            $val = _request($matches[2], $contexte);
227
+            $url = parametre_url($url, $matches[1], $val ?: '', '&');
228
+        }
229
+        $url = str_replace('&', '&amp;', $url);
230
+    }
231 231
 
232
-	return $url;
232
+    return $url;
233 233
 }
234 234
 
235 235
 /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
  *     Code HTML du bandeau
240 240
  */
241 241
 function inc_bandeau_dist() {
242
-	return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
242
+    return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
243 243
 }
244 244
 
245 245
 
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
  * @return array
249 249
  */
250 250
 function obtenir_menus_favoris() {
251
-	if (
252
-		isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
253
-		&& is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
254
-		&& $GLOBALS['visiteur_session']['prefs']['menus_favoris']
255
-	) {
256
-		return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
257
-	}
258
-	$definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
259
-	return $definir_menus_favoris();
251
+    if (
252
+        isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
253
+        && is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
254
+        && $GLOBALS['visiteur_session']['prefs']['menus_favoris']
255
+    ) {
256
+        return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
257
+    }
258
+    $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
259
+    return $definir_menus_favoris();
260 260
 }
Please login to merge, or discard this patch.
ecrire/inc/cookie.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -51,64 +51,64 @@  discard block
 block discarded – undo
51 51
  *     cookie sécurisé ou non ?
52 52
  **/
53 53
 function spip_setcookie($name = '', $value = '', $options = []) {
54
-	static $to_secure_list = ['spip_session'];
55
-	if (defined('_COOKIE_SECURE_LIST') && is_array(_COOKIE_SECURE_LIST)) {
56
-		$to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST);
57
-	}
58
-
59
-	if (!is_array($options)) {
60
-		// anciens paramètres :
61
-		# spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '')
62
-		$opt = func_get_args();
63
-		$opt = array_slice($opt, 2);
64
-		$options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !);
65
-		if (isset($opt[0])) {
66
-			$options['expires'] = $opt[0];
67
-		}
68
-		if (isset($opt[1])) {
69
-			$options['path'] = $opt[1];
70
-		}
71
-		if (isset($opt[2])) {
72
-			$options['domain'] = $opt[2];
73
-		}
74
-		if (isset($opt[3])) {
75
-			$options['secure'] = $opt[3];
76
-		}
77
-	}
78
-
79
-	// expires
80
-	if (!isset($options['expires'])) {
81
-		$options['expires'] = 0;
82
-	}
83
-	if (!isset($options['path']) || $options['path'] === 'AUTO') {
84
-		$options['path'] = defined('_COOKIE_PATH') ? _COOKIE_PATH : preg_replace(',^\w+://[^/]*,', '', url_de_base());
85
-	}
86
-	if (empty($options['domain']) && defined('_COOKIE_DOMAIN') && _COOKIE_DOMAIN) {
87
-		$options['domain'] = _COOKIE_DOMAIN;
88
-	}
89
-	if (in_array($name, $to_secure_list)) {
90
-		if (empty($options['secure']) && defined('_COOKIE_SECURE') && _COOKIE_SECURE) {
91
-			$options['secure'] = true;
92
-		}
93
-		if (empty($options['httponly'])) {
94
-			$options['httponly'] = true;
95
-		}
96
-	}
97
-	if (empty($options['samesite'])) {
98
-		$options['samesite'] = 'Lax';
99
-	}
100
-
101
-	// in fine renommer le prefixe si besoin
102
-	if (str_starts_with($name, 'spip_')) {
103
-		$name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
104
-	}
105
-
106
-	#spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
107
-	$a = @setcookie($name, $value, $options);
108
-
109
-	spip_cookie_envoye(true);
110
-
111
-	return $a;
54
+    static $to_secure_list = ['spip_session'];
55
+    if (defined('_COOKIE_SECURE_LIST') && is_array(_COOKIE_SECURE_LIST)) {
56
+        $to_secure_list = array_merge($to_secure_list, _COOKIE_SECURE_LIST);
57
+    }
58
+
59
+    if (!is_array($options)) {
60
+        // anciens paramètres :
61
+        # spip_setcookie($name = '', $value = '', $expire = 0, $path = 'AUTO', $domain = '', $secure = '')
62
+        $opt = func_get_args();
63
+        $opt = array_slice($opt, 2);
64
+        $options = []; # /!\ après le func_get_args (sinon $opt[0] référence la nouvelle valeur de $options !);
65
+        if (isset($opt[0])) {
66
+            $options['expires'] = $opt[0];
67
+        }
68
+        if (isset($opt[1])) {
69
+            $options['path'] = $opt[1];
70
+        }
71
+        if (isset($opt[2])) {
72
+            $options['domain'] = $opt[2];
73
+        }
74
+        if (isset($opt[3])) {
75
+            $options['secure'] = $opt[3];
76
+        }
77
+    }
78
+
79
+    // expires
80
+    if (!isset($options['expires'])) {
81
+        $options['expires'] = 0;
82
+    }
83
+    if (!isset($options['path']) || $options['path'] === 'AUTO') {
84
+        $options['path'] = defined('_COOKIE_PATH') ? _COOKIE_PATH : preg_replace(',^\w+://[^/]*,', '', url_de_base());
85
+    }
86
+    if (empty($options['domain']) && defined('_COOKIE_DOMAIN') && _COOKIE_DOMAIN) {
87
+        $options['domain'] = _COOKIE_DOMAIN;
88
+    }
89
+    if (in_array($name, $to_secure_list)) {
90
+        if (empty($options['secure']) && defined('_COOKIE_SECURE') && _COOKIE_SECURE) {
91
+            $options['secure'] = true;
92
+        }
93
+        if (empty($options['httponly'])) {
94
+            $options['httponly'] = true;
95
+        }
96
+    }
97
+    if (empty($options['samesite'])) {
98
+        $options['samesite'] = 'Lax';
99
+    }
100
+
101
+    // in fine renommer le prefixe si besoin
102
+    if (str_starts_with($name, 'spip_')) {
103
+        $name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
104
+    }
105
+
106
+    #spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
107
+    $a = @setcookie($name, $value, $options);
108
+
109
+    spip_cookie_envoye(true);
110
+
111
+    return $a;
112 112
 }
113 113
 
114 114
 /**
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
  * @return bool
125 125
  **/
126 126
 function spip_cookie_envoye($set = '') {
127
-	static $envoye = false;
128
-	if ($set) {
129
-		$envoye = true;
130
-	}
127
+    static $envoye = false;
128
+    if ($set) {
129
+        $envoye = true;
130
+    }
131 131
 
132
-	return $envoye;
132
+    return $envoye;
133 133
 }
134 134
 
135 135
 /**
@@ -148,21 +148,21 @@  discard block
 block discarded – undo
148 148
  *     Préfixe des cookies de SPIP
149 149
  **/
150 150
 function recuperer_cookies_spip($cookie_prefix) {
151
-	$prefix_long = strlen($cookie_prefix);
152
-
153
-	foreach (array_keys($_COOKIE) as $name) {
154
-		if (str_starts_with($name, 'spip_') && substr($name, 0, $prefix_long) != $cookie_prefix) {
155
-			unset($_COOKIE[$name]);
156
-			unset($GLOBALS[$name]);
157
-		}
158
-	}
159
-	foreach ($_COOKIE as $name => $value) {
160
-		if (substr($name, 0, $prefix_long) == $cookie_prefix) {
161
-			$spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
162
-			$_COOKIE[$spipname] = $value;
163
-			$GLOBALS[$spipname] = $value;
164
-		}
165
-	}
151
+    $prefix_long = strlen($cookie_prefix);
152
+
153
+    foreach (array_keys($_COOKIE) as $name) {
154
+        if (str_starts_with($name, 'spip_') && substr($name, 0, $prefix_long) != $cookie_prefix) {
155
+            unset($_COOKIE[$name]);
156
+            unset($GLOBALS[$name]);
157
+        }
158
+    }
159
+    foreach ($_COOKIE as $name => $value) {
160
+        if (substr($name, 0, $prefix_long) == $cookie_prefix) {
161
+            $spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
162
+            $_COOKIE[$spipname] = $value;
163
+            $GLOBALS[$spipname] = $value;
164
+        }
165
+    }
166 166
 }
167 167
 
168 168
 
@@ -181,18 +181,18 @@  discard block
 block discarded – undo
181 181
  *
182 182
  **/
183 183
 function exec_test_ajax_dist() {
184
-	switch (_request('js')) {
185
-		// on est appele par <noscript>
186
-		case -1:
187
-			spip_setcookie('spip_accepte_ajax', -1);
188
-			include_spip('inc/headers');
189
-			redirige_par_entete(chemin_image('erreur-xx.svg'));
190
-			break;
191
-
192
-		// ou par ajax
193
-		case 1:
194
-		default:
195
-			spip_setcookie('spip_accepte_ajax', 1);
196
-			break;
197
-	}
184
+    switch (_request('js')) {
185
+        // on est appele par <noscript>
186
+        case -1:
187
+            spip_setcookie('spip_accepte_ajax', -1);
188
+            include_spip('inc/headers');
189
+            redirige_par_entete(chemin_image('erreur-xx.svg'));
190
+            break;
191
+
192
+        // ou par ajax
193
+        case 1:
194
+        default:
195
+            spip_setcookie('spip_accepte_ajax', 1);
196
+            break;
197
+    }
198 198
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
 	// in fine renommer le prefixe si besoin
102 102
 	if (str_starts_with($name, 'spip_')) {
103
-		$name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
103
+		$name = $GLOBALS['cookie_prefix'].'_'.substr($name, 5);
104 104
 	}
105 105
 
106 106
 	#spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	}
159 159
 	foreach ($_COOKIE as $name => $value) {
160 160
 		if (substr($name, 0, $prefix_long) == $cookie_prefix) {
161
-			$spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
161
+			$spipname = preg_replace('/^'.$cookie_prefix.'_/', 'spip_', $name);
162 162
 			$_COOKIE[$spipname] = $value;
163 163
 			$GLOBALS[$spipname] = $value;
164 164
 		}
Please login to merge, or discard this patch.
ecrire/inc/selectionner.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 	if ($aff_racine) {
55 55
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
56
-		$idom3 = $idom . '_selection';
56
+		$idom3 = $idom.'_selection';
57 57
 
58 58
 		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59 59
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			'  '
72 72
 		);
73 73
 
74
-		$js_func = $do . '_selection_titre';
74
+		$js_func = $do.'_selection_titre';
75 75
 		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
76 76
 
77 77
 		$aff_racine = "<div class='petit-item petite-racine item'>"
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
  **/
113 113
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
114 114
 
115
-	$idom1 = $idom . '_champ_recherche';
116
-	$idom2 = $idom . '_principal';
117
-	$idom3 = $idom . '_selection';
118
-	$idom4 = $idom . '_col_1';
119
-	$idom5 = 'img_' . $idom4;
120
-	$idom6 = $idom . '_fonc';
115
+	$idom1 = $idom.'_champ_recherche';
116
+	$idom2 = $idom.'_principal';
117
+	$idom3 = $idom.'_selection';
118
+	$idom4 = $idom.'_col_1';
119
+	$idom5 = 'img_'.$idom4;
120
+	$idom6 = $idom.'_fonc';
121 121
 
122 122
 	return "<div id='$idom'>"
123 123
 	. "<a id='$idom6' style='visibility: hidden;'"
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 	. http_img_pack(
128 128
 		'loader.svg',
129 129
 		'',
130
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
130
+		"class='loader' style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'"
131 131
 	)
132 132
 	. ''
133
-	. "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
133
+	. "<input style='width: 10em;float:".$GLOBALS['spip_lang_right'].";' type='text' class='text search' id='$idom1' placeholder='"._T('info_rechercher')."'"
134 134
 	// eliminer Return car il provoque la soumission (balise unique)
135 135
 	// et eliminer Tab pour la navigation au clavier
136 136
 	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 
178 178
 	$liste = $id_rubrique;
179 179
 	$id_rubrique = (int) $id_rubrique;
180
-	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
181
-		$liste = $id_rubrique . ",$liste";
180
+	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = '.$id_rubrique)) {
181
+		$liste = $id_rubrique.",$liste";
182 182
 	}
183 183
 
184 184
 	return explode(',', "0,$liste");
Please login to merge, or discard this patch.
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/filtres');
@@ -45,56 +45,56 @@  discard block
 block discarded – undo
45 45
  **/
46 46
 function inc_selectionner_dist($sel, $idom = '', $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') {
47 47
 
48
-	if ($recur) {
49
-		$recur = mini_hier($sel);
50
-	} else {
51
-		$sel = 0;
52
-	}
53
-
54
-	if ($aff_racine) {
55
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
56
-		$idom3 = $idom . '_selection';
57
-
58
-		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59
-
60
-		$ondbClick = strtr(
61
-			str_replace(
62
-				"'",
63
-				'&#8217;',
64
-				str_replace(
65
-					'"',
66
-					'&#34;',
67
-					(string) textebrut(_T('info_racine_site'))
68
-				)
69
-			),
70
-			"\n\r",
71
-			'  '
72
-		);
73
-
74
-		$js_func = $do . '_selection_titre';
75
-		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
76
-
77
-		$aff_racine = "<div class='petit-item petite-racine item'>"
78
-			. "<a href='#'"
79
-			. 'onclick="'
80
-			. $onClick
81
-			. "\"\nondbclick=\""
82
-			. $ondbClick
83
-			. $onClick
84
-			. '">'
85
-			. _T('info_racine_site')
86
-			. '</a></div>';
87
-	}
88
-
89
-	$url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
90
-
91
-	$plonger = charger_fonction('plonger', 'inc');
92
-	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
93
-
94
-	// url completee par la fonction JS onkeypress_rechercher
95
-	$url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
96
-
97
-	return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
48
+    if ($recur) {
49
+        $recur = mini_hier($sel);
50
+    } else {
51
+        $sel = 0;
52
+    }
53
+
54
+    if ($aff_racine) {
55
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
56
+        $idom3 = $idom . '_selection';
57
+
58
+        $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
59
+
60
+        $ondbClick = strtr(
61
+            str_replace(
62
+                "'",
63
+                '&#8217;',
64
+                str_replace(
65
+                    '"',
66
+                    '&#34;',
67
+                    (string) textebrut(_T('info_racine_site'))
68
+                )
69
+            ),
70
+            "\n\r",
71
+            '  '
72
+        );
73
+
74
+        $js_func = $do . '_selection_titre';
75
+        $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
76
+
77
+        $aff_racine = "<div class='petit-item petite-racine item'>"
78
+            . "<a href='#'"
79
+            . 'onclick="'
80
+            . $onClick
81
+            . "\"\nondbclick=\""
82
+            . $ondbClick
83
+            . $onClick
84
+            . '">'
85
+            . _T('info_racine_site')
86
+            . '</a></div>';
87
+    }
88
+
89
+    $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
90
+
91
+    $plonger = charger_fonction('plonger', 'inc');
92
+    $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
93
+
94
+    // url completee par la fonction JS onkeypress_rechercher
95
+    $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
96
+
97
+    return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
98 98
 }
99 99
 
100 100
 /**
@@ -112,58 +112,58 @@  discard block
 block discarded – undo
112 112
  **/
113 113
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') {
114 114
 
115
-	$idom1 = $idom . '_champ_recherche';
116
-	$idom2 = $idom . '_principal';
117
-	$idom3 = $idom . '_selection';
118
-	$idom4 = $idom . '_col_1';
119
-	$idom5 = 'img_' . $idom4;
120
-	$idom6 = $idom . '_fonc';
121
-
122
-	return "<div id='$idom'>"
123
-	. "<a id='$idom6' style='visibility: hidden;'"
124
-	. ($url_init ? "\nhref='$url_init'" : '')
125
-	. '></a>'
126
-	. "<div class='recherche_rapide_parent formulaire_recherche'>"
127
-	. http_img_pack(
128
-		'loader.svg',
129
-		'',
130
-		"class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
131
-	)
132
-	. ''
133
-	. "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
134
-	// eliminer Return car il provoque la soumission (balise unique)
135
-	// et eliminer Tab pour la navigation au clavier
136
-	// ce serait encore mieux de ne le faire que s'il y a encore plusieurs
137
-	// resultats retournes par la recherche
138
-	. "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
139
-	// lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
140
-	. "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
141
-	// la destination de la recherche
142
-	. "'$idom4'"
115
+    $idom1 = $idom . '_champ_recherche';
116
+    $idom2 = $idom . '_principal';
117
+    $idom3 = $idom . '_selection';
118
+    $idom4 = $idom . '_col_1';
119
+    $idom5 = 'img_' . $idom4;
120
+    $idom6 = $idom . '_fonc';
121
+
122
+    return "<div id='$idom'>"
123
+    . "<a id='$idom6' style='visibility: hidden;'"
124
+    . ($url_init ? "\nhref='$url_init'" : '')
125
+    . '></a>'
126
+    . "<div class='recherche_rapide_parent formulaire_recherche'>"
127
+    . http_img_pack(
128
+        'loader.svg',
129
+        '',
130
+        "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'"
131
+    )
132
+    . ''
133
+    . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'"
134
+    // eliminer Return car il provoque la soumission (balise unique)
135
+    // et eliminer Tab pour la navigation au clavier
136
+    // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
137
+    // resultats retournes par la recherche
138
+    . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\""
139
+    // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier)
140
+    . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value,"
141
+    // la destination de la recherche
142
+    . "'$idom4'"
143 143
 #	. "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
144
-	. ",'"
145
-	// l'url effectuant la recherche
146
-	. $url
147
-	. "',"
148
-	// le noeud contenant un gif anime
149
-	// . "'idom5'"
150
-	. 'this.parentNode.previousSibling.firstChild'
151
-	. ",'"
152
-	// la valeur de l'attribut Name a remplir
153
-	. $name
154
-	. "','"
155
-	// noeud invisible memorisant l'URL initiale (pour re-initialisation)
156
-	. $idom6
157
-	. "')\""
158
-	. ' />'
159
-	. "\n</div>"
160
-	. ($racine ? "<div>$racine</div>" : '')
161
-	. "<div id='"
162
-	. $idom2
163
-	. "'><div id='$idom4'"
164
-	. " class=''>"
165
-	. $liste
166
-	. "</div></div>\n<div id='$idom3'></div></div>\n";
144
+    . ",'"
145
+    // l'url effectuant la recherche
146
+    . $url
147
+    . "',"
148
+    // le noeud contenant un gif anime
149
+    // . "'idom5'"
150
+    . 'this.parentNode.previousSibling.firstChild'
151
+    . ",'"
152
+    // la valeur de l'attribut Name a remplir
153
+    . $name
154
+    . "','"
155
+    // noeud invisible memorisant l'URL initiale (pour re-initialisation)
156
+    . $idom6
157
+    . "')\""
158
+    . ' />'
159
+    . "\n</div>"
160
+    . ($racine ? "<div>$racine</div>" : '')
161
+    . "<div id='"
162
+    . $idom2
163
+    . "'><div id='$idom4'"
164
+    . " class=''>"
165
+    . $liste
166
+    . "</div></div>\n<div id='$idom3'></div></div>\n";
167 167
 }
168 168
 
169 169
 /**
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
  **/
176 176
 function mini_hier($id_rubrique) {
177 177
 
178
-	$liste = $id_rubrique;
179
-	$id_rubrique = (int) $id_rubrique;
180
-	while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
181
-		$liste = $id_rubrique . ",$liste";
182
-	}
178
+    $liste = $id_rubrique;
179
+    $id_rubrique = (int) $id_rubrique;
180
+    while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) {
181
+        $liste = $id_rubrique . ",$liste";
182
+    }
183 183
 
184
-	return explode(',', "0,$liste");
184
+    return explode(',', "0,$liste");
185 185
 }
Please login to merge, or discard this patch.
ecrire/inc/completer_traduction.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -28,51 +28,51 @@  discard block
 block discarded – undo
28 28
  * @return string Erreur éventuelle
29 29
  */
30 30
 function inc_completer_traduction_dist($objet, $id_objet, $id_trad) {
31
-	// dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit
32
-	// cf API editer_liens
33
-	include_spip('action/editer_liens');
34
-	objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']);
35
-	$_id_table = id_table_objet($objet);
31
+    // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit
32
+    // cf API editer_liens
33
+    include_spip('action/editer_liens');
34
+    objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']);
35
+    $_id_table = id_table_objet($objet);
36 36
 
37
-	// recuperer le logo
38
-	$chercher_logo = charger_fonction('chercher_logo', 'inc');
39
-	include_spip('action/editer_logo');
40
-	foreach (['on', 'off'] as $etat) {
41
-		$logo = $chercher_logo($id_trad, $_id_table, $etat);
42
-		if ($logo && ($file = reset($logo))) {
43
-			logo_modifier($objet, $id_objet, $etat, $file);
44
-		}
45
-	}
37
+    // recuperer le logo
38
+    $chercher_logo = charger_fonction('chercher_logo', 'inc');
39
+    include_spip('action/editer_logo');
40
+    foreach (['on', 'off'] as $etat) {
41
+        $logo = $chercher_logo($id_trad, $_id_table, $etat);
42
+        if ($logo && ($file = reset($logo))) {
43
+            logo_modifier($objet, $id_objet, $etat, $file);
44
+        }
45
+    }
46 46
 
47
-	// dupliquer certains champs
48
-	$trouver_table = charger_fonction('trouver_table', 'base');
49
-	$desc = $trouver_table(table_objet_sql($objet));
50
-	$champs = $set = [];
47
+    // dupliquer certains champs
48
+    $trouver_table = charger_fonction('trouver_table', 'base');
49
+    $desc = $trouver_table(table_objet_sql($objet));
50
+    $champs = $set = [];
51 51
 
52
-	// un éventuel champ 'virtuel' (redirections)
53
-	if (!empty($desc['field']['virtuel'])) {
54
-		$champs[] = 'virtuel';
55
-	}
52
+    // un éventuel champ 'virtuel' (redirections)
53
+    if (!empty($desc['field']['virtuel'])) {
54
+        $champs[] = 'virtuel';
55
+    }
56 56
 
57
-	$data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad);
57
+    $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad);
58 58
 
59
-	foreach ($champs as $c) {
60
-		$set[$c] = $data[$c];
61
-	}
59
+    foreach ($champs as $c) {
60
+        $set[$c] = $data[$c];
61
+    }
62 62
 
63
-	/*
63
+    /*
64 64
 	 * Le pipeline 'pre_edition' sera appelé avec l'action 'completer_traduction'.
65 65
 	 * Des plugins pourront ainsi compléter les champs d'un objet traduit lors d'une nouvelle traduction.
66 66
 	 */
67
-	$err = objet_modifier_champs(
68
-		$objet,
69
-		$id_objet,
70
-		[
71
-			'data' => $data,
72
-			'action' => 'completer_traduction',
73
-		],
74
-		$set
75
-	);
67
+    $err = objet_modifier_champs(
68
+        $objet,
69
+        $id_objet,
70
+        [
71
+            'data' => $data,
72
+            'action' => 'completer_traduction',
73
+        ],
74
+        $set
75
+    );
76 76
 
77
-	return $err;
77
+    return $err;
78 78
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 		$champs[] = 'virtuel';
55 55
 	}
56 56
 
57
-	$data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad);
57
+	$data = sql_fetsel('*', $desc['table'], $_id_table.'='.(int) $id_trad);
58 58
 
59 59
 	foreach ($champs as $c) {
60 60
 		$set[$c] = $data[$c];
Please login to merge, or discard this patch.
ecrire/inc/log.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -10,101 +10,101 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 function inc_log_dist($message, $logname = null, $logdir = null, $logsuf = null) {
17
-	static $test_repertoire = [];
18
-	static $compteur = [];
19
-	static $debugverb = ''; // pour ne pas le recalculer au reappel
20
-
21
-	if (is_null($logname) || !is_string($logname)) {
22
-		$logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
23
-	}
24
-	if (!isset($compteur[$logname])) {
25
-		$compteur[$logname] = 0;
26
-	}
27
-	if (
28
-		$logname != 'maj'
29
-		&& defined('_MAX_LOG')
30
-		&& ($compteur[$logname]++ > _MAX_LOG || !$GLOBALS['nombre_de_logs'] || !$GLOBALS['taille_des_logs'])
31
-	) {
32
-		return;
33
-	}
34
-
35
-	// si spip_log() est appelé dans mes_options, toutes les constantes n'ont pas été définies
36
-	$logfile =
37
-		($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES))
38
-		. $logname
39
-		. ($logsuf ?? (defined('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log'));
40
-
41
-	if (!isset($test_repertoire[$d = dirname($logfile)])) {
42
-		$test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
43
-		$test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
44
-			$d,
45
-			'',
46
-			false,
47
-			true
48
-		) : false));
49
-	}
50
-
51
-	// Si le repertoire défini n'existe pas, poser dans tmp/
52
-	if (!$test_repertoire[$d]) {
53
-		$logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
54
-	}
55
-
56
-	$rotate = 0;
57
-	$pid = '(pid ' . @getmypid() . ')';
58
-
59
-	// accepter spip_log( Array )
60
-	if (!is_string($message)) {
61
-		$message = var_export($message, true);
62
-	}
63
-
64
-	if (!$debugverb && defined('_LOG_FILELINE') && _LOG_FILELINE) {
65
-		$debug = debug_backtrace();
66
-		$l = $debug[1]['line'];
67
-		$fi = $debug[1]['file'];
68
-		if (str_starts_with($fi, _ROOT_RACINE)) {
69
-			$fi = substr($fi, strlen(_ROOT_RACINE));
70
-		}
71
-		$fu = $debug[2]['function'] ?? '';
72
-		$debugverb = "$fi:L$l:$fu" . '():';
73
-	}
74
-
75
-	$m = date('Y-m-d H:i:s') . ' ' . ($GLOBALS['ip'] ?? '') . ' ' . $pid . ' '
76
-		//distinguer les logs prives et publics dans les grep
77
-		. $debugverb
78
-		. (test_espace_prive() ? ':Pri:' : ':Pub:')
79
-		. preg_replace("/\n*$/", "\n", $message);
80
-
81
-
82
-	if (
83
-		@is_readable($logfile)
84
-		&& ((!$s = @filesize($logfile)) || $s > $GLOBALS['taille_des_logs'] * 1024)
85
-	) {
86
-		$rotate = $GLOBALS['nombre_de_logs'];
87
-		$m .= "[-- rotate --]\n";
88
-	}
89
-
90
-	$f = @fopen($logfile, 'ab');
91
-	if ($f) {
92
-		fwrite($f, (defined('_LOG_BRUT') && _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
93
-		fclose($f);
94
-	}
95
-
96
-	if (
97
-		$rotate-- > 0 && function_exists('spip_unlink')
98
-	) {
99
-		spip_unlink($logfile . '.' . $rotate);
100
-		while ($rotate--) {
101
-			@rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
102
-		}
103
-	}
104
-
105
-	// Dupliquer les erreurs specifiques dans le log general
106
-	if (defined('_FILE_LOG') && $logname !== _FILE_LOG) {
107
-		inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
108
-	}
109
-	$debugverb = '';
17
+    static $test_repertoire = [];
18
+    static $compteur = [];
19
+    static $debugverb = ''; // pour ne pas le recalculer au reappel
20
+
21
+    if (is_null($logname) || !is_string($logname)) {
22
+        $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
23
+    }
24
+    if (!isset($compteur[$logname])) {
25
+        $compteur[$logname] = 0;
26
+    }
27
+    if (
28
+        $logname != 'maj'
29
+        && defined('_MAX_LOG')
30
+        && ($compteur[$logname]++ > _MAX_LOG || !$GLOBALS['nombre_de_logs'] || !$GLOBALS['taille_des_logs'])
31
+    ) {
32
+        return;
33
+    }
34
+
35
+    // si spip_log() est appelé dans mes_options, toutes les constantes n'ont pas été définies
36
+    $logfile =
37
+        ($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES))
38
+        . $logname
39
+        . ($logsuf ?? (defined('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log'));
40
+
41
+    if (!isset($test_repertoire[$d = dirname($logfile)])) {
42
+        $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
43
+        $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
44
+            $d,
45
+            '',
46
+            false,
47
+            true
48
+        ) : false));
49
+    }
50
+
51
+    // Si le repertoire défini n'existe pas, poser dans tmp/
52
+    if (!$test_repertoire[$d]) {
53
+        $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
54
+    }
55
+
56
+    $rotate = 0;
57
+    $pid = '(pid ' . @getmypid() . ')';
58
+
59
+    // accepter spip_log( Array )
60
+    if (!is_string($message)) {
61
+        $message = var_export($message, true);
62
+    }
63
+
64
+    if (!$debugverb && defined('_LOG_FILELINE') && _LOG_FILELINE) {
65
+        $debug = debug_backtrace();
66
+        $l = $debug[1]['line'];
67
+        $fi = $debug[1]['file'];
68
+        if (str_starts_with($fi, _ROOT_RACINE)) {
69
+            $fi = substr($fi, strlen(_ROOT_RACINE));
70
+        }
71
+        $fu = $debug[2]['function'] ?? '';
72
+        $debugverb = "$fi:L$l:$fu" . '():';
73
+    }
74
+
75
+    $m = date('Y-m-d H:i:s') . ' ' . ($GLOBALS['ip'] ?? '') . ' ' . $pid . ' '
76
+        //distinguer les logs prives et publics dans les grep
77
+        . $debugverb
78
+        . (test_espace_prive() ? ':Pri:' : ':Pub:')
79
+        . preg_replace("/\n*$/", "\n", $message);
80
+
81
+
82
+    if (
83
+        @is_readable($logfile)
84
+        && ((!$s = @filesize($logfile)) || $s > $GLOBALS['taille_des_logs'] * 1024)
85
+    ) {
86
+        $rotate = $GLOBALS['nombre_de_logs'];
87
+        $m .= "[-- rotate --]\n";
88
+    }
89
+
90
+    $f = @fopen($logfile, 'ab');
91
+    if ($f) {
92
+        fwrite($f, (defined('_LOG_BRUT') && _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
93
+        fclose($f);
94
+    }
95
+
96
+    if (
97
+        $rotate-- > 0 && function_exists('spip_unlink')
98
+    ) {
99
+        spip_unlink($logfile . '.' . $rotate);
100
+        while ($rotate--) {
101
+            @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
102
+        }
103
+    }
104
+
105
+    // Dupliquer les erreurs specifiques dans le log general
106
+    if (defined('_FILE_LOG') && $logname !== _FILE_LOG) {
107
+        inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
108
+    }
109
+    $debugverb = '';
110 110
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 	// si spip_log() est appelé dans mes_options, toutes les constantes n'ont pas été définies
36 36
 	$logfile =
37
-		($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES))
37
+		($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES))
38 38
 		. $logname
39 39
 		. ($logsuf ?? (defined('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log'));
40 40
 
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 
51 51
 	// Si le repertoire défini n'existe pas, poser dans tmp/
52 52
 	if (!$test_repertoire[$d]) {
53
-		$logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
53
+		$logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log';
54 54
 	}
55 55
 
56 56
 	$rotate = 0;
57
-	$pid = '(pid ' . @getmypid() . ')';
57
+	$pid = '(pid '.@getmypid().')';
58 58
 
59 59
 	// accepter spip_log( Array )
60 60
 	if (!is_string($message)) {
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 			$fi = substr($fi, strlen(_ROOT_RACINE));
70 70
 		}
71 71
 		$fu = $debug[2]['function'] ?? '';
72
-		$debugverb = "$fi:L$l:$fu" . '():';
72
+		$debugverb = "$fi:L$l:$fu".'():';
73 73
 	}
74 74
 
75
-	$m = date('Y-m-d H:i:s') . ' ' . ($GLOBALS['ip'] ?? '') . ' ' . $pid . ' '
75
+	$m = date('Y-m-d H:i:s').' '.($GLOBALS['ip'] ?? '').' '.$pid.' '
76 76
 		//distinguer les logs prives et publics dans les grep
77 77
 		. $debugverb
78 78
 		. (test_espace_prive() ? ':Pri:' : ':Pub:')
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 	if (
97 97
 		$rotate-- > 0 && function_exists('spip_unlink')
98 98
 	) {
99
-		spip_unlink($logfile . '.' . $rotate);
99
+		spip_unlink($logfile.'.'.$rotate);
100 100
 		while ($rotate--) {
101
-			@rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
101
+			@rename($logfile.($rotate ? '.'.$rotate : ''), $logfile.'.'.($rotate + 1));
102 102
 		}
103 103
 	}
104 104
 
Please login to merge, or discard this patch.
ecrire/inc/svg.php 3 patches
Indentation   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 if (!defined('IMG_SVG')) {
23
-	// complete 	IMG_BMP | IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM | IMG_WEBP
24
-	define('IMG_SVG', 128);
25
-	define('IMAGETYPE_SVG', 19);
23
+    // complete 	IMG_BMP | IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM | IMG_WEBP
24
+    define('IMG_SVG', 128);
25
+    define('IMAGETYPE_SVG', 19);
26 26
 }
27 27
 
28 28
 /**
@@ -38,34 +38,34 @@  discard block
 block discarded – undo
38 38
  *   false si on a pas pu charger l'image
39 39
  */
40 40
 function svg_charger($fichier, $maxlen = null) {
41
-	if (str_starts_with($fichier, 'data:image/svg+xml')) {
42
-		$image = explode(';', $fichier, 2);
43
-		$image = end($image);
44
-		if (str_starts_with($image, 'base64,')) {
45
-			$image = base64_decode(substr($image, 7));
46
-		}
47
-		if (str_contains($image, '<svg')) {
48
-			return $image;
49
-		}
50
-		// encodage inconnu ou autre format d'image ?
51
-		return false;
52
-	}
53
-	// c'est peut etre deja une image svg ?
54
-	if (str_contains($fichier, '<svg')) {
55
-		return $fichier;
56
-	}
57
-	if (!file_exists($fichier)) {
58
-		$fichier  = supprimer_timestamp($fichier);
59
-		if (!file_exists($fichier)) {
60
-			return false;
61
-		}
62
-	}
63
-	$image = is_null($maxlen) ? file_get_contents($fichier) : file_get_contents($fichier, false, null, 0, $maxlen);
64
-	// est-ce bien une image svg ?
65
-	if (str_contains($image, '<svg')) {
66
-		return $image;
67
-	}
68
-	return false;
41
+    if (str_starts_with($fichier, 'data:image/svg+xml')) {
42
+        $image = explode(';', $fichier, 2);
43
+        $image = end($image);
44
+        if (str_starts_with($image, 'base64,')) {
45
+            $image = base64_decode(substr($image, 7));
46
+        }
47
+        if (str_contains($image, '<svg')) {
48
+            return $image;
49
+        }
50
+        // encodage inconnu ou autre format d'image ?
51
+        return false;
52
+    }
53
+    // c'est peut etre deja une image svg ?
54
+    if (str_contains($fichier, '<svg')) {
55
+        return $fichier;
56
+    }
57
+    if (!file_exists($fichier)) {
58
+        $fichier  = supprimer_timestamp($fichier);
59
+        if (!file_exists($fichier)) {
60
+            return false;
61
+        }
62
+    }
63
+    $image = is_null($maxlen) ? file_get_contents($fichier) : file_get_contents($fichier, false, null, 0, $maxlen);
64
+    // est-ce bien une image svg ?
65
+    if (str_contains($image, '<svg')) {
66
+        return $image;
67
+    }
68
+    return false;
69 69
 }
70 70
 
71 71
 /**
@@ -74,28 +74,28 @@  discard block
 block discarded – undo
74 74
  * @return array|bool
75 75
  */
76 76
 function svg_lire_balise_svg($fichier) {
77
-	if (!$debut_fichier = svg_charger($fichier, 4096)) {
78
-		return false;
79
-	}
80
-
81
-	if (($ps = stripos($debut_fichier, '<svg')) !== false) {
82
-		$pe = stripos($debut_fichier, '>', $ps);
83
-		$balise_svg = substr($debut_fichier, $ps, $pe - $ps + 1);
84
-
85
-		if (preg_match_all(',([\w:\-]+)=,Uims', $balise_svg, $matches)) {
86
-			if (!function_exists('extraire_attribut')) {
87
-				include_spip('inc/filtres');
88
-			}
89
-			$attributs = [];
90
-			foreach ($matches[1] as $att) {
91
-				$attributs[$att] = extraire_attribut($balise_svg, $att);
92
-			}
93
-
94
-			return [$balise_svg, $attributs];
95
-		}
96
-	}
97
-
98
-	return false;
77
+    if (!$debut_fichier = svg_charger($fichier, 4096)) {
78
+        return false;
79
+    }
80
+
81
+    if (($ps = stripos($debut_fichier, '<svg')) !== false) {
82
+        $pe = stripos($debut_fichier, '>', $ps);
83
+        $balise_svg = substr($debut_fichier, $ps, $pe - $ps + 1);
84
+
85
+        if (preg_match_all(',([\w:\-]+)=,Uims', $balise_svg, $matches)) {
86
+            if (!function_exists('extraire_attribut')) {
87
+                include_spip('inc/filtres');
88
+            }
89
+            $attributs = [];
90
+            foreach ($matches[1] as $att) {
91
+                $attributs[$att] = extraire_attribut($balise_svg, $att);
92
+            }
93
+
94
+            return [$balise_svg, $attributs];
95
+        }
96
+    }
97
+
98
+    return false;
99 99
 }
100 100
 
101 101
 /**
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
  */
106 106
 function svg_lire_attributs($img) {
107 107
 
108
-	if ($svg_infos = svg_lire_balise_svg($img)) {
109
-		[$balise_svg, $attributs] = $svg_infos;
110
-		return $attributs;
111
-	}
108
+    if ($svg_infos = svg_lire_balise_svg($img)) {
109
+        [$balise_svg, $attributs] = $svg_infos;
110
+        return $attributs;
111
+    }
112 112
 
113
-	return false;
113
+    return false;
114 114
 }
115 115
 
116 116
 /**
@@ -120,19 +120,19 @@  discard block
 block discarded – undo
120 120
  * @return bool|float|int
121 121
  */
122 122
 function svg_dimension_to_pixels($dimension, $precision = 2) {
123
-	if (preg_match(',^(-?\d+(\.\d+)?)([^\d]*),i', trim($dimension), $m)) {
124
-		return match (strtolower($m[2])) {
125
-			'%' => false,
126
-			'em' => round($m[1] * 16, $precision),
127
-			'ex' => round($m[1] * 16, $precision),
128
-			'pc' => round($m[1] * 16, $precision),
129
-			'cm' => round($m[1] * 96 / 2.54, $precision),
130
-			'mm' => round($m[1] * 96 / 25.4, $precision),
131
-			'in' => round($m[1] * 96, $precision),
132
-			default => $m[1],
133
-		};
134
-	}
135
-	return false;
123
+    if (preg_match(',^(-?\d+(\.\d+)?)([^\d]*),i', trim($dimension), $m)) {
124
+        return match (strtolower($m[2])) {
125
+            '%' => false,
126
+            'em' => round($m[1] * 16, $precision),
127
+            'ex' => round($m[1] * 16, $precision),
128
+            'pc' => round($m[1] * 16, $precision),
129
+            'cm' => round($m[1] * 96 / 2.54, $precision),
130
+            'mm' => round($m[1] * 96 / 25.4, $precision),
131
+            'in' => round($m[1] * 96, $precision),
132
+            default => $m[1],
133
+        };
134
+    }
135
+    return false;
136 136
 }
137 137
 
138 138
 /**
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
  * @return string
144 144
  */
145 145
 function svg_change_balise_svg($svg, $old_balise_svg, $attributs) {
146
-	$new_balise_svg = '<svg';
147
-	foreach ($attributs as $k => $v) {
148
-		$new_balise_svg .= " $k=\"" . entites_html($v) . '"';
149
-	}
150
-	$new_balise_svg .= '>';
151
-
152
-	$p = strpos($svg, $old_balise_svg);
153
-	return substr_replace($svg, $new_balise_svg, $p, strlen($old_balise_svg));
146
+    $new_balise_svg = '<svg';
147
+    foreach ($attributs as $k => $v) {
148
+        $new_balise_svg .= " $k=\"" . entites_html($v) . '"';
149
+    }
150
+    $new_balise_svg .= '>';
151
+
152
+    $p = strpos($svg, $old_balise_svg);
153
+    return substr_replace($svg, $new_balise_svg, $p, strlen($old_balise_svg));
154 154
 }
155 155
 
156 156
 /**
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
  */
163 163
 function svg_insert_shapes($svg, $shapes, $start = true) {
164 164
 
165
-	if ($start === false || $start === 'end') {
166
-		$svg = str_replace('</svg>', $shapes . '</svg>', $svg);
167
-	}
168
-	else {
169
-		$p = stripos($svg, '<svg');
170
-		$p = strpos($svg, '>', $p);
171
-		$svg = substr_replace($svg, $shapes, $p + 1, 0);
172
-	}
173
-	return $svg;
165
+    if ($start === false || $start === 'end') {
166
+        $svg = str_replace('</svg>', $shapes . '</svg>', $svg);
167
+    }
168
+    else {
169
+        $p = stripos($svg, '<svg');
170
+        $p = strpos($svg, '>', $p);
171
+        $svg = substr_replace($svg, $shapes, $p + 1, 0);
172
+    }
173
+    return $svg;
174 174
 }
175 175
 
176 176
 /**
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
  * @return string
184 184
  */
185 185
 function svg_clip_in_box($svg, $x, $y, $width, $height) {
186
-	$rect = "<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\" />";
187
-	$id = 'clip-' . substr(md5($rect . strlen($svg)), 0, 8);
188
-	$clippath = "<clipPath id=\"$id\">$rect</clipPath>";
189
-	$g = "<g clip-path=\"url(#$id)\">";
190
-	$svg = svg_insert_shapes($svg, $clippath . $g);
191
-	return svg_insert_shapes($svg, '</g>', false);
186
+    $rect = "<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\" />";
187
+    $id = 'clip-' . substr(md5($rect . strlen($svg)), 0, 8);
188
+    $clippath = "<clipPath id=\"$id\">$rect</clipPath>";
189
+    $g = "<g clip-path=\"url(#$id)\">";
190
+    $svg = svg_insert_shapes($svg, $clippath . $g);
191
+    return svg_insert_shapes($svg, '</g>', false);
192 192
 }
193 193
 
194 194
 /**
@@ -199,20 +199,20 @@  discard block
 block discarded – undo
199 199
  * @return bool|string
200 200
  */
201 201
 function svg_redimensionner($img, $new_width, $new_height) {
202
-	if (
203
-		($svg = svg_charger($img))
204
-		&& ($svg_infos = svg_lire_balise_svg($svg))
205
-	) {
206
-		[$balise_svg, $attributs] = $svg_infos;
207
-		if (!isset($attributs['viewBox'])) {
208
-			$attributs['viewBox'] = '0 0 ' . $attributs['width'] . ' ' . $attributs['height'];
209
-		}
210
-		$attributs['width'] = (string) $new_width;
211
-		$attributs['height'] = (string) $new_height;
212
-		return svg_change_balise_svg($svg, $balise_svg, $attributs);
213
-	}
214
-
215
-	return $img;
202
+    if (
203
+        ($svg = svg_charger($img))
204
+        && ($svg_infos = svg_lire_balise_svg($svg))
205
+    ) {
206
+        [$balise_svg, $attributs] = $svg_infos;
207
+        if (!isset($attributs['viewBox'])) {
208
+            $attributs['viewBox'] = '0 0 ' . $attributs['width'] . ' ' . $attributs['height'];
209
+        }
210
+        $attributs['width'] = (string) $new_width;
211
+        $attributs['height'] = (string) $new_height;
212
+        return svg_change_balise_svg($svg, $balise_svg, $attributs);
213
+    }
214
+
215
+    return $img;
216 216
 }
217 217
 
218 218
 /**
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
  * @return string
222 222
  */
223 223
 function svg_couleur_to_hexa($couleur) {
224
-	if (str_starts_with($couleur, 'rgb(')) {
225
-		$c = explode(',', substr($couleur, 4));
226
-		$couleur = _couleur_dec_to_hex((int) $c[0], (int) $c[1], (int) $c[2]);
227
-	}
228
-	else {
229
-		$couleur = couleur_html_to_hex($couleur);
230
-	}
231
-	return '#' . ltrim($couleur, '#');
224
+    if (str_starts_with($couleur, 'rgb(')) {
225
+        $c = explode(',', substr($couleur, 4));
226
+        $couleur = _couleur_dec_to_hex((int) $c[0], (int) $c[1], (int) $c[2]);
227
+    }
228
+    else {
229
+        $couleur = couleur_html_to_hex($couleur);
230
+    }
231
+    return '#' . ltrim($couleur, '#');
232 232
 }
233 233
 
234 234
 /**
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
  * @return array
238 238
  */
239 239
 function svg_couleur_to_rgb($couleur) {
240
-	if (str_starts_with($couleur, 'rgb(')) {
241
-		$c = explode(',', substr($couleur, 4));
242
-		return ['red' => (int) $c[0],'green' => (int) $c[1],'blue' => (int) $c[2]];
243
-	}
244
-	return _couleur_hex_to_dec($couleur);
240
+    if (str_starts_with($couleur, 'rgb(')) {
241
+        $c = explode(',', substr($couleur, 4));
242
+        return ['red' => (int) $c[0],'green' => (int) $c[1],'blue' => (int) $c[2]];
243
+    }
244
+    return _couleur_hex_to_dec($couleur);
245 245
 }
246 246
 
247 247
 
@@ -251,80 +251,80 @@  discard block
 block discarded – undo
251 251
  * @return array
252 252
  */
253 253
 function svg_getimagesize_from_attr($attributs) {
254
-	$width = 350; // default width
255
-	$height = 150; // default height
256
-
257
-	$viewBox = "0 0 $width $height";
258
-	if (isset($attributs['viewBox'])) {
259
-		$viewBox = $attributs['viewBox'];
260
-		$viewBox = preg_replace(',\s+,', ' ', $viewBox);
261
-	}
262
-	// et on la convertit en px
263
-	$viewBox = explode(' ', $viewBox);
264
-	$viewBox = array_map('svg_dimension_to_pixels', $viewBox);
265
-	if (!$viewBox[2]) {
266
-		$viewBox[2] = $width;
267
-	}
268
-	if (!$viewBox[3]) {
269
-		$viewBox[3] = $height;
270
-	}
271
-
272
-	$coeff = 1;
273
-	if (
274
-		isset($attributs['width'])
275
-		&& ($w = svg_dimension_to_pixels($attributs['width']))
276
-	) {
277
-		$width = $w;
278
-		// si on avait pas de viewBox, la construire a partir de ce width
279
-		if (empty($attributs['viewBox'])) {
280
-			$viewBox[2] = $width;
281
-			// si pas de height valide, on suppose l'image carree
282
-			$viewBox[3] = $width;
283
-		}
284
-	}
285
-	else {
286
-		// si on recupere la taille de la viewbox mais si la viewbox est petite on met un multiplicateur pour la taille finale
287
-		$width = $viewBox[2];
288
-		if ($width < 1) {
289
-			$coeff = max($coeff, 1000);
290
-		}
291
-		elseif ($width < 10) {
292
-			$coeff = max($coeff, 100);
293
-		}
294
-		elseif ($width < 100) {
295
-			$coeff = max($coeff, 10);
296
-		}
297
-	}
298
-	if (
299
-		isset($attributs['height'])
300
-		&& ($h = svg_dimension_to_pixels($attributs['height']))
301
-	) {
302
-		$height = $h;
303
-		// si on avait pas de viewBox, la construire a partir de ce height
304
-		if (empty($attributs['viewBox'])) {
305
-			$viewBox[3] = $height;
306
-		}
307
-	}
308
-	else {
309
-		$height = $viewBox[3];
310
-		if ($height < 1) {
311
-			$coeff = max($coeff, 1000);
312
-		}
313
-		elseif ($height < 10) {
314
-			$coeff = max($coeff, 100);
315
-		}
316
-		elseif ($height < 100) {
317
-			$coeff = max($coeff, 10);
318
-		}
319
-	}
320
-
321
-	// arrondir le width et height en pixel in fine
322
-	$width = round($coeff * $width);
323
-	$height = round($coeff * $height);
324
-
325
-	$viewBox = implode(' ', $viewBox);
326
-
327
-	return [$width, $height, $viewBox];
254
+    $width = 350; // default width
255
+    $height = 150; // default height
256
+
257
+    $viewBox = "0 0 $width $height";
258
+    if (isset($attributs['viewBox'])) {
259
+        $viewBox = $attributs['viewBox'];
260
+        $viewBox = preg_replace(',\s+,', ' ', $viewBox);
261
+    }
262
+    // et on la convertit en px
263
+    $viewBox = explode(' ', $viewBox);
264
+    $viewBox = array_map('svg_dimension_to_pixels', $viewBox);
265
+    if (!$viewBox[2]) {
266
+        $viewBox[2] = $width;
267
+    }
268
+    if (!$viewBox[3]) {
269
+        $viewBox[3] = $height;
270
+    }
271
+
272
+    $coeff = 1;
273
+    if (
274
+        isset($attributs['width'])
275
+        && ($w = svg_dimension_to_pixels($attributs['width']))
276
+    ) {
277
+        $width = $w;
278
+        // si on avait pas de viewBox, la construire a partir de ce width
279
+        if (empty($attributs['viewBox'])) {
280
+            $viewBox[2] = $width;
281
+            // si pas de height valide, on suppose l'image carree
282
+            $viewBox[3] = $width;
283
+        }
284
+    }
285
+    else {
286
+        // si on recupere la taille de la viewbox mais si la viewbox est petite on met un multiplicateur pour la taille finale
287
+        $width = $viewBox[2];
288
+        if ($width < 1) {
289
+            $coeff = max($coeff, 1000);
290
+        }
291
+        elseif ($width < 10) {
292
+            $coeff = max($coeff, 100);
293
+        }
294
+        elseif ($width < 100) {
295
+            $coeff = max($coeff, 10);
296
+        }
297
+    }
298
+    if (
299
+        isset($attributs['height'])
300
+        && ($h = svg_dimension_to_pixels($attributs['height']))
301
+    ) {
302
+        $height = $h;
303
+        // si on avait pas de viewBox, la construire a partir de ce height
304
+        if (empty($attributs['viewBox'])) {
305
+            $viewBox[3] = $height;
306
+        }
307
+    }
308
+    else {
309
+        $height = $viewBox[3];
310
+        if ($height < 1) {
311
+            $coeff = max($coeff, 1000);
312
+        }
313
+        elseif ($height < 10) {
314
+            $coeff = max($coeff, 100);
315
+        }
316
+        elseif ($height < 100) {
317
+            $coeff = max($coeff, 10);
318
+        }
319
+    }
320
+
321
+    // arrondir le width et height en pixel in fine
322
+    $width = round($coeff * $width);
323
+    $height = round($coeff * $height);
324
+
325
+    $viewBox = implode(' ', $viewBox);
326
+
327
+    return [$width, $height, $viewBox];
328 328
 }
329 329
 
330 330
 /**
@@ -340,23 +340,23 @@  discard block
 block discarded – undo
340 340
  * @return string
341 341
  */
342 342
 function svg_force_viewBox_px($img, $force_width_and_height = false) {
343
-	if (
344
-		($svg = svg_charger($img))
345
-		&& ($svg_infos = svg_lire_balise_svg($svg))
346
-	) {
347
-		[$balise_svg, $attributs] = $svg_infos;
348
-
349
-		[$width, $height, $viewBox] = svg_getimagesize_from_attr($attributs);
350
-
351
-		if ($force_width_and_height) {
352
-			$attributs['width'] = $width;
353
-			$attributs['height'] = $height;
354
-		}
355
-
356
-		$attributs['viewBox'] = $viewBox;
357
-		return svg_change_balise_svg($svg, $balise_svg, $attributs);
358
-	}
359
-	return $img;
343
+    if (
344
+        ($svg = svg_charger($img))
345
+        && ($svg_infos = svg_lire_balise_svg($svg))
346
+    ) {
347
+        [$balise_svg, $attributs] = $svg_infos;
348
+
349
+        [$width, $height, $viewBox] = svg_getimagesize_from_attr($attributs);
350
+
351
+        if ($force_width_and_height) {
352
+            $attributs['width'] = $width;
353
+            $attributs['height'] = $height;
354
+        }
355
+
356
+        $attributs['viewBox'] = $viewBox;
357
+        return svg_change_balise_svg($svg, $balise_svg, $attributs);
358
+    }
359
+    return $img;
360 360
 }
361 361
 
362 362
 /**
@@ -365,13 +365,13 @@  discard block
 block discarded – undo
365 365
  * @return array|mixed
366 366
  */
367 367
 function svg_extract_couleurs($img) {
368
-	if (
369
-		($svg = svg_charger($img))
370
-		&& preg_match_all('/(#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])|(rgb\([\s\d]+,[\s\d]+,[\s\d]+\))|(#[0-9a-f][0-9a-f][0-9a-f])/imS', $svg, $matches)
371
-	) {
372
-		return $matches[0];
373
-	}
374
-	return [];
368
+    if (
369
+        ($svg = svg_charger($img))
370
+        && preg_match_all('/(#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])|(rgb\([\s\d]+,[\s\d]+,[\s\d]+\))|(#[0-9a-f][0-9a-f][0-9a-f])/imS', $svg, $matches)
371
+    ) {
372
+        return $matches[0];
373
+    }
374
+    return [];
375 375
 }
376 376
 
377 377
 /**
@@ -382,58 +382,58 @@  discard block
 block discarded – undo
382 382
  * @return bool|string
383 383
  */
384 384
 function svg_recadrer($img, $new_width, $new_height, $offset_width, $offset_height, $background_color = '') {
385
-	if (
386
-		($svg = svg_force_viewBox_px($img))
387
-		&& ($svg_infos = svg_lire_balise_svg($svg))
388
-	) {
389
-		[$balise_svg, $attributs] = $svg_infos;
390
-		$viewBox = explode(' ', $attributs['viewBox']);
391
-
392
-		$viewport_w = $new_width;
393
-		$viewport_h = $new_height;
394
-		$viewport_ox = $offset_width;
395
-		$viewport_oy = $offset_height;
396
-
397
-		// si on a un width/height qui rescale, il faut rescaler
398
-		if (
399
-			isset($attributs['width'])
400
-			&& ($w = svg_dimension_to_pixels($attributs['width']))
401
-			&& isset($attributs['height'])
402
-			&& ($h = svg_dimension_to_pixels($attributs['height']))
403
-		) {
404
-			$xscale = $viewBox[2] / $w;
405
-			$viewport_w = round($viewport_w * $xscale, 2);
406
-			$viewport_ox = round($viewport_ox * $xscale, 2);
407
-			$yscale = $viewBox[3] / $h;
408
-			$viewport_h = round($viewport_h * $yscale, 2);
409
-			$viewport_oy = round($viewport_oy * $yscale, 2);
410
-		}
411
-
412
-		if ($viewport_w > $viewBox[2] || $viewport_h > $viewBox[3]) {
413
-			$svg = svg_clip_in_box($svg, $viewBox[0], $viewBox[1], $viewBox[2], $viewBox[3]);
414
-		}
415
-
416
-		// maintenant on redefinit la viewBox
417
-		$viewBox[0] += $viewport_ox;
418
-		$viewBox[1] += $viewport_oy;
419
-		$viewBox[2] = $viewport_w;
420
-		$viewBox[3] = $viewport_h;
421
-
422
-		$attributs['viewBox'] = implode(' ', $viewBox);
423
-		$attributs['width'] = (string) $new_width;
424
-		$attributs['height'] = (string) $new_height;
425
-
426
-		$svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
427
-
428
-		// ajouter un background
429
-		if ($background_color && $background_color !== 'transparent') {
430
-			$svg = svg_ajouter_background($svg, $background_color);
431
-		}
432
-
433
-		return $svg;
434
-	}
435
-
436
-	return $img;
385
+    if (
386
+        ($svg = svg_force_viewBox_px($img))
387
+        && ($svg_infos = svg_lire_balise_svg($svg))
388
+    ) {
389
+        [$balise_svg, $attributs] = $svg_infos;
390
+        $viewBox = explode(' ', $attributs['viewBox']);
391
+
392
+        $viewport_w = $new_width;
393
+        $viewport_h = $new_height;
394
+        $viewport_ox = $offset_width;
395
+        $viewport_oy = $offset_height;
396
+
397
+        // si on a un width/height qui rescale, il faut rescaler
398
+        if (
399
+            isset($attributs['width'])
400
+            && ($w = svg_dimension_to_pixels($attributs['width']))
401
+            && isset($attributs['height'])
402
+            && ($h = svg_dimension_to_pixels($attributs['height']))
403
+        ) {
404
+            $xscale = $viewBox[2] / $w;
405
+            $viewport_w = round($viewport_w * $xscale, 2);
406
+            $viewport_ox = round($viewport_ox * $xscale, 2);
407
+            $yscale = $viewBox[3] / $h;
408
+            $viewport_h = round($viewport_h * $yscale, 2);
409
+            $viewport_oy = round($viewport_oy * $yscale, 2);
410
+        }
411
+
412
+        if ($viewport_w > $viewBox[2] || $viewport_h > $viewBox[3]) {
413
+            $svg = svg_clip_in_box($svg, $viewBox[0], $viewBox[1], $viewBox[2], $viewBox[3]);
414
+        }
415
+
416
+        // maintenant on redefinit la viewBox
417
+        $viewBox[0] += $viewport_ox;
418
+        $viewBox[1] += $viewport_oy;
419
+        $viewBox[2] = $viewport_w;
420
+        $viewBox[3] = $viewport_h;
421
+
422
+        $attributs['viewBox'] = implode(' ', $viewBox);
423
+        $attributs['width'] = (string) $new_width;
424
+        $attributs['height'] = (string) $new_height;
425
+
426
+        $svg = svg_change_balise_svg($svg, $balise_svg, $attributs);
427
+
428
+        // ajouter un background
429
+        if ($background_color && $background_color !== 'transparent') {
430
+            $svg = svg_ajouter_background($svg, $background_color);
431
+        }
432
+
433
+        return $svg;
434
+    }
435
+
436
+    return $img;
437 437
 }
438 438
 
439 439
 /**
@@ -443,26 +443,26 @@  discard block
 block discarded – undo
443 443
  * @return bool|string
444 444
  */
445 445
 function svg_ajouter_background($img, $background_color) {
446
-	if (
447
-		($svg = svg_charger($img))
448
-		&& ($svg_infos = svg_lire_balise_svg($svg))
449
-	) {
450
-		if ($background_color && $background_color !== 'transparent') {
451
-			[$balise_svg, $attributs] = $svg_infos;
452
-
453
-			$background_color = svg_couleur_to_hexa($background_color);
454
-			if (isset($attributs['viewBox'])) {
455
-				$viewBox = explode(' ', $attributs['viewBox']);
456
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
457
-			}
458
-			else {
459
-				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
460
-			}
461
-			$svg = svg_insert_shapes($svg, $rect);
462
-		}
463
-		return $svg;
464
-	}
465
-	return $img;
446
+    if (
447
+        ($svg = svg_charger($img))
448
+        && ($svg_infos = svg_lire_balise_svg($svg))
449
+    ) {
450
+        if ($background_color && $background_color !== 'transparent') {
451
+            [$balise_svg, $attributs] = $svg_infos;
452
+
453
+            $background_color = svg_couleur_to_hexa($background_color);
454
+            if (isset($attributs['viewBox'])) {
455
+                $viewBox = explode(' ', $attributs['viewBox']);
456
+                $rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
457
+            }
458
+            else {
459
+                $rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
460
+            }
461
+            $svg = svg_insert_shapes($svg, $rect);
462
+        }
463
+        return $svg;
464
+    }
465
+    return $img;
466 466
 }
467 467
 
468 468
 
@@ -473,26 +473,26 @@  discard block
 block discarded – undo
473 473
  * @return bool|string
474 474
  */
475 475
 function svg_ajouter_voile($img, $background_color, $opacity) {
476
-	if (
477
-		($svg = svg_charger($img))
478
-		&& ($svg_infos = svg_lire_balise_svg($svg))
479
-	) {
480
-		if ($background_color && $background_color !== 'transparent') {
481
-			[$balise_svg, $attributs] = $svg_infos;
482
-
483
-			$background_color = svg_couleur_to_hexa($background_color);
484
-			if (isset($attributs['viewBox'])) {
485
-				$viewBox = explode(' ', $attributs['viewBox']);
486
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
487
-			}
488
-			else {
489
-				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
490
-			}
491
-			$svg = svg_insert_shapes($svg, $rect, false);
492
-		}
493
-		return $svg;
494
-	}
495
-	return $img;
476
+    if (
477
+        ($svg = svg_charger($img))
478
+        && ($svg_infos = svg_lire_balise_svg($svg))
479
+    ) {
480
+        if ($background_color && $background_color !== 'transparent') {
481
+            [$balise_svg, $attributs] = $svg_infos;
482
+
483
+            $background_color = svg_couleur_to_hexa($background_color);
484
+            if (isset($attributs['viewBox'])) {
485
+                $viewBox = explode(' ', $attributs['viewBox']);
486
+                $rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
487
+            }
488
+            else {
489
+                $rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
490
+            }
491
+            $svg = svg_insert_shapes($svg, $rect, false);
492
+        }
493
+        return $svg;
494
+    }
495
+    return $img;
496 496
 }
497 497
 
498 498
 
@@ -503,27 +503,27 @@  discard block
 block discarded – undo
503 503
  * @return bool|string
504 504
  */
505 505
 function svg_transformer($img, $attributs) {
506
-	if (
507
-		($svg = svg_charger($img))
508
-		&& ($svg_infos = svg_lire_balise_svg($svg))
509
-	) {
510
-		if ($attributs) {
511
-			[$balise_svg, ] = $svg_infos;
512
-			$g = '<g';
513
-			foreach ($attributs as $k => $v) {
514
-				if (strlen($v)) {
515
-					$g .= " $k=\"" . attribut_html($v) . '"';
516
-				}
517
-			}
518
-			if (strlen($g) > 2) {
519
-				$g .= '>';
520
-				$svg = svg_insert_shapes($svg, $g);
521
-				$svg = svg_insert_shapes($svg, '</g>', false);
522
-			}
523
-		}
524
-		return $svg;
525
-	}
526
-	return $img;
506
+    if (
507
+        ($svg = svg_charger($img))
508
+        && ($svg_infos = svg_lire_balise_svg($svg))
509
+    ) {
510
+        if ($attributs) {
511
+            [$balise_svg, ] = $svg_infos;
512
+            $g = '<g';
513
+            foreach ($attributs as $k => $v) {
514
+                if (strlen($v)) {
515
+                    $g .= " $k=\"" . attribut_html($v) . '"';
516
+                }
517
+            }
518
+            if (strlen($g) > 2) {
519
+                $g .= '>';
520
+                $svg = svg_insert_shapes($svg, $g);
521
+                $svg = svg_insert_shapes($svg, '</g>', false);
522
+            }
523
+        }
524
+        return $svg;
525
+    }
526
+    return $img;
527 527
 }
528 528
 
529 529
 /**
@@ -534,21 +534,21 @@  discard block
 block discarded – undo
534 534
  * @return bool|string
535 535
  */
536 536
 function svg_apply_filter($img, $filter_def) {
537
-	if (
538
-		($svg = svg_charger($img))
539
-		&& ($svg_infos = svg_lire_balise_svg($svg))
540
-	) {
541
-		if ($filter_def) {
542
-			[$balise_svg, ] = $svg_infos;
543
-			$filter_id = 'filter-' . substr(md5($filter_def . strlen($svg)), 0, 8);
544
-			$filter = "<defs><filter id=\"$filter_id\">$filter_def</filter></defs>";
545
-			$g = "<g filter=\"url(#$filter_id)\">";
546
-			$svg = svg_insert_shapes($svg, $filter . $g);
547
-			$svg = svg_insert_shapes($svg, '</g>', false);
548
-		}
549
-		return $svg;
550
-	}
551
-	return $img;
537
+    if (
538
+        ($svg = svg_charger($img))
539
+        && ($svg_infos = svg_lire_balise_svg($svg))
540
+    ) {
541
+        if ($filter_def) {
542
+            [$balise_svg, ] = $svg_infos;
543
+            $filter_id = 'filter-' . substr(md5($filter_def . strlen($svg)), 0, 8);
544
+            $filter = "<defs><filter id=\"$filter_id\">$filter_def</filter></defs>";
545
+            $g = "<g filter=\"url(#$filter_id)\">";
546
+            $svg = svg_insert_shapes($svg, $filter . $g);
547
+            $svg = svg_insert_shapes($svg, '</g>', false);
548
+        }
549
+        return $svg;
550
+    }
551
+    return $img;
552 552
 }
553 553
 
554 554
 /**
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
  * @return string
559 559
  */
560 560
 function svg_filter_blur($img, $blur_width) {
561
-	$blur_width = (int) $blur_width;
562
-	return svg_apply_filter($img, "<feGaussianBlur stdDeviation=\"$blur_width\"/>");
561
+    $blur_width = (int) $blur_width;
562
+    return svg_apply_filter($img, "<feGaussianBlur stdDeviation=\"$blur_width\"/>");
563 563
 }
564 564
 
565 565
 /**
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
  * @return bool|string
570 570
  */
571 571
 function svg_filter_grayscale($img, $intensity) {
572
-	$value = round(1.0 - $intensity, 2);
573
-	//$filter = "<feColorMatrix type=\"matrix\" values=\"0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\"/>";
574
-	$filter = "<feColorMatrix type=\"saturate\" values=\"$value\"/>";
575
-	return svg_apply_filter($img, $filter);
572
+    $value = round(1.0 - $intensity, 2);
573
+    //$filter = "<feColorMatrix type=\"matrix\" values=\"0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\"/>";
574
+    $filter = "<feColorMatrix type=\"saturate\" values=\"$value\"/>";
575
+    return svg_apply_filter($img, $filter);
576 576
 }
577 577
 
578 578
 /**
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
  * @return bool|string
583 583
  */
584 584
 function svg_filter_sepia($img, $intensity) {
585
-	$filter = '<feColorMatrix type="matrix" values="0.30 0.30 0.30 0.0 0 0.25 0.25 0.25 0.0 0 0.20 0.20 0.20 0.0 0 0.00 0.00 0.00 1 0"/>';
586
-	return svg_apply_filter($img, $filter);
585
+    $filter = '<feColorMatrix type="matrix" values="0.30 0.30 0.30 0.0 0 0.25 0.25 0.25 0.0 0 0.20 0.20 0.20 0.0 0 0.00 0.00 0.00 1 0"/>';
586
+    return svg_apply_filter($img, $filter);
587 587
 }
588 588
 
589 589
 /**
@@ -593,30 +593,30 @@  discard block
 block discarded – undo
593 593
  * @return bool|string
594 594
  */
595 595
 function svg_flip($img, $HorV) {
596
-	if (
597
-		($svg = svg_force_viewBox_px($img))
598
-		&& ($svg_infos = svg_lire_balise_svg($svg))
599
-	) {
600
-		[$balise_svg, $atts] = $svg_infos;
601
-		$viewBox = explode(' ', $atts['viewBox']);
602
-
603
-		if (!in_array($HorV, ['h', 'H'])) {
604
-			$transform = 'scale(-1,1)';
605
-
606
-			$x = (int) $viewBox[0] + (int) ($viewBox[2] / 2);
607
-			$mx = -$x;
608
-			$transform = "translate($x, 0) $transform translate($mx, 0)";
609
-		}
610
-		else {
611
-			$transform = 'scale(1,-1)';
612
-
613
-			$y = (int) $viewBox[1] + (int) ($viewBox[3] / 2);
614
-			$my = -$y;
615
-			$transform = "translate(0, $y) $transform translate(0, $my)";
616
-		}
617
-		return svg_transformer($svg, ['transform' => $transform]);
618
-	}
619
-	return $img;
596
+    if (
597
+        ($svg = svg_force_viewBox_px($img))
598
+        && ($svg_infos = svg_lire_balise_svg($svg))
599
+    ) {
600
+        [$balise_svg, $atts] = $svg_infos;
601
+        $viewBox = explode(' ', $atts['viewBox']);
602
+
603
+        if (!in_array($HorV, ['h', 'H'])) {
604
+            $transform = 'scale(-1,1)';
605
+
606
+            $x = (int) $viewBox[0] + (int) ($viewBox[2] / 2);
607
+            $mx = -$x;
608
+            $transform = "translate($x, 0) $transform translate($mx, 0)";
609
+        }
610
+        else {
611
+            $transform = 'scale(1,-1)';
612
+
613
+            $y = (int) $viewBox[1] + (int) ($viewBox[3] / 2);
614
+            $my = -$y;
615
+            $transform = "translate(0, $y) $transform translate(0, $my)";
616
+        }
617
+        return svg_transformer($svg, ['transform' => $transform]);
618
+    }
619
+    return $img;
620 620
 }
621 621
 
622 622
 /**
@@ -630,19 +630,19 @@  discard block
 block discarded – undo
630 630
  * @return bool|string
631 631
  */
632 632
 function svg_rotate($img, $angle, $center_x, $center_y) {
633
-	if (
634
-		($svg = svg_force_viewBox_px($img))
635
-		&& ($svg_infos = svg_lire_balise_svg($svg))
636
-	) {
637
-		[$balise_svg, $atts] = $svg_infos;
638
-		$viewBox = explode(' ', $atts['viewBox']);
639
-
640
-		$center_x = round($viewBox[0] + $center_x * $viewBox[2]);
641
-		$center_y = round($viewBox[1] + $center_y * $viewBox[3]);
642
-
643
-		return svg_transformer($svg, ['transform' => "rotate($angle $center_x $center_y)"]);
644
-	}
645
-	return $img;
633
+    if (
634
+        ($svg = svg_force_viewBox_px($img))
635
+        && ($svg_infos = svg_lire_balise_svg($svg))
636
+    ) {
637
+        [$balise_svg, $atts] = $svg_infos;
638
+        $viewBox = explode(' ', $atts['viewBox']);
639
+
640
+        $center_x = round($viewBox[0] + $center_x * $viewBox[2]);
641
+        $center_y = round($viewBox[1] + $center_y * $viewBox[3]);
642
+
643
+        return svg_transformer($svg, ['transform' => "rotate($angle $center_x $center_y)"]);
644
+    }
645
+    return $img;
646 646
 }
647 647
 
648 648
 /**
@@ -654,40 +654,40 @@  discard block
 block discarded – undo
654 654
  * @return bool|mixed|string
655 655
  */
656 656
 function svg_filtrer_couleurs($img, $callback_filter) {
657
-	if (
658
-		($svg = svg_force_viewBox_px($img))
659
-		&& ($colors = svg_extract_couleurs($svg))
660
-	) {
661
-		$colors = array_unique($colors);
662
-
663
-		$short = [];
664
-		$long = [];
665
-		while (count($colors)) {
666
-			$c = array_shift($colors);
667
-			if (strlen($c) == 4) {
668
-				$short[] = $c;
669
-			}
670
-			else {
671
-				$long[] = $c;
672
-			}
673
-		}
674
-
675
-		$colors = [...$long, ...$short];
676
-		$new_colors = [];
677
-		$colors = array_flip($colors);
678
-		foreach ($colors as $c => $k) {
679
-			$colors[$c] = "@@@COLOR$$k$@@@";
680
-		}
681
-
682
-
683
-		foreach ($colors as $original => $replace) {
684
-			$new = svg_couleur_to_hexa($original);
685
-			$new_colors[$replace] = $callback_filter($new);
686
-		}
687
-
688
-		$svg = str_replace(array_keys($colors), array_values($colors), $svg);
689
-
690
-		return str_replace(array_keys($new_colors), array_values($new_colors), $svg);
691
-	}
692
-	return $img;
657
+    if (
658
+        ($svg = svg_force_viewBox_px($img))
659
+        && ($colors = svg_extract_couleurs($svg))
660
+    ) {
661
+        $colors = array_unique($colors);
662
+
663
+        $short = [];
664
+        $long = [];
665
+        while (count($colors)) {
666
+            $c = array_shift($colors);
667
+            if (strlen($c) == 4) {
668
+                $short[] = $c;
669
+            }
670
+            else {
671
+                $long[] = $c;
672
+            }
673
+        }
674
+
675
+        $colors = [...$long, ...$short];
676
+        $new_colors = [];
677
+        $colors = array_flip($colors);
678
+        foreach ($colors as $c => $k) {
679
+            $colors[$c] = "@@@COLOR$$k$@@@";
680
+        }
681
+
682
+
683
+        foreach ($colors as $original => $replace) {
684
+            $new = svg_couleur_to_hexa($original);
685
+            $new_colors[$replace] = $callback_filter($new);
686
+        }
687
+
688
+        $svg = str_replace(array_keys($colors), array_values($colors), $svg);
689
+
690
+        return str_replace(array_keys($new_colors), array_values($new_colors), $svg);
691
+    }
692
+    return $img;
693 693
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		return $fichier;
56 56
 	}
57 57
 	if (!file_exists($fichier)) {
58
-		$fichier  = supprimer_timestamp($fichier);
58
+		$fichier = supprimer_timestamp($fichier);
59 59
 		if (!file_exists($fichier)) {
60 60
 			return false;
61 61
 		}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 function svg_change_balise_svg($svg, $old_balise_svg, $attributs) {
146 146
 	$new_balise_svg = '<svg';
147 147
 	foreach ($attributs as $k => $v) {
148
-		$new_balise_svg .= " $k=\"" . entites_html($v) . '"';
148
+		$new_balise_svg .= " $k=\"".entites_html($v).'"';
149 149
 	}
150 150
 	$new_balise_svg .= '>';
151 151
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 function svg_insert_shapes($svg, $shapes, $start = true) {
164 164
 
165 165
 	if ($start === false || $start === 'end') {
166
-		$svg = str_replace('</svg>', $shapes . '</svg>', $svg);
166
+		$svg = str_replace('</svg>', $shapes.'</svg>', $svg);
167 167
 	}
168 168
 	else {
169 169
 		$p = stripos($svg, '<svg');
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
  */
185 185
 function svg_clip_in_box($svg, $x, $y, $width, $height) {
186 186
 	$rect = "<rect x=\"$x\" y=\"$y\" width=\"$width\" height=\"$height\" />";
187
-	$id = 'clip-' . substr(md5($rect . strlen($svg)), 0, 8);
187
+	$id = 'clip-'.substr(md5($rect.strlen($svg)), 0, 8);
188 188
 	$clippath = "<clipPath id=\"$id\">$rect</clipPath>";
189 189
 	$g = "<g clip-path=\"url(#$id)\">";
190
-	$svg = svg_insert_shapes($svg, $clippath . $g);
190
+	$svg = svg_insert_shapes($svg, $clippath.$g);
191 191
 	return svg_insert_shapes($svg, '</g>', false);
192 192
 }
193 193
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	) {
206 206
 		[$balise_svg, $attributs] = $svg_infos;
207 207
 		if (!isset($attributs['viewBox'])) {
208
-			$attributs['viewBox'] = '0 0 ' . $attributs['width'] . ' ' . $attributs['height'];
208
+			$attributs['viewBox'] = '0 0 '.$attributs['width'].' '.$attributs['height'];
209 209
 		}
210 210
 		$attributs['width'] = (string) $new_width;
211 211
 		$attributs['height'] = (string) $new_height;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	else {
229 229
 		$couleur = couleur_html_to_hex($couleur);
230 230
 	}
231
-	return '#' . ltrim($couleur, '#');
231
+	return '#'.ltrim($couleur, '#');
232 232
 }
233 233
 
234 234
 /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 function svg_couleur_to_rgb($couleur) {
240 240
 	if (str_starts_with($couleur, 'rgb(')) {
241 241
 		$c = explode(',', substr($couleur, 4));
242
-		return ['red' => (int) $c[0],'green' => (int) $c[1],'blue' => (int) $c[2]];
242
+		return ['red' => (int) $c[0], 'green' => (int) $c[1], 'blue' => (int) $c[2]];
243 243
 	}
244 244
 	return _couleur_hex_to_dec($couleur);
245 245
 }
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 			$background_color = svg_couleur_to_hexa($background_color);
454 454
 			if (isset($attributs['viewBox'])) {
455 455
 				$viewBox = explode(' ', $attributs['viewBox']);
456
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
456
+				$rect = '<rect x="'.$viewBox[0].'" y="'.$viewBox[1].'" width="'.$viewBox[2].'" height="'.$viewBox[3]."\" fill=\"$background_color\"/>";
457 457
 			}
458 458
 			else {
459 459
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 			$background_color = svg_couleur_to_hexa($background_color);
484 484
 			if (isset($attributs['viewBox'])) {
485 485
 				$viewBox = explode(' ', $attributs['viewBox']);
486
-				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
486
+				$rect = '<rect x="'.$viewBox[0].'" y="'.$viewBox[1].'" width="'.$viewBox[2].'" height="'.$viewBox[3]."\" fill=\"$background_color\" opacity=\"$opacity\"/>";
487 487
 			}
488 488
 			else {
489 489
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			$g = '<g';
513 513
 			foreach ($attributs as $k => $v) {
514 514
 				if (strlen($v)) {
515
-					$g .= " $k=\"" . attribut_html($v) . '"';
515
+					$g .= " $k=\"".attribut_html($v).'"';
516 516
 				}
517 517
 			}
518 518
 			if (strlen($g) > 2) {
@@ -540,10 +540,10 @@  discard block
 block discarded – undo
540 540
 	) {
541 541
 		if ($filter_def) {
542 542
 			[$balise_svg, ] = $svg_infos;
543
-			$filter_id = 'filter-' . substr(md5($filter_def . strlen($svg)), 0, 8);
543
+			$filter_id = 'filter-'.substr(md5($filter_def.strlen($svg)), 0, 8);
544 544
 			$filter = "<defs><filter id=\"$filter_id\">$filter_def</filter></defs>";
545 545
 			$g = "<g filter=\"url(#$filter_id)\">";
546
-			$svg = svg_insert_shapes($svg, $filter . $g);
546
+			$svg = svg_insert_shapes($svg, $filter.$g);
547 547
 			$svg = svg_insert_shapes($svg, '</g>', false);
548 548
 		}
549 549
 		return $svg;
Please login to merge, or discard this patch.
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -164,8 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 	if ($start === false || $start === 'end') {
166 166
 		$svg = str_replace('</svg>', $shapes . '</svg>', $svg);
167
-	}
168
-	else {
167
+	} else {
169 168
 		$p = stripos($svg, '<svg');
170 169
 		$p = strpos($svg, '>', $p);
171 170
 		$svg = substr_replace($svg, $shapes, $p + 1, 0);
@@ -224,8 +223,7 @@  discard block
 block discarded – undo
224 223
 	if (str_starts_with($couleur, 'rgb(')) {
225 224
 		$c = explode(',', substr($couleur, 4));
226 225
 		$couleur = _couleur_dec_to_hex((int) $c[0], (int) $c[1], (int) $c[2]);
227
-	}
228
-	else {
226
+	} else {
229 227
 		$couleur = couleur_html_to_hex($couleur);
230 228
 	}
231 229
 	return '#' . ltrim($couleur, '#');
@@ -281,17 +279,14 @@  discard block
 block discarded – undo
281 279
 			// si pas de height valide, on suppose l'image carree
282 280
 			$viewBox[3] = $width;
283 281
 		}
284
-	}
285
-	else {
282
+	} else {
286 283
 		// si on recupere la taille de la viewbox mais si la viewbox est petite on met un multiplicateur pour la taille finale
287 284
 		$width = $viewBox[2];
288 285
 		if ($width < 1) {
289 286
 			$coeff = max($coeff, 1000);
290
-		}
291
-		elseif ($width < 10) {
287
+		} elseif ($width < 10) {
292 288
 			$coeff = max($coeff, 100);
293
-		}
294
-		elseif ($width < 100) {
289
+		} elseif ($width < 100) {
295 290
 			$coeff = max($coeff, 10);
296 291
 		}
297 292
 	}
@@ -304,16 +299,13 @@  discard block
 block discarded – undo
304 299
 		if (empty($attributs['viewBox'])) {
305 300
 			$viewBox[3] = $height;
306 301
 		}
307
-	}
308
-	else {
302
+	} else {
309 303
 		$height = $viewBox[3];
310 304
 		if ($height < 1) {
311 305
 			$coeff = max($coeff, 1000);
312
-		}
313
-		elseif ($height < 10) {
306
+		} elseif ($height < 10) {
314 307
 			$coeff = max($coeff, 100);
315
-		}
316
-		elseif ($height < 100) {
308
+		} elseif ($height < 100) {
317 309
 			$coeff = max($coeff, 10);
318 310
 		}
319 311
 	}
@@ -454,8 +446,7 @@  discard block
 block discarded – undo
454 446
 			if (isset($attributs['viewBox'])) {
455 447
 				$viewBox = explode(' ', $attributs['viewBox']);
456 448
 				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\"/>";
457
-			}
458
-			else {
449
+			} else {
459 450
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
460 451
 			}
461 452
 			$svg = svg_insert_shapes($svg, $rect);
@@ -484,8 +475,7 @@  discard block
 block discarded – undo
484 475
 			if (isset($attributs['viewBox'])) {
485 476
 				$viewBox = explode(' ', $attributs['viewBox']);
486 477
 				$rect = '<rect x="' . $viewBox[0] . '" y="' . $viewBox[1] . '" width="' . $viewBox[2] . '" height="' . $viewBox[3] . "\" fill=\"$background_color\" opacity=\"$opacity\"/>";
487
-			}
488
-			else {
478
+			} else {
489 479
 				$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>";
490 480
 			}
491 481
 			$svg = svg_insert_shapes($svg, $rect, false);
@@ -606,8 +596,7 @@  discard block
 block discarded – undo
606 596
 			$x = (int) $viewBox[0] + (int) ($viewBox[2] / 2);
607 597
 			$mx = -$x;
608 598
 			$transform = "translate($x, 0) $transform translate($mx, 0)";
609
-		}
610
-		else {
599
+		} else {
611 600
 			$transform = 'scale(1,-1)';
612 601
 
613 602
 			$y = (int) $viewBox[1] + (int) ($viewBox[3] / 2);
@@ -666,8 +655,7 @@  discard block
 block discarded – undo
666 655
 			$c = array_shift($colors);
667 656
 			if (strlen($c) == 4) {
668 657
 				$short[] = $c;
669
-			}
670
-			else {
658
+			} else {
671 659
 				$long[] = $c;
672 660
 			}
673 661
 		}
Please login to merge, or discard this patch.
ecrire/src/Afficher/Minipage/Installation.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@
 block discarded – undo
15 15
  * Présentation des pages simplifiées pour installer SPIP
16 16
  **/
17 17
 class Installation extends Admin {
18
-	public const TYPE = 'installation';
18
+    public const TYPE = 'installation';
19 19
 
20
-	protected function setOptions(array $options) {
21
-		$options['titre'] ??= '';
22
-		if (!$options['titre'] || $options['titre'] === 'AUTO') {
23
-			$options['titre'] = _T('info_installation_systeme_publication');
24
-		}
25
-		$options = parent::setOptions($options);
26
-		$options['couleur_fond'] = '#a1124d';
27
-		$options['css_files'][] = find_in_theme('installation.css');
28
-		$options['footer'] = '';
29
-		return $options;
30
-	}
20
+    protected function setOptions(array $options) {
21
+        $options['titre'] ??= '';
22
+        if (!$options['titre'] || $options['titre'] === 'AUTO') {
23
+            $options['titre'] = _T('info_installation_systeme_publication');
24
+        }
25
+        $options = parent::setOptions($options);
26
+        $options['couleur_fond'] = '#a1124d';
27
+        $options['css_files'][] = find_in_theme('installation.css');
28
+        $options['footer'] = '';
29
+        return $options;
30
+    }
31 31
 
32
-	public function page($corps = '', $options = []) {
33
-		$options['titre'] ??= 'AUTO';
34
-		return parent::page($corps, $options);
35
-	}
32
+    public function page($corps = '', $options = []) {
33
+        $options['titre'] ??= 'AUTO';
34
+        return parent::page($corps, $options);
35
+    }
36 36
 }
Please login to merge, or discard this patch.
ecrire/src/Sql/Sqlite/Sqlite.php 1 patch
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -8,112 +8,112 @@
 block discarded – undo
8 8
  **/
9 9
 class Sqlite
10 10
 {
11
-	/** @var Requeteur[] Liste des instances de requêteurs créés */
12
-	public static $requeteurs = [];
13
-	/** @var bool[] Pour chaque connexion, flag pour savoir si une transaction est en cours */
14
-	public static $transaction_en_cours = [];
11
+    /** @var Requeteur[] Liste des instances de requêteurs créés */
12
+    public static $requeteurs = [];
13
+    /** @var bool[] Pour chaque connexion, flag pour savoir si une transaction est en cours */
14
+    public static $transaction_en_cours = [];
15 15
 
16 16
 
17
-	/**
18
-	 * Retourne une unique instance du requêteur
19
-	 *
20
-	 * Retourne une instance unique du requêteur pour une connexion SQLite
21
-	 * donnée
22
-	 *
23
-	 * @param string $serveur
24
-	 *    Nom du connecteur
25
-	 * @return Requeteur
26
-	 *    Instance unique du requêteur
27
-	 **/
28
-	public static function requeteur($serveur) {
29
-		if (!isset(static::$requeteurs[$serveur])) {
30
-			static::$requeteurs[$serveur] = new Requeteur($serveur);
31
-		}
17
+    /**
18
+     * Retourne une unique instance du requêteur
19
+     *
20
+     * Retourne une instance unique du requêteur pour une connexion SQLite
21
+     * donnée
22
+     *
23
+     * @param string $serveur
24
+     *    Nom du connecteur
25
+     * @return Requeteur
26
+     *    Instance unique du requêteur
27
+     **/
28
+    public static function requeteur($serveur) {
29
+        if (!isset(static::$requeteurs[$serveur])) {
30
+            static::$requeteurs[$serveur] = new Requeteur($serveur);
31
+        }
32 32
 
33
-		return static::$requeteurs[$serveur];
34
-	}
33
+        return static::$requeteurs[$serveur];
34
+    }
35 35
 
36
-	/**
37
-	 * Prépare le texte d'une requête avant son exécution
38
-	 *
39
-	 * Adapte la requête au format plus ou moins MySQL par un format
40
-	 * compris de SQLite.
41
-	 *
42
-	 * Change les préfixes de tables SPIP par ceux véritables
43
-	 *
44
-	 * @param string $query Requête à préparer
45
-	 * @param string $serveur Nom de la connexion
46
-	 * @return string           Requête préparée
47
-	 */
48
-	public static function traduire_requete($query, $serveur) {
49
-		$requeteur = static::requeteur($serveur);
50
-		$traducteur = new Traducteur($query, $requeteur->prefixe, $requeteur->sqlite_version);
36
+    /**
37
+     * Prépare le texte d'une requête avant son exécution
38
+     *
39
+     * Adapte la requête au format plus ou moins MySQL par un format
40
+     * compris de SQLite.
41
+     *
42
+     * Change les préfixes de tables SPIP par ceux véritables
43
+     *
44
+     * @param string $query Requête à préparer
45
+     * @param string $serveur Nom de la connexion
46
+     * @return string           Requête préparée
47
+     */
48
+    public static function traduire_requete($query, $serveur) {
49
+        $requeteur = static::requeteur($serveur);
50
+        $traducteur = new Traducteur($query, $requeteur->prefixe, $requeteur->sqlite_version);
51 51
 
52
-		return $traducteur->traduire_requete();
53
-	}
52
+        return $traducteur->traduire_requete();
53
+    }
54 54
 
55
-	/**
56
-	 * Démarre une transaction
57
-	 *
58
-	 * @param string $serveur Nom de la connexion
59
-	 **/
60
-	public static function demarrer_transaction($serveur) {
61
-		Sqlite::executer_requete('BEGIN TRANSACTION', $serveur);
62
-		Sqlite::$transaction_en_cours[$serveur] = true;
63
-	}
55
+    /**
56
+     * Démarre une transaction
57
+     *
58
+     * @param string $serveur Nom de la connexion
59
+     **/
60
+    public static function demarrer_transaction($serveur) {
61
+        Sqlite::executer_requete('BEGIN TRANSACTION', $serveur);
62
+        Sqlite::$transaction_en_cours[$serveur] = true;
63
+    }
64 64
 
65
-	/**
66
-	 * Exécute la requête donnée
67
-	 *
68
-	 * @param string $query Requête
69
-	 * @param string $serveur Nom de la connexion
70
-	 * @param null|bool $tracer Demander des statistiques (temps) ?
71
-	 **/
72
-	public static function executer_requete($query, $serveur, $tracer = null) {
73
-		$requeteur = Sqlite::requeteur($serveur);
65
+    /**
66
+     * Exécute la requête donnée
67
+     *
68
+     * @param string $query Requête
69
+     * @param string $serveur Nom de la connexion
70
+     * @param null|bool $tracer Demander des statistiques (temps) ?
71
+     **/
72
+    public static function executer_requete($query, $serveur, $tracer = null) {
73
+        $requeteur = Sqlite::requeteur($serveur);
74 74
 
75
-		return $requeteur->executer_requete($query, $tracer);
76
-	}
75
+        return $requeteur->executer_requete($query, $tracer);
76
+    }
77 77
 
78
-	/**
79
-	 * Obtient l'identifiant de la dernière ligne insérée ou modifiée
80
-	 *
81
-	 * @param string $serveur Nom de la connexion
82
-	 * return int                Identifiant
83
-	 **/
84
-	public static function last_insert_id($serveur) {
85
-		$requeteur = Sqlite::requeteur($serveur);
78
+    /**
79
+     * Obtient l'identifiant de la dernière ligne insérée ou modifiée
80
+     *
81
+     * @param string $serveur Nom de la connexion
82
+     * return int                Identifiant
83
+     **/
84
+    public static function last_insert_id($serveur) {
85
+        $requeteur = Sqlite::requeteur($serveur);
86 86
 
87
-		return $requeteur->last_insert_id();
88
-	}
87
+        return $requeteur->last_insert_id();
88
+    }
89 89
 
90
-	/**
91
-	 * Annule une transaction
92
-	 *
93
-	 * @param string $serveur Nom de la connexion
94
-	 **/
95
-	public static function annuler_transaction($serveur) {
96
-		Sqlite::executer_requete('ROLLBACK', $serveur);
97
-		Sqlite::$transaction_en_cours[$serveur] = false;
98
-	}
90
+    /**
91
+     * Annule une transaction
92
+     *
93
+     * @param string $serveur Nom de la connexion
94
+     **/
95
+    public static function annuler_transaction($serveur) {
96
+        Sqlite::executer_requete('ROLLBACK', $serveur);
97
+        Sqlite::$transaction_en_cours[$serveur] = false;
98
+    }
99 99
 
100
-	/**
101
-	 * Termine une transaction
102
-	 *
103
-	 * @param string $serveur Nom de la connexion
104
-	 **/
105
-	public static function finir_transaction($serveur) {
106
-		// si pas de transaction en cours, ne rien faire et le dire
107
-		if (
108
-			!isset(Sqlite::$transaction_en_cours[$serveur])
109
-			|| Sqlite::$transaction_en_cours[$serveur] == false
110
-		) {
111
-			return false;
112
-		}
113
-		// sinon fermer la transaction et retourner true
114
-		Sqlite::executer_requete('COMMIT', $serveur);
115
-		Sqlite::$transaction_en_cours[$serveur] = false;
100
+    /**
101
+     * Termine une transaction
102
+     *
103
+     * @param string $serveur Nom de la connexion
104
+     **/
105
+    public static function finir_transaction($serveur) {
106
+        // si pas de transaction en cours, ne rien faire et le dire
107
+        if (
108
+            !isset(Sqlite::$transaction_en_cours[$serveur])
109
+            || Sqlite::$transaction_en_cours[$serveur] == false
110
+        ) {
111
+            return false;
112
+        }
113
+        // sinon fermer la transaction et retourner true
114
+        Sqlite::executer_requete('COMMIT', $serveur);
115
+        Sqlite::$transaction_en_cours[$serveur] = false;
116 116
 
117
-		return true;
118
-	}
117
+        return true;
118
+    }
119 119
 }
Please login to merge, or discard this patch.