Completed
Push — master ( 0df2ac...a4a09d )
by cam
01:04
created
ecrire/inc/lang.php 1 patch
Indentation   +254 added lines, -254 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Langue
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -39,36 +39,36 @@  discard block
 block discarded – undo
39 39
  **/
40 40
 function changer_langue($lang, $liste_langues = null) {
41 41
 
42
-	if (is_null($liste_langues)) {
43
-		$liste_langues = @$GLOBALS['meta']['langues_proposees'] . ',' . @$GLOBALS['meta']['langues_multilingue'];
44
-	}
45
-	else {
46
-		if (is_array($liste_langues)) {
47
-			$liste_langues = implode(',', $liste_langues);
48
-		}
49
-	}
50
-	$liste_langues = ',' . $liste_langues . ',';
51
-
52
-	// Si la langue demandee n'existe pas, on essaie d'autres variantes
53
-	// Exemple : 'pt-br' => 'pt_br' => 'pt'
54
-	$lang = str_replace('-', '_', trim($lang));
55
-	if (!$lang) {
56
-		return false;
57
-	}
58
-
59
-	if (
60
-		strpos($liste_langues, ",$lang,") !== false
61
-		or ($lang = preg_replace(',_.*,', '', $lang)
62
-			and strpos($liste_langues, ",$lang,") !== false)
63
-	) {
64
-		$GLOBALS['spip_lang_rtl'] = lang_dir($lang, '', '_rtl');
65
-		$GLOBALS['spip_lang_right'] = $GLOBALS['spip_lang_rtl'] ? 'left' : 'right';
66
-		$GLOBALS['spip_lang_left'] = $GLOBALS['spip_lang_rtl'] ? 'right' : 'left';
67
-
68
-		return $GLOBALS['spip_lang'] = $lang;
69
-	} else {
70
-		return false;
71
-	}
42
+    if (is_null($liste_langues)) {
43
+        $liste_langues = @$GLOBALS['meta']['langues_proposees'] . ',' . @$GLOBALS['meta']['langues_multilingue'];
44
+    }
45
+    else {
46
+        if (is_array($liste_langues)) {
47
+            $liste_langues = implode(',', $liste_langues);
48
+        }
49
+    }
50
+    $liste_langues = ',' . $liste_langues . ',';
51
+
52
+    // Si la langue demandee n'existe pas, on essaie d'autres variantes
53
+    // Exemple : 'pt-br' => 'pt_br' => 'pt'
54
+    $lang = str_replace('-', '_', trim($lang));
55
+    if (!$lang) {
56
+        return false;
57
+    }
58
+
59
+    if (
60
+        strpos($liste_langues, ",$lang,") !== false
61
+        or ($lang = preg_replace(',_.*,', '', $lang)
62
+            and strpos($liste_langues, ",$lang,") !== false)
63
+    ) {
64
+        $GLOBALS['spip_lang_rtl'] = lang_dir($lang, '', '_rtl');
65
+        $GLOBALS['spip_lang_right'] = $GLOBALS['spip_lang_rtl'] ? 'left' : 'right';
66
+        $GLOBALS['spip_lang_left'] = $GLOBALS['spip_lang_rtl'] ? 'right' : 'left';
67
+
68
+        return $GLOBALS['spip_lang'] = $lang;
69
+    } else {
70
+        return false;
71
+    }
72 72
 }
73 73
 
74 74
 //
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 // par exemple le francais pour l'espagnol, l'anglais pour l'allemand, etc.
82 82
 
83 83
 function choisir_traduction($trads, $lang = '') {
84
-	$k = approcher_langue($trads, $lang);
84
+    $k = approcher_langue($trads, $lang);
85 85
 
86
-	return $k ? $trads[$k] : array_shift($trads);
86
+    return $k ? $trads[$k] : array_shift($trads);
87 87
 }
88 88
 
89 89
 // retourne son 2e argument si c'est un index du premier
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 // la langue X etant consideree comme une approche de X_Y
92 92
 function approcher_langue($trads, $lang = '') {
93 93
 
94
-	if (!$lang) {
95
-		$lang = $GLOBALS['spip_lang'];
96
-	}
97
-
98
-	if (isset($trads[$lang])) {
99
-		return $lang;
100
-	} // cas des langues xx_yy
101
-	else {
102
-		$r = explode('_', $lang);
103
-		if (isset($trads[$r[0]])) {
104
-			return $r[0];
105
-		}
106
-	}
107
-
108
-	return '';
94
+    if (!$lang) {
95
+        $lang = $GLOBALS['spip_lang'];
96
+    }
97
+
98
+    if (isset($trads[$lang])) {
99
+        return $lang;
100
+    } // cas des langues xx_yy
101
+    else {
102
+        $r = explode('_', $lang);
103
+        if (isset($trads[$r[0]])) {
104
+            return $r[0];
105
+        }
106
+    }
107
+
108
+    return '';
109 109
 }
110 110
 
111 111
 /**
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
  *     Nom de la langue, sinon son code.
121 121
  **/
122 122
 function traduire_nom_langue($lang) {
123
-	include_spip('inc/lang_liste');
124
-	include_spip('inc/charsets');
123
+    include_spip('inc/lang_liste');
124
+    include_spip('inc/charsets');
125 125
 
126
-	return html2unicode(isset($GLOBALS['codes_langues'][$lang]) ? $GLOBALS['codes_langues'][$lang] : $lang);
126
+    return html2unicode(isset($GLOBALS['codes_langues'][$lang]) ? $GLOBALS['codes_langues'][$lang] : $lang);
127 127
 }
128 128
 
129 129
 //
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 // C'est utilise par #LANG_DIR, #LANG_LEFT, #LANG_RIGHT.
138 138
 // https://code.spip.net/@lang_dir
139 139
 function lang_dir($lang = '', $droitier = 'ltr', $gaucher = 'rtl') {
140
-	static $lang_rtl = ['ar', 'fa', 'ku', 'prs', 'ps', 'ur', 'he', 'heb', 'hbo', 'yi'];
140
+    static $lang_rtl = ['ar', 'fa', 'ku', 'prs', 'ps', 'ur', 'he', 'heb', 'hbo', 'yi'];
141 141
 
142
-	return in_array(($lang ? $lang : $GLOBALS['spip_lang']), $lang_rtl) ?
143
-		$gaucher : $droitier;
142
+    return in_array(($lang ? $lang : $GLOBALS['spip_lang']), $lang_rtl) ?
143
+        $gaucher : $droitier;
144 144
 }
145 145
 
146 146
 // typo francaise ou anglaise ?
@@ -150,32 +150,32 @@  discard block
 block discarded – undo
150 150
 
151 151
 // https://code.spip.net/@lang_typo
152 152
 function lang_typo($lang = '') {
153
-	if (!$lang) {
154
-		$lang = isset($GLOBALS['lang_objet'])
155
-			? $GLOBALS['lang_objet']
156
-			: $GLOBALS['spip_lang'];
157
-	}
158
-	if (
159
-		$lang == 'eo'
160
-		or $lang == 'fr'
161
-		or strncmp($lang, 'fr_', 3) == 0
162
-		or $lang == 'cpf'
163
-	) {
164
-		return 'fr';
165
-	} else {
166
-		return 'en';
167
-	}
153
+    if (!$lang) {
154
+        $lang = isset($GLOBALS['lang_objet'])
155
+            ? $GLOBALS['lang_objet']
156
+            : $GLOBALS['spip_lang'];
157
+    }
158
+    if (
159
+        $lang == 'eo'
160
+        or $lang == 'fr'
161
+        or strncmp($lang, 'fr_', 3) == 0
162
+        or $lang == 'cpf'
163
+    ) {
164
+        return 'fr';
165
+    } else {
166
+        return 'en';
167
+    }
168 168
 }
169 169
 
170 170
 // gestion de la globale $lang_objet pour que les textes soient affiches
171 171
 // avec les memes typo et direction dans l'espace prive que dans le public
172 172
 // https://code.spip.net/@changer_typo
173 173
 function changer_typo($lang = '') {
174
-	if ($lang) {
175
-		$GLOBALS['lang_objet'] = $lang;
176
-	} else {
177
-		unset($GLOBALS['lang_objet']);
178
-	}
174
+    if ($lang) {
175
+        $GLOBALS['lang_objet'] = $lang;
176
+    } else {
177
+        unset($GLOBALS['lang_objet']);
178
+    }
179 179
 }
180 180
 
181 181
 //
@@ -186,59 +186,59 @@  discard block
 block discarded – undo
186 186
 //
187 187
 // https://code.spip.net/@menu_langues
188 188
 function menu_langues($nom_select, $default = '') {
189
-	include_spip('inc/actions');
190
-
191
-	$langues = liste_options_langues($nom_select);
192
-	$ret = '';
193
-	if (!count($langues)) {
194
-		return '';
195
-	}
196
-
197
-	if (!$default) {
198
-		$default = $GLOBALS['spip_lang'];
199
-	}
200
-	foreach ($langues as $l) {
201
-		$selected = ($l == $default) ? ' selected=\'selected\'' : '';
202
-		$ret .= "<option value='$l'$selected>[" . $l . '] ' . traduire_nom_langue($l) . "</option>\n";
203
-	}
204
-
205
-	if (!test_espace_prive()) {
206
-		$cible = self();
207
-		$base = '';
208
-	} else {
209
-		$cible = self();
210
-		$base = spip_connect() ? 'base' : '';
211
-	}
212
-
213
-	$change = ' onchange="this.parentNode.parentNode.submit()"';
214
-
215
-	return generer_action_auteur(
216
-		'converser',
217
-		$base,
218
-		$cible,
219
-		(select_langues($nom_select, $change, $ret)
220
-			. "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"),
221
-		" method='post'"
222
-	);
189
+    include_spip('inc/actions');
190
+
191
+    $langues = liste_options_langues($nom_select);
192
+    $ret = '';
193
+    if (!count($langues)) {
194
+        return '';
195
+    }
196
+
197
+    if (!$default) {
198
+        $default = $GLOBALS['spip_lang'];
199
+    }
200
+    foreach ($langues as $l) {
201
+        $selected = ($l == $default) ? ' selected=\'selected\'' : '';
202
+        $ret .= "<option value='$l'$selected>[" . $l . '] ' . traduire_nom_langue($l) . "</option>\n";
203
+    }
204
+
205
+    if (!test_espace_prive()) {
206
+        $cible = self();
207
+        $base = '';
208
+    } else {
209
+        $cible = self();
210
+        $base = spip_connect() ? 'base' : '';
211
+    }
212
+
213
+    $change = ' onchange="this.parentNode.parentNode.submit()"';
214
+
215
+    return generer_action_auteur(
216
+        'converser',
217
+        $base,
218
+        $cible,
219
+        (select_langues($nom_select, $change, $ret)
220
+            . "<noscript><div style='display:inline'><input type='submit' class='fondo' value='" . _T('bouton_changer') . "' /></div></noscript>"),
221
+        " method='post'"
222
+    );
223 223
 }
224 224
 
225 225
 // https://code.spip.net/@select_langues
226 226
 function select_langues($nom_select, $change, $options, $label = '') {
227
-	static $cpt = 0;
228
-	$id = 'menu_langues' . $cpt++;
229
-
230
-	return
231
-		"<label for='$id'>" . ($label ? $label : _T('info_langues')) . '</label> ' .
232
-		"<select name='$nom_select' id='$id' "
233
-		. ((!test_espace_prive()) ?
234
-			("class='forml menu_langues'") :
235
-			(($nom_select == 'var_lang_ecrire') ?
236
-				("class='lang_ecrire'") :
237
-				"class='fondl'"))
238
-		. $change
239
-		. ">\n"
240
-		. $options
241
-		. '</select>';
227
+    static $cpt = 0;
228
+    $id = 'menu_langues' . $cpt++;
229
+
230
+    return
231
+        "<label for='$id'>" . ($label ? $label : _T('info_langues')) . '</label> ' .
232
+        "<select name='$nom_select' id='$id' "
233
+        . ((!test_espace_prive()) ?
234
+            ("class='forml menu_langues'") :
235
+            (($nom_select == 'var_lang_ecrire') ?
236
+                ("class='lang_ecrire'") :
237
+                "class='fondl'"))
238
+        . $change
239
+        . ">\n"
240
+        . $options
241
+        . '</select>';
242 242
 }
243 243
 
244 244
 /**
@@ -260,34 +260,34 @@  discard block
 block discarded – undo
260 260
  */
261 261
 function liste_options_langues($nom_select) {
262 262
 
263
-	switch ($nom_select) {
264
-		# #MENU_LANG
265
-		case 'var_lang':
266
-			# menu de changement de la langue d'un article
267
-			# les langues selectionnees dans la configuration "multilinguisme"
268
-		case 'changer_lang':
269
-			$langues = explode(',', $GLOBALS['meta']['langues_multilingue']);
270
-			break;
271
-		# menu de l'interface (privee, installation et panneau de login)
272
-		# les langues presentes sous forme de fichiers de langue
273
-		# on force la relecture du repertoire des langues pour etre synchrone.
274
-		case 'var_lang_ecrire':
275
-		default:
276
-			$GLOBALS['meta']['langues_proposees'] = '';
277
-			init_langues();
278
-			$langues = explode(',', $GLOBALS['meta']['langues_proposees']);
279
-			break;
263
+    switch ($nom_select) {
264
+        # #MENU_LANG
265
+        case 'var_lang':
266
+            # menu de changement de la langue d'un article
267
+            # les langues selectionnees dans la configuration "multilinguisme"
268
+        case 'changer_lang':
269
+            $langues = explode(',', $GLOBALS['meta']['langues_multilingue']);
270
+            break;
271
+        # menu de l'interface (privee, installation et panneau de login)
272
+        # les langues presentes sous forme de fichiers de langue
273
+        # on force la relecture du repertoire des langues pour etre synchrone.
274
+        case 'var_lang_ecrire':
275
+        default:
276
+            $GLOBALS['meta']['langues_proposees'] = '';
277
+            init_langues();
278
+            $langues = explode(',', $GLOBALS['meta']['langues_proposees']);
279
+            break;
280 280
 
281 281
 # dernier choix possible : toutes les langues = langues_proposees
282 282
 # + langues_multilingues ; mais, ne sert pas
283 283
 #			$langues = explode(',', $GLOBALS['all_langs']);
284
-	}
285
-	if (count($langues) <= 1) {
286
-		return [];
287
-	}
288
-	sort($langues);
284
+    }
285
+    if (count($langues) <= 1) {
286
+        return [];
287
+    }
288
+    sort($langues);
289 289
 
290
-	return $langues;
290
+    return $langues;
291 291
 }
292 292
 
293 293
 
@@ -302,39 +302,39 @@  discard block
 block discarded – undo
302 302
  **/
303 303
 function verifier_lang_url() {
304 304
 
305
-	// quelle langue est demandee ?
306
-	$lang_demandee = (test_espace_prive() ? $GLOBALS['spip_lang'] : $GLOBALS['meta']['langue_site']);
307
-	if (isset($_COOKIE['spip_lang_ecrire'])) {
308
-		$lang_demandee = $_COOKIE['spip_lang_ecrire'];
309
-	}
310
-	if (!test_espace_prive() and isset($_COOKIE['spip_lang'])) {
311
-		$lang_demandee = $_COOKIE['spip_lang'];
312
-	}
313
-	if (isset($_GET['lang'])) {
314
-		$lang_demandee = $_GET['lang'];
315
-	}
316
-
317
-	// Renvoyer si besoin (et si la langue demandee existe)
318
-	if (
319
-		$GLOBALS['spip_lang'] != $lang_demandee
320
-		and changer_langue($lang_demandee)
321
-		and $lang_demandee != @$_GET['lang']
322
-	) {
323
-		$destination = parametre_url(self(), 'lang', $lang_demandee, '&');
324
-		// ici on a besoin des var_truc
325
-		foreach ($_GET as $var => $val) {
326
-			if (!strncmp('var_', $var, 4)) {
327
-				$destination = parametre_url($destination, $var, $val, '&');
328
-			}
329
-		}
330
-		include_spip('inc/headers');
331
-		redirige_par_entete($destination);
332
-	}
333
-
334
-	// Subtilite : si la langue demandee par cookie est la bonne
335
-	// alors on fait comme si $lang etait passee dans l'URL
336
-	// (pour criteres {lang}).
337
-	$GLOBALS['lang'] = $_GET['lang'] = $GLOBALS['spip_lang'];
305
+    // quelle langue est demandee ?
306
+    $lang_demandee = (test_espace_prive() ? $GLOBALS['spip_lang'] : $GLOBALS['meta']['langue_site']);
307
+    if (isset($_COOKIE['spip_lang_ecrire'])) {
308
+        $lang_demandee = $_COOKIE['spip_lang_ecrire'];
309
+    }
310
+    if (!test_espace_prive() and isset($_COOKIE['spip_lang'])) {
311
+        $lang_demandee = $_COOKIE['spip_lang'];
312
+    }
313
+    if (isset($_GET['lang'])) {
314
+        $lang_demandee = $_GET['lang'];
315
+    }
316
+
317
+    // Renvoyer si besoin (et si la langue demandee existe)
318
+    if (
319
+        $GLOBALS['spip_lang'] != $lang_demandee
320
+        and changer_langue($lang_demandee)
321
+        and $lang_demandee != @$_GET['lang']
322
+    ) {
323
+        $destination = parametre_url(self(), 'lang', $lang_demandee, '&');
324
+        // ici on a besoin des var_truc
325
+        foreach ($_GET as $var => $val) {
326
+            if (!strncmp('var_', $var, 4)) {
327
+                $destination = parametre_url($destination, $var, $val, '&');
328
+            }
329
+        }
330
+        include_spip('inc/headers');
331
+        redirige_par_entete($destination);
332
+    }
333
+
334
+    // Subtilite : si la langue demandee par cookie est la bonne
335
+    // alors on fait comme si $lang etait passee dans l'URL
336
+    // (pour criteres {lang}).
337
+    $GLOBALS['lang'] = $_GET['lang'] = $GLOBALS['spip_lang'];
338 338
 }
339 339
 
340 340
 
@@ -352,22 +352,22 @@  discard block
 block discarded – undo
352 352
  *     La langue sélectionnée
353 353
  **/
354 354
 function utiliser_langue_site($liste_langues = null) {
355
-	// s'il existe une langue du site (en gros tout le temps en théorie)
356
-	if (
357
-		isset($GLOBALS['meta']['langue_site'])
358
-		// et si spip_langue est pas encore définie (ce que va faire changer_langue())
359
-		// ou qu'elle n'est pas identique à la langue du site
360
-		and (!isset($GLOBALS['spip_lang'])
361
-			or $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site'])
362
-	) {
363
-		return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues);//@:install
364
-	}
365
-	// en theorie là, la globale est définie, sinon c'est un problème.
366
-	if (!isset($GLOBALS['spip_lang'])) {
367
-		spip_log('La globale spip_lang est indéfinie dans utiliser_langue_site() !', _LOG_ERREUR);
368
-	}
369
-
370
-	return $GLOBALS['spip_lang'];
355
+    // s'il existe une langue du site (en gros tout le temps en théorie)
356
+    if (
357
+        isset($GLOBALS['meta']['langue_site'])
358
+        // et si spip_langue est pas encore définie (ce que va faire changer_langue())
359
+        // ou qu'elle n'est pas identique à la langue du site
360
+        and (!isset($GLOBALS['spip_lang'])
361
+            or $GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site'])
362
+    ) {
363
+        return changer_langue($GLOBALS['meta']['langue_site'], $liste_langues);//@:install
364
+    }
365
+    // en theorie là, la globale est définie, sinon c'est un problème.
366
+    if (!isset($GLOBALS['spip_lang'])) {
367
+        spip_log('La globale spip_lang est indéfinie dans utiliser_langue_site() !', _LOG_ERREUR);
368
+    }
369
+
370
+    return $GLOBALS['spip_lang'];
371 371
 }
372 372
 
373 373
 /**
@@ -386,30 +386,30 @@  discard block
 block discarded – undo
386 386
  **/
387 387
 function utiliser_langue_visiteur($liste_langues = null) {
388 388
 
389
-	$l = (!test_espace_prive() ? 'spip_lang' : 'spip_lang_ecrire');
390
-	if (isset($_COOKIE[$l])) {
391
-		if (changer_langue($l = $_COOKIE[$l], $liste_langues)) {
392
-			return $l;
393
-		}
394
-	}
395
-
396
-	if (isset($GLOBALS['visiteur_session']['lang'])) {
397
-		if (changer_langue($l = $GLOBALS['visiteur_session']['lang'], $liste_langues)) {
398
-			return $l;
399
-		}
400
-	}
401
-
402
-	if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
403
-		foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $s) {
404
-			if (preg_match('#^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$#i', trim($s), $r)) {
405
-				if (changer_langue($l = strtolower($r[1]), $liste_langues)) {
406
-					return $l;
407
-				}
408
-			}
409
-		}
410
-	}
411
-
412
-	return utiliser_langue_site($liste_langues);
389
+    $l = (!test_espace_prive() ? 'spip_lang' : 'spip_lang_ecrire');
390
+    if (isset($_COOKIE[$l])) {
391
+        if (changer_langue($l = $_COOKIE[$l], $liste_langues)) {
392
+            return $l;
393
+        }
394
+    }
395
+
396
+    if (isset($GLOBALS['visiteur_session']['lang'])) {
397
+        if (changer_langue($l = $GLOBALS['visiteur_session']['lang'], $liste_langues)) {
398
+            return $l;
399
+        }
400
+    }
401
+
402
+    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
403
+        foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $s) {
404
+            if (preg_match('#^([a-z]{2,3})(-[a-z]{2,3})?(;q=[0-9.]+)?$#i', trim($s), $r)) {
405
+                if (changer_langue($l = strtolower($r[1]), $liste_langues)) {
406
+                    return $l;
407
+                }
408
+            }
409
+        }
410
+    }
411
+
412
+    return utiliser_langue_site($liste_langues);
413 413
 }
414 414
 
415 415
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
  * @return int
420 420
  */
421 421
 function match_langue($chaine) {
422
-	return preg_match('/^[a-z]{2,3}(_[a-z]{2,3}){0,2}$/', $chaine);
422
+    return preg_match('/^[a-z]{2,3}(_[a-z]{2,3}){0,2}$/', $chaine);
423 423
 }
424 424
 
425 425
 /**
@@ -437,36 +437,36 @@  discard block
 block discarded – undo
437 437
  **/
438 438
 function init_langues() {
439 439
 
440
-	// liste des langues dans les meta, sauf a l'install
441
-	$all_langs = @$GLOBALS['meta']['langues_proposees'];
442
-
443
-	$tout = [];
444
-	if (!$all_langs) {
445
-		// trouver tous les modules lang/spip_xx.php
446
-		$modules = find_all_in_path('lang/', '/spip_([a-z_]+)\.php$');
447
-		foreach ($modules as $name => $path) {
448
-			if (preg_match(',^spip_([a-z_]+)\.php$,', $name, $regs)) {
449
-				if (match_langue($regs[1])) {
450
-					$tout[] = $regs[1];
451
-				}
452
-			}
453
-		}
454
-		sort($tout);
455
-		$tout = join(',', $tout);
456
-		// Si les langues n'ont pas change, ne rien faire
457
-		if ($tout != $all_langs) {
458
-			$GLOBALS['meta']['langues_proposees'] = $tout;
459
-			include_spip('inc/meta');
460
-			ecrire_meta('langues_proposees', $tout);
461
-		}
462
-	}
463
-	if (!isset($GLOBALS['meta']['langue_site'])) {
464
-		// Initialisation : le francais si dispo, sinon la premiere langue trouvee
465
-		$GLOBALS['meta']['langue_site'] = $tout =
466
-			(!$all_langs or (strpos(',' . _LANGUE_PAR_DEFAUT . ',', ",$all_langs,") !== false))
467
-				? _LANGUE_PAR_DEFAUT : substr($all_langs, 0, strpos($all_langs, ','));
468
-		ecrire_meta('langue_site', $tout);
469
-	}
440
+    // liste des langues dans les meta, sauf a l'install
441
+    $all_langs = @$GLOBALS['meta']['langues_proposees'];
442
+
443
+    $tout = [];
444
+    if (!$all_langs) {
445
+        // trouver tous les modules lang/spip_xx.php
446
+        $modules = find_all_in_path('lang/', '/spip_([a-z_]+)\.php$');
447
+        foreach ($modules as $name => $path) {
448
+            if (preg_match(',^spip_([a-z_]+)\.php$,', $name, $regs)) {
449
+                if (match_langue($regs[1])) {
450
+                    $tout[] = $regs[1];
451
+                }
452
+            }
453
+        }
454
+        sort($tout);
455
+        $tout = join(',', $tout);
456
+        // Si les langues n'ont pas change, ne rien faire
457
+        if ($tout != $all_langs) {
458
+            $GLOBALS['meta']['langues_proposees'] = $tout;
459
+            include_spip('inc/meta');
460
+            ecrire_meta('langues_proposees', $tout);
461
+        }
462
+    }
463
+    if (!isset($GLOBALS['meta']['langue_site'])) {
464
+        // Initialisation : le francais si dispo, sinon la premiere langue trouvee
465
+        $GLOBALS['meta']['langue_site'] = $tout =
466
+            (!$all_langs or (strpos(',' . _LANGUE_PAR_DEFAUT . ',', ",$all_langs,") !== false))
467
+                ? _LANGUE_PAR_DEFAUT : substr($all_langs, 0, strpos($all_langs, ','));
468
+        ecrire_meta('langue_site', $tout);
469
+    }
470 470
 }
471 471
 
472 472
 /**
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
  *     Code html de la balise <html>
481 481
  **/
482 482
 function html_lang_attributes() {
483
-	$lang = $GLOBALS['spip_lang'];
484
-	$dir = ($GLOBALS['spip_lang_rtl'] ? 'rtl' : 'ltr');
483
+    $lang = $GLOBALS['spip_lang'];
484
+    $dir = ($GLOBALS['spip_lang_rtl'] ? 'rtl' : 'ltr');
485 485
 
486
-	return "<html class='$dir $lang no-js' xmlns='http://www.w3.org/1999/xhtml' lang='$lang' dir='$dir'>\n";
486
+    return "<html class='$dir $lang no-js' xmlns='http://www.w3.org/1999/xhtml' lang='$lang' dir='$dir'>\n";
487 487
 }
488 488
 
489 489
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
  * @return string
498 498
  */
499 499
 function aide_lang_dir($spip_lang, $spip_lang_rtl) {
500
-	return ($spip_lang <> 'he') ? $spip_lang_rtl : '';
500
+    return ($spip_lang <> 'he') ? $spip_lang_rtl : '';
501 501
 }
502 502
 
503 503
 
Please login to merge, or discard this patch.
ecrire/inc/pipelines_ecrire.php 1 patch
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Pipelines
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -36,37 +36,37 @@  discard block
 block discarded – undo
36 36
  * @return string          Contenu complété des scripts javascripts, dont jQuery
37 37
  **/
38 38
 function f_jQuery_prive($texte) {
39
-	$x = '';
40
-	$jquery_plugins = pipeline(
41
-		'jquery_plugins',
42
-		[
43
-			'prive/javascript/jquery.js',
44
-			'prive/javascript/jquery.form.js',
45
-			'prive/javascript/jquery.autosave.js',
46
-			'prive/javascript/jquery.placeholder-label.js',
47
-			'prive/javascript/ajaxCallback.js',
48
-			'prive/javascript/js.cookie.js',
49
-			'prive/javascript/jquery.cookie.js',
50
-			'prive/javascript/spip_barre.js',
51
-		]
52
-	);
53
-	foreach (array_unique($jquery_plugins) as $script) {
54
-		if ($script = find_in_path(supprimer_timestamp($script))) {
55
-			$script = timestamp($script);
56
-			$x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
57
-		}
58
-	}
59
-	// inserer avant le premier script externe ou a la fin
60
-	if (
61
-		preg_match(',<script[^><]*src=,', $texte, $match)
62
-		and $p = strpos($texte, $match[0])
63
-	) {
64
-		$texte = substr_replace($texte, $x, $p, 0);
65
-	} else {
66
-		$texte .= $x;
67
-	}
39
+    $x = '';
40
+    $jquery_plugins = pipeline(
41
+        'jquery_plugins',
42
+        [
43
+            'prive/javascript/jquery.js',
44
+            'prive/javascript/jquery.form.js',
45
+            'prive/javascript/jquery.autosave.js',
46
+            'prive/javascript/jquery.placeholder-label.js',
47
+            'prive/javascript/ajaxCallback.js',
48
+            'prive/javascript/js.cookie.js',
49
+            'prive/javascript/jquery.cookie.js',
50
+            'prive/javascript/spip_barre.js',
51
+        ]
52
+    );
53
+    foreach (array_unique($jquery_plugins) as $script) {
54
+        if ($script = find_in_path(supprimer_timestamp($script))) {
55
+            $script = timestamp($script);
56
+            $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
57
+        }
58
+    }
59
+    // inserer avant le premier script externe ou a la fin
60
+    if (
61
+        preg_match(',<script[^><]*src=,', $texte, $match)
62
+        and $p = strpos($texte, $match[0])
63
+    ) {
64
+        $texte = substr_replace($texte, $x, $p, 0);
65
+    } else {
66
+        $texte .= $x;
67
+    }
68 68
 
69
-	return $texte;
69
+    return $texte;
70 70
 }
71 71
 
72 72
 
@@ -79,43 +79,43 @@  discard block
 block discarded – undo
79 79
  * @return string
80 80
  */
81 81
 function affichage_final_prive_title_auto($texte) {
82
-	if (
83
-		strpos($texte, '<title>') === false
84
-		and
85
-		(preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match)
86
-			or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match))
87
-		and $match = textebrut(trim($match[1]))
88
-		and ($p = strpos($texte, '<head>')) !== false
89
-	) {
90
-		if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
91
-			$nom_site_spip = _T('info_mon_site_spip');
92
-		}
82
+    if (
83
+        strpos($texte, '<title>') === false
84
+        and
85
+        (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match)
86
+            or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match))
87
+        and $match = textebrut(trim($match[1]))
88
+        and ($p = strpos($texte, '<head>')) !== false
89
+    ) {
90
+        if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
91
+            $nom_site_spip = _T('info_mon_site_spip');
92
+        }
93 93
 
94
-		$titre = '<title>['
95
-			. $nom_site_spip
96
-			. '] ' . $match
97
-			. '</title>';
94
+        $titre = '<title>['
95
+            . $nom_site_spip
96
+            . '] ' . $match
97
+            . '</title>';
98 98
 
99
-		$texte = substr_replace($texte, $titre, $p + 6, 0);
100
-	}
99
+        $texte = substr_replace($texte, $titre, $p + 6, 0);
100
+    }
101 101
 
102
-	return $texte;
102
+    return $texte;
103 103
 }
104 104
 
105 105
 
106 106
 // Fonction standard pour le pipeline 'boite_infos'
107 107
 // https://code.spip.net/@f_boite_infos
108 108
 function f_boite_infos($flux) {
109
-	$args = $flux['args'];
110
-	$type = $args['type'];
111
-	unset($args['row']);
112
-	if (!trouver_fond($type, 'prive/objets/infos/')) {
113
-		$type = 'objet';
114
-	}
115
-	$args['espace_prive'] = 1;
116
-	$flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args);
109
+    $args = $flux['args'];
110
+    $type = $args['type'];
111
+    unset($args['row']);
112
+    if (!trouver_fond($type, 'prive/objets/infos/')) {
113
+        $type = 'objet';
114
+    }
115
+    $args['espace_prive'] = 1;
116
+    $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args);
117 117
 
118
-	return $flux;
118
+    return $flux;
119 119
 }
120 120
 
121 121
 
@@ -134,97 +134,97 @@  discard block
 block discarded – undo
134 134
  * @return array Données du pipeline
135 135
  */
136 136
 function f_afficher_blocs_ecrire($flux) {
137
-	static $o = [];
138
-	if (is_string($fond = $flux['args']['fond'])) {
139
-		$exec = isset($flux['args']['contexte']['exec']) ? $flux['args']['contexte']['exec'] : _request('exec');
140
-		if (!isset($o[$exec])) {
141
-			$o[$exec] = trouver_objet_exec($exec);
142
-		}
143
-		// cas particulier
144
-		if ($exec == 'infos_perso') {
145
-			$flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'];
146
-		}
147
-		$typepage = (isset($flux['args']['contexte']['type-page']) ? $flux['args']['contexte']['type-page'] : $exec);
148
-		if ($fond == "prive/squelettes/navigation/$typepage") {
149
-			$flux['data']['texte'] = pipeline(
150
-				'affiche_gauche',
151
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
152
-			);
153
-		} elseif ($fond == "prive/squelettes/extra/$typepage") {
154
-			include_spip('inc/presentation_mini');
155
-			$flux['data']['texte'] = pipeline(
156
-				'affiche_droite',
157
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
158
-			) . liste_objets_bloques(
159
-				$exec,
160
-				$flux['args']['contexte']
161
-			);
162
-		} elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) {
163
-			// id non defini sur les formulaire de nouveaux objets
164
-			$id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0;
165
-			$flux['data']['texte'] = pipeline(
166
-				'affiche_hierarchie',
167
-				['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']]
168
-			);
169
-		} elseif ($fond == "prive/squelettes/contenu/$typepage") {
170
-			// Préparation du marqueur affiche_milieu
171
-			// Si c'est la page d'un objet pas en édition, on l'encapsule dans un div
172
-			$est_page_objet = !empty($o[$exec]['type']);
173
-			$est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true);
174
-			$encapsuler_milieu = ($est_page_objet and !$est_en_edition);
175
-			$flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur(
176
-				$flux['data']['texte'],
177
-				'<!--affiche_milieu-->',
178
-				'<div id=["\']wysiwyg',
179
-				$encapsuler_milieu ? '<div class="affiche_milieu">' : '',
180
-				$encapsuler_milieu ? '</div>' : ''
181
-			);
182
-			if (
183
-				$o[$exec]
184
-				and $objet = $o[$exec]['type']
185
-				and $o[$exec]['edition'] == false
186
-				and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']])
187
-				and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])
188
-			) {
189
-				// inserer le formulaire de traduction
190
-				$flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond(
191
-					'prive/objets/editer/traductions',
192
-					['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1]
193
-				) . '<!--affiche_milieu-->', $flux['data']['texte']);
194
-				$flux['data']['texte'] = pipeline('afficher_fiche_objet', [
195
-					'args' => [
196
-						'contexte' => $flux['args']['contexte'],
197
-						'type' => $objet,
198
-						'id' => $id
199
-					],
200
-					'data' => $flux['data']['texte']
201
-				]);
202
-			}
203
-			$flux['data']['texte'] = pipeline(
204
-				'affiche_milieu',
205
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
206
-			);
207
-		} elseif ($fond == 'prive/squelettes/inclure/pied') {
208
-			$flux['data']['texte'] = pipeline(
209
-				'affiche_pied',
210
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
211
-			);
212
-		} elseif (
213
-			strncmp($fond, 'prive/objets/contenu/', 21) == 0
214
-			and $objet = basename($fond)
215
-			and $objet == substr($fond, 21)
216
-			and isset($o[$objet])
217
-			and $o[$objet]
218
-		) {
219
-			$id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]);
220
-			$flux['data']['texte'] = pipeline('afficher_contenu_objet', [
221
-				'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']],
222
-				'data' => $flux['data']['texte']
223
-			]);
224
-		}
225
-	}
137
+    static $o = [];
138
+    if (is_string($fond = $flux['args']['fond'])) {
139
+        $exec = isset($flux['args']['contexte']['exec']) ? $flux['args']['contexte']['exec'] : _request('exec');
140
+        if (!isset($o[$exec])) {
141
+            $o[$exec] = trouver_objet_exec($exec);
142
+        }
143
+        // cas particulier
144
+        if ($exec == 'infos_perso') {
145
+            $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'];
146
+        }
147
+        $typepage = (isset($flux['args']['contexte']['type-page']) ? $flux['args']['contexte']['type-page'] : $exec);
148
+        if ($fond == "prive/squelettes/navigation/$typepage") {
149
+            $flux['data']['texte'] = pipeline(
150
+                'affiche_gauche',
151
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
152
+            );
153
+        } elseif ($fond == "prive/squelettes/extra/$typepage") {
154
+            include_spip('inc/presentation_mini');
155
+            $flux['data']['texte'] = pipeline(
156
+                'affiche_droite',
157
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
158
+            ) . liste_objets_bloques(
159
+                $exec,
160
+                $flux['args']['contexte']
161
+            );
162
+        } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) {
163
+            // id non defini sur les formulaire de nouveaux objets
164
+            $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0;
165
+            $flux['data']['texte'] = pipeline(
166
+                'affiche_hierarchie',
167
+                ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']]
168
+            );
169
+        } elseif ($fond == "prive/squelettes/contenu/$typepage") {
170
+            // Préparation du marqueur affiche_milieu
171
+            // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div
172
+            $est_page_objet = !empty($o[$exec]['type']);
173
+            $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true);
174
+            $encapsuler_milieu = ($est_page_objet and !$est_en_edition);
175
+            $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur(
176
+                $flux['data']['texte'],
177
+                '<!--affiche_milieu-->',
178
+                '<div id=["\']wysiwyg',
179
+                $encapsuler_milieu ? '<div class="affiche_milieu">' : '',
180
+                $encapsuler_milieu ? '</div>' : ''
181
+            );
182
+            if (
183
+                $o[$exec]
184
+                and $objet = $o[$exec]['type']
185
+                and $o[$exec]['edition'] == false
186
+                and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']])
187
+                and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])
188
+            ) {
189
+                // inserer le formulaire de traduction
190
+                $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond(
191
+                    'prive/objets/editer/traductions',
192
+                    ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1]
193
+                ) . '<!--affiche_milieu-->', $flux['data']['texte']);
194
+                $flux['data']['texte'] = pipeline('afficher_fiche_objet', [
195
+                    'args' => [
196
+                        'contexte' => $flux['args']['contexte'],
197
+                        'type' => $objet,
198
+                        'id' => $id
199
+                    ],
200
+                    'data' => $flux['data']['texte']
201
+                ]);
202
+            }
203
+            $flux['data']['texte'] = pipeline(
204
+                'affiche_milieu',
205
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
206
+            );
207
+        } elseif ($fond == 'prive/squelettes/inclure/pied') {
208
+            $flux['data']['texte'] = pipeline(
209
+                'affiche_pied',
210
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
211
+            );
212
+        } elseif (
213
+            strncmp($fond, 'prive/objets/contenu/', 21) == 0
214
+            and $objet = basename($fond)
215
+            and $objet == substr($fond, 21)
216
+            and isset($o[$objet])
217
+            and $o[$objet]
218
+        ) {
219
+            $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]);
220
+            $flux['data']['texte'] = pipeline('afficher_contenu_objet', [
221
+                'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']],
222
+                'data' => $flux['data']['texte']
223
+            ]);
224
+        }
225
+    }
226 226
 
227
-	return $flux;
227
+    return $flux;
228 228
 }
229 229
 
230 230
 /**
@@ -252,36 +252,36 @@  discard block
 block discarded – undo
252 252
  */
253 253
 function afficher_blocs_ecrire_preparer_marqueur(?string $texte, string $marqueur, string $inserer_avant, string $ouvrir = '', string $fermer = ''): ?string {
254 254
 
255
-	if ($texte) {
256
-		$encapsuler = (($ouvrir and $fermer) ? true : false);
257
-		$marqueur_pos = strpos($texte, $marqueur);
258
-		$full_marqueur = "$ouvrir$marqueur$fermer";
255
+    if ($texte) {
256
+        $encapsuler = (($ouvrir and $fermer) ? true : false);
257
+        $marqueur_pos = strpos($texte, $marqueur);
258
+        $full_marqueur = "$ouvrir$marqueur$fermer";
259 259
 
260
-		// Le marqueur est absent : on l'ajoute avant l'élément indiqué
261
-		if ($marqueur_pos  === false) {
262
-			$texte = preg_replace(
263
-				",$inserer_avant,",
264
-				"$full_marqueur\\0",
265
-				$texte
266
-			);
267
-		// Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes.
268
-		// Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante.
269
-		// Il ne faut donc aucun espace blanc en trop.
270
-		} elseif (
271
-			$marqueur_pos !== false
272
-			and $encapsuler
273
-			and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir
274
-		) {
275
-			$texte = substr_replace(
276
-				$texte,
277
-				$full_marqueur,
278
-				$marqueur_pos,
279
-				strlen($marqueur)
280
-			);
281
-		}
282
-	}
260
+        // Le marqueur est absent : on l'ajoute avant l'élément indiqué
261
+        if ($marqueur_pos  === false) {
262
+            $texte = preg_replace(
263
+                ",$inserer_avant,",
264
+                "$full_marqueur\\0",
265
+                $texte
266
+            );
267
+        // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes.
268
+        // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante.
269
+        // Il ne faut donc aucun espace blanc en trop.
270
+        } elseif (
271
+            $marqueur_pos !== false
272
+            and $encapsuler
273
+            and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir
274
+        ) {
275
+            $texte = substr_replace(
276
+                $texte,
277
+                $full_marqueur,
278
+                $marqueur_pos,
279
+                strlen($marqueur)
280
+            );
281
+        }
282
+    }
283 283
 
284
-	return $texte;
284
+    return $texte;
285 285
 }
286 286
 
287 287
 /**
@@ -292,23 +292,23 @@  discard block
 block discarded – undo
292 292
  * @return string
293 293
  */
294 294
 function f_queue_affiche_milieu($flux) {
295
-	$args = $flux['args'];
296
-	$res = '';
297
-	foreach ($args as $key => $arg) {
298
-		if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) {
299
-			$objet = preg_replace(',^id_,', '', $key);
300
-			$res .= recuperer_fond(
301
-				'modeles/object_jobs_list',
302
-				['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1],
303
-				['ajax' => true]
304
-			);
305
-		}
306
-	}
307
-	if ($res) {
308
-		$flux['data'] = $res . $flux['data'];
309
-	}
295
+    $args = $flux['args'];
296
+    $res = '';
297
+    foreach ($args as $key => $arg) {
298
+        if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) {
299
+            $objet = preg_replace(',^id_,', '', $key);
300
+            $res .= recuperer_fond(
301
+                'modeles/object_jobs_list',
302
+                ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1],
303
+                ['ajax' => true]
304
+            );
305
+        }
306
+    }
307
+    if ($res) {
308
+        $flux['data'] = $res . $flux['data'];
309
+    }
310 310
 
311
-	return $flux;
311
+    return $flux;
312 312
 }
313 313
 
314 314
 /**
@@ -322,39 +322,39 @@  discard block
 block discarded – undo
322 322
  * @return array|bool
323 323
  */
324 324
 function trouver_objet_exec($exec) {
325
-	static $objet_exec = [];
326
-	if (!$exec) {
327
-		return false;
328
-	}
329
-	// cas particulier
330
-	if ($exec == 'infos_perso') {
331
-		$exec = 'auteur';
332
-		set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']);
333
-	}
334
-	if (!isset($objet_exec[$exec])) {
335
-		$objet_exec[$exec] = false;
336
-		$infos = lister_tables_objets_sql();
337
-		foreach ($infos as $t => $info) {
338
-			if ($exec == $info['url_edit'] and $info['editable']) {
339
-				return $objet_exec[$exec] = [
340
-					'edition' => $exec == $info['url_voir'] ? '' : true,
341
-					'table_objet_sql' => $t,
342
-					'table' => $info['table_objet'],
343
-					'type' => $info['type'],
344
-					'id_table_objet' => id_table_objet($info['type'])
345
-				];
346
-			}
347
-			if ($exec == $info['url_voir']) {
348
-				return $objet_exec[$exec] = [
349
-					'edition' => false,
350
-					'table_objet_sql' => $t,
351
-					'table' => $info['table_objet'],
352
-					'type' => $info['type'],
353
-					'id_table_objet' => id_table_objet($info['type'])
354
-				];
355
-			}
356
-		}
357
-	}
325
+    static $objet_exec = [];
326
+    if (!$exec) {
327
+        return false;
328
+    }
329
+    // cas particulier
330
+    if ($exec == 'infos_perso') {
331
+        $exec = 'auteur';
332
+        set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']);
333
+    }
334
+    if (!isset($objet_exec[$exec])) {
335
+        $objet_exec[$exec] = false;
336
+        $infos = lister_tables_objets_sql();
337
+        foreach ($infos as $t => $info) {
338
+            if ($exec == $info['url_edit'] and $info['editable']) {
339
+                return $objet_exec[$exec] = [
340
+                    'edition' => $exec == $info['url_voir'] ? '' : true,
341
+                    'table_objet_sql' => $t,
342
+                    'table' => $info['table_objet'],
343
+                    'type' => $info['type'],
344
+                    'id_table_objet' => id_table_objet($info['type'])
345
+                ];
346
+            }
347
+            if ($exec == $info['url_voir']) {
348
+                return $objet_exec[$exec] = [
349
+                    'edition' => false,
350
+                    'table_objet_sql' => $t,
351
+                    'table' => $info['table_objet'],
352
+                    'type' => $info['type'],
353
+                    'id_table_objet' => id_table_objet($info['type'])
354
+                ];
355
+            }
356
+        }
357
+    }
358 358
 
359
-	return $objet_exec[$exec];
359
+    return $objet_exec[$exec];
360 360
 }
Please login to merge, or discard this patch.
ecrire/inc/informer.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -11,74 +11,74 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 # Les information d'une rubrique selectionnee dans le mini navigateur
18 18
 
19 19
 // https://code.spip.net/@inc_informer_dist
20 20
 function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff') {
21
-	include_spip('inc/texte');
22
-	$titre = $descriptif = '';
23
-	if ($type == 'rubrique') {
24
-		$row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id));
25
-		if ($row) {
26
-			$titre = typo($row['titre']);
27
-			$descriptif = propre($row['descriptif']);
28
-		} else {
29
-			$titre = _T('info_racine_site');
30
-		}
31
-	}
21
+    include_spip('inc/texte');
22
+    $titre = $descriptif = '';
23
+    if ($type == 'rubrique') {
24
+        $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . intval($id));
25
+        if ($row) {
26
+            $titre = typo($row['titre']);
27
+            $descriptif = propre($row['descriptif']);
28
+        } else {
29
+            $titre = _T('info_racine_site');
30
+        }
31
+    }
32 32
 
33
-	$res = '';
34
-	if ($type == 'rubrique' and $GLOBALS['spip_display'] != 1 and isset($GLOBALS['meta']['image_process'])) {
35
-		if ($GLOBALS['meta']['image_process'] != 'non') {
36
-			$chercher_logo = charger_fonction('chercher_logo', 'inc');
37
-			if ($res = $chercher_logo($id, 'id_rubrique', 'on')) {
38
-				list($fid, $dir, $nom, $format) = $res;
39
-				include_spip('inc/filtres_images_mini');
40
-				$res = image_reduire("<img src='$fid' alt='' />", 100, 48);
41
-				if ($res) {
42
-					$res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>";
43
-				}
44
-			}
45
-		}
46
-	}
33
+    $res = '';
34
+    if ($type == 'rubrique' and $GLOBALS['spip_display'] != 1 and isset($GLOBALS['meta']['image_process'])) {
35
+        if ($GLOBALS['meta']['image_process'] != 'non') {
36
+            $chercher_logo = charger_fonction('chercher_logo', 'inc');
37
+            if ($res = $chercher_logo($id, 'id_rubrique', 'on')) {
38
+                list($fid, $dir, $nom, $format) = $res;
39
+                include_spip('inc/filtres_images_mini');
40
+                $res = image_reduire("<img src='$fid' alt='' />", 100, 48);
41
+                if ($res) {
42
+                    $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>";
43
+                }
44
+            }
45
+        }
46
+    }
47 47
 
48
-	$rac = spip_htmlentities($rac, ENT_QUOTES);
49
-	$do = spip_htmlentities($do, ENT_QUOTES);
50
-	$id = intval($id);
48
+    $rac = spip_htmlentities($rac, ENT_QUOTES);
49
+    $do = spip_htmlentities($do, ENT_QUOTES);
50
+    $id = intval($id);
51 51
 
52 52
 # ce lien provoque la selection (directe) de la rubrique cliquee
53 53
 # et l'affichage de son titre dans le bandeau
54
-	$titre = strtr(
55
-		str_replace(
56
-			"'",
57
-			'&#8217;',
58
-			str_replace('"', '&#34;', textebrut($titre))
59
-		),
60
-		"\n\r",
61
-		'  '
62
-	);
54
+    $titre = strtr(
55
+        str_replace(
56
+            "'",
57
+            '&#8217;',
58
+            str_replace('"', '&#34;', textebrut($titre))
59
+        ),
60
+        "\n\r",
61
+        '  '
62
+    );
63 63
 
64
-	$js_func = $do . '_selection_titre';
64
+    $js_func = $do . '_selection_titre';
65 65
 
66
-	return "<div style='display: none;'>"
67
-	. "<input type='text' id='" . $rac . "_sel' value='$id' />"
68
-	. "<input type='text' id='" . $rac . "_sel2' value=\""
69
-	. entites_html($titre)
70
-	. '" />'
71
-	. '</div>'
72
-	. "<div class='informer' style='padding: 5px; border-top: 0px;'>"
73
-	. '<div class="informer__item">'
74
-	. (!$res ? '' : $res)
75
-	. "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>'
76
-	. (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>')
77
-	. '</div>'
78
-	. "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
79
-	. "<input type='submit' class='fondo btn submit' value='"
80
-	. _T('bouton_choisir')
81
-	. "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />"
82
-	. '</div>'
83
-	. '</div>';
66
+    return "<div style='display: none;'>"
67
+    . "<input type='text' id='" . $rac . "_sel' value='$id' />"
68
+    . "<input type='text' id='" . $rac . "_sel2' value=\""
69
+    . entites_html($titre)
70
+    . '" />'
71
+    . '</div>'
72
+    . "<div class='informer' style='padding: 5px; border-top: 0px;'>"
73
+    . '<div class="informer__item">'
74
+    . (!$res ? '' : $res)
75
+    . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>'
76
+    . (!$descriptif ? '' : "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>')
77
+    . '</div>'
78
+    . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
79
+    . "<input type='submit' class='fondo btn submit' value='"
80
+    . _T('bouton_choisir')
81
+    . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />"
82
+    . '</div>'
83
+    . '</div>';
84 84
 }
Please login to merge, or discard this patch.
ecrire/inc/admin.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -45,29 +45,29 @@  discard block
 block discarded – undo
45 45
  *     sinon code HTML de la page après le traitement effectué.
46 46
  **/
47 47
 function inc_admin_dist($script, $titre, $comment = '', $anonymous = false) {
48
-	$reprise = true;
49
-	if (
50
-		!isset($GLOBALS['meta'][$script])
51
-		or !isset($GLOBALS['meta']['admin'])
52
-	) {
53
-		$reprise = false;
54
-		$res = debut_admin($script, $titre, $comment);
55
-		if ($res) {
56
-			return $res;
57
-		}
58
-		spip_log("meta: $script " . print_r($_POST, true));
59
-		ecrire_meta($script, serialize($_POST));
60
-	}
48
+    $reprise = true;
49
+    if (
50
+        !isset($GLOBALS['meta'][$script])
51
+        or !isset($GLOBALS['meta']['admin'])
52
+    ) {
53
+        $reprise = false;
54
+        $res = debut_admin($script, $titre, $comment);
55
+        if ($res) {
56
+            return $res;
57
+        }
58
+        spip_log("meta: $script " . print_r($_POST, true));
59
+        ecrire_meta($script, serialize($_POST));
60
+    }
61 61
 
62
-	$res = admin_verifie_session($script, $anonymous);
63
-	if ($res) {
64
-		return $res;
65
-	}
66
-	$base = charger_fonction($script, 'base');
67
-	$base($titre, $reprise);
68
-	fin_admin($script);
62
+    $res = admin_verifie_session($script, $anonymous);
63
+    if ($res) {
64
+        return $res;
65
+    }
66
+    $base = charger_fonction($script, 'base');
67
+    $base($titre, $reprise);
68
+    fin_admin($script);
69 69
 
70
-	return '';
70
+    return '';
71 71
 }
72 72
 
73 73
 /**
@@ -98,35 +98,35 @@  discard block
 block discarded – undo
98 98
  *     Code HTML si message d'erreur, '' sinon;
99 99
  */
100 100
 function admin_verifie_session($script, $anonymous = false) {
101
-	include_spip('base/abstract_sql');
102
-	$pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']);
103
-	$signal = fichier_admin($script, "$script$pref");
104
-	$valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
105
-	if ($valeur === null) {
106
-		ecrire_meta('admin', $signal, 'non');
107
-	} else {
108
-		if (!$anonymous and ($valeur != $signal)) {
109
-			if (
110
-				!preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)
111
-				or intval($l[2]) != $GLOBALS['visiteur_session']['id_auteur']
112
-			) {
113
-				include_spip('inc/minipres');
114
-				spip_log("refus de lancer $script, priorite a $valeur");
101
+    include_spip('base/abstract_sql');
102
+    $pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']);
103
+    $signal = fichier_admin($script, "$script$pref");
104
+    $valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
105
+    if ($valeur === null) {
106
+        ecrire_meta('admin', $signal, 'non');
107
+    } else {
108
+        if (!$anonymous and ($valeur != $signal)) {
109
+            if (
110
+                !preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)
111
+                or intval($l[2]) != $GLOBALS['visiteur_session']['id_auteur']
112
+            ) {
113
+                include_spip('inc/minipres');
114
+                spip_log("refus de lancer $script, priorite a $valeur");
115 115
 
116
-				return minipres(_T('info_travaux_texte'), '', ['status' => 503]);
117
-			}
118
-		}
119
-	}
120
-	$journal = 'spip';
121
-	if (autoriser('configurer')) {
122
-		// c'est une action webmestre, soit par ftp soit par statut webmestre
123
-		$journal = 'webmestre';
124
-	}
125
-	// on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
116
+                return minipres(_T('info_travaux_texte'), '', ['status' => 503]);
117
+            }
118
+        }
119
+    }
120
+    $journal = 'spip';
121
+    if (autoriser('configurer')) {
122
+        // c'est une action webmestre, soit par ftp soit par statut webmestre
123
+        $journal = 'webmestre';
124
+    }
125
+    // on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
126 126
 
127
-	spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal);
127
+    spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal);
128 128
 
129
-	return '';
129
+    return '';
130 130
 }
131 131
 
132 132
 /**
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
  *     Chemin du répertoire.
140 140
  **/
141 141
 function dir_admin() {
142
-	if (autoriser('configurer')) {
143
-		return _DIR_TMP;
144
-	} else {
145
-		return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
146
-	}
142
+    if (autoriser('configurer')) {
143
+        return _DIR_TMP;
144
+    } else {
145
+        return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
146
+    }
147 147
 }
148 148
 
149 149
 /**
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
  *     Nom du fichier
161 161
  **/
162 162
 function fichier_admin($action, $pref = 'admin_') {
163
-	return $pref .
164
-	substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10);
163
+    return $pref .
164
+    substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10);
165 165
 }
166 166
 
167 167
 /**
@@ -187,73 +187,73 @@  discard block
 block discarded – undo
187 187
  *     sinon chaîne vide si déjà fait.
188 188
  **/
189 189
 function debut_admin($script, $action = '', $corps = '') {
190
-	if ((!$action) || !(autoriser('webmestre') or autoriser('chargerftp'))) {
191
-		include_spip('inc/minipres');
190
+    if ((!$action) || !(autoriser('webmestre') or autoriser('chargerftp'))) {
191
+        include_spip('inc/minipres');
192 192
 
193
-		return minipres();
194
-	} else {
195
-		$dir = dir_admin();
196
-		$signal = fichier_admin($script);
197
-		if (@file_exists($dir . $signal)) {
198
-			spip_log("Action admin: $action");
193
+        return minipres();
194
+    } else {
195
+        $dir = dir_admin();
196
+        $signal = fichier_admin($script);
197
+        if (@file_exists($dir . $signal)) {
198
+            spip_log("Action admin: $action");
199 199
 
200
-			return '';
201
-		}
202
-		include_spip('inc/minipres');
200
+            return '';
201
+        }
202
+        include_spip('inc/minipres');
203 203
 
204
-		// Si on est un super-admin, un bouton de validation suffit
205
-		// sauf dans les cas destroy
206
-		if (
207
-			(autoriser('webmestre') or $script === 'repair')
208
-			and $script != 'delete_all'
209
-		) {
210
-			if (_request('validation_admin') == $signal) {
211
-				spip_log("Action super-admin: $action");
204
+        // Si on est un super-admin, un bouton de validation suffit
205
+        // sauf dans les cas destroy
206
+        if (
207
+            (autoriser('webmestre') or $script === 'repair')
208
+            and $script != 'delete_all'
209
+        ) {
210
+            if (_request('validation_admin') == $signal) {
211
+                spip_log("Action super-admin: $action");
212 212
 
213
-				return '';
214
-			}
215
-			$corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />';
216
-			$suivant = _T('bouton_valider');
217
-			$js = '';
218
-		} else {
219
-			// cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
220
-			// l'insertion du script a cet endroit n'est pas xhtml licite
221
-			// mais evite de l'embarquer dans toutes les pages minipres
222
-			$corps .= http_script('', 'spip_barre.js');
213
+                return '';
214
+            }
215
+            $corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />';
216
+            $suivant = _T('bouton_valider');
217
+            $js = '';
218
+        } else {
219
+            // cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
220
+            // l'insertion du script a cet endroit n'est pas xhtml licite
221
+            // mais evite de l'embarquer dans toutes les pages minipres
222
+            $corps .= http_script('', 'spip_barre.js');
223 223
 
224
-			$corps .= '<fieldset><legend>'
225
-				. _T('info_authentification_ftp')
226
-				. aider('ftp_auth')
227
-				. "</legend>\n<label for='fichier'>"
228
-				. _T('info_creer_repertoire')
229
-				. "</label>\n"
230
-				. "<span id='signal' class='formo'>" . $signal . '</span>'
231
-				. "<input type='hidden' id='fichier' name='fichier' value='"
232
-				. $signal
233
-				. "' />"
234
-				. _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)])
235
-				. '</fieldset>';
224
+            $corps .= '<fieldset><legend>'
225
+                . _T('info_authentification_ftp')
226
+                . aider('ftp_auth')
227
+                . "</legend>\n<label for='fichier'>"
228
+                . _T('info_creer_repertoire')
229
+                . "</label>\n"
230
+                . "<span id='signal' class='formo'>" . $signal . '</span>'
231
+                . "<input type='hidden' id='fichier' name='fichier' value='"
232
+                . $signal
233
+                . "' />"
234
+                . _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)])
235
+                . '</fieldset>';
236 236
 
237
-			$suivant = _T('bouton_recharger_page');
237
+            $suivant = _T('bouton_recharger_page');
238 238
 
239
-			// code volontairement tordu:
240
-			// provoquer la copie dans le presse papier du nom du repertoire
241
-			// en remettant a vide le champ pour que ca marche aussi en cas
242
-			// de JavaScript inactif.
243
-			$js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
244
-		}
239
+            // code volontairement tordu:
240
+            // provoquer la copie dans le presse papier du nom du repertoire
241
+            // en remettant a vide le champ pour que ca marche aussi en cas
242
+            // de JavaScript inactif.
243
+            $js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
244
+        }
245 245
 
246
-		// admin/xxx correspond
247
-		// a exec/base_xxx de preference
248
-		// et exec/xxx sinon (compat)
249
-		if (tester_url_ecrire("base_$script")) {
250
-			$script = "base_$script";
251
-		}
252
-		$form = copy_request($script, $corps, $suivant);
253
-		$info_action = _T('info_action', ['action' => "$action"]);
246
+        // admin/xxx correspond
247
+        // a exec/base_xxx de preference
248
+        // et exec/xxx sinon (compat)
249
+        if (tester_url_ecrire("base_$script")) {
250
+            $script = "base_$script";
251
+        }
252
+        $form = copy_request($script, $corps, $suivant);
253
+        $info_action = _T('info_action', ['action' => "$action"]);
254 254
 
255
-		return minipres($info_action, $form, $js);
256
-	}
255
+        return minipres($info_action, $form, $js);
256
+    }
257 257
 }
258 258
 
259 259
 /**
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
  *     Nom de l'action (en base) qui a été exécutée
265 265
  **/
266 266
 function fin_admin($action) {
267
-	$signal = dir_admin() . fichier_admin($action);
268
-	spip_unlink($signal);
269
-	if ($action != 'delete_all') {
270
-		effacer_meta($action);
271
-		effacer_meta('admin');
272
-		spip_log("efface les meta admin et $action ");
273
-	}
267
+    $signal = dir_admin() . fichier_admin($action);
268
+    spip_unlink($signal);
269
+    if ($action != 'delete_all') {
270
+        effacer_meta($action);
271
+        effacer_meta('admin');
272
+        spip_log("efface les meta admin et $action ");
273
+    }
274 274
 }
275 275
 
276 276
 /**
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
  *     Code HTML du formulaire
290 290
  **/
291 291
 function copy_request($script, $suite, $submit = '') {
292
-	include_spip('inc/filtres');
293
-	foreach (array_merge($_POST, $_GET) as $n => $c) {
294
-		if (!in_array($n, ['fichier', 'exec', 'validation_admin']) and !is_array($c)) {
295
-			$suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" .
296
-				entites_html($c) .
297
-				"'  />";
298
-		}
299
-	}
292
+    include_spip('inc/filtres');
293
+    foreach (array_merge($_POST, $_GET) as $n => $c) {
294
+        if (!in_array($n, ['fichier', 'exec', 'validation_admin']) and !is_array($c)) {
295
+            $suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" .
296
+                entites_html($c) .
297
+                "'  />";
298
+        }
299
+    }
300 300
 
301
-	return generer_form_ecrire($script, $suite, '', $submit);
301
+    return generer_form_ecrire($script, $suite, '', $submit);
302 302
 }
Please login to merge, or discard this patch.
ecrire/inc/journal.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
  * @param array $opt
25 25
  */
26 26
 function inc_journal_dist($phrase, $opt = []) {
27
-	if (!strlen($phrase)) {
28
-		return;
29
-	}
30
-	if ($opt) {
31
-		$phrase .= ' :: ' . str_replace("\n", ' ', join(', ', $opt));
32
-	}
33
-	spip_log($phrase, 'journal');
27
+    if (!strlen($phrase)) {
28
+        return;
29
+    }
30
+    if ($opt) {
31
+        $phrase .= ' :: ' . str_replace("\n", ' ', join(', ', $opt));
32
+    }
33
+    spip_log($phrase, 'journal');
34 34
 }
Please login to merge, or discard this patch.
ecrire/inc/actions.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
44 44
  */
45 45
 function generer_action_auteur($action, $arg = '', $redirect = '', $mode = false, $att = '', $public = false) {
46
-	$securiser_action = charger_fonction('securiser_action', 'inc');
46
+    $securiser_action = charger_fonction('securiser_action', 'inc');
47 47
 
48
-	return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
48
+    return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
49 49
 }
50 50
 
51 51
 /**
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
  *     Code HTML du formulaire
79 79
  */
80 80
 function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) {
81
-	$r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
81
+    $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
82 82
 
83
-	return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
83
+    return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
84 84
 }
85 85
 
86 86
 /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
106 106
  */
107 107
 function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = '') {
108
-	$r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
108
+    $r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
109 109
 
110
-	return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
110
+    return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
111 111
 }
112 112
 
113 113
 
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
  *   passer "text/html" comme $content_type
123 123
  */
124 124
 function ajax_retour($corps, $content_type = null) {
125
-	$xml = false;
126
-	if (is_null($content_type) or $content_type === true) {
127
-		$xml = true;
128
-		$content_type = 'text/html';
129
-	} elseif (!$content_type or !is_string($content_type) or strpos($content_type, '/') === false) {
130
-		$content_type = 'text/html';
131
-	}
125
+    $xml = false;
126
+    if (is_null($content_type) or $content_type === true) {
127
+        $xml = true;
128
+        $content_type = 'text/html';
129
+    } elseif (!$content_type or !is_string($content_type) or strpos($content_type, '/') === false) {
130
+        $content_type = 'text/html';
131
+    }
132 132
 
133
-	$e = '';
134
-	if (
135
-		isset($_COOKIE['spip_admin'])
136
-		and ((_request('var_mode') == 'debug') or !empty($GLOBALS['tableau_des_temps']))
137
-	) {
138
-		$e = erreur_squelette();
139
-	}
133
+    $e = '';
134
+    if (
135
+        isset($_COOKIE['spip_admin'])
136
+        and ((_request('var_mode') == 'debug') or !empty($GLOBALS['tableau_des_temps']))
137
+    ) {
138
+        $e = erreur_squelette();
139
+    }
140 140
 
141
-	$c = $GLOBALS['meta']['charset'];
142
-	header('Content-Type: ' . $content_type . '; charset=' . $c);
143
-	$debut = (($xml and strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
144
-	$fin = '';
141
+    $c = $GLOBALS['meta']['charset'];
142
+    header('Content-Type: ' . $content_type . '; charset=' . $c);
143
+    $debut = (($xml and strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
144
+    $fin = '';
145 145
 
146
-	echo $debut, $corps, $fin, $e;
146
+    echo $debut, $corps, $fin, $e;
147 147
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_alertes.php 1 patch
Indentation   +81 added lines, -81 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
 /**
@@ -43,22 +43,22 @@  discard block
 block discarded – undo
43 43
  *     Pile complétée par le code à générer
44 44
  */
45 45
 function balise_ALERTE_MESSAGE_dist($p) {
46
-	$_texte = interprete_argument_balise(1, $p);
47
-	$_titre = interprete_argument_balise(2, $p);
48
-	$_class = interprete_argument_balise(3, $p);
49
-	$_role  = interprete_argument_balise(4, $p);
50
-	$_id    = interprete_argument_balise(5, $p);
51
-	$_texte = ($_texte ? $_texte     : "''");
52
-	$_titre = ($_titre ? ", $_titre" : ', null');
53
-	$_class = ($_class ? ", $_class" : ', null');
54
-	$_role  = ($_role  ? ", $_role"  : ', null');
55
-	$_id    = ($_id    ? ", $_id"    : ', null');
46
+    $_texte = interprete_argument_balise(1, $p);
47
+    $_titre = interprete_argument_balise(2, $p);
48
+    $_class = interprete_argument_balise(3, $p);
49
+    $_role  = interprete_argument_balise(4, $p);
50
+    $_id    = interprete_argument_balise(5, $p);
51
+    $_texte = ($_texte ? $_texte     : "''");
52
+    $_titre = ($_titre ? ", $_titre" : ', null');
53
+    $_class = ($_class ? ", $_class" : ', null');
54
+    $_role  = ($_role  ? ", $_role"  : ', null');
55
+    $_id    = ($_id    ? ", $_id"    : ', null');
56 56
 
57
-	$f = chercher_filtre('message_alerte');
58
-	$p->code = "$f($_texte$_titre$_class$_role$_id)";
59
-	$p->interdire_scripts = false;
57
+    $f = chercher_filtre('message_alerte');
58
+    $p->code = "$f($_texte$_titre$_class$_role$_id)";
59
+    $p->interdire_scripts = false;
60 60
 
61
-	return $p;
61
+    return $p;
62 62
 }
63 63
 
64 64
 /**
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
  *     Pile complétée par le code à générer
87 87
  */
88 88
 function balise_ALERTE_OUVRIR_dist($p) {
89
-	$_titre = interprete_argument_balise(1, $p);
90
-	$_class = interprete_argument_balise(2, $p);
91
-	$_role  = interprete_argument_balise(3, $p);
92
-	$_id    = interprete_argument_balise(4, $p);
93
-	$_titre = ($_titre ? "$_titre"   : 'null');
94
-	$_class = ($_class ? ", $_class" : ', null');
95
-	$_role  = ($_role  ? ", $_role"  : ', null');
96
-	$_id    = ($_id    ? ", $_id"    : ', null');
89
+    $_titre = interprete_argument_balise(1, $p);
90
+    $_class = interprete_argument_balise(2, $p);
91
+    $_role  = interprete_argument_balise(3, $p);
92
+    $_id    = interprete_argument_balise(4, $p);
93
+    $_titre = ($_titre ? "$_titre"   : 'null');
94
+    $_class = ($_class ? ", $_class" : ', null');
95
+    $_role  = ($_role  ? ", $_role"  : ', null');
96
+    $_id    = ($_id    ? ", $_id"    : ', null');
97 97
 
98
-	$f = chercher_filtre('message_alerte_ouvrir');
99
-	$p->code = "$f($_titre$_class$_role$_id)";
100
-	$p->interdire_scripts = false;
98
+    $f = chercher_filtre('message_alerte_ouvrir');
99
+    $p->code = "$f($_titre$_class$_role$_id)";
100
+    $p->interdire_scripts = false;
101 101
 
102
-	return $p;
102
+    return $p;
103 103
 }
104 104
 
105 105
 /**
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
  *     Pile complétée par le code à générer
122 122
  */
123 123
 function balise_ALERTE_FERMER_dist($p) {
124
-	$f = chercher_filtre('message_alerte_fermer');
125
-	$p->code = "$f()";
126
-	$p->interdire_scripts = false;
124
+    $f = chercher_filtre('message_alerte_fermer');
125
+    $p->code = "$f()";
126
+    $p->interdire_scripts = false;
127 127
 
128
-	return $p;
128
+    return $p;
129 129
 }
130 130
 
131 131
 /**
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
  */
161 161
 function message_alerte(string $texte, ?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string {
162 162
 
163
-	$message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir');
164
-	$message_alerte_fermer = chercher_filtre('message_alerte_fermer');
165
-	$message =
166
-		$message_alerte_ouvrir($titre, $class, $role, $id) .
167
-		$texte .
168
-		$message_alerte_fermer();
163
+    $message_alerte_ouvrir = chercher_filtre('message_alerte_ouvrir');
164
+    $message_alerte_fermer = chercher_filtre('message_alerte_fermer');
165
+    $message =
166
+        $message_alerte_ouvrir($titre, $class, $role, $id) .
167
+        $texte .
168
+        $message_alerte_fermer();
169 169
 
170
-	return $message;
170
+    return $message;
171 171
 }
172 172
 
173 173
 /**
@@ -198,55 +198,55 @@  discard block
 block discarded – undo
198 198
  */
199 199
 function message_alerte_ouvrir(?string $titre = null, ?string $class = null, ?string $role = null, ?string $id = null): string {
200 200
 
201
-	$prive = test_espace_prive();
201
+    $prive = test_espace_prive();
202 202
 
203
-	// Valeurs par défaut
204
-	$role = $role ?? 'alert'; // fallback uniquement si null
205
-	$class = $class ?? 'notice'; // fallback uniquement si null
203
+    // Valeurs par défaut
204
+    $role = $role ?? 'alert'; // fallback uniquement si null
205
+    $class = $class ?? 'notice'; // fallback uniquement si null
206 206
 
207
-	// Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter
208
-	$types = [
209
-		'notice',
210
-		'error',
211
-		'success',
212
-		'info',
213
-	];
214
-	$type  = array_intersect(explode(' ', $class), $types);
215
-	$type  = reset($type);
216
-	$class = trim(str_replace($types, '', $class) . " $type");
207
+    // Type d'alerte : le chercher dans les classes, nettoyer celles-ci, puis le réinjecter
208
+    $types = [
209
+        'notice',
210
+        'error',
211
+        'success',
212
+        'info',
213
+    ];
214
+    $type  = array_intersect(explode(' ', $class), $types);
215
+    $type  = reset($type);
216
+    $class = trim(str_replace($types, '', $class) . " $type");
217 217
 
218
-	// Classes
219
-	$class_racine = 'msg-alert';
220
-	$clearfix     = ($prive ? 'clearfix' : '');
221
-	$class_alerte = "$class_racine $class";
222
-	$class_texte  = "${class_racine}__text $clearfix";
223
-	$class_titre  = "${class_racine}__heading";
218
+    // Classes
219
+    $class_racine = 'msg-alert';
220
+    $clearfix     = ($prive ? 'clearfix' : '');
221
+    $class_alerte = "$class_racine $class";
222
+    $class_texte  = "${class_racine}__text $clearfix";
223
+    $class_titre  = "${class_racine}__heading";
224 224
 
225
-	// Titre : markup
226
-	$titre = trim($titre);
227
-	if (strlen($titre)) {
228
-		include_spip('inc/filtres');
229
-		// Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon.
230
-		$cherche_tag = ($prive ? '<h' : '<');
231
-		$wrap_tag    = ($prive ? '<h3>' : '<div>');
232
-		if (strpos($titre, $cherche_tag) !== 0) {
233
-			$titre = wrap($titre, $wrap_tag);
234
-		}
235
-		// puis on ajoute la classe
236
-		$titre = ajouter_class($titre, $class_titre);
237
-	}
225
+    // Titre : markup
226
+    $titre = trim($titre);
227
+    if (strlen($titre)) {
228
+        include_spip('inc/filtres');
229
+        // Si besoin on encapsule le titre : un h3 dans le privé, un simple div sinon.
230
+        $cherche_tag = ($prive ? '<h' : '<');
231
+        $wrap_tag    = ($prive ? '<h3>' : '<div>');
232
+        if (strpos($titre, $cherche_tag) !== 0) {
233
+            $titre = wrap($titre, $wrap_tag);
234
+        }
235
+        // puis on ajoute la classe
236
+        $titre = ajouter_class($titre, $class_titre);
237
+    }
238 238
 
239
-	// Attributs
240
-	$attr_role = ($role ? "role=\"$role\"" : '');
241
-	$attr_id   = ($id   ? "id=\"$id\"" : '');
242
-	$attr_data = ($type ? "data-alert=\"$type\"" : '');
239
+    // Attributs
240
+    $attr_role = ($role ? "role=\"$role\"" : '');
241
+    $attr_id   = ($id   ? "id=\"$id\"" : '');
242
+    $attr_data = ($type ? "data-alert=\"$type\"" : '');
243 243
 
244
-	$message =
245
-		"<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>"
246
-			. $titre
247
-			. "<div class=\"$class_texte\">";
244
+    $message =
245
+        "<div class=\"$class_alerte\" $attr_role $attr_id $attr_data>"
246
+            . $titre
247
+            . "<div class=\"$class_texte\">";
248 248
 
249
-	return $message;
249
+    return $message;
250 250
 }
251 251
 
252 252
 /**
@@ -260,5 +260,5 @@  discard block
 block discarded – undo
260 260
  *     HTML de fin de l'alerte
261 261
  */
262 262
 function message_alerte_fermer(): string {
263
-	return '</div></div>';
263
+    return '</div></div>';
264 264
 }
Please login to merge, or discard this patch.
ecrire/inc/acces.php 1 patch
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -31,47 +31,47 @@  discard block
 block discarded – undo
31 31
  *     Mot de passe
32 32
  **/
33 33
 function creer_pass_aleatoire($longueur = 16, $sel = '') {
34
-	$seed = (int)round(((float)microtime() + 1) * time());
35
-
36
-	mt_srand($seed);
37
-	srand($seed);
38
-	$s = '';
39
-	$pass = '';
40
-	for ($i = 0; $i < $longueur; $i++) {
41
-		if (!$s) {
42
-			$s = mt_rand();
43
-			if (!$s) {
44
-				$s = rand();
45
-			}
46
-			$s = substr(md5(uniqid($s) . $sel), 0, 16);
47
-		}
48
-		$r = unpack('Cr', pack('H2', $s . $s));
49
-		$x = $r['r'] & 63;
50
-		if ($x < 10) {
51
-			$x = chr($x + 48);
52
-		} else {
53
-			if ($x < 36) {
54
-				$x = chr($x + 55);
55
-			} else {
56
-				if ($x < 62) {
57
-					$x = chr($x + 61);
58
-				} else {
59
-					if ($x == 63) {
60
-						$x = '/';
61
-					} else {
62
-						$x = '.';
63
-					}
64
-				}
65
-			}
66
-		}
67
-		$pass .= $x;
68
-		$s = substr($s, 2);
69
-	}
70
-	$pass = preg_replace('@[./]@', 'a', $pass);
71
-	$pass = preg_replace('@[I1l]@', 'L', $pass);
72
-	$pass = preg_replace('@[0O]@', 'o', $pass);
73
-
74
-	return $pass;
34
+    $seed = (int)round(((float)microtime() + 1) * time());
35
+
36
+    mt_srand($seed);
37
+    srand($seed);
38
+    $s = '';
39
+    $pass = '';
40
+    for ($i = 0; $i < $longueur; $i++) {
41
+        if (!$s) {
42
+            $s = mt_rand();
43
+            if (!$s) {
44
+                $s = rand();
45
+            }
46
+            $s = substr(md5(uniqid($s) . $sel), 0, 16);
47
+        }
48
+        $r = unpack('Cr', pack('H2', $s . $s));
49
+        $x = $r['r'] & 63;
50
+        if ($x < 10) {
51
+            $x = chr($x + 48);
52
+        } else {
53
+            if ($x < 36) {
54
+                $x = chr($x + 55);
55
+            } else {
56
+                if ($x < 62) {
57
+                    $x = chr($x + 61);
58
+                } else {
59
+                    if ($x == 63) {
60
+                        $x = '/';
61
+                    } else {
62
+                        $x = '.';
63
+                    }
64
+                }
65
+            }
66
+        }
67
+        $pass .= $x;
68
+        $s = substr($s, 2);
69
+    }
70
+    $pass = preg_replace('@[./]@', 'a', $pass);
71
+    $pass = preg_replace('@[I1l]@', 'L', $pass);
72
+    $pass = preg_replace('@[0O]@', 'o', $pass);
73
+
74
+    return $pass;
75 75
 }
76 76
 
77 77
 /**
@@ -80,21 +80,21 @@  discard block
 block discarded – undo
80 80
  * @return string Identifiant
81 81
  */
82 82
 function creer_uniqid() {
83
-	static $seeded;
83
+    static $seeded;
84 84
 
85
-	if (!$seeded) {
86
-		$seed = (int)round(((float)microtime() + 1) * time());
87
-		mt_srand($seed);
88
-		srand($seed);
89
-		$seeded = true;
90
-	}
85
+    if (!$seeded) {
86
+        $seed = (int)round(((float)microtime() + 1) * time());
87
+        mt_srand($seed);
88
+        srand($seed);
89
+        $seeded = true;
90
+    }
91 91
 
92
-	$s = mt_rand();
93
-	if (!$s) {
94
-		$s = rand();
95
-	}
92
+    $s = mt_rand();
93
+    if (!$s) {
94
+        $s = rand();
95
+    }
96 96
 
97
-	return uniqid($s, 1);
97
+    return uniqid($s, 1);
98 98
 }
99 99
 
100 100
 /**
@@ -108,42 +108,42 @@  discard block
 block discarded – undo
108 108
  * @return string Retourne l'alea éphemère actuel au passage
109 109
  */
110 110
 function charger_aleas() {
111
-	if (!isset($GLOBALS['meta']['alea_ephemere'])) {
112
-		include_spip('base/abstract_sql');
113
-		$aleas = sql_allfetsel(
114
-			['nom', 'valeur'],
115
-			'spip_meta',
116
-			sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']),
117
-			'',
118
-			'',
119
-			'',
120
-			'',
121
-			'',
122
-			'continue'
123
-		);
124
-		if ($aleas) {
125
-			foreach ($aleas as $a) {
126
-				$GLOBALS['meta'][$a['nom']] = $a['valeur'];
127
-			}
128
-			return $GLOBALS['meta']['alea_ephemere'];
129
-		} else {
130
-			spip_log('aleas indisponibles', 'session');
131
-			return '';
132
-		}
133
-	}
134
-	return $GLOBALS['meta']['alea_ephemere'];
111
+    if (!isset($GLOBALS['meta']['alea_ephemere'])) {
112
+        include_spip('base/abstract_sql');
113
+        $aleas = sql_allfetsel(
114
+            ['nom', 'valeur'],
115
+            'spip_meta',
116
+            sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']),
117
+            '',
118
+            '',
119
+            '',
120
+            '',
121
+            '',
122
+            'continue'
123
+        );
124
+        if ($aleas) {
125
+            foreach ($aleas as $a) {
126
+                $GLOBALS['meta'][$a['nom']] = $a['valeur'];
127
+            }
128
+            return $GLOBALS['meta']['alea_ephemere'];
129
+        } else {
130
+            spip_log('aleas indisponibles', 'session');
131
+            return '';
132
+        }
133
+    }
134
+    return $GLOBALS['meta']['alea_ephemere'];
135 135
 }
136 136
 
137 137
 /**
138 138
  * Renouveller l'alea (utilisé pour sécuriser les scripts du répertoire `action/`)
139 139
  **/
140 140
 function renouvelle_alea() {
141
-	charger_aleas();
142
-	ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non');
143
-	$GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid());
144
-	ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non');
145
-	ecrire_meta('alea_ephemere_date', time(), 'non');
146
-	spip_log("renouvellement de l'alea_ephemere");
141
+    charger_aleas();
142
+    ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non');
143
+    $GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid());
144
+    ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non');
145
+    ecrire_meta('alea_ephemere_date', time(), 'non');
146
+    spip_log("renouvellement de l'alea_ephemere");
147 147
 }
148 148
 
149 149
 
@@ -163,21 +163,21 @@  discard block
 block discarded – undo
163 163
  *     Clé de sécurité.
164 164
  **/
165 165
 function low_sec($id_auteur) {
166
-	// Pas d'id_auteur : low_sec
167
-	if (!$id_auteur = intval($id_auteur)) {
168
-		include_spip('inc/config');
169
-		if (!$low_sec = lire_config('low_sec')) {
170
-			ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
171
-		}
172
-	} else {
173
-		$low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . intval($id_auteur));
174
-		if (!$low_sec) {
175
-			$low_sec = creer_pass_aleatoire();
176
-			sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . intval($id_auteur));
177
-		}
178
-	}
179
-
180
-	return $low_sec;
166
+    // Pas d'id_auteur : low_sec
167
+    if (!$id_auteur = intval($id_auteur)) {
168
+        include_spip('inc/config');
169
+        if (!$low_sec = lire_config('low_sec')) {
170
+            ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
171
+        }
172
+    } else {
173
+        $low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . intval($id_auteur));
174
+        if (!$low_sec) {
175
+            $low_sec = creer_pass_aleatoire();
176
+            sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . intval($id_auteur));
177
+        }
178
+    }
179
+
180
+    return $low_sec;
181 181
 }
182 182
 
183 183
 /**
@@ -193,27 +193,27 @@  discard block
 block discarded – undo
193 193
  * @return string
194 194
  */
195 195
 function param_low_sec($op, $args = [], $lang = '', $mime = 'rss') {
196
-	$a = $b = '';
197
-	foreach ($args as $val => $var) {
198
-		if ($var) {
199
-			if ($val <> 'statut') {
200
-				$a .= ':' . $val . '-' . $var;
201
-			}
202
-			$b .= $val . '=' . $var . '&';
203
-		}
204
-	}
205
-	$a = substr($a, 1);
206
-	$id = intval(@$GLOBALS['connect_id_auteur']);
207
-
208
-	return $b
209
-	. 'op='
210
-	. $op
211
-	. '&id='
212
-	. $id
213
-	. '&cle='
214
-	. afficher_low_sec($id, "$mime $op $a")
215
-	. (!$a ? '' : "&args=$a")
216
-	. (!$lang ? '' : "&lang=$lang");
196
+    $a = $b = '';
197
+    foreach ($args as $val => $var) {
198
+        if ($var) {
199
+            if ($val <> 'statut') {
200
+                $a .= ':' . $val . '-' . $var;
201
+            }
202
+            $b .= $val . '=' . $var . '&';
203
+        }
204
+    }
205
+    $a = substr($a, 1);
206
+    $id = intval(@$GLOBALS['connect_id_auteur']);
207
+
208
+    return $b
209
+    . 'op='
210
+    . $op
211
+    . '&id='
212
+    . $id
213
+    . '&cle='
214
+    . afficher_low_sec($id, "$mime $op $a")
215
+    . (!$a ? '' : "&args=$a")
216
+    . (!$lang ? '' : "&lang=$lang");
217 217
 }
218 218
 
219 219
 /**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
  *     Clé
230 230
  **/
231 231
 function afficher_low_sec($id_auteur, $action = '') {
232
-	return substr(md5($action . low_sec($id_auteur)), 0, 8);
232
+    return substr(md5($action . low_sec($id_auteur)), 0, 8);
233 233
 }
234 234
 
235 235
 /**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
  *     true si les clés corresponde, false sinon
248 248
  **/
249 249
 function verifier_low_sec($id_auteur, $cle, $action = '') {
250
-	return ($cle == afficher_low_sec($id_auteur, $action));
250
+    return ($cle == afficher_low_sec($id_auteur, $action));
251 251
 }
252 252
 
253 253
 /**
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
  *     Identifiant de l'auteur
258 258
  **/
259 259
 function effacer_low_sec($id_auteur) {
260
-	if (!$id_auteur = intval($id_auteur)) {
261
-		return;
262
-	} // jamais trop prudent ;)
263
-	sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . intval($id_auteur));
260
+    if (!$id_auteur = intval($id_auteur)) {
261
+        return;
262
+    } // jamais trop prudent ;)
263
+    sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . intval($id_auteur));
264 264
 }
265 265
 
266 266
 /**
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
  * @return void|bool
270 270
  */
271 271
 function initialiser_sel() {
272
-	if (!isset($GLOBALS['htsalt'])) {
273
-		if (CRYPT_MD5) {
274
-			$GLOBALS['htsalt'] = '$1$' . creer_pass_aleatoire();
275
-		} else {
276
-			$GLOBALS['htsalt'] = '';
277
-		}
278
-	}
279
-	return $GLOBALS['htsalt'];
272
+    if (!isset($GLOBALS['htsalt'])) {
273
+        if (CRYPT_MD5) {
274
+            $GLOBALS['htsalt'] = '$1$' . creer_pass_aleatoire();
275
+        } else {
276
+            $GLOBALS['htsalt'] = '';
277
+        }
278
+    }
279
+    return $GLOBALS['htsalt'];
280 280
 }
281 281
 
282 282
 /**
@@ -293,32 +293,32 @@  discard block
 block discarded – undo
293 293
  *     - void sinon.
294 294
  **/
295 295
 function ecrire_acces() {
296
-	$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
297
-	$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
298
-
299
-	// Cette variable de configuration peut etre posee par un plugin
300
-	// par exemple acces_restreint ;
301
-	// si .htaccess existe, outrepasser spip_meta
302
-	if (
303
-		(!isset($GLOBALS['meta']['creer_htpasswd'])
304
-			or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
305
-		and !@file_exists($htaccess)
306
-	) {
307
-		spip_unlink($htpasswd);
308
-		spip_unlink($htpasswd . '-admin');
309
-		return;
310
-	}
311
-
312
-	# remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
313
-	# de devenir redacteur le cas echeant (auth http)... a nettoyer
314
-	// attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
315
-	// TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test spip_connect_ldap()
316
-
317
-	if (spip_connect_ldap()) {
318
-		return;
319
-	}
320
-
321
-	generer_htpasswd_files($htpasswd, "$htpasswd-admin");
296
+    $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
297
+    $htpasswd = _DIR_TMP . _AUTH_USER_FILE;
298
+
299
+    // Cette variable de configuration peut etre posee par un plugin
300
+    // par exemple acces_restreint ;
301
+    // si .htaccess existe, outrepasser spip_meta
302
+    if (
303
+        (!isset($GLOBALS['meta']['creer_htpasswd'])
304
+            or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
305
+        and !@file_exists($htaccess)
306
+    ) {
307
+        spip_unlink($htpasswd);
308
+        spip_unlink($htpasswd . '-admin');
309
+        return;
310
+    }
311
+
312
+    # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
313
+    # de devenir redacteur le cas echeant (auth http)... a nettoyer
314
+    // attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
315
+    // TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test spip_connect_ldap()
316
+
317
+    if (spip_connect_ldap()) {
318
+        return;
319
+    }
320
+
321
+    generer_htpasswd_files($htpasswd, "$htpasswd-admin");
322 322
 }
323 323
 
324 324
 /**
@@ -327,29 +327,29 @@  discard block
 block discarded – undo
327 327
  * @param $htpasswd_admin
328 328
  */
329 329
 function generer_htpasswd_files($htpasswd, $htpasswd_admin) {
330
-	if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) {
331
-		$generer_htpasswd($htpasswd, $htpasswd_admin);
332
-	}
333
-
334
-	$pwd_all = ''; // login:htpass pour tous
335
-	$pwd_admin = ''; // login:htpass pour les admins
336
-
337
-	$res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
338
-	while ($row = sql_fetch($res)) {
339
-		if (strlen($row['login']) and strlen($row['htpass'])) {
340
-			$ligne = $row['login'] . ':' . $row['htpass'] . "\n";
341
-			$pwd_all .= $ligne;
342
-			if ($row['statut'] == '0minirezo') {
343
-				$pwd_admin .= $ligne;
344
-			}
345
-		}
346
-	}
347
-
348
-	if ($pwd_all) {
349
-		ecrire_fichier($htpasswd, $pwd_all);
350
-		ecrire_fichier($htpasswd_admin, $pwd_admin);
351
-		spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass');
352
-	}
330
+    if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) {
331
+        $generer_htpasswd($htpasswd, $htpasswd_admin);
332
+    }
333
+
334
+    $pwd_all = ''; // login:htpass pour tous
335
+    $pwd_admin = ''; // login:htpass pour les admins
336
+
337
+    $res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
338
+    while ($row = sql_fetch($res)) {
339
+        if (strlen($row['login']) and strlen($row['htpass'])) {
340
+            $ligne = $row['login'] . ':' . $row['htpass'] . "\n";
341
+            $pwd_all .= $ligne;
342
+            if ($row['statut'] == '0minirezo') {
343
+                $pwd_admin .= $ligne;
344
+            }
345
+        }
346
+    }
347
+
348
+    if ($pwd_all) {
349
+        ecrire_fichier($htpasswd, $pwd_all);
350
+        ecrire_fichier($htpasswd_admin, $pwd_admin);
351
+        spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass');
352
+    }
353 353
 }
354 354
 
355 355
 /**
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
  *  La chaîne hachée si fonction crypt présente, rien sinon.
364 364
  */
365 365
 function generer_htpass($pass) {
366
-	if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) {
367
-		return $generer_htpass($pass);
368
-	}
369
-	elseif (function_exists('crypt')) {
370
-		return crypt($pass, initialiser_sel());
371
-	}
372
-	return '';
366
+    if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) {
367
+        return $generer_htpass($pass);
368
+    }
369
+    elseif (function_exists('crypt')) {
370
+        return crypt($pass, initialiser_sel());
371
+    }
372
+    return '';
373 373
 }
374 374
 
375 375
 /**
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
  * @return boolean
383 383
  */
384 384
 function verifier_htaccess($rep, $force = false) {
385
-	$htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
386
-	if (((@file_exists($htaccess)) or defined('_TEST_DIRS')) and !$force) {
387
-		return true;
388
-	}
389
-
390
-	// directive deny compatible Apache 2.0+
391
-	$deny =
392
-		'# Deny all requests from Apache 2.4+.
385
+    $htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
386
+    if (((@file_exists($htaccess)) or defined('_TEST_DIRS')) and !$force) {
387
+        return true;
388
+    }
389
+
390
+    // directive deny compatible Apache 2.0+
391
+    $deny =
392
+        '# Deny all requests from Apache 2.4+.
393 393
 <IfModule mod_authz_core.c>
394 394
   Require all denied
395 395
 </IfModule>
@@ -398,32 +398,32 @@  discard block
 block discarded – undo
398 398
   Deny from all
399 399
 </IfModule>
400 400
 ';
401
-	// support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD)
402
-	if (
403
-		function_exists('apache_get_version')
404
-		and $v = apache_get_version()
405
-		and strncmp($v, 'Apache/1.', 9) == 0
406
-	) {
407
-		$deny = "deny from all\n";
408
-	}
409
-
410
-	if ($ht = @fopen($htaccess, 'w')) {
411
-		fputs($ht, $deny);
412
-		fclose($ht);
413
-		@chmod($htaccess, _SPIP_CHMOD & 0666);
414
-		$t = rtrim($rep, '/') . '/.ok';
415
-		if ($ht = @fopen($t, 'w')) {
416
-			@fclose($ht);
417
-			include_spip('inc/distant');
418
-			$t = substr($t, strlen(_DIR_RACINE));
419
-			$t = url_de_base() . $t;
420
-			$ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
421
-			$ht = ($ht['status'] ?? null) === 403;
422
-		}
423
-	}
424
-	spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
425
-
426
-	return $ht;
401
+    // support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD)
402
+    if (
403
+        function_exists('apache_get_version')
404
+        and $v = apache_get_version()
405
+        and strncmp($v, 'Apache/1.', 9) == 0
406
+    ) {
407
+        $deny = "deny from all\n";
408
+    }
409
+
410
+    if ($ht = @fopen($htaccess, 'w')) {
411
+        fputs($ht, $deny);
412
+        fclose($ht);
413
+        @chmod($htaccess, _SPIP_CHMOD & 0666);
414
+        $t = rtrim($rep, '/') . '/.ok';
415
+        if ($ht = @fopen($t, 'w')) {
416
+            @fclose($ht);
417
+            include_spip('inc/distant');
418
+            $t = substr($t, strlen(_DIR_RACINE));
419
+            $t = url_de_base() . $t;
420
+            $ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
421
+            $ht = ($ht['status'] ?? null) === 403;
422
+        }
423
+    }
424
+    spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
425
+
426
+    return $ht;
427 427
 }
428 428
 
429 429
 /**
@@ -441,20 +441,20 @@  discard block
 block discarded – undo
441 441
  *         Valeur de la configuration `creer_htaccess`
442 442
  */
443 443
 function gerer_htaccess() {
444
-	// Cette variable de configuration peut etre posee par un plugin
445
-	// par exemple acces_restreint
446
-	$f = (isset($GLOBALS['meta']['creer_htaccess']) and ($GLOBALS['meta']['creer_htaccess'] === 'oui'));
447
-	$dirs = sql_allfetsel('extension', 'spip_types_documents');
448
-	$dirs[] = ['extension' => 'distant'];
449
-	foreach ($dirs as $e) {
450
-		if (is_dir($dir = _DIR_IMG . $e['extension'])) {
451
-			if ($f) {
452
-				verifier_htaccess($dir);
453
-			} else {
454
-				spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
455
-			}
456
-		}
457
-	}
458
-
459
-	return isset($GLOBALS['meta']['creer_htaccess']) ? $GLOBALS['meta']['creer_htaccess'] : '';
444
+    // Cette variable de configuration peut etre posee par un plugin
445
+    // par exemple acces_restreint
446
+    $f = (isset($GLOBALS['meta']['creer_htaccess']) and ($GLOBALS['meta']['creer_htaccess'] === 'oui'));
447
+    $dirs = sql_allfetsel('extension', 'spip_types_documents');
448
+    $dirs[] = ['extension' => 'distant'];
449
+    foreach ($dirs as $e) {
450
+        if (is_dir($dir = _DIR_IMG . $e['extension'])) {
451
+            if ($f) {
452
+                verifier_htaccess($dir);
453
+            } else {
454
+                spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
455
+            }
456
+        }
457
+    }
458
+
459
+    return isset($GLOBALS['meta']['creer_htaccess']) ? $GLOBALS['meta']['creer_htaccess'] : '';
460 460
 }
Please login to merge, or discard this patch.
ecrire/inc/couleurs.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -38,70 +38,70 @@  discard block
 block discarded – undo
38 38
  * @return array|string
39 39
  */
40 40
 function inc_couleurs_dist($choix = null, $ajouter = false) {
41
-	static $couleurs_spip = [
42
-		// Violet soutenu
43
-		9 => ['couleur_theme' => '#9a6ef2'],
44
-		// Violet rosé
45
-		4 => ['couleur_theme' => '#c464cb'],
46
-		// Rose interface SPIP
47
-		2 => ['couleur_theme' =>  '#F02364'],
48
-		// Rouge
49
-		8 => ['couleur_theme' => '#ff4524'],
50
-		// Orange
51
-		3 => ['couleur_theme' => '#c97500'],
52
-		// Vert SPIP
53
-		1 => ['couleur_theme' => '#9dba00'],
54
-		// Vert Troglo
55
-		7 => ['couleur_theme' => '#419a2c'],
56
-		// Bleu-vert
57
-		12 => ['couleur_theme' => '#269681'],
58
-		//  Bleu pastel
59
-		5 => ['couleur_theme' => '#3190ae'],
60
-		//  Bleu Kermesse
61
-		11 => ['couleur_theme' => '#288bdd'],
62
-		//  Gris bleuté
63
-		6 => ['couleur_theme' => '#7d90a2'],
64
-		//  Gris
65
-		10 => ['couleur_theme' => '#909090'],
66
-	];
41
+    static $couleurs_spip = [
42
+        // Violet soutenu
43
+        9 => ['couleur_theme' => '#9a6ef2'],
44
+        // Violet rosé
45
+        4 => ['couleur_theme' => '#c464cb'],
46
+        // Rose interface SPIP
47
+        2 => ['couleur_theme' =>  '#F02364'],
48
+        // Rouge
49
+        8 => ['couleur_theme' => '#ff4524'],
50
+        // Orange
51
+        3 => ['couleur_theme' => '#c97500'],
52
+        // Vert SPIP
53
+        1 => ['couleur_theme' => '#9dba00'],
54
+        // Vert Troglo
55
+        7 => ['couleur_theme' => '#419a2c'],
56
+        // Bleu-vert
57
+        12 => ['couleur_theme' => '#269681'],
58
+        //  Bleu pastel
59
+        5 => ['couleur_theme' => '#3190ae'],
60
+        //  Bleu Kermesse
61
+        11 => ['couleur_theme' => '#288bdd'],
62
+        //  Gris bleuté
63
+        6 => ['couleur_theme' => '#7d90a2'],
64
+        //  Gris
65
+        10 => ['couleur_theme' => '#909090'],
66
+    ];
67 67
 
68
-	if (is_numeric($choix)) {
69
-		$c = $couleurs_spip[$choix];
70
-		// compat < SPIP 3.3
71
-		include_spip('inc/filtres_images_mini');
72
-		$c['couleur_foncee'] = $c['couleur_theme'];
73
-		$c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
68
+    if (is_numeric($choix)) {
69
+        $c = $couleurs_spip[$choix];
70
+        // compat < SPIP 3.3
71
+        include_spip('inc/filtres_images_mini');
72
+        $c['couleur_foncee'] = $c['couleur_theme'];
73
+        $c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
74 74
 
75
-		return
76
-			'couleur_theme=' . substr($c['couleur_theme'], 1)
77
-			// compat < SPIP 3.3
78
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
79
-			. '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
80
-	} else {
81
-		if (is_array($choix)) {
82
-			// compat < SPIP 3.3
83
-			$compat_spip_33 = function ($c) {
84
-				if (!isset($c['couleur_theme'])) {
85
-					$c['couleur_theme'] = $c['couleur_foncee'];
86
-					unset($c['couleur_foncee']);
87
-					unset($c['couleur_claire']);
88
-					unset($c['couleur_lien']);
89
-					unset($c['couleur_lien_off']);
90
-				}
91
-				return $c;
92
-			};
93
-			if ($ajouter) {
94
-				foreach ($choix as $c) {
95
-					$couleurs_spip[] = $compat_spip_33($c);
96
-				}
75
+        return
76
+            'couleur_theme=' . substr($c['couleur_theme'], 1)
77
+            // compat < SPIP 3.3
78
+            . '&couleur_claire=' . substr($c['couleur_claire'], 1)
79
+            . '&couleur_foncee=' . substr($c['couleur_foncee'], 1);
80
+    } else {
81
+        if (is_array($choix)) {
82
+            // compat < SPIP 3.3
83
+            $compat_spip_33 = function ($c) {
84
+                if (!isset($c['couleur_theme'])) {
85
+                    $c['couleur_theme'] = $c['couleur_foncee'];
86
+                    unset($c['couleur_foncee']);
87
+                    unset($c['couleur_claire']);
88
+                    unset($c['couleur_lien']);
89
+                    unset($c['couleur_lien_off']);
90
+                }
91
+                return $c;
92
+            };
93
+            if ($ajouter) {
94
+                foreach ($choix as $c) {
95
+                    $couleurs_spip[] = $compat_spip_33($c);
96
+                }
97 97
 
98
-				return $couleurs_spip;
99
-			} else {
100
-				$choix = array_map($compat_spip_33, $choix);
101
-				return $couleurs_spip = $choix;
102
-			}
103
-		}
104
-	}
98
+                return $couleurs_spip;
99
+            } else {
100
+                $choix = array_map($compat_spip_33, $choix);
101
+                return $couleurs_spip = $choix;
102
+            }
103
+        }
104
+    }
105 105
 
106
-	return $couleurs_spip;
106
+    return $couleurs_spip;
107 107
 }
Please login to merge, or discard this patch.