Completed
Push — master ( 4aa2c5...a38486 )
by cam
01:23
created
ecrire/inc/install.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = '<' . "?php\n"
46
+	$texte = '<'."?php\n"
47 47
 		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48 48
 		. $texte;
49 49
 
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 		return $regs;
113 113
 	} else {
114 114
 		$ar = '\s*\'([^\']*)\'';
115
-		$r = '\s*,' . $ar;
115
+		$r = '\s*,'.$ar;
116 116
 		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
117 117
 		if (preg_match($r, $s, $regs)) {
118
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
118
+			$regs[2] = $regs[1].(!$regs[2] ? '' : ':'.$regs[2].';');
119 119
 			array_shift($regs);
120 120
 			array_shift($regs);
121 121
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	// Si on n'a pas la bonne version de PHP, c'est la fin
181 181
 	if ($err) {
182 182
 		die("<div class='error'>"
183
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
183
+			. '<h3>'._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>"
184 184
 			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
185 185
 	}
186 186
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
 	if ($err) {
203 203
 		echo "<div class='error'>"
204
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
204
+			. '<h3>'._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>";
205 205
 		foreach ($err as $e) {
206 206
 			echo "<li><strong>$e</strong></li>\n";
207 207
 		}
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 
235 235
 
236 236
 function info_etape($titre, $complement = '') {
237
-	return '<h2>' . $titre . "</h2>\n" .
238
-	($complement ? '' . $complement . "\n" : '');
237
+	return '<h2>'.$titre."</h2>\n".
238
+	($complement ? ''.$complement."\n" : '');
239 239
 }
240 240
 
241 241
 /**
@@ -249,18 +249,18 @@  discard block
 block discarded – undo
249 249
 		$code = _T('bouton_suivant');
250 250
 	}
251 251
 	static $suivant = 0;
252
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
252
+	$id = 'suivant'.(($suivant > 0) ? strval($suivant) : '');
253 253
 	$suivant += 1;
254 254
 
255
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
256
-	$code .
255
+	return "\n<p class='boutons suivant'><input id='".$id."' type='submit'\nvalue=\"".
256
+	$code.
257 257
 	" >>\" /></p>\n";
258 258
 }
259 259
 
260 260
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
261 261
 	$intitule_etat = [];
262 262
 	//$en_cours = _request('etape')?_request('etape'):"";
263
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
263
+	$liste = find_all_in_path($dir, $phase.'(([0-9])+|fin)[.]php$');
264 264
 	$debut = 1;
265 265
 	$etat = 'ok';
266 266
 	$last = count($liste);
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 
300 300
 			$aff_etapes .= "<li class='$class'><div class='fond'>";
301 301
 			$aff_etapes .= ($debut == $en_cours) ? '<strong>' : '';
302
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
302
+			$aff_etapes .= '<em>'._T('etape')." </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
303 303
 			$aff_etapes .= $intitule_etat["$phase"][$debut];
304 304
 			$aff_etapes .= ($debut == $en_cours) ? '</strong>' : '';
305 305
 			$aff_etapes .= '</div></li>';
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 
315 315
 
316 316
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
317
-	return "<fieldset>\n" .
318
-	$avant .
319
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
320
-	fieldset_champs($champs) .
321
-	$apres .
317
+	return "<fieldset>\n".
318
+	$avant.
319
+	($legend ? '<legend>'.$legend."</legend>\n" : '').
320
+	fieldset_champs($champs).
321
+	$apres.
322 322
 	"</fieldset>\n";
323 323
 }
324 324
 
@@ -328,18 +328,18 @@  discard block
 block discarded – undo
328 328
 		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
329 329
 		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
330 330
 		if (isset($contenu['alternatives'])) {
331
-			$fieldset .= $contenu['label'] . "\n";
331
+			$fieldset .= $contenu['label']."\n";
332 332
 			foreach ($contenu['alternatives'] as $valeur => $label) {
333
-				$fieldset .= "<input type='radio' name='" . $nom .
333
+				$fieldset .= "<input type='radio' name='".$nom.
334 334
 					"' id='$nom-$valeur' value='$valeur'"
335 335
 					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
336 336
 					. "/>\n";
337
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
337
+				$fieldset .= "<label for='$nom-$valeur'>".$label."</label>\n";
338 338
 			}
339 339
 			$fieldset .= "<br />\n";
340 340
 		} else {
341
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
342
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
341
+			$fieldset .= "<label for='".$nom."'>".$contenu['label']."</label>\n";
342
+			$fieldset .= '<input '.$class."type='".$type."' id='".$nom."' name='".$nom."'\nvalue='".$contenu['valeur']."'"
343 343
 				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
344 344
 				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
345 345
 				. " />\n";
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 
352 352
 function install_select_serveur() {
353 353
 	$options = [];
354
-	$dir = _DIR_RESTREINT . 'req/';
354
+	$dir = _DIR_RESTREINT.'req/';
355 355
 	$d = opendir($dir);
356 356
 	if (!$d) {
357 357
 		return [];
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
 	while (($f = readdir($d)) !== false) {
360 360
 		if (
361 361
 			(preg_match('/^(.*)[.]php$/', $f, $s))
362
-			and is_readable($f = $dir . $f)
362
+			and is_readable($f = $dir.$f)
363 363
 		) {
364 364
 			require_once($f);
365 365
 			$s = $s[1];
366
-			$v = 'spip_versions_' . $s;
366
+			$v = 'spip_versions_'.$s;
367 367
 			if (function_exists($v) and $v()) {
368 368
 				$titre = _T("install_select_type_$s");
369 369
 				// proposer mysql par defaut si dispo
370 370
 				$checked = ($s == 'mysql' ? " checked='checked'" : '');
371 371
 				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
372
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
372
+					. "<label for='$s'>".($titre ?: $s).'</label></li>';
373 373
 			} else {
374 374
 				spip_log("$s: portage indisponible");
375 375
 			}
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 		"\n<input type='hidden' name='etape' value='$etape' />"
388 388
 		. $hidden
389 389
 		. (_request('echec') ?
390
-			('<p><b>' . _T('avis_connexion_echec_1') .
391
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
390
+			('<p><b>'._T('avis_connexion_echec_1').
391
+				'</b></p><p>'._T('avis_connexion_echec_2')."</p><p style='font-size: small;'>"._T('avis_connexion_echec_3').'</p>')
392 392
 			: '')
393 393
 
394 394
 		. ($jquery ? http_script('', 'jquery.js') : '')
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
 		});')
427 427
 
428 428
 		. ($server_db
429
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
429
+			? '<input type="hidden" name="server_db" value="'.$server_db.'" />'
430 430
 			. (($predef[0])
431
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
431
+				? ('<h3>'._T('install_serveur_hebergeur').'</h3>')
432 432
 				: '')
433 433
 			: ('<fieldset><legend>'
434 434
 				. _T('install_select_type_db')
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
 				. "\n</ul>\n</div></fieldset>")
444 444
 		)
445 445
 		. '<div id="install_adresse_base_hebergeur">'
446
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
446
+		. '<p>'._T('texte_connexion_mysql').'</p>'
447 447
 		. ($predef[1]
448
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
448
+			? '<h3>'._T('install_adresse_base_hebergeur').'</h3>'
449 449
 			: fieldset(
450 450
 				_T('entree_base_donnee_1'),
451 451
 				[
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 
461 461
 		. '<div id="install_login_base_hebergeur">'
462 462
 		. ($predef[2]
463
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
463
+			? '<h3>'._T('install_login_base_hebergeur').'</h3>'
464 464
 			: fieldset(
465 465
 				_T('entree_login_connexion_1'),
466 466
 				[
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
 		. '<div id="install_pass_base_hebergeur">'
477 477
 		. ($predef[3]
478
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
478
+			? '<h3>'._T('install_pass_base_hebergeur').'</h3>'
479 479
 			: fieldset(
480 480
 				_T('entree_mot_passe_1'),
481 481
 				[
@@ -497,20 +497,20 @@  discard block
 block discarded – undo
497 497
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
498 498
 	return ((defined('_INSTALL_HOST_DB'))
499 499
 		? ''
500
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
500
+		: "\n<input type='hidden' name='adresse_db'  value=\"".spip_htmlspecialchars($adresse_db).'" />'
501 501
 	)
502 502
 	. ((defined('_INSTALL_USER_DB'))
503 503
 		? ''
504
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
504
+		: "\n<input type='hidden' name='login_db' value=\"".spip_htmlspecialchars($login_db).'" />'
505 505
 	)
506 506
 	. ((defined('_INSTALL_PASS_DB'))
507 507
 		? ''
508
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
508
+		: "\n<input type='hidden' name='pass_db' value=\"".spip_htmlspecialchars($pass_db).'" />'
509 509
 	)
510 510
 
511 511
 	. ((defined('_INSTALL_SERVER_DB'))
512 512
 		? ''
513
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
513
+		: "\n<input type='hidden' name='server_db' value=\"".spip_htmlspecialchars($server_db).'" />'
514 514
 	);
515 515
 }
516 516
 
Please login to merge, or discard this patch.
Indentation   +364 added lines, -364 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,11 +43,11 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = '<' . "?php\n"
47
-		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
-		. $texte;
46
+    $texte = '<' . "?php\n"
47
+        . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
+        . $texte;
49 49
 
50
-	ecrire_fichier($nom, $texte);
50
+    ecrire_fichier($nom, $texte);
51 51
 }
52 52
 
53 53
 
@@ -76,20 +76,20 @@  discard block
 block discarded – undo
76 76
  *
77 77
  **/
78 78
 function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') {
79
-	$adr = addcslashes($adr, "'\\");
80
-	$port = addcslashes($port, "'\\");
81
-	$login = addcslashes($login, "'\\");
82
-	$pass = addcslashes($pass, "'\\");
83
-	$base = addcslashes($base, "'\\");
84
-	$type = addcslashes($type, "'\\");
85
-	$pref = addcslashes($pref, "'\\");
86
-	$ldap = addcslashes($ldap, "'\\");
87
-	$charset = addcslashes($charset, "'\\");
88
-
89
-	return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
90
-	. 'spip_connect_db('
91
-	. "'$adr','$port','$login','$pass','$base'"
92
-	. ",'$type', '$pref','$ldap','$charset');\n";
79
+    $adr = addcslashes($adr, "'\\");
80
+    $port = addcslashes($port, "'\\");
81
+    $login = addcslashes($login, "'\\");
82
+    $pass = addcslashes($pass, "'\\");
83
+    $base = addcslashes($base, "'\\");
84
+    $type = addcslashes($type, "'\\");
85
+    $pref = addcslashes($pref, "'\\");
86
+    $ldap = addcslashes($ldap, "'\\");
87
+    $charset = addcslashes($charset, "'\\");
88
+
89
+    return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
90
+    . 'spip_connect_db('
91
+    . "'$adr','$port','$login','$pass','$base'"
92
+    . ",'$type', '$pref','$ldap','$charset');\n";
93 93
 }
94 94
 
95 95
 
@@ -105,29 +105,29 @@  discard block
 block discarded – undo
105 105
  *     Tableau des informations sur la connexion
106 106
  **/
107 107
 function analyse_fichier_connection(string $file): array {
108
-	if (!file_exists($file)) {
109
-		return [];
110
-	}
111
-	$s = file_get_contents($file);
112
-	if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
113
-		array_shift($regs);
114
-
115
-		return $regs;
116
-	} else {
117
-		$ar = '\s*\'([^\']*)\'';
118
-		$r = '\s*,' . $ar;
119
-		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
120
-		if (preg_match($r, $s, $regs)) {
121
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
122
-			array_shift($regs);
123
-			array_shift($regs);
124
-
125
-			return $regs;
126
-		}
127
-	}
128
-	spip_log("$file n'est pas un fichier de connexion");
129
-
130
-	return [];
108
+    if (!file_exists($file)) {
109
+        return [];
110
+    }
111
+    $s = file_get_contents($file);
112
+    if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
113
+        array_shift($regs);
114
+
115
+        return $regs;
116
+    } else {
117
+        $ar = '\s*\'([^\']*)\'';
118
+        $r = '\s*,' . $ar;
119
+        $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
120
+        if (preg_match($r, $s, $regs)) {
121
+            $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
122
+            array_shift($regs);
123
+            array_shift($regs);
124
+
125
+            return $regs;
126
+        }
127
+    }
128
+    spip_log("$file n'est pas un fichier de connexion");
129
+
130
+    return [];
131 131
 }
132 132
 
133 133
 /**
@@ -144,75 +144,75 @@  discard block
 block discarded – undo
144 144
  *     Liste des noms de connecteurs
145 145
  **/
146 146
 function bases_referencees($exclu = '') {
147
-	$tables = [];
148
-	foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
149
-		if ($f != $exclu and analyse_fichier_connection($f)) {
150
-			$tables[] = basename($f, '.php');
151
-		}
152
-	}
153
-
154
-	return $tables;
147
+    $tables = [];
148
+    foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
149
+        if ($f != $exclu and analyse_fichier_connection($f)) {
150
+            $tables[] = basename($f, '.php');
151
+        }
152
+    }
153
+
154
+    return $tables;
155 155
 }
156 156
 
157 157
 
158 158
 function install_mode_appel($server_db, $tout = true) {
159
-	return ($server_db != 'mysql') ? ''
160
-		: (($tout ? test_rappel_nom_base_mysql($server_db) : '')
161
-			. test_sql_mode_mysql($server_db));
159
+    return ($server_db != 'mysql') ? ''
160
+        : (($tout ? test_rappel_nom_base_mysql($server_db) : '')
161
+            . test_sql_mode_mysql($server_db));
162 162
 }
163 163
 
164 164
 //
165 165
 // Verifier que l'hebergement est compatible SPIP ... ou l'inverse :-)
166 166
 // (sert a l'etape 1 de l'installation)
167 167
 function tester_compatibilite_hebergement() {
168
-	$err = [];
169
-
170
-	$p = phpversion();
171
-	if (version_compare($p, _PHP_MIN, '<')) {
172
-		$err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
173
-	}
174
-	if (version_compare($p, _PHP_MAX, '>')) {
175
-		$err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]);
176
-	}
177
-
178
-	$diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions());
179
-	if (!empty($diff)) {
180
-		$err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]);
181
-	}
182
-
183
-	// Si on n'a pas la bonne version de PHP, c'est la fin
184
-	if ($err) {
185
-		die("<div class='error'>"
186
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
187
-			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
188
-	}
189
-
190
-	// Il faut une base de donnees tout de meme ...
191
-	$serveurs = install_select_serveur();
192
-	if (!$serveurs) {
193
-		$err[] = _T('install_extension_php_obligatoire')
194
-			. " <a href='http://www.php.net/mysql'>MYSQL</a>"
195
-			. "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
196
-			. "| <a href='http://www.php.net/sqlite'>SQLite</a>";
197
-	}
198
-
199
-	// et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0)
200
-	if ($a = @ini_get('mbstring.func_overload')) {
201
-		$err[] = _T('install_extension_mbstring')
202
-			. "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
203
-	}
204
-
205
-	if ($err) {
206
-		echo "<div class='error'>"
207
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
208
-		foreach ($err as $e) {
209
-			echo "<li><strong>$e</strong></li>\n";
210
-		}
211
-
212
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
213
-		# de forcer malgre tout (pour tester, ou si bug de detection)
214
-		echo "</ul></div>\n";
215
-	}
168
+    $err = [];
169
+
170
+    $p = phpversion();
171
+    if (version_compare($p, _PHP_MIN, '<')) {
172
+        $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
173
+    }
174
+    if (version_compare($p, _PHP_MAX, '>')) {
175
+        $err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]);
176
+    }
177
+
178
+    $diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions());
179
+    if (!empty($diff)) {
180
+        $err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]);
181
+    }
182
+
183
+    // Si on n'a pas la bonne version de PHP, c'est la fin
184
+    if ($err) {
185
+        die("<div class='error'>"
186
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
187
+            . "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
188
+    }
189
+
190
+    // Il faut une base de donnees tout de meme ...
191
+    $serveurs = install_select_serveur();
192
+    if (!$serveurs) {
193
+        $err[] = _T('install_extension_php_obligatoire')
194
+            . " <a href='http://www.php.net/mysql'>MYSQL</a>"
195
+            . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
196
+            . "| <a href='http://www.php.net/sqlite'>SQLite</a>";
197
+    }
198
+
199
+    // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0)
200
+    if ($a = @ini_get('mbstring.func_overload')) {
201
+        $err[] = _T('install_extension_mbstring')
202
+            . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
203
+    }
204
+
205
+    if ($err) {
206
+        echo "<div class='error'>"
207
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
208
+        foreach ($err as $e) {
209
+            echo "<li><strong>$e</strong></li>\n";
210
+        }
211
+
212
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
213
+        # de forcer malgre tout (pour tester, ou si bug de detection)
214
+        echo "</ul></div>\n";
215
+    }
216 216
 }
217 217
 
218 218
 
@@ -222,23 +222,23 @@  discard block
 block discarded – undo
222 222
  * @note superflu ??
223 223
  */
224 224
 function login_hebergeur() {
225
-	$base_hebergeur = 'localhost'; # par defaut
225
+    $base_hebergeur = 'localhost'; # par defaut
226 226
 
227
-	// Free
228
-	if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
229
-		$base_hebergeur = 'sql.free.fr';
230
-		$login_hebergeur = $regs[1];
231
-	} else {
232
-		$login_hebergeur = '';
233
-	}
227
+    // Free
228
+    if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
229
+        $base_hebergeur = 'sql.free.fr';
230
+        $login_hebergeur = $regs[1];
231
+    } else {
232
+        $login_hebergeur = '';
233
+    }
234 234
 
235
-	return [$base_hebergeur, $login_hebergeur];
235
+    return [$base_hebergeur, $login_hebergeur];
236 236
 }
237 237
 
238 238
 
239 239
 function info_etape($titre, $complement = '') {
240
-	return '<h2>' . $titre . "</h2>\n" .
241
-	($complement ? '' . $complement . "\n" : '');
240
+    return '<h2>' . $titre . "</h2>\n" .
241
+    ($complement ? '' . $complement . "\n" : '');
242 242
 }
243 243
 
244 244
 /**
@@ -248,154 +248,154 @@  discard block
 block discarded – undo
248 248
  * @return string Code HTML du bouton
249 249
  **/
250 250
 function bouton_suivant($code = '') {
251
-	if ($code == '') {
252
-		$code = _T('bouton_suivant');
253
-	}
254
-	static $suivant = 0;
255
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
256
-	$suivant += 1;
257
-
258
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
259
-	$code .
260
-	" >>\" /></p>\n";
251
+    if ($code == '') {
252
+        $code = _T('bouton_suivant');
253
+    }
254
+    static $suivant = 0;
255
+    $id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
256
+    $suivant += 1;
257
+
258
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
259
+    $code .
260
+    " >>\" /></p>\n";
261 261
 }
262 262
 
263 263
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
264
-	$intitule_etat = [];
265
-	//$en_cours = _request('etape')?_request('etape'):"";
266
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
267
-	$debut = 1;
268
-	$etat = 'ok';
269
-	$last = count($liste);
264
+    $intitule_etat = [];
265
+    //$en_cours = _request('etape')?_request('etape'):"";
266
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
267
+    $debut = 1;
268
+    $etat = 'ok';
269
+    $last = count($liste);
270 270
 //	$texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo'));
271 271
 
272
-	$intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
273
-	$intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
274
-	$intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
275
-	$intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
272
+    $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
273
+    $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
274
+    $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
275
+    $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
276 276
 
277
-	$intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
278
-	$intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
279
-	$intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
280
-	$intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
281
-	$intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
277
+    $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
278
+    $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
279
+    $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
280
+    $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
281
+    $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
282 282
 
283 283
 //	$aff_etapes = "<span id='etapes'>";
284 284
 
285
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
286
-
287
-	foreach ($liste as $etape => $fichier) {
288
-		if ($debut < $last) {
289
-			if ($debut == $en_cours && $erreur) {
290
-				$class = 'on erreur';
291
-			} else {
292
-				if ($debut == $en_cours) {
293
-					$class = 'on';
294
-				} else {
295
-					if ($debut > $en_cours) {
296
-						$class = 'prochains';
297
-					} else {
298
-						$class = 'valides';
299
-					}
300
-				}
301
-			}
302
-
303
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
304
-			$aff_etapes .= ($debut == $en_cours) ? '<strong>' : '';
305
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
306
-			$aff_etapes .= $intitule_etat["$phase"][$debut];
307
-			$aff_etapes .= ($debut == $en_cours) ? '</strong>' : '';
308
-			$aff_etapes .= '</div></li>';
309
-		}
310
-		$debut++;
311
-	}
312
-	$aff_etapes .= '</ul>';
313
-	$aff_etapes .= "<br class='nettoyeur' />\n";
314
-
315
-	return $aff_etapes;
285
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
286
+
287
+    foreach ($liste as $etape => $fichier) {
288
+        if ($debut < $last) {
289
+            if ($debut == $en_cours && $erreur) {
290
+                $class = 'on erreur';
291
+            } else {
292
+                if ($debut == $en_cours) {
293
+                    $class = 'on';
294
+                } else {
295
+                    if ($debut > $en_cours) {
296
+                        $class = 'prochains';
297
+                    } else {
298
+                        $class = 'valides';
299
+                    }
300
+                }
301
+            }
302
+
303
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
304
+            $aff_etapes .= ($debut == $en_cours) ? '<strong>' : '';
305
+            $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
306
+            $aff_etapes .= $intitule_etat["$phase"][$debut];
307
+            $aff_etapes .= ($debut == $en_cours) ? '</strong>' : '';
308
+            $aff_etapes .= '</div></li>';
309
+        }
310
+        $debut++;
311
+    }
312
+    $aff_etapes .= '</ul>';
313
+    $aff_etapes .= "<br class='nettoyeur' />\n";
314
+
315
+    return $aff_etapes;
316 316
 }
317 317
 
318 318
 
319 319
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
320
-	return "<fieldset>\n" .
321
-	$avant .
322
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
323
-	fieldset_champs($champs) .
324
-	$apres .
325
-	"</fieldset>\n";
320
+    return "<fieldset>\n" .
321
+    $avant .
322
+    ($legend ? '<legend>' . $legend . "</legend>\n" : '') .
323
+    fieldset_champs($champs) .
324
+    $apres .
325
+    "</fieldset>\n";
326 326
 }
327 327
 
328 328
 function fieldset_champs($champs = []) {
329
-	$fieldset = '';
330
-	foreach ($champs as $nom => $contenu) {
331
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
332
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
333
-		if (isset($contenu['alternatives'])) {
334
-			$fieldset .= $contenu['label'] . "\n";
335
-			foreach ($contenu['alternatives'] as $valeur => $label) {
336
-				$fieldset .= "<input type='radio' name='" . $nom .
337
-					"' id='$nom-$valeur' value='$valeur'"
338
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
339
-					. "/>\n";
340
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
341
-			}
342
-			$fieldset .= "<br />\n";
343
-		} else {
344
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
345
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
346
-				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
347
-				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
348
-				. " />\n";
349
-		}
350
-	}
351
-
352
-	return $fieldset;
329
+    $fieldset = '';
330
+    foreach ($champs as $nom => $contenu) {
331
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
332
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
333
+        if (isset($contenu['alternatives'])) {
334
+            $fieldset .= $contenu['label'] . "\n";
335
+            foreach ($contenu['alternatives'] as $valeur => $label) {
336
+                $fieldset .= "<input type='radio' name='" . $nom .
337
+                    "' id='$nom-$valeur' value='$valeur'"
338
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
339
+                    . "/>\n";
340
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
341
+            }
342
+            $fieldset .= "<br />\n";
343
+        } else {
344
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
345
+            $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
346
+                . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
347
+                . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
348
+                . " />\n";
349
+        }
350
+    }
351
+
352
+    return $fieldset;
353 353
 }
354 354
 
355 355
 function install_select_serveur() {
356
-	$options = [];
357
-	$dir = _DIR_RESTREINT . 'req/';
358
-	$d = opendir($dir);
359
-	if (!$d) {
360
-		return [];
361
-	}
362
-	while (($f = readdir($d)) !== false) {
363
-		if (
364
-			(preg_match('/^(.*)[.]php$/', $f, $s))
365
-			and is_readable($f = $dir . $f)
366
-		) {
367
-			require_once($f);
368
-			$s = $s[1];
369
-			$v = 'spip_versions_' . $s;
370
-			if (function_exists($v) and $v()) {
371
-				$titre = _T("install_select_type_$s");
372
-				// proposer mysql par defaut si dispo
373
-				$checked = ($s == 'mysql' ? " checked='checked'" : '');
374
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
375
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
376
-			} else {
377
-				spip_log("$s: portage indisponible");
378
-			}
379
-		}
380
-	}
381
-	sort($options);
382
-
383
-	return $options;
356
+    $options = [];
357
+    $dir = _DIR_RESTREINT . 'req/';
358
+    $d = opendir($dir);
359
+    if (!$d) {
360
+        return [];
361
+    }
362
+    while (($f = readdir($d)) !== false) {
363
+        if (
364
+            (preg_match('/^(.*)[.]php$/', $f, $s))
365
+            and is_readable($f = $dir . $f)
366
+        ) {
367
+            require_once($f);
368
+            $s = $s[1];
369
+            $v = 'spip_versions_' . $s;
370
+            if (function_exists($v) and $v()) {
371
+                $titre = _T("install_select_type_$s");
372
+                // proposer mysql par defaut si dispo
373
+                $checked = ($s == 'mysql' ? " checked='checked'" : '');
374
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
375
+                    . "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
376
+            } else {
377
+                spip_log("$s: portage indisponible");
378
+            }
379
+        }
380
+    }
381
+    sort($options);
382
+
383
+    return $options;
384 384
 }
385 385
 
386 386
 function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) {
387
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
388
-
389
-	return generer_form_ecrire('install', (
390
-		"\n<input type='hidden' name='etape' value='$etape' />"
391
-		. $hidden
392
-		. (_request('echec') ?
393
-			('<p><b>' . _T('avis_connexion_echec_1') .
394
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
395
-			: '')
396
-
397
-		. ($jquery ? http_script('', 'jquery.js') : '')
398
-		. http_script('
387
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
388
+
389
+    return generer_form_ecrire('install', (
390
+        "\n<input type='hidden' name='etape' value='$etape' />"
391
+        . $hidden
392
+        . (_request('echec') ?
393
+            ('<p><b>' . _T('avis_connexion_echec_1') .
394
+                '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
395
+            : '')
396
+
397
+        . ($jquery ? http_script('', 'jquery.js') : '')
398
+        . http_script('
399 399
 		jQuery(function($) {
400 400
 			$details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur");
401 401
 			$("input[type=hidden][name=server_db]").each(function(){
@@ -428,145 +428,145 @@  discard block
 block discarded – undo
428 428
 			});
429 429
 		});')
430 430
 
431
-		. ($server_db
432
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
433
-			. (($predef[0])
434
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
435
-				: '')
436
-			: ('<fieldset><legend>'
437
-				. _T('install_select_type_db')
438
-				. '</legend>'
439
-				. '<p class="explication">'
440
-				. _T('install_types_db_connus')
441
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
442
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
443
-				. '</p>'
444
-				. "\n<div class='p'>\n<ul>\n"
445
-				. join("\n", install_select_serveur())
446
-				. "\n</ul>\n</div></fieldset>")
447
-		)
448
-		. '<div id="install_adresse_base_hebergeur">'
449
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
450
-		. ($predef[1]
451
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
452
-			: fieldset(
453
-				_T('entree_base_donnee_1'),
454
-				[
455
-					'adresse_db' => [
456
-						'label' => $db[1],
457
-						'valeur' => $db[0]
458
-					],
459
-				]
460
-			)
461
-		)
462
-		. '</div>'
463
-
464
-		. '<div id="install_login_base_hebergeur">'
465
-		. ($predef[2]
466
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
467
-			: fieldset(
468
-				_T('entree_login_connexion_1'),
469
-				[
470
-					'login_db' => [
471
-						'label' => $login[1],
472
-						'valeur' => $login[0]
473
-					],
474
-				]
475
-			)
476
-		)
477
-		. '</div>'
478
-
479
-		. '<div id="install_pass_base_hebergeur">'
480
-		. ($predef[3]
481
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
482
-			: fieldset(
483
-				_T('entree_mot_passe_1'),
484
-				[
485
-					'pass_db' => [
486
-						'label' => $pass[1],
487
-						'valeur' => $pass[0]
488
-					],
489
-				]
490
-			)
491
-		)
492
-		. '</div>'
493
-
494
-		. bouton_suivant()));
431
+        . ($server_db
432
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
433
+            . (($predef[0])
434
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
435
+                : '')
436
+            : ('<fieldset><legend>'
437
+                . _T('install_select_type_db')
438
+                . '</legend>'
439
+                . '<p class="explication">'
440
+                . _T('install_types_db_connus')
441
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
442
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
443
+                . '</p>'
444
+                . "\n<div class='p'>\n<ul>\n"
445
+                . join("\n", install_select_serveur())
446
+                . "\n</ul>\n</div></fieldset>")
447
+        )
448
+        . '<div id="install_adresse_base_hebergeur">'
449
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
450
+        . ($predef[1]
451
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
452
+            : fieldset(
453
+                _T('entree_base_donnee_1'),
454
+                [
455
+                    'adresse_db' => [
456
+                        'label' => $db[1],
457
+                        'valeur' => $db[0]
458
+                    ],
459
+                ]
460
+            )
461
+        )
462
+        . '</div>'
463
+
464
+        . '<div id="install_login_base_hebergeur">'
465
+        . ($predef[2]
466
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
467
+            : fieldset(
468
+                _T('entree_login_connexion_1'),
469
+                [
470
+                    'login_db' => [
471
+                        'label' => $login[1],
472
+                        'valeur' => $login[0]
473
+                    ],
474
+                ]
475
+            )
476
+        )
477
+        . '</div>'
478
+
479
+        . '<div id="install_pass_base_hebergeur">'
480
+        . ($predef[3]
481
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
482
+            : fieldset(
483
+                _T('entree_mot_passe_1'),
484
+                [
485
+                    'pass_db' => [
486
+                        'label' => $pass[1],
487
+                        'valeur' => $pass[0]
488
+                    ],
489
+                ]
490
+            )
491
+        )
492
+        . '</div>'
493
+
494
+        . bouton_suivant()));
495 495
 }
496 496
 
497 497
 // 4 valeurs qu'on reconduit d'un script a l'autre
498 498
 // sauf s'ils sont predefinis.
499 499
 
500 500
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
501
-	return ((defined('_INSTALL_HOST_DB'))
502
-		? ''
503
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
504
-	)
505
-	. ((defined('_INSTALL_USER_DB'))
506
-		? ''
507
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
508
-	)
509
-	. ((defined('_INSTALL_PASS_DB'))
510
-		? ''
511
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
512
-	)
513
-
514
-	. ((defined('_INSTALL_SERVER_DB'))
515
-		? ''
516
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
517
-	);
501
+    return ((defined('_INSTALL_HOST_DB'))
502
+        ? ''
503
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
504
+    )
505
+    . ((defined('_INSTALL_USER_DB'))
506
+        ? ''
507
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
508
+    )
509
+    . ((defined('_INSTALL_PASS_DB'))
510
+        ? ''
511
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
512
+    )
513
+
514
+    . ((defined('_INSTALL_SERVER_DB'))
515
+        ? ''
516
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
517
+    );
518 518
 }
519 519
 
520 520
 // presentation des bases existantes
521 521
 
522 522
 function install_etape_liste_bases($server_db, $login_db, $disabled = []) {
523
-	$bases = $checked = [];
524
-	$noms = sql_listdbs($server_db);
525
-	if (!$noms) {
526
-		return '';
527
-	}
528
-
529
-	foreach ($noms as $nom) {
530
-		$id = spip_htmlspecialchars($nom);
531
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
532
-		$base = ' name="choix_db" value="'
533
-			. $nom
534
-			. '"'
535
-			. $dis
536
-			. " type='radio' id='$id'";
537
-		$label = "<label for='$id'>"
538
-			. ($dis ? "<i>$nom</i>" : $nom)
539
-			. '</label>';
540
-
541
-		if (
542
-			!$checked and !$dis and
543
-			(($nom == $login_db) or
544
-				($GLOBALS['table_prefix'] == $nom))
545
-		) {
546
-			$checked = "<input$base checked='checked' />\n$label";
547
-		} else {
548
-			$bases[] = "<input$base />\n$label";
549
-		}
550
-	}
551
-
552
-	if (!$bases && !$checked) {
553
-		return false;
554
-	}
555
-
556
-	if ($checked) {
557
-		array_unshift($bases, $checked);
558
-		$checked = true;
559
-	}
560
-
561
-	return [$checked, $bases];
523
+    $bases = $checked = [];
524
+    $noms = sql_listdbs($server_db);
525
+    if (!$noms) {
526
+        return '';
527
+    }
528
+
529
+    foreach ($noms as $nom) {
530
+        $id = spip_htmlspecialchars($nom);
531
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
532
+        $base = ' name="choix_db" value="'
533
+            . $nom
534
+            . '"'
535
+            . $dis
536
+            . " type='radio' id='$id'";
537
+        $label = "<label for='$id'>"
538
+            . ($dis ? "<i>$nom</i>" : $nom)
539
+            . '</label>';
540
+
541
+        if (
542
+            !$checked and !$dis and
543
+            (($nom == $login_db) or
544
+                ($GLOBALS['table_prefix'] == $nom))
545
+        ) {
546
+            $checked = "<input$base checked='checked' />\n$label";
547
+        } else {
548
+            $bases[] = "<input$base />\n$label";
549
+        }
550
+    }
551
+
552
+    if (!$bases && !$checked) {
553
+        return false;
554
+    }
555
+
556
+    if ($checked) {
557
+        array_unshift($bases, $checked);
558
+        $checked = true;
559
+    }
560
+
561
+    return [$checked, $bases];
562 562
 }
563 563
 
564 564
 function install_propager($hidden) {
565
-	$res = '';
566
-	foreach ($hidden as $k) {
567
-		$v = spip_htmlentities(_request($k));
568
-		$res .= "<input type='hidden' name='$k' value='$v' />";
569
-	}
565
+    $res = '';
566
+    foreach ($hidden as $k) {
567
+        $v = spip_htmlentities(_request($k));
568
+        $res .= "<input type='hidden' name='$k' value='$v' />";
569
+    }
570 570
 
571
-	return $res;
571
+    return $res;
572 572
 }
Please login to merge, or discard this patch.
ecrire/action/editer_rubrique.php 2 patches
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Rubriques\Edition
17 17
  */
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/rubriques');
@@ -38,34 +38,34 @@  discard block
 block discarded – undo
38 38
  */
39 39
 function action_editer_rubrique_dist($arg = null) {
40 40
 
41
-	if (is_null($arg)) {
42
-		$securiser_action = charger_fonction('securiser_action', 'inc');
43
-		$arg = $securiser_action();
44
-	}
45
-
46
-	if (!$id_rubrique = intval($arg)) {
47
-		if ($arg != 'oui') {
48
-			include_spip('inc/headers');
49
-			redirige_url_ecrire();
50
-		}
51
-		$id_rubrique = rubrique_inserer(_request('id_parent'));
52
-	}
53
-
54
-	$err = rubrique_modifier($id_rubrique);
55
-
56
-	if (_request('redirect')) {
57
-		$redirect = parametre_url(
58
-			urldecode(_request('redirect')),
59
-			'id_rubrique',
60
-			$id_rubrique,
61
-			'&'
62
-		);
63
-
64
-		include_spip('inc/headers');
65
-		redirige_par_entete($redirect);
66
-	}
67
-
68
-	return [$id_rubrique, $err];
41
+    if (is_null($arg)) {
42
+        $securiser_action = charger_fonction('securiser_action', 'inc');
43
+        $arg = $securiser_action();
44
+    }
45
+
46
+    if (!$id_rubrique = intval($arg)) {
47
+        if ($arg != 'oui') {
48
+            include_spip('inc/headers');
49
+            redirige_url_ecrire();
50
+        }
51
+        $id_rubrique = rubrique_inserer(_request('id_parent'));
52
+    }
53
+
54
+    $err = rubrique_modifier($id_rubrique);
55
+
56
+    if (_request('redirect')) {
57
+        $redirect = parametre_url(
58
+            urldecode(_request('redirect')),
59
+            'id_rubrique',
60
+            $id_rubrique,
61
+            '&'
62
+        );
63
+
64
+        include_spip('inc/headers');
65
+        redirige_par_entete($redirect);
66
+    }
67
+
68
+    return [$id_rubrique, $err];
69 69
 }
70 70
 
71 71
 
@@ -80,42 +80,42 @@  discard block
 block discarded – undo
80 80
  *     Identifiant de la rubrique crée
81 81
  */
82 82
 function rubrique_inserer($id_parent, $set = null) {
83
-	$champs = [
84
-		'titre' => _T('item_nouvelle_rubrique'),
85
-		'id_parent' => intval($id_parent),
86
-		'statut' => 'prepa'
87
-	];
88
-
89
-	if ($set) {
90
-		$champs = array_merge($champs, $set);
91
-	}
92
-
93
-	// Envoyer aux plugins
94
-	$champs = pipeline(
95
-		'pre_insertion',
96
-		[
97
-			'args' => [
98
-				'table' => 'spip_rubriques',
99
-			],
100
-			'data' => $champs
101
-		]
102
-	);
103
-
104
-	$id_rubrique = sql_insertq('spip_rubriques', $champs);
105
-	pipeline(
106
-		'post_insertion',
107
-		[
108
-			'args' => [
109
-				'table' => 'spip_rubriques',
110
-				'id_objet' => $id_rubrique
111
-			],
112
-			'data' => $champs
113
-		]
114
-	);
115
-	propager_les_secteurs();
116
-	calculer_langues_rubriques();
117
-
118
-	return $id_rubrique;
83
+    $champs = [
84
+        'titre' => _T('item_nouvelle_rubrique'),
85
+        'id_parent' => intval($id_parent),
86
+        'statut' => 'prepa'
87
+    ];
88
+
89
+    if ($set) {
90
+        $champs = array_merge($champs, $set);
91
+    }
92
+
93
+    // Envoyer aux plugins
94
+    $champs = pipeline(
95
+        'pre_insertion',
96
+        [
97
+            'args' => [
98
+                'table' => 'spip_rubriques',
99
+            ],
100
+            'data' => $champs
101
+        ]
102
+    );
103
+
104
+    $id_rubrique = sql_insertq('spip_rubriques', $champs);
105
+    pipeline(
106
+        'post_insertion',
107
+        [
108
+            'args' => [
109
+                'table' => 'spip_rubriques',
110
+                'id_objet' => $id_rubrique
111
+            ],
112
+            'data' => $champs
113
+        ]
114
+    );
115
+    propager_les_secteurs();
116
+    calculer_langues_rubriques();
117
+
118
+    return $id_rubrique;
119 119
 }
120 120
 
121 121
 /**
@@ -131,46 +131,46 @@  discard block
 block discarded – undo
131 131
  *     - chaîne : Texte d'un message d'erreur
132 132
  */
133 133
 function rubrique_modifier($id_rubrique, $set = null) {
134
-	include_spip('inc/autoriser');
135
-	include_spip('inc/filtres');
136
-
137
-	include_spip('inc/modifier');
138
-	$c = collecter_requests(
139
-		// include list
140
-		objet_info('rubrique', 'champs_editables'),
141
-		// exclude list
142
-		['id_parent', 'confirme_deplace'],
143
-		// donnees eventuellement fournies
144
-		$set
145
-	);
146
-
147
-	if (
148
-		$err = objet_modifier_champs(
149
-			'rubrique',
150
-			$id_rubrique,
151
-			[
152
-			'data' => $set,
153
-			'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique]
154
-			],
155
-			$c
156
-		)
157
-	) {
158
-		return $err;
159
-	}
160
-
161
-	$c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set);
162
-	// Deplacer la rubrique
163
-	if (isset($c['id_parent'])) {
164
-		$err = rubrique_instituer($id_rubrique, $c);
165
-	}
166
-
167
-	// invalider les caches marques de cette rubrique
168
-	include_spip('inc/invalideur');
169
-	suivre_invalideur("id='rubrique/$id_rubrique'");
170
-	// et celui de menu_rubriques
171
-	effacer_meta('date_calcul_rubriques');
172
-
173
-	return $err;
134
+    include_spip('inc/autoriser');
135
+    include_spip('inc/filtres');
136
+
137
+    include_spip('inc/modifier');
138
+    $c = collecter_requests(
139
+        // include list
140
+        objet_info('rubrique', 'champs_editables'),
141
+        // exclude list
142
+        ['id_parent', 'confirme_deplace'],
143
+        // donnees eventuellement fournies
144
+        $set
145
+    );
146
+
147
+    if (
148
+        $err = objet_modifier_champs(
149
+            'rubrique',
150
+            $id_rubrique,
151
+            [
152
+            'data' => $set,
153
+            'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique]
154
+            ],
155
+            $c
156
+        )
157
+    ) {
158
+        return $err;
159
+    }
160
+
161
+    $c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set);
162
+    // Deplacer la rubrique
163
+    if (isset($c['id_parent'])) {
164
+        $err = rubrique_instituer($id_rubrique, $c);
165
+    }
166
+
167
+    // invalider les caches marques de cette rubrique
168
+    include_spip('inc/invalideur');
169
+    suivre_invalideur("id='rubrique/$id_rubrique'");
170
+    // et celui de menu_rubriques
171
+    effacer_meta('date_calcul_rubriques');
172
+
173
+    return $err;
174 174
 }
175 175
 
176 176
 /**
@@ -193,25 +193,25 @@  discard block
 block discarded – undo
193 193
  *     false si la confirmation du déplacement n'est pas présente
194 194
  */
195 195
 function editer_rubrique_breves($id_rubrique, $id_parent, $c = []) {
196
-	if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) {
197
-		return true;
198
-	}
199
-
200
-	if (empty($c['confirme_deplace']) or $c['confirme_deplace'] != 'oui') {
201
-		return false;
202
-	}
203
-
204
-	if (
205
-		$id_secteur = sql_getfetsel(
206
-			'id_secteur',
207
-			'spip_rubriques',
208
-			"id_rubrique=$id_parent"
209
-		)
210
-	) {
211
-		sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique");
212
-	}
213
-
214
-	return true;
196
+    if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) {
197
+        return true;
198
+    }
199
+
200
+    if (empty($c['confirme_deplace']) or $c['confirme_deplace'] != 'oui') {
201
+        return false;
202
+    }
203
+
204
+    if (
205
+        $id_secteur = sql_getfetsel(
206
+            'id_secteur',
207
+            'spip_rubriques',
208
+            "id_rubrique=$id_parent"
209
+        )
210
+    ) {
211
+        sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique");
212
+    }
213
+
214
+    return true;
215 215
 }
216 216
 
217 217
 
@@ -233,50 +233,50 @@  discard block
 block discarded – undo
233 233
  *     Chaîne : Texte du message d'erreur
234 234
  */
235 235
 function rubrique_instituer($id_rubrique, $c) {
236
-	// traitement de la rubrique parente
237
-	// interdiction de deplacer vers ou a partir d'une rubrique
238
-	// qu'on n'administre pas.
239
-
240
-	if (null !== ($id_parent = $c['id_parent'])) {
241
-		$id_parent = intval($id_parent);
242
-		$filles = calcul_branche_in($id_rubrique);
243
-		if (strpos(",$id_parent,", (string) ",$filles,") !== false) {
244
-			spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent");
245
-		} else {
246
-			$s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique");
247
-			$old_parent = $s['id_parent'];
248
-
249
-			if (
250
-				!($id_parent != $old_parent
251
-				and autoriser('publierdans', 'rubrique', $id_parent)
252
-				and autoriser('creerrubriquedans', 'rubrique', $id_parent)
253
-				and autoriser('publierdans', 'rubrique', $old_parent)
254
-				)
255
-			) {
256
-				if ($s['statut'] != 'prepa') {
257
-					spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']);
258
-				}
259
-			} elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) {
260
-				$statut_ancien = $s['statut'];
261
-				sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique");
262
-
263
-
264
-				propager_les_secteurs();
265
-
266
-				// Deplacement d'une rubrique publiee ==> chgt general de leur statut
267
-				if ($statut_ancien == 'publie') {
268
-					calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]);
269
-				}
270
-				// Creation ou deplacement d'une rubrique non publiee
271
-				// invalider le cache de leur menu
272
-				elseif (!$statut_ancien || $old_parent != $id_parent) {
273
-					effacer_meta('date_calcul_rubriques');
274
-				}
275
-
276
-				calculer_langues_rubriques();
277
-			}
278
-		}
279
-	}
280
-
281
-	return ''; // pas d'erreur
236
+    // traitement de la rubrique parente
237
+    // interdiction de deplacer vers ou a partir d'une rubrique
238
+    // qu'on n'administre pas.
239
+
240
+    if (null !== ($id_parent = $c['id_parent'])) {
241
+        $id_parent = intval($id_parent);
242
+        $filles = calcul_branche_in($id_rubrique);
243
+        if (strpos(",$id_parent,", (string) ",$filles,") !== false) {
244
+            spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent");
245
+        } else {
246
+            $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique");
247
+            $old_parent = $s['id_parent'];
248
+
249
+            if (
250
+                !($id_parent != $old_parent
251
+                and autoriser('publierdans', 'rubrique', $id_parent)
252
+                and autoriser('creerrubriquedans', 'rubrique', $id_parent)
253
+                and autoriser('publierdans', 'rubrique', $old_parent)
254
+                )
255
+            ) {
256
+                if ($s['statut'] != 'prepa') {
257
+                    spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']);
258
+                }
259
+            } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) {
260
+                $statut_ancien = $s['statut'];
261
+                sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique");
262
+
263
+
264
+                propager_les_secteurs();
265
+
266
+                // Deplacement d'une rubrique publiee ==> chgt general de leur statut
267
+                if ($statut_ancien == 'publie') {
268
+                    calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]);
269
+                }
270
+                // Creation ou deplacement d'une rubrique non publiee
271
+                // invalider le cache de leur menu
272
+                elseif (!$statut_ancien || $old_parent != $id_parent) {
273
+                    effacer_meta('date_calcul_rubriques');
274
+                }
275
+
276
+                calculer_langues_rubriques();
277
+            }
278
+        }
279
+    }
280
+
281
+    return ''; // pas d'erreur
282 282
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			$id_rubrique,
151 151
 			[
152 152
 			'data' => $set,
153
-			'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique]
153
+			'nonvide' => ['titre' => _T('titre_nouvelle_rubrique').' '._T('info_numero_abbreviation').$id_rubrique]
154 154
 			],
155 155
 			$c
156 156
 		)
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 				)
255 255
 			) {
256 256
 				if ($s['statut'] != 'prepa') {
257
-					spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']);
257
+					spip_log("deplacement de $id_rubrique vers $id_parent refuse a ".$GLOBALS['visiteur_session']['id_auteur'].' '.$GLOBALS['visiteur_session']['statut']);
258 258
 				}
259 259
 			} elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) {
260 260
 				$statut_ancien = $s['statut'];
Please login to merge, or discard this patch.
ecrire/inc/filtres_dates.php 2 patches
Indentation   +580 added lines, -580 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
  *    Date au format SQL tel que `2008-04-01` sinon ''
38 38
  **/
39 39
 function extraire_date($texte): string {
40
-	// format = 2001-08
41
-	if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) {
42
-		return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01';
43
-	}
44
-	return '';
40
+    // format = 2001-08
41
+    if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) {
42
+        return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01';
43
+    }
44
+    return '';
45 45
 }
46 46
 
47 47
 
@@ -63,29 +63,29 @@  discard block
 block discarded – undo
63 63
  *     - une chaîne vide si la date est considérée nulle
64 64
  **/
65 65
 function normaliser_date($date, $forcer_jour = false): string {
66
-	$date = vider_date($date);
67
-	if ($date) {
68
-		if (preg_match('/^[0-9]{8,10}$/', $date)) {
69
-			$date = date('Y-m-d H:i:s', $date);
70
-		}
71
-		if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
72
-			$regs = array_pad($regs, 4, null); // eviter notice php
73
-			$date = $regs[1] . '-00-00' . $regs[3];
74
-		} else {
75
-			if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
76
-				$regs = array_pad($regs, 4, null); // eviter notice php
77
-				$date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3];
78
-			} else {
79
-				$date = date('Y-m-d H:i:s', strtotime($date));
80
-			}
81
-		}
82
-
83
-		if ($forcer_jour) {
84
-			$date = str_replace('-00', '-01', $date);
85
-		}
86
-	}
87
-
88
-	return $date;
66
+    $date = vider_date($date);
67
+    if ($date) {
68
+        if (preg_match('/^[0-9]{8,10}$/', $date)) {
69
+            $date = date('Y-m-d H:i:s', $date);
70
+        }
71
+        if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
72
+            $regs = array_pad($regs, 4, null); // eviter notice php
73
+            $date = $regs[1] . '-00-00' . $regs[3];
74
+        } else {
75
+            if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
76
+                $regs = array_pad($regs, 4, null); // eviter notice php
77
+                $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3];
78
+            } else {
79
+                $date = date('Y-m-d H:i:s', strtotime($date));
80
+            }
81
+        }
82
+
83
+        if ($forcer_jour) {
84
+            $date = str_replace('-00', '-01', $date);
85
+        }
86
+    }
87
+
88
+    return $date;
89 89
 }
90 90
 
91 91
 /**
@@ -98,23 +98,23 @@  discard block
 block discarded – undo
98 98
  *     - Une chaine vide
99 99
  **/
100 100
 function vider_date($letexte, $verif_format_date = false): string {
101
-	$letexte ??= '';
102
-	if (
103
-		!$verif_format_date
104
-		or (in_array(strlen($letexte), [10,19]) and
105
-			  preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte))
106
-	) {
107
-		if (strncmp('0000-00-00', $letexte, 10) == 0) {
108
-			return '';
109
-		}
110
-		if (strncmp('0001-01-01', $letexte, 10) == 0) {
111
-			return '';
112
-		}
113
-		if (strncmp('1970-01-01', $letexte, 10) == 0) {
114
-			return '';
115
-		}  // eviter le bug GMT-1
116
-	}
117
-	return $letexte;
101
+    $letexte ??= '';
102
+    if (
103
+        !$verif_format_date
104
+        or (in_array(strlen($letexte), [10,19]) and
105
+              preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte))
106
+    ) {
107
+        if (strncmp('0000-00-00', $letexte, 10) == 0) {
108
+            return '';
109
+        }
110
+        if (strncmp('0001-01-01', $letexte, 10) == 0) {
111
+            return '';
112
+        }
113
+        if (strncmp('1970-01-01', $letexte, 10) == 0) {
114
+            return '';
115
+        }  // eviter le bug GMT-1
116
+    }
117
+    return $letexte;
118 118
 }
119 119
 
120 120
 /**
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
  **/
131 131
 function recup_heure($date): array {
132 132
 
133
-	static $d = [0, 0, 0];
134
-	if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) {
135
-		return $d;
136
-	}
133
+    static $d = [0, 0, 0];
134
+    if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) {
135
+        return $d;
136
+    }
137 137
 
138
-	array_shift($r);
138
+    array_shift($r);
139 139
 
140
-	return $r;
140
+    return $r;
141 141
 }
142 142
 
143 143
 /**
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
  * @return string heures, sinon 0
152 152
  **/
153 153
 function heures($numdate): string {
154
-	$heures = null;
155
-	$date_array = recup_heure($numdate);
156
-	if ($date_array) {
157
-		[$heures, $minutes, $secondes] = $date_array;
158
-	}
154
+    $heures = null;
155
+    $date_array = recup_heure($numdate);
156
+    if ($date_array) {
157
+        [$heures, $minutes, $secondes] = $date_array;
158
+    }
159 159
 
160
-	return $heures;
160
+    return $heures;
161 161
 }
162 162
 
163 163
 /**
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
  * @return string minutes, sinon 0
172 172
  **/
173 173
 function minutes($numdate): string {
174
-	$minutes = null;
175
-	$date_array = recup_heure($numdate);
176
-	if ($date_array) {
177
-		[$heures, $minutes, $secondes] = $date_array;
178
-	}
174
+    $minutes = null;
175
+    $date_array = recup_heure($numdate);
176
+    if ($date_array) {
177
+        [$heures, $minutes, $secondes] = $date_array;
178
+    }
179 179
 
180
-	return $minutes;
180
+    return $minutes;
181 181
 }
182 182
 
183 183
 /**
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
  * @return string secondes, sinon 0
192 192
  **/
193 193
 function secondes($numdate): string {
194
-	$secondes = null;
195
-	$date_array = recup_heure($numdate);
196
-	if ($date_array) {
197
-		[$heures, $minutes, $secondes] = $date_array;
198
-	}
194
+    $secondes = null;
195
+    $date_array = recup_heure($numdate);
196
+    if ($date_array) {
197
+        [$heures, $minutes, $secondes] = $date_array;
198
+    }
199 199
 
200
-	return $secondes;
200
+    return $secondes;
201 201
 }
202 202
 
203 203
 /**
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
  * @return string L'heure formatée dans la langue en cours.
217 217
  **/
218 218
 function heures_minutes($numdate, $forme = ''): string {
219
-	if ($forme !== 'abbr') {
220
-		return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]);
221
-	} else {
222
-		return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]);
223
-	}
219
+    if ($forme !== 'abbr') {
220
+        return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]);
221
+    } else {
222
+        return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]);
223
+    }
224 224
 }
225 225
 
226 226
 /**
@@ -245,57 +245,57 @@  discard block
 block discarded – undo
245 245
  * @return array [année, mois, jour, heures, minutes, secondes] ou []
246 246
  **/
247 247
 function recup_date($numdate, $forcer_jour = true): array {
248
-	if (!$numdate) {
249
-		return [];
250
-	}
251
-	$heures = $minutes = $secondes = 0;
252
-	if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) {
253
-		$jour = $regs[1];
254
-		$mois = $regs[2];
255
-		$annee = $regs[3];
256
-		if ($annee < 90) {
257
-			$annee = 2000 + $annee;
258
-		} elseif ($annee < 100) {
259
-			$annee = 1900 + $annee;
260
-		}
261
-		[$heures, $minutes, $secondes] = recup_heure($numdate);
262
-	} elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) {
263
-		$annee = $regs[1];
264
-		$mois = $regs[2];
265
-		$jour = $regs[3];
266
-		[$heures, $minutes, $secondes] = recup_heure($numdate);
267
-	} elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) {
268
-		$annee = $regs[1];
269
-		$mois = $regs[2];
270
-		$jour = '';
271
-		[$heures, $minutes, $secondes] = recup_heure($numdate);
272
-	} elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) {
273
-		$annee = $regs[1];
274
-		$mois = $regs[2];
275
-		$jour = $regs[3];
276
-		$heures = $regs[4];
277
-		$minutes = $regs[5];
278
-		$secondes = $regs[6];
279
-	} else {
280
-		$annee = $mois = $jour = '';
281
-	}
282
-	if ($annee > 4000) {
283
-		$annee -= 9000;
284
-	}
285
-	if (strlen($jour) and substr($jour, 0, 1) == '0') {
286
-		$jour = substr($jour, 1);
287
-	}
288
-
289
-	if ($forcer_jour and $jour == '0') {
290
-		$jour = '1';
291
-	}
292
-	if ($forcer_jour and $mois == '0') {
293
-		$mois = '1';
294
-	}
295
-	if ($annee or $mois or $jour or $heures or $minutes or $secondes) {
296
-		return [$annee, $mois, $jour, $heures, $minutes, $secondes];
297
-	}
298
-	return [];
248
+    if (!$numdate) {
249
+        return [];
250
+    }
251
+    $heures = $minutes = $secondes = 0;
252
+    if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) {
253
+        $jour = $regs[1];
254
+        $mois = $regs[2];
255
+        $annee = $regs[3];
256
+        if ($annee < 90) {
257
+            $annee = 2000 + $annee;
258
+        } elseif ($annee < 100) {
259
+            $annee = 1900 + $annee;
260
+        }
261
+        [$heures, $minutes, $secondes] = recup_heure($numdate);
262
+    } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) {
263
+        $annee = $regs[1];
264
+        $mois = $regs[2];
265
+        $jour = $regs[3];
266
+        [$heures, $minutes, $secondes] = recup_heure($numdate);
267
+    } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) {
268
+        $annee = $regs[1];
269
+        $mois = $regs[2];
270
+        $jour = '';
271
+        [$heures, $minutes, $secondes] = recup_heure($numdate);
272
+    } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) {
273
+        $annee = $regs[1];
274
+        $mois = $regs[2];
275
+        $jour = $regs[3];
276
+        $heures = $regs[4];
277
+        $minutes = $regs[5];
278
+        $secondes = $regs[6];
279
+    } else {
280
+        $annee = $mois = $jour = '';
281
+    }
282
+    if ($annee > 4000) {
283
+        $annee -= 9000;
284
+    }
285
+    if (strlen($jour) and substr($jour, 0, 1) == '0') {
286
+        $jour = substr($jour, 1);
287
+    }
288
+
289
+    if ($forcer_jour and $jour == '0') {
290
+        $jour = '1';
291
+    }
292
+    if ($forcer_jour and $mois == '0') {
293
+        $mois = '1';
294
+    }
295
+    if ($annee or $mois or $jour or $heures or $minutes or $secondes) {
296
+        return [$annee, $mois, $jour, $heures, $minutes, $secondes];
297
+    }
298
+    return [];
299 299
 }
300 300
 
301 301
 /**
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
  *     La date relative ou complète
323 323
  **/
324 324
 function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */): string {
325
-	return sinon(
326
-		date_relative($date, $decalage_maxi),
327
-		affdate_heure($date)
328
-	);
325
+    return sinon(
326
+        date_relative($date, $decalage_maxi),
327
+        affdate_heure($date)
328
+    );
329 329
 }
330 330
 
331 331
 /**
@@ -358,86 +358,86 @@  discard block
 block discarded – undo
358 358
  **/
359 359
 function date_relative($date, $decalage_maxi = 0, $ref_date = null): string {
360 360
 
361
-	if (!$date) {
362
-		return '';
363
-	}
364
-
365
-	if (is_null($ref_date)) {
366
-		$ref_time = time();
367
-	} else {
368
-		$ref_time = strtotime($ref_date);
369
-	}
370
-
371
-	$decal = date('U', $ref_time) - date('U', strtotime($date));
372
-
373
-	if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) {
374
-		return '';
375
-	}
376
-
377
-	if ($decal < 0) {
378
-		$il_y_a = 'date_dans';
379
-		$decal = -1 * $decal;
380
-	} else {
381
-		$il_y_a = 'date_il_y_a';
382
-	}
383
-
384
-	if ($decal > 3600 * 24 * 30 * 6) {
385
-		return affdate_court($date);
386
-	}
387
-
388
-	if ($decal > 3600 * 24 * 30) {
389
-		$mois = floor($decal / (3600 * 24 * 30));
390
-		if ($mois < 2) {
391
-			$delai = "$mois " . _T('date_un_mois');
392
-		} else {
393
-			$delai = "$mois " . _T('date_mois');
394
-		}
395
-	} else {
396
-		if ($decal > 3600 * 24 * 7) {
397
-			$semaines = floor($decal / (3600 * 24 * 7));
398
-			if ($semaines < 2) {
399
-				$delai = "$semaines " . _T('date_une_semaine');
400
-			} else {
401
-				$delai = "$semaines " . _T('date_semaines');
402
-			}
403
-		} else {
404
-			if ($decal > 3600 * 24) {
405
-				$jours = floor($decal / (3600 * 24));
406
-				if ($jours < 2) {
407
-					return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier');
408
-				} else {
409
-					$delai = "$jours " . _T('date_jours');
410
-				}
411
-			} else {
412
-				if ($decal >= 3600) {
413
-					$heures = floor($decal / 3600);
414
-					if ($heures < 2) {
415
-						$delai = "$heures " . _T('date_une_heure');
416
-					} else {
417
-						$delai = "$heures " . _T('date_heures');
418
-					}
419
-				} else {
420
-					if ($decal >= 60) {
421
-						$minutes = floor($decal / 60);
422
-						if ($minutes < 2) {
423
-							$delai = "$minutes " . _T('date_une_minute');
424
-						} else {
425
-							$delai = "$minutes " . _T('date_minutes');
426
-						}
427
-					} else {
428
-						$secondes = ceil($decal);
429
-						if ($secondes < 2) {
430
-							$delai = "$secondes " . _T('date_une_seconde');
431
-						} else {
432
-							$delai = "$secondes " . _T('date_secondes');
433
-						}
434
-					}
435
-				}
436
-			}
437
-		}
438
-	}
439
-
440
-	return _T($il_y_a, ['delai' => $delai]);
361
+    if (!$date) {
362
+        return '';
363
+    }
364
+
365
+    if (is_null($ref_date)) {
366
+        $ref_time = time();
367
+    } else {
368
+        $ref_time = strtotime($ref_date);
369
+    }
370
+
371
+    $decal = date('U', $ref_time) - date('U', strtotime($date));
372
+
373
+    if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) {
374
+        return '';
375
+    }
376
+
377
+    if ($decal < 0) {
378
+        $il_y_a = 'date_dans';
379
+        $decal = -1 * $decal;
380
+    } else {
381
+        $il_y_a = 'date_il_y_a';
382
+    }
383
+
384
+    if ($decal > 3600 * 24 * 30 * 6) {
385
+        return affdate_court($date);
386
+    }
387
+
388
+    if ($decal > 3600 * 24 * 30) {
389
+        $mois = floor($decal / (3600 * 24 * 30));
390
+        if ($mois < 2) {
391
+            $delai = "$mois " . _T('date_un_mois');
392
+        } else {
393
+            $delai = "$mois " . _T('date_mois');
394
+        }
395
+    } else {
396
+        if ($decal > 3600 * 24 * 7) {
397
+            $semaines = floor($decal / (3600 * 24 * 7));
398
+            if ($semaines < 2) {
399
+                $delai = "$semaines " . _T('date_une_semaine');
400
+            } else {
401
+                $delai = "$semaines " . _T('date_semaines');
402
+            }
403
+        } else {
404
+            if ($decal > 3600 * 24) {
405
+                $jours = floor($decal / (3600 * 24));
406
+                if ($jours < 2) {
407
+                    return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier');
408
+                } else {
409
+                    $delai = "$jours " . _T('date_jours');
410
+                }
411
+            } else {
412
+                if ($decal >= 3600) {
413
+                    $heures = floor($decal / 3600);
414
+                    if ($heures < 2) {
415
+                        $delai = "$heures " . _T('date_une_heure');
416
+                    } else {
417
+                        $delai = "$heures " . _T('date_heures');
418
+                    }
419
+                } else {
420
+                    if ($decal >= 60) {
421
+                        $minutes = floor($decal / 60);
422
+                        if ($minutes < 2) {
423
+                            $delai = "$minutes " . _T('date_une_minute');
424
+                        } else {
425
+                            $delai = "$minutes " . _T('date_minutes');
426
+                        }
427
+                    } else {
428
+                        $secondes = ceil($decal);
429
+                        if ($secondes < 2) {
430
+                            $delai = "$secondes " . _T('date_une_seconde');
431
+                        } else {
432
+                            $delai = "$secondes " . _T('date_secondes');
433
+                        }
434
+                    }
435
+                }
436
+            }
437
+        }
438
+    }
439
+
440
+    return _T($il_y_a, ['delai' => $delai]);
441 441
 }
442 442
 
443 443
 
@@ -463,32 +463,32 @@  discard block
 block discarded – undo
463 463
  **/
464 464
 function date_relativecourt($date, $decalage_maxi = 0): string {
465 465
 
466
-	if (!$date) {
467
-		return '';
468
-	}
469
-	$decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date))));
470
-
471
-	if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) {
472
-		return '';
473
-	}
474
-
475
-	if ($decal < -24 * 3600) {
476
-		$retour = date_relative($date, $decalage_maxi);
477
-	} elseif ($decal < 0) {
478
-		$retour = _T('date_demain');
479
-	} else {
480
-		if ($decal < (3600 * 24)) {
481
-			$retour = _T('date_aujourdhui');
482
-		} else {
483
-			if ($decal < (3600 * 24 * 2)) {
484
-				$retour = _T('date_hier');
485
-			} else {
486
-				$retour = date_relative($date, $decalage_maxi);
487
-			}
488
-		}
489
-	}
490
-
491
-	return $retour;
466
+    if (!$date) {
467
+        return '';
468
+    }
469
+    $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date))));
470
+
471
+    if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) {
472
+        return '';
473
+    }
474
+
475
+    if ($decal < -24 * 3600) {
476
+        $retour = date_relative($date, $decalage_maxi);
477
+    } elseif ($decal < 0) {
478
+        $retour = _T('date_demain');
479
+    } else {
480
+        if ($decal < (3600 * 24)) {
481
+            $retour = _T('date_aujourdhui');
482
+        } else {
483
+            if ($decal < (3600 * 24 * 2)) {
484
+                $retour = _T('date_hier');
485
+            } else {
486
+                $retour = date_relative($date, $decalage_maxi);
487
+            }
488
+        }
489
+    }
490
+
491
+    return $retour;
492 492
 }
493 493
 
494 494
 /**
@@ -505,174 +505,174 @@  discard block
 block discarded – undo
505 505
  * @return string
506 506
  */
507 507
 function affdate_base($numdate, $vue, $options = []): string {
508
-	if (is_string($options)) {
509
-		$options = ['param' => $options];
510
-	}
511
-	$date_array = recup_date($numdate, false);
512
-	if (!$date_array) {
513
-		return '';
514
-	}
515
-	[$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array;
516
-
517
-	// 1er, 21st, etc.
518
-	$journum = $jour;
519
-
520
-	if ($jour == 0) {
521
-		$jour = '';
522
-		$njour = 0;
523
-	} else {
524
-		$njour = intval($jour);
525
-		if ($jourth = _T('date_jnum' . $jour)) {
526
-			$jour = $jourth;
527
-		}
528
-	}
529
-
530
-	$mois = intval($mois);
531
-	if ($mois > 0 and $mois < 13) {
532
-		/* Traiter le cas "abbr" pour les noms de mois */
533
-		$param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : '');
534
-		$nommois = _T('date_mois_' . $mois . $param);
535
-		if ($jour) {
536
-			$jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]);
537
-		} else {
538
-			$jourmois = $nommois;
539
-		}
540
-	} else {
541
-		$nommois = '';
542
-		$jourmois = '';
543
-	}
544
-
545
-	if ($annee < 0) {
546
-		$annee = -$annee . ' ' . _T('date_avant_jc');
547
-		$avjc = true;
548
-	} else {
549
-		$avjc = false;
550
-	}
551
-
552
-	switch ($vue) {
553
-		case 'saison':
554
-		case 'saison_annee':
555
-			$saison = '';
556
-			if ($mois > 0) {
557
-				$saison = ($options['param'] == 'sud') ? 3 : 1;
558
-				if (($mois == 3 and $jour >= 21) or $mois > 3) {
559
-					$saison = ($options['param'] == 'sud') ? 4 : 2;
560
-				}
561
-				if (($mois == 6 and $jour >= 21) or $mois > 6) {
562
-					$saison = ($options['param'] == 'sud') ? 1 : 3;
563
-				}
564
-				if (($mois == 9 and $jour >= 21) or $mois > 9) {
565
-					$saison = ($options['param'] == 'sud') ? 2 : 4;
566
-				}
567
-				if (($mois == 12 and $jour >= 21) or $mois > 12) {
568
-					$saison = ($options['param'] == 'sud') ? 3 : 1;
569
-				}
570
-			}
571
-			if ($vue == 'saison') {
572
-				return $saison ? _T('date_saison_' . $saison) : '';
573
-			} else {
574
-				return $saison ? trim(_T(
575
-					'date_fmt_saison_annee',
576
-					['saison' => _T('date_saison_' . $saison), 'annee' => $annee]
577
-				)) : '';
578
-			}
579
-
580
-		case 'court':
581
-			if ($avjc) {
582
-				return $annee;
583
-			}
584
-			$a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y'));
585
-			if ($annee < ($a - 100) or $annee > ($a + 100)) {
586
-				return $annee;
587
-			}
588
-			if ($annee != $a) {
589
-				return _T(
590
-					'date_fmt_mois_annee',
591
-					['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee]
592
-				);
593
-			}
594
-
595
-			return _T(
596
-				'date_fmt_jour_mois',
597
-				['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
598
-			);
599
-
600
-		case 'jourcourt':
601
-			if ($avjc) {
602
-				return $annee;
603
-			}
604
-			$a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y'));
605
-			if ($annee < ($a - 100) or $annee > ($a + 100)) {
606
-				return $annee;
607
-			}
608
-			if ($annee != $a) {
609
-				return _T(
610
-					'date_fmt_jour_mois_annee',
611
-					['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
612
-				);
613
-			}
614
-
615
-			return _T(
616
-				'date_fmt_jour_mois',
617
-				['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
618
-			);
619
-
620
-		case 'entier':
621
-			if ($avjc) {
622
-				return $annee;
623
-			}
624
-			if ($jour) {
625
-				return _T(
626
-					'date_fmt_jour_mois_annee',
627
-					['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
628
-				);
629
-			} elseif ($mois) {
630
-				return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]));
631
-			} else {
632
-				return $annee;
633
-			}
634
-
635
-		case 'nom_mois':
636
-			return $nommois;
637
-
638
-		case 'mois':
639
-			return sprintf('%02s', $mois);
640
-
641
-		case 'jour':
642
-			return $jour;
643
-
644
-		case 'journum':
645
-			return $journum;
646
-
647
-		case 'nom_jour':
648
-			if (!$mois or !$njour) {
649
-				return '';
650
-			}
651
-			$nom = mktime(1, 1, 1, $mois, $njour, $annee);
652
-			$nom = 1 + (int) date('w', $nom);
653
-			$param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : '');
654
-
655
-			return _T('date_jour_' . $nom . $param);
656
-
657
-		case 'mois_annee':
658
-			if ($avjc) {
659
-				return $annee;
660
-			}
661
-
662
-			return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]));
663
-
664
-		case 'annee':
665
-			return $annee;
666
-
667
-		// Cas d'une vue non definie : retomber sur le format
668
-		// de date propose par http://www.php.net/date
669
-		default:
670
-			[$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array;
671
-			if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) {
672
-				$time = strtotime($numdate);
673
-			}
674
-			return date($vue, $time);
675
-	}
508
+    if (is_string($options)) {
509
+        $options = ['param' => $options];
510
+    }
511
+    $date_array = recup_date($numdate, false);
512
+    if (!$date_array) {
513
+        return '';
514
+    }
515
+    [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array;
516
+
517
+    // 1er, 21st, etc.
518
+    $journum = $jour;
519
+
520
+    if ($jour == 0) {
521
+        $jour = '';
522
+        $njour = 0;
523
+    } else {
524
+        $njour = intval($jour);
525
+        if ($jourth = _T('date_jnum' . $jour)) {
526
+            $jour = $jourth;
527
+        }
528
+    }
529
+
530
+    $mois = intval($mois);
531
+    if ($mois > 0 and $mois < 13) {
532
+        /* Traiter le cas "abbr" pour les noms de mois */
533
+        $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : '');
534
+        $nommois = _T('date_mois_' . $mois . $param);
535
+        if ($jour) {
536
+            $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]);
537
+        } else {
538
+            $jourmois = $nommois;
539
+        }
540
+    } else {
541
+        $nommois = '';
542
+        $jourmois = '';
543
+    }
544
+
545
+    if ($annee < 0) {
546
+        $annee = -$annee . ' ' . _T('date_avant_jc');
547
+        $avjc = true;
548
+    } else {
549
+        $avjc = false;
550
+    }
551
+
552
+    switch ($vue) {
553
+        case 'saison':
554
+        case 'saison_annee':
555
+            $saison = '';
556
+            if ($mois > 0) {
557
+                $saison = ($options['param'] == 'sud') ? 3 : 1;
558
+                if (($mois == 3 and $jour >= 21) or $mois > 3) {
559
+                    $saison = ($options['param'] == 'sud') ? 4 : 2;
560
+                }
561
+                if (($mois == 6 and $jour >= 21) or $mois > 6) {
562
+                    $saison = ($options['param'] == 'sud') ? 1 : 3;
563
+                }
564
+                if (($mois == 9 and $jour >= 21) or $mois > 9) {
565
+                    $saison = ($options['param'] == 'sud') ? 2 : 4;
566
+                }
567
+                if (($mois == 12 and $jour >= 21) or $mois > 12) {
568
+                    $saison = ($options['param'] == 'sud') ? 3 : 1;
569
+                }
570
+            }
571
+            if ($vue == 'saison') {
572
+                return $saison ? _T('date_saison_' . $saison) : '';
573
+            } else {
574
+                return $saison ? trim(_T(
575
+                    'date_fmt_saison_annee',
576
+                    ['saison' => _T('date_saison_' . $saison), 'annee' => $annee]
577
+                )) : '';
578
+            }
579
+
580
+        case 'court':
581
+            if ($avjc) {
582
+                return $annee;
583
+            }
584
+            $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y'));
585
+            if ($annee < ($a - 100) or $annee > ($a + 100)) {
586
+                return $annee;
587
+            }
588
+            if ($annee != $a) {
589
+                return _T(
590
+                    'date_fmt_mois_annee',
591
+                    ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee]
592
+                );
593
+            }
594
+
595
+            return _T(
596
+                'date_fmt_jour_mois',
597
+                ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
598
+            );
599
+
600
+        case 'jourcourt':
601
+            if ($avjc) {
602
+                return $annee;
603
+            }
604
+            $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y'));
605
+            if ($annee < ($a - 100) or $annee > ($a + 100)) {
606
+                return $annee;
607
+            }
608
+            if ($annee != $a) {
609
+                return _T(
610
+                    'date_fmt_jour_mois_annee',
611
+                    ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
612
+                );
613
+            }
614
+
615
+            return _T(
616
+                'date_fmt_jour_mois',
617
+                ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
618
+            );
619
+
620
+        case 'entier':
621
+            if ($avjc) {
622
+                return $annee;
623
+            }
624
+            if ($jour) {
625
+                return _T(
626
+                    'date_fmt_jour_mois_annee',
627
+                    ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]
628
+                );
629
+            } elseif ($mois) {
630
+                return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]));
631
+            } else {
632
+                return $annee;
633
+            }
634
+
635
+        case 'nom_mois':
636
+            return $nommois;
637
+
638
+        case 'mois':
639
+            return sprintf('%02s', $mois);
640
+
641
+        case 'jour':
642
+            return $jour;
643
+
644
+        case 'journum':
645
+            return $journum;
646
+
647
+        case 'nom_jour':
648
+            if (!$mois or !$njour) {
649
+                return '';
650
+            }
651
+            $nom = mktime(1, 1, 1, $mois, $njour, $annee);
652
+            $nom = 1 + (int) date('w', $nom);
653
+            $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : '');
654
+
655
+            return _T('date_jour_' . $nom . $param);
656
+
657
+        case 'mois_annee':
658
+            if ($avjc) {
659
+                return $annee;
660
+            }
661
+
662
+            return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee]));
663
+
664
+        case 'annee':
665
+            return $annee;
666
+
667
+        // Cas d'une vue non definie : retomber sur le format
668
+        // de date propose par http://www.php.net/date
669
+        default:
670
+            [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array;
671
+            if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) {
672
+                $time = strtotime($numdate);
673
+            }
674
+            return date($vue, $time);
675
+    }
676 676
 }
677 677
 
678 678
 
@@ -699,11 +699,11 @@  discard block
 block discarded – undo
699 699
  *     Nom du jour
700 700
  **/
701 701
 function nom_jour($numdate, $forme = ''): string {
702
-	if (!($forme === 'abbr' or $forme === 'initiale')) {
703
-		$forme = '';
704
-	}
702
+    if (!($forme === 'abbr' or $forme === 'initiale')) {
703
+        $forme = '';
704
+    }
705 705
 
706
-	return affdate_base($numdate, 'nom_jour', ['param' => $forme]);
706
+    return affdate_base($numdate, 'nom_jour', ['param' => $forme]);
707 707
 }
708 708
 
709 709
 /**
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
  *     Numéro du jour
726 726
  **/
727 727
 function jour($numdate): string {
728
-	return affdate_base($numdate, 'jour');
728
+    return affdate_base($numdate, 'jour');
729 729
 }
730 730
 
731 731
 /**
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
  *     Numéro du jour
744 744
  **/
745 745
 function journum($numdate): string {
746
-	return affdate_base($numdate, 'journum');
746
+    return affdate_base($numdate, 'journum');
747 747
 }
748 748
 
749 749
 /**
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
  *     Numéro du mois (sur 2 chiffres)
762 762
  **/
763 763
 function mois($numdate): string {
764
-	return  affdate_base($numdate, 'mois');
764
+    return  affdate_base($numdate, 'mois');
765 765
 }
766 766
 
767 767
 /**
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
  *     Nom du mois
786 786
  **/
787 787
 function nom_mois($numdate, $forme = ''): string {
788
-	if (!($forme === 'abbr')) {
789
-		$forme = '';
790
-	}
788
+    if (!($forme === 'abbr')) {
789
+        $forme = '';
790
+    }
791 791
 
792
-	return affdate_base($numdate, 'nom_mois', ['param' => $forme]);
792
+    return affdate_base($numdate, 'nom_mois', ['param' => $forme]);
793 793
 }
794 794
 
795 795
 /**
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
  *     Année (sur 4 chiffres)
808 808
  **/
809 809
 function annee($numdate): string {
810
-	return affdate_base($numdate, 'annee');
810
+    return affdate_base($numdate, 'annee');
811 811
 }
812 812
 
813 813
 
@@ -837,11 +837,11 @@  discard block
 block discarded – undo
837 837
  *     La date formatée
838 838
  **/
839 839
 function saison($numdate, $hemisphere = 'nord'): string {
840
-	if ($hemisphere !== 'sud') {
841
-		$hemisphere = 'nord';
842
-	}
840
+    if ($hemisphere !== 'sud') {
841
+        $hemisphere = 'nord';
842
+    }
843 843
 
844
-	return affdate_base($numdate, 'saison', ['param' => $hemisphere]);
844
+    return affdate_base($numdate, 'saison', ['param' => $hemisphere]);
845 845
 }
846 846
 
847 847
 
@@ -870,11 +870,11 @@  discard block
 block discarded – undo
870 870
  *     La date formatée
871 871
  **/
872 872
 function saison_annee($numdate, $hemisphere = 'nord'): string {
873
-	if ($hemisphere !== 'sud') {
874
-		$hemisphere = 'nord';
875
-	}
873
+    if ($hemisphere !== 'sud') {
874
+        $hemisphere = 'nord';
875
+    }
876 876
 
877
-	return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]);
877
+    return affdate_base($numdate, 'saison_annee', ['param' => $hemisphere]);
878 878
 }
879 879
 
880 880
 /**
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
  *     La date formatée
903 903
  **/
904 904
 function affdate($numdate, $format = 'entier'): string {
905
-	return affdate_base($numdate, $format);
905
+    return affdate_base($numdate, $format);
906 906
 }
907 907
 
908 908
 
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
  *     La date formatée
930 930
  **/
931 931
 function affdate_court($numdate, $annee_courante = null): string {
932
-	return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]);
932
+    return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]);
933 933
 }
934 934
 
935 935
 
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
  *     La date formatée
957 957
  **/
958 958
 function affdate_jourcourt($numdate, $annee_courante = null): string {
959
-	return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]);
959
+    return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]);
960 960
 }
961 961
 
962 962
 /**
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
  *     La date formatée
975 975
  **/
976 976
 function affdate_mois_annee($numdate): string {
977
-	return affdate_base($numdate, 'mois_annee');
977
+    return affdate_base($numdate, 'mois_annee');
978 978
 }
979 979
 
980 980
 /**
@@ -992,16 +992,16 @@  discard block
 block discarded – undo
992 992
  *     La date formatée, sinon ''
993 993
  **/
994 994
 function affdate_heure($numdate): string {
995
-	$date_array = recup_date($numdate);
996
-	if (!$date_array) {
997
-		return '';
998
-	}
999
-	[$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array;
1000
-
1001
-	return _T('date_fmt_jour_heure', [
1002
-		'jour' => affdate($numdate),
1003
-		'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes])
1004
-	]);
995
+    $date_array = recup_date($numdate);
996
+    if (!$date_array) {
997
+        return '';
998
+    }
999
+    [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array;
1000
+
1001
+    return _T('date_fmt_jour_heure', [
1002
+        'jour' => affdate($numdate),
1003
+        'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes])
1004
+    ]);
1005 1005
 }
1006 1006
 
1007 1007
 /**
@@ -1033,117 +1033,117 @@  discard block
 block discarded – undo
1033 1033
  *     Texte de la date
1034 1034
  */
1035 1035
 function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = ''): string {
1036
-	$abbr = $jour = '';
1037
-	$affdate = 'affdate_jourcourt';
1038
-	if (strpos($forme, 'abbr') !== false) {
1039
-		$abbr = 'abbr';
1040
-	}
1041
-	if (strpos($forme, 'annee') !== false) {
1042
-		$affdate = 'affdate';
1043
-	}
1044
-	if (strpos($forme, 'jour') !== false) {
1045
-		$jour = 'jour';
1046
-	}
1047
-
1048
-	$dtstart = $dtend = $dtabbr = '';
1049
-	if (strpos($forme, 'hcal') !== false) {
1050
-		$dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>";
1051
-		$dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>";
1052
-		$dtabbr = '</abbr>';
1053
-	}
1054
-
1055
-	$date_debut = strtotime($date_debut);
1056
-	$date_fin = strtotime($date_fin);
1057
-	$d = date('Y-m-d', $date_debut);
1058
-	$f = date('Y-m-d', $date_fin);
1059
-	$h = ($horaire === 'oui' or $horaire === true);
1060
-	$hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]);
1061
-	$hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]);
1062
-
1063
-	if ($d == $f) { // meme jour
1064
-		$nomjour = nom_jour($d, $abbr);
1065
-		$s = $affdate($d);
1066
-		$s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]);
1067
-		if ($h) {
1068
-			if ($hd == $hf) {
1069
-				// Lundi 20 fevrier a 18h25
1070
-				$s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd]));
1071
-				$s = "$dtstart$s$dtabbr";
1072
-			} else {
1073
-				// Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr>
1074
-				if ($dtabbr && $dtstart && $dtend) {
1075
-					$s = _T(
1076
-						'date_fmt_jour_heure_debut_fin_abbr',
1077
-						[
1078
-						'jour' => spip_ucfirst($s),
1079
-						'heure_debut' => $hd,
1080
-						'heure_fin' => $hf,
1081
-						'dtstart' => $dtstart,
1082
-						'dtend' => $dtend,
1083
-						'dtabbr' => $dtabbr
1084
-						],
1085
-						[
1086
-							'sanitize' => false
1087
-						]
1088
-					);
1089
-				} // Le lundi 20 fevrier de 18h00 a 20h00
1090
-				else {
1091
-					$s = spip_ucfirst(_T(
1092
-						'date_fmt_jour_heure_debut_fin',
1093
-						['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf]
1094
-					));
1095
-				}
1096
-			}
1097
-		} else {
1098
-			if ($dtabbr && $dtstart) {
1099
-				$s = $dtstart . spip_ucfirst($s) . $dtabbr;
1100
-			} else {
1101
-				$s = spip_ucfirst($s);
1102
-			}
1103
-		}
1104
-	} else {
1105
-		if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents
1106
-			if (!$h) {
1107
-				$date_debut = jour($d);
1108
-			} else {
1109
-				$date_debut = affdate_jourcourt($d, date('Y', $date_fin));
1110
-			}
1111
-			$date_fin = $affdate($f);
1112
-			if ($jour) {
1113
-				$nomjour_debut = nom_jour($d, $abbr);
1114
-				$date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]);
1115
-				$nomjour_fin = nom_jour($f, $abbr);
1116
-				$date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]);
1117
-			}
1118
-			if ($h) {
1119
-				$date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1120
-				$date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1121
-			}
1122
-			$date_debut = $dtstart . $date_debut . $dtabbr;
1123
-			$date_fin = $dtend . $date_fin . $dtabbr;
1124
-
1125
-			$s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1126
-		} else {
1127
-			$date_debut = affdate_jourcourt($d, date('Y', $date_fin));
1128
-			$date_fin = $affdate($f);
1129
-			if ($jour) {
1130
-				$nomjour_debut = nom_jour($d, $abbr);
1131
-				$date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]);
1132
-				$nomjour_fin = nom_jour($f, $abbr);
1133
-				$date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]);
1134
-			}
1135
-			if ($h) {
1136
-				$date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1137
-				$date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1138
-			}
1139
-
1140
-			$date_debut = $dtstart . $date_debut . $dtabbr;
1141
-			$date_fin = $dtend . $date_fin . $dtabbr;
1142
-			$s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1143
-		}
1144
-	}
1145
-
1146
-	return $s;
1036
+    $abbr = $jour = '';
1037
+    $affdate = 'affdate_jourcourt';
1038
+    if (strpos($forme, 'abbr') !== false) {
1039
+        $abbr = 'abbr';
1040
+    }
1041
+    if (strpos($forme, 'annee') !== false) {
1042
+        $affdate = 'affdate';
1043
+    }
1044
+    if (strpos($forme, 'jour') !== false) {
1045
+        $jour = 'jour';
1046
+    }
1047
+
1048
+    $dtstart = $dtend = $dtabbr = '';
1049
+    if (strpos($forme, 'hcal') !== false) {
1050
+        $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>";
1051
+        $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>";
1052
+        $dtabbr = '</abbr>';
1053
+    }
1054
+
1055
+    $date_debut = strtotime($date_debut);
1056
+    $date_fin = strtotime($date_fin);
1057
+    $d = date('Y-m-d', $date_debut);
1058
+    $f = date('Y-m-d', $date_fin);
1059
+    $h = ($horaire === 'oui' or $horaire === true);
1060
+    $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]);
1061
+    $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]);
1062
+
1063
+    if ($d == $f) { // meme jour
1064
+        $nomjour = nom_jour($d, $abbr);
1065
+        $s = $affdate($d);
1066
+        $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]);
1067
+        if ($h) {
1068
+            if ($hd == $hf) {
1069
+                // Lundi 20 fevrier a 18h25
1070
+                $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd]));
1071
+                $s = "$dtstart$s$dtabbr";
1072
+            } else {
1073
+                // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr>
1074
+                if ($dtabbr && $dtstart && $dtend) {
1075
+                    $s = _T(
1076
+                        'date_fmt_jour_heure_debut_fin_abbr',
1077
+                        [
1078
+                        'jour' => spip_ucfirst($s),
1079
+                        'heure_debut' => $hd,
1080
+                        'heure_fin' => $hf,
1081
+                        'dtstart' => $dtstart,
1082
+                        'dtend' => $dtend,
1083
+                        'dtabbr' => $dtabbr
1084
+                        ],
1085
+                        [
1086
+                            'sanitize' => false
1087
+                        ]
1088
+                    );
1089
+                } // Le lundi 20 fevrier de 18h00 a 20h00
1090
+                else {
1091
+                    $s = spip_ucfirst(_T(
1092
+                        'date_fmt_jour_heure_debut_fin',
1093
+                        ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf]
1094
+                    ));
1095
+                }
1096
+            }
1097
+        } else {
1098
+            if ($dtabbr && $dtstart) {
1099
+                $s = $dtstart . spip_ucfirst($s) . $dtabbr;
1100
+            } else {
1101
+                $s = spip_ucfirst($s);
1102
+            }
1103
+        }
1104
+    } else {
1105
+        if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents
1106
+            if (!$h) {
1107
+                $date_debut = jour($d);
1108
+            } else {
1109
+                $date_debut = affdate_jourcourt($d, date('Y', $date_fin));
1110
+            }
1111
+            $date_fin = $affdate($f);
1112
+            if ($jour) {
1113
+                $nomjour_debut = nom_jour($d, $abbr);
1114
+                $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]);
1115
+                $nomjour_fin = nom_jour($f, $abbr);
1116
+                $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]);
1117
+            }
1118
+            if ($h) {
1119
+                $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1120
+                $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1121
+            }
1122
+            $date_debut = $dtstart . $date_debut . $dtabbr;
1123
+            $date_fin = $dtend . $date_fin . $dtabbr;
1124
+
1125
+            $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1126
+        } else {
1127
+            $date_debut = affdate_jourcourt($d, date('Y', $date_fin));
1128
+            $date_fin = $affdate($f);
1129
+            if ($jour) {
1130
+                $nomjour_debut = nom_jour($d, $abbr);
1131
+                $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]);
1132
+                $nomjour_fin = nom_jour($f, $abbr);
1133
+                $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]);
1134
+            }
1135
+            if ($h) {
1136
+                $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1137
+                $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1138
+            }
1139
+
1140
+            $date_debut = $dtstart . $date_debut . $dtabbr;
1141
+            $date_fin = $dtend . $date_fin . $dtabbr;
1142
+            $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1143
+        }
1144
+    }
1145
+
1146
+    return $s;
1147 1147
 }
1148 1148
 
1149 1149
 /**
@@ -1164,10 +1164,10 @@  discard block
 block discarded – undo
1164 1164
  *     Date au format ical
1165 1165
  **/
1166 1166
 function date_ical($date, $addminutes = 0): string {
1167
-	[$heures, $minutes, $secondes] = recup_heure($date);
1168
-	[$annee, $mois, $jour] = recup_date($date);
1167
+    [$heures, $minutes, $secondes] = recup_heure($date);
1168
+    [$annee, $mois, $jour] = recup_date($date);
1169 1169
 
1170
-	return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee));
1170
+    return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee));
1171 1171
 }
1172 1172
 
1173 1173
 
@@ -1191,11 +1191,11 @@  discard block
 block discarded – undo
1191 1191
  *     La date formatée
1192 1192
  **/
1193 1193
 function date_iso($date_heure): string {
1194
-	[$annee, $mois, $jour] = recup_date($date_heure);
1195
-	[$heures, $minutes, $secondes] = recup_heure($date_heure);
1196
-	$time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
1194
+    [$annee, $mois, $jour] = recup_date($date_heure);
1195
+    [$heures, $minutes, $secondes] = recup_heure($date_heure);
1196
+    $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
1197 1197
 
1198
-	return gmdate('Y-m-d\TH:i:s\Z', $time);
1198
+    return gmdate('Y-m-d\TH:i:s\Z', $time);
1199 1199
 }
1200 1200
 
1201 1201
 /**
@@ -1218,11 +1218,11 @@  discard block
 block discarded – undo
1218 1218
  *     La date formatée
1219 1219
  **/
1220 1220
 function date_822($date_heure): string {
1221
-	[$annee, $mois, $jour] = recup_date($date_heure);
1222
-	[$heures, $minutes, $secondes] = recup_heure($date_heure);
1223
-	$time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
1221
+    [$annee, $mois, $jour] = recup_date($date_heure);
1222
+    [$heures, $minutes, $secondes] = recup_heure($date_heure);
1223
+    $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee);
1224 1224
 
1225
-	return date('r', $time);
1225
+    return date('r', $time);
1226 1226
 }
1227 1227
 
1228 1228
 /**
@@ -1238,11 +1238,11 @@  discard block
 block discarded – undo
1238 1238
  *     Date au format `Ymd`
1239 1239
  **/
1240 1240
 function date_anneemoisjour($d): string {
1241
-	if (!$d) {
1242
-		$d = date('Y-m-d');
1243
-	}
1241
+    if (!$d) {
1242
+        $d = date('Y-m-d');
1243
+    }
1244 1244
 
1245
-	return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2);
1245
+    return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2);
1246 1246
 }
1247 1247
 
1248 1248
 /**
@@ -1258,11 +1258,11 @@  discard block
 block discarded – undo
1258 1258
  *     Date au format `Ym`
1259 1259
  **/
1260 1260
 function date_anneemois($d): string {
1261
-	if (!$d) {
1262
-		$d = date('Y-m-d');
1263
-	}
1261
+    if (!$d) {
1262
+        $d = date('Y-m-d');
1263
+    }
1264 1264
 
1265
-	return substr($d, 0, 4) . substr($d, 5, 2);
1265
+    return substr($d, 0, 4) . substr($d, 5, 2);
1266 1266
 }
1267 1267
 
1268 1268
 /**
@@ -1278,13 +1278,13 @@  discard block
 block discarded – undo
1278 1278
  *     Date au lundi de la même semaine au format `Ymd`
1279 1279
  **/
1280 1280
 function date_debut_semaine($annee, $mois, $jour): string {
1281
-	$w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee));
1282
-	if ($w_day == 0) {
1283
-		$w_day = 7;
1284
-	} // Gaffe: le dimanche est zero
1285
-	$debut = $jour - $w_day + 1;
1281
+    $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee));
1282
+    if ($w_day == 0) {
1283
+        $w_day = 7;
1284
+    } // Gaffe: le dimanche est zero
1285
+    $debut = $jour - $w_day + 1;
1286 1286
 
1287
-	return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee));
1287
+    return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee));
1288 1288
 }
1289 1289
 
1290 1290
 /**
@@ -1300,11 +1300,11 @@  discard block
 block discarded – undo
1300 1300
  *     Date au dimanche de la même semaine au format `Ymd`
1301 1301
  **/
1302 1302
 function date_fin_semaine($annee, $mois, $jour): string {
1303
-	$w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee));
1304
-	if ($w_day == 0) {
1305
-		$w_day = 7;
1306
-	} // Gaffe: le dimanche est zero
1307
-	$debut = $jour - $w_day + 1;
1303
+    $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee));
1304
+    if ($w_day == 0) {
1305
+        $w_day = 7;
1306
+    } // Gaffe: le dimanche est zero
1307
+    $debut = $jour - $w_day + 1;
1308 1308
 
1309
-	return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee));
1309
+    return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee));
1310 1310
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 function extraire_date($texte): string {
40 40
 	// format = 2001-08
41 41
 	if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) {
42
-		return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01';
42
+		return $regs[1].'-'.sprintf('%02d', $regs[2]).'-01';
43 43
 	}
44 44
 	return '';
45 45
 }
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 		}
71 71
 		if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
72 72
 			$regs = array_pad($regs, 4, null); // eviter notice php
73
-			$date = $regs[1] . '-00-00' . $regs[3];
73
+			$date = $regs[1].'-00-00'.$regs[3];
74 74
 		} else {
75 75
 			if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) {
76 76
 				$regs = array_pad($regs, 4, null); // eviter notice php
77
-				$date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3];
77
+				$date = preg_replace('@/@', '-', $regs[1]).'-00'.$regs[3];
78 78
 			} else {
79 79
 				$date = date('Y-m-d H:i:s', strtotime($date));
80 80
 			}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	$letexte ??= '';
102 102
 	if (
103 103
 		!$verif_format_date
104
-		or (in_array(strlen($letexte), [10,19]) and
104
+		or (in_array(strlen($letexte), [10, 19]) and
105 105
 			  preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte))
106 106
 	) {
107 107
 		if (strncmp('0000-00-00', $letexte, 10) == 0) {
@@ -388,17 +388,17 @@  discard block
 block discarded – undo
388 388
 	if ($decal > 3600 * 24 * 30) {
389 389
 		$mois = floor($decal / (3600 * 24 * 30));
390 390
 		if ($mois < 2) {
391
-			$delai = "$mois " . _T('date_un_mois');
391
+			$delai = "$mois "._T('date_un_mois');
392 392
 		} else {
393
-			$delai = "$mois " . _T('date_mois');
393
+			$delai = "$mois "._T('date_mois');
394 394
 		}
395 395
 	} else {
396 396
 		if ($decal > 3600 * 24 * 7) {
397 397
 			$semaines = floor($decal / (3600 * 24 * 7));
398 398
 			if ($semaines < 2) {
399
-				$delai = "$semaines " . _T('date_une_semaine');
399
+				$delai = "$semaines "._T('date_une_semaine');
400 400
 			} else {
401
-				$delai = "$semaines " . _T('date_semaines');
401
+				$delai = "$semaines "._T('date_semaines');
402 402
 			}
403 403
 		} else {
404 404
 			if ($decal > 3600 * 24) {
@@ -406,30 +406,30 @@  discard block
 block discarded – undo
406 406
 				if ($jours < 2) {
407 407
 					return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier');
408 408
 				} else {
409
-					$delai = "$jours " . _T('date_jours');
409
+					$delai = "$jours "._T('date_jours');
410 410
 				}
411 411
 			} else {
412 412
 				if ($decal >= 3600) {
413 413
 					$heures = floor($decal / 3600);
414 414
 					if ($heures < 2) {
415
-						$delai = "$heures " . _T('date_une_heure');
415
+						$delai = "$heures "._T('date_une_heure');
416 416
 					} else {
417
-						$delai = "$heures " . _T('date_heures');
417
+						$delai = "$heures "._T('date_heures');
418 418
 					}
419 419
 				} else {
420 420
 					if ($decal >= 60) {
421 421
 						$minutes = floor($decal / 60);
422 422
 						if ($minutes < 2) {
423
-							$delai = "$minutes " . _T('date_une_minute');
423
+							$delai = "$minutes "._T('date_une_minute');
424 424
 						} else {
425
-							$delai = "$minutes " . _T('date_minutes');
425
+							$delai = "$minutes "._T('date_minutes');
426 426
 						}
427 427
 					} else {
428 428
 						$secondes = ceil($decal);
429 429
 						if ($secondes < 2) {
430
-							$delai = "$secondes " . _T('date_une_seconde');
430
+							$delai = "$secondes "._T('date_une_seconde');
431 431
 						} else {
432
-							$delai = "$secondes " . _T('date_secondes');
432
+							$delai = "$secondes "._T('date_secondes');
433 433
 						}
434 434
 					}
435 435
 				}
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 		$njour = 0;
523 523
 	} else {
524 524
 		$njour = intval($jour);
525
-		if ($jourth = _T('date_jnum' . $jour)) {
525
+		if ($jourth = _T('date_jnum'.$jour)) {
526 526
 			$jour = $jourth;
527 527
 		}
528 528
 	}
@@ -530,10 +530,10 @@  discard block
 block discarded – undo
530 530
 	$mois = intval($mois);
531 531
 	if ($mois > 0 and $mois < 13) {
532 532
 		/* Traiter le cas "abbr" pour les noms de mois */
533
-		$param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : '');
534
-		$nommois = _T('date_mois_' . $mois . $param);
533
+		$param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_'.$options['param'] : '');
534
+		$nommois = _T('date_mois_'.$mois.$param);
535 535
 		if ($jour) {
536
-			$jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]);
536
+			$jourmois = _T('date_de_mois_'.$mois, ['j' => $jour, 'nommois' => $nommois]);
537 537
 		} else {
538 538
 			$jourmois = $nommois;
539 539
 		}
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	}
544 544
 
545 545
 	if ($annee < 0) {
546
-		$annee = -$annee . ' ' . _T('date_avant_jc');
546
+		$annee = -$annee.' '._T('date_avant_jc');
547 547
 		$avjc = true;
548 548
 	} else {
549 549
 		$avjc = false;
@@ -569,11 +569,11 @@  discard block
 block discarded – undo
569 569
 				}
570 570
 			}
571 571
 			if ($vue == 'saison') {
572
-				return $saison ? _T('date_saison_' . $saison) : '';
572
+				return $saison ? _T('date_saison_'.$saison) : '';
573 573
 			} else {
574 574
 				return $saison ? trim(_T(
575 575
 					'date_fmt_saison_annee',
576
-					['saison' => _T('date_saison_' . $saison), 'annee' => $annee]
576
+					['saison' => _T('date_saison_'.$saison), 'annee' => $annee]
577 577
 				)) : '';
578 578
 			}
579 579
 
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
 			}
651 651
 			$nom = mktime(1, 1, 1, $mois, $njour, $annee);
652 652
 			$nom = 1 + (int) date('w', $nom);
653
-			$param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : '');
653
+			$param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : '');
654 654
 
655
-			return _T('date_jour_' . $nom . $param);
655
+			return _T('date_jour_'.$nom.$param);
656 656
 
657 657
 		case 'mois_annee':
658 658
 			if ($avjc) {
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 
1048 1048
 	$dtstart = $dtend = $dtabbr = '';
1049 1049
 	if (strpos($forme, 'hcal') !== false) {
1050
-		$dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>";
1051
-		$dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>";
1050
+		$dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>";
1051
+		$dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>";
1052 1052
 		$dtabbr = '</abbr>';
1053 1053
 	}
1054 1054
 
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 			}
1097 1097
 		} else {
1098 1098
 			if ($dtabbr && $dtstart) {
1099
-				$s = $dtstart . spip_ucfirst($s) . $dtabbr;
1099
+				$s = $dtstart.spip_ucfirst($s).$dtabbr;
1100 1100
 			} else {
1101 1101
 				$s = spip_ucfirst($s);
1102 1102
 			}
@@ -1119,8 +1119,8 @@  discard block
 block discarded – undo
1119 1119
 				$date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]);
1120 1120
 				$date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1121 1121
 			}
1122
-			$date_debut = $dtstart . $date_debut . $dtabbr;
1123
-			$date_fin = $dtend . $date_fin . $dtabbr;
1122
+			$date_debut = $dtstart.$date_debut.$dtabbr;
1123
+			$date_fin = $dtend.$date_fin.$dtabbr;
1124 1124
 
1125 1125
 			$s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1126 1126
 		} else {
@@ -1137,8 +1137,8 @@  discard block
 block discarded – undo
1137 1137
 				$date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]);
1138 1138
 			}
1139 1139
 
1140
-			$date_debut = $dtstart . $date_debut . $dtabbr;
1141
-			$date_fin = $dtend . $date_fin . $dtabbr;
1140
+			$date_debut = $dtstart.$date_debut.$dtabbr;
1141
+			$date_fin = $dtend.$date_fin.$dtabbr;
1142 1142
 			$s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]);
1143 1143
 		}
1144 1144
 	}
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 		$d = date('Y-m-d');
1243 1243
 	}
1244 1244
 
1245
-	return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2);
1245
+	return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2);
1246 1246
 }
1247 1247
 
1248 1248
 /**
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 		$d = date('Y-m-d');
1263 1263
 	}
1264 1264
 
1265
-	return substr($d, 0, 4) . substr($d, 5, 2);
1265
+	return substr($d, 0, 4).substr($d, 5, 2);
1266 1266
 }
1267 1267
 
1268 1268
 /**
Please login to merge, or discard this patch.
prive/formulaires/editer_article.php 1 patch
Indentation   +96 added lines, -96 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
 include_spip('inc/actions');
@@ -46,33 +46,33 @@  discard block
 block discarded – undo
46 46
  *     Environnement du formulaire
47 47
  **/
48 48
 function formulaires_editer_article_charger_dist(
49
-	$id_article = 'new',
50
-	$id_rubrique = 0,
51
-	$retour = '',
52
-	$lier_trad = 0,
53
-	$config_fonc = 'articles_edit_config',
54
-	$row = [],
55
-	$hidden = ''
49
+    $id_article = 'new',
50
+    $id_rubrique = 0,
51
+    $retour = '',
52
+    $lier_trad = 0,
53
+    $config_fonc = 'articles_edit_config',
54
+    $row = [],
55
+    $hidden = ''
56 56
 ) {
57
-	$valeurs = formulaires_editer_objet_charger(
58
-		'article',
59
-		$id_article,
60
-		$id_rubrique,
61
-		$lier_trad,
62
-		$retour,
63
-		$config_fonc,
64
-		$row,
65
-		$hidden
66
-	);
57
+    $valeurs = formulaires_editer_objet_charger(
58
+        'article',
59
+        $id_article,
60
+        $id_rubrique,
61
+        $lier_trad,
62
+        $retour,
63
+        $config_fonc,
64
+        $row,
65
+        $hidden
66
+    );
67 67
 
68
-	if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) {
69
-		$valeurs['editable'] = '';
70
-	}
68
+    if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) {
69
+        $valeurs['editable'] = '';
70
+    }
71 71
 
72
-	// il faut enlever l'id_rubrique car la saisie se fait sur id_parent
73
-	// et id_rubrique peut etre passe dans l'url comme rubrique parent initiale
74
-	// et sera perdue si elle est supposee saisie
75
-	return $valeurs;
72
+    // il faut enlever l'id_rubrique car la saisie se fait sur id_parent
73
+    // et id_rubrique peut etre passe dans l'url comme rubrique parent initiale
74
+    // et sera perdue si elle est supposee saisie
75
+    return $valeurs;
76 76
 }
77 77
 
78 78
 /**
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
  *     Hash du formulaire
98 98
  */
99 99
 function formulaires_editer_article_identifier_dist(
100
-	$id_article = 'new',
101
-	$id_rubrique = 0,
102
-	$retour = '',
103
-	$lier_trad = 0,
104
-	$config_fonc = 'articles_edit_config',
105
-	$row = [],
106
-	$hidden = ''
100
+    $id_article = 'new',
101
+    $id_rubrique = 0,
102
+    $retour = '',
103
+    $lier_trad = 0,
104
+    $config_fonc = 'articles_edit_config',
105
+    $row = [],
106
+    $hidden = ''
107 107
 ) {
108
-	return serialize([intval($id_article), $lier_trad]);
108
+    return serialize([intval($id_article), $lier_trad]);
109 109
 }
110 110
 
111 111
 /**
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
  */
119 119
 function articles_edit_config(array $row): array {
120 120
 
121
-	$config = [];
122
-	$config['lignes'] = 8;
123
-	$config['langue'] = $GLOBALS['spip_lang'];
124
-	$config['restreint'] = ($row['statut'] === 'publie');
121
+    $config = [];
122
+    $config['lignes'] = 8;
123
+    $config['langue'] = $GLOBALS['spip_lang'];
124
+    $config['restreint'] = ($row['statut'] === 'publie');
125 125
 
126
-	return $config;
126
+    return $config;
127 127
 }
128 128
 
129 129
 /**
@@ -149,43 +149,43 @@  discard block
 block discarded – undo
149 149
  *     Erreurs du formulaire
150 150
  **/
151 151
 function formulaires_editer_article_verifier_dist(
152
-	$id_article = 'new',
153
-	$id_rubrique = 0,
154
-	$retour = '',
155
-	$lier_trad = 0,
156
-	$config_fonc = 'articles_edit_config',
157
-	$row = [],
158
-	$hidden = ''
152
+    $id_article = 'new',
153
+    $id_rubrique = 0,
154
+    $retour = '',
155
+    $lier_trad = 0,
156
+    $config_fonc = 'articles_edit_config',
157
+    $row = [],
158
+    $hidden = ''
159 159
 ) {
160
-	// auto-renseigner le titre si il n'existe pas
161
-	titre_automatique('titre', ['descriptif', 'chapo', 'texte']);
162
-	if (!_request('id_parent') and !intval($id_article)) {
163
-		$valeurs = formulaires_editer_objet_charger(
164
-			'article',
165
-			$id_article,
166
-			$id_rubrique,
167
-			$lier_trad,
168
-			$retour,
169
-			$config_fonc,
170
-			$row,
171
-			$hidden
172
-		);
173
-		set_request('id_parent', $valeurs['id_parent']);
174
-	}
175
-	// on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide
176
-	$erreurs = formulaires_editer_objet_verifier('article', $id_article, ['id_parent']);
177
-	// si on utilise le formulaire dans le public
178
-	if (!function_exists('autoriser')) {
179
-		include_spip('inc/autoriser');
180
-	}
181
-	if (
182
-		!isset($erreurs['id_parent'])
183
-		and !autoriser('creerarticledans', 'rubrique', _request('id_parent'))
184
-	) {
185
-		$erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise');
186
-	}
160
+    // auto-renseigner le titre si il n'existe pas
161
+    titre_automatique('titre', ['descriptif', 'chapo', 'texte']);
162
+    if (!_request('id_parent') and !intval($id_article)) {
163
+        $valeurs = formulaires_editer_objet_charger(
164
+            'article',
165
+            $id_article,
166
+            $id_rubrique,
167
+            $lier_trad,
168
+            $retour,
169
+            $config_fonc,
170
+            $row,
171
+            $hidden
172
+        );
173
+        set_request('id_parent', $valeurs['id_parent']);
174
+    }
175
+    // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide
176
+    $erreurs = formulaires_editer_objet_verifier('article', $id_article, ['id_parent']);
177
+    // si on utilise le formulaire dans le public
178
+    if (!function_exists('autoriser')) {
179
+        include_spip('inc/autoriser');
180
+    }
181
+    if (
182
+        !isset($erreurs['id_parent'])
183
+        and !autoriser('creerarticledans', 'rubrique', _request('id_parent'))
184
+    ) {
185
+        $erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise');
186
+    }
187 187
 
188
-	return $erreurs;
188
+    return $erreurs;
189 189
 }
190 190
 
191 191
 /**
@@ -211,29 +211,29 @@  discard block
 block discarded – undo
211 211
  *     Retours des traitements
212 212
  **/
213 213
 function formulaires_editer_article_traiter_dist(
214
-	$id_article = 'new',
215
-	$id_rubrique = 0,
216
-	$retour = '',
217
-	$lier_trad = 0,
218
-	$config_fonc = 'articles_edit_config',
219
-	$row = [],
220
-	$hidden = ''
214
+    $id_article = 'new',
215
+    $id_rubrique = 0,
216
+    $retour = '',
217
+    $lier_trad = 0,
218
+    $config_fonc = 'articles_edit_config',
219
+    $row = [],
220
+    $hidden = ''
221 221
 ) {
222
-	// ici on ignore changer_lang qui est poste en cas de trad,
223
-	// car l'heuristique du choix de la langue est pris en charge par article_inserer
224
-	// en fonction de la config du site et de la rubrique choisie
225
-	if (!$lier_trad) {
226
-		set_request('changer_lang');
227
-	}
222
+    // ici on ignore changer_lang qui est poste en cas de trad,
223
+    // car l'heuristique du choix de la langue est pris en charge par article_inserer
224
+    // en fonction de la config du site et de la rubrique choisie
225
+    if (!$lier_trad) {
226
+        set_request('changer_lang');
227
+    }
228 228
 
229
-	return formulaires_editer_objet_traiter(
230
-		'article',
231
-		$id_article,
232
-		$id_rubrique,
233
-		$lier_trad,
234
-		$retour,
235
-		$config_fonc,
236
-		$row,
237
-		$hidden
238
-	);
229
+    return formulaires_editer_objet_traiter(
230
+        'article',
231
+        $id_article,
232
+        $id_rubrique,
233
+        $lier_trad,
234
+        $retour,
235
+        $config_fonc,
236
+        $row,
237
+        $hidden
238
+    );
239 239
 }
Please login to merge, or discard this patch.
prive/formulaires/editer_rubrique.php 1 patch
Indentation   +81 added lines, -81 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
 include_spip('inc/actions');
@@ -47,30 +47,30 @@  discard block
 block discarded – undo
47 47
  *     Environnement du formulaire
48 48
  **/
49 49
 function formulaires_editer_rubrique_charger_dist(
50
-	$id_rubrique = 'new',
51
-	$id_parent = 0,
52
-	$retour = '',
53
-	$lier_trad = 0,
54
-	$config_fonc = 'rubriques_edit_config',
55
-	$row = [],
56
-	$hidden = ''
50
+    $id_rubrique = 'new',
51
+    $id_parent = 0,
52
+    $retour = '',
53
+    $lier_trad = 0,
54
+    $config_fonc = 'rubriques_edit_config',
55
+    $row = [],
56
+    $hidden = ''
57 57
 ) {
58
-	$valeurs = formulaires_editer_objet_charger(
59
-		'rubrique',
60
-		$id_rubrique,
61
-		$id_parent,
62
-		$lier_trad,
63
-		$retour,
64
-		$config_fonc,
65
-		$row,
66
-		$hidden
67
-	);
68
-
69
-	if (intval($id_rubrique) and !autoriser('modifier', 'rubrique', intval($id_rubrique))) {
70
-		$valeurs['editable'] = '';
71
-	}
72
-
73
-	return $valeurs;
58
+    $valeurs = formulaires_editer_objet_charger(
59
+        'rubrique',
60
+        $id_rubrique,
61
+        $id_parent,
62
+        $lier_trad,
63
+        $retour,
64
+        $config_fonc,
65
+        $row,
66
+        $hidden
67
+    );
68
+
69
+    if (intval($id_rubrique) and !autoriser('modifier', 'rubrique', intval($id_rubrique))) {
70
+        $valeurs['editable'] = '';
71
+    }
72
+
73
+    return $valeurs;
74 74
 }
75 75
 
76 76
 /**
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
  */
84 84
 function rubriques_edit_config(array $row): array {
85 85
 
86
-	$config = [];
87
-	$config['lignes'] = 8;
88
-	$config['langue'] = $GLOBALS['spip_lang'];
89
-	$config['restreint'] = (!$GLOBALS['connect_toutes_rubriques']);
86
+    $config = [];
87
+    $config['lignes'] = 8;
88
+    $config['langue'] = $GLOBALS['spip_lang'];
89
+    $config['restreint'] = (!$GLOBALS['connect_toutes_rubriques']);
90 90
 
91
-	return $config;
91
+    return $config;
92 92
 }
93 93
 
94 94
 /**
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
  *     Hash du formulaire
114 114
  */
115 115
 function formulaires_editer_rubrique_identifier_dist(
116
-	$id_rubrique = 'new',
117
-	$id_parent = 0,
118
-	$retour = '',
119
-	$lier_trad = 0,
120
-	$config_fonc = 'rubriques_edit_config',
121
-	$row = [],
122
-	$hidden = ''
116
+    $id_rubrique = 'new',
117
+    $id_parent = 0,
118
+    $retour = '',
119
+    $lier_trad = 0,
120
+    $config_fonc = 'rubriques_edit_config',
121
+    $row = [],
122
+    $hidden = ''
123 123
 ) {
124
-	return serialize([intval($id_rubrique), $lier_trad]);
124
+    return serialize([intval($id_rubrique), $lier_trad]);
125 125
 }
126 126
 
127 127
 /**
@@ -147,34 +147,34 @@  discard block
 block discarded – undo
147 147
  *     Erreurs du formulaire
148 148
  **/
149 149
 function formulaires_editer_rubrique_verifier_dist(
150
-	$id_rubrique = 'new',
151
-	$id_parent = 0,
152
-	$retour = '',
153
-	$lier_trad = 0,
154
-	$config_fonc = 'rubriques_edit_config',
155
-	$row = [],
156
-	$hidden = ''
150
+    $id_rubrique = 'new',
151
+    $id_parent = 0,
152
+    $retour = '',
153
+    $lier_trad = 0,
154
+    $config_fonc = 'rubriques_edit_config',
155
+    $row = [],
156
+    $hidden = ''
157 157
 ) {
158
-	// auto-renseigner le titre si il n'existe pas
159
-	titre_automatique('titre', ['descriptif', 'texte']);
160
-	// on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_rubrique si vide
161
-	$erreurs = formulaires_editer_objet_verifier('rubrique', $id_rubrique, []);
162
-
163
-	// s'assurer qu'on ne s'auto-designe pas comme parent !
164
-	if (
165
-		intval($id_rubrique)
166
-		and empty($erreurs['id_parent'])
167
-		and $id_parent = _request('id_parent')
168
-	) {
169
-		include_spip('inc/rubriques');
170
-		$branche = calcul_branche_in($id_rubrique);
171
-		$branche = explode(',', $branche);
172
-		if (in_array($id_parent, $branche)) {
173
-			$erreurs['id_parent'] = _L('Impossible de déplacer une rubrique dans sa propre branche, on tourne en rond !');
174
-		}
175
-	}
176
-
177
-	return $erreurs;
158
+    // auto-renseigner le titre si il n'existe pas
159
+    titre_automatique('titre', ['descriptif', 'texte']);
160
+    // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_rubrique si vide
161
+    $erreurs = formulaires_editer_objet_verifier('rubrique', $id_rubrique, []);
162
+
163
+    // s'assurer qu'on ne s'auto-designe pas comme parent !
164
+    if (
165
+        intval($id_rubrique)
166
+        and empty($erreurs['id_parent'])
167
+        and $id_parent = _request('id_parent')
168
+    ) {
169
+        include_spip('inc/rubriques');
170
+        $branche = calcul_branche_in($id_rubrique);
171
+        $branche = explode(',', $branche);
172
+        if (in_array($id_parent, $branche)) {
173
+            $erreurs['id_parent'] = _L('Impossible de déplacer une rubrique dans sa propre branche, on tourne en rond !');
174
+        }
175
+    }
176
+
177
+    return $erreurs;
178 178
 }
179 179
 
180 180
 /**
@@ -200,22 +200,22 @@  discard block
 block discarded – undo
200 200
  *     Retour des traitements
201 201
  **/
202 202
 function formulaires_editer_rubrique_traiter_dist(
203
-	$id_rubrique = 'new',
204
-	$id_parent = 0,
205
-	$retour = '',
206
-	$lier_trad = 0,
207
-	$config_fonc = 'rubriques_edit_config',
208
-	$row = [],
209
-	$hidden = ''
203
+    $id_rubrique = 'new',
204
+    $id_parent = 0,
205
+    $retour = '',
206
+    $lier_trad = 0,
207
+    $config_fonc = 'rubriques_edit_config',
208
+    $row = [],
209
+    $hidden = ''
210 210
 ) {
211
-	return formulaires_editer_objet_traiter(
212
-		'rubrique',
213
-		$id_rubrique,
214
-		$id_parent,
215
-		$lier_trad,
216
-		$retour,
217
-		$config_fonc,
218
-		$row,
219
-		$hidden
220
-	);
211
+    return formulaires_editer_objet_traiter(
212
+        'rubrique',
213
+        $id_rubrique,
214
+        $id_parent,
215
+        $lier_trad,
216
+        $retour,
217
+        $config_fonc,
218
+        $row,
219
+        $hidden
220
+    );
221 221
 }
Please login to merge, or discard this patch.
ecrire/inc/acces.php 2 patches
Indentation   +234 added lines, -234 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,46 +31,46 @@  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
-	$s = '';
38
-	$pass = '';
39
-	for ($i = 0; $i < $longueur; $i++) {
40
-		if (!$s) {
41
-			$s = random_int(0, mt_getrandmax());
42
-			if (!$s) {
43
-				$s = random_int(0, mt_getrandmax());
44
-			}
45
-			$s = substr(md5(uniqid($s) . $sel), 0, 16);
46
-		}
47
-		$r = unpack('Cr', pack('H2', $s . $s));
48
-		$x = $r['r'] & 63;
49
-		if ($x < 10) {
50
-			$x = chr($x + 48);
51
-		} else {
52
-			if ($x < 36) {
53
-				$x = chr($x + 55);
54
-			} else {
55
-				if ($x < 62) {
56
-					$x = chr($x + 61);
57
-				} else {
58
-					if ($x == 63) {
59
-						$x = '/';
60
-					} else {
61
-						$x = '.';
62
-					}
63
-				}
64
-			}
65
-		}
66
-		$pass .= $x;
67
-		$s = substr($s, 2);
68
-	}
69
-	$pass = preg_replace('@[./]@', 'a', $pass);
70
-	$pass = preg_replace('@[I1l]@', 'L', $pass);
71
-	$pass = preg_replace('@[0O]@', 'o', $pass);
72
-
73
-	return $pass;
34
+    $seed = (int)round(((float)microtime() + 1) * time());
35
+
36
+    mt_srand($seed);
37
+    $s = '';
38
+    $pass = '';
39
+    for ($i = 0; $i < $longueur; $i++) {
40
+        if (!$s) {
41
+            $s = random_int(0, mt_getrandmax());
42
+            if (!$s) {
43
+                $s = random_int(0, mt_getrandmax());
44
+            }
45
+            $s = substr(md5(uniqid($s) . $sel), 0, 16);
46
+        }
47
+        $r = unpack('Cr', pack('H2', $s . $s));
48
+        $x = $r['r'] & 63;
49
+        if ($x < 10) {
50
+            $x = chr($x + 48);
51
+        } else {
52
+            if ($x < 36) {
53
+                $x = chr($x + 55);
54
+            } else {
55
+                if ($x < 62) {
56
+                    $x = chr($x + 61);
57
+                } else {
58
+                    if ($x == 63) {
59
+                        $x = '/';
60
+                    } else {
61
+                        $x = '.';
62
+                    }
63
+                }
64
+            }
65
+        }
66
+        $pass .= $x;
67
+        $s = substr($s, 2);
68
+    }
69
+    $pass = preg_replace('@[./]@', 'a', $pass);
70
+    $pass = preg_replace('@[I1l]@', 'L', $pass);
71
+    $pass = preg_replace('@[0O]@', 'o', $pass);
72
+
73
+    return $pass;
74 74
 }
75 75
 
76 76
 /**
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
  * @return string Identifiant
80 80
  */
81 81
 function creer_uniqid() {
82
-	static $seeded;
82
+    static $seeded;
83 83
 
84
-	if (!$seeded) {
85
-		$seed = (int)round(((float)microtime() + 1) * time());
86
-		mt_srand($seed);
87
-		$seeded = true;
88
-	}
84
+    if (!$seeded) {
85
+        $seed = (int)round(((float)microtime() + 1) * time());
86
+        mt_srand($seed);
87
+        $seeded = true;
88
+    }
89 89
 
90
-	$s = random_int(0, mt_getrandmax());
91
-	if (!$s) {
92
-		$s = random_int(0, mt_getrandmax());
93
-	}
90
+    $s = random_int(0, mt_getrandmax());
91
+    if (!$s) {
92
+        $s = random_int(0, mt_getrandmax());
93
+    }
94 94
 
95
-	return uniqid($s, 1);
95
+    return uniqid($s, 1);
96 96
 }
97 97
 
98 98
 /**
@@ -106,42 +106,42 @@  discard block
 block discarded – undo
106 106
  * @return string Retourne l'alea éphemère actuel au passage
107 107
  */
108 108
 function charger_aleas() {
109
-	if (!isset($GLOBALS['meta']['alea_ephemere'])) {
110
-		include_spip('base/abstract_sql');
111
-		$aleas = sql_allfetsel(
112
-			['nom', 'valeur'],
113
-			'spip_meta',
114
-			sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']),
115
-			'',
116
-			'',
117
-			'',
118
-			'',
119
-			'',
120
-			'continue'
121
-		);
122
-		if ($aleas) {
123
-			foreach ($aleas as $a) {
124
-				$GLOBALS['meta'][$a['nom']] = $a['valeur'];
125
-			}
126
-			return $GLOBALS['meta']['alea_ephemere'];
127
-		} else {
128
-			spip_log('aleas indisponibles', 'session');
129
-			return '';
130
-		}
131
-	}
132
-	return $GLOBALS['meta']['alea_ephemere'];
109
+    if (!isset($GLOBALS['meta']['alea_ephemere'])) {
110
+        include_spip('base/abstract_sql');
111
+        $aleas = sql_allfetsel(
112
+            ['nom', 'valeur'],
113
+            'spip_meta',
114
+            sql_in('nom', ['alea_ephemere', 'alea_ephemere_ancien']),
115
+            '',
116
+            '',
117
+            '',
118
+            '',
119
+            '',
120
+            'continue'
121
+        );
122
+        if ($aleas) {
123
+            foreach ($aleas as $a) {
124
+                $GLOBALS['meta'][$a['nom']] = $a['valeur'];
125
+            }
126
+            return $GLOBALS['meta']['alea_ephemere'];
127
+        } else {
128
+            spip_log('aleas indisponibles', 'session');
129
+            return '';
130
+        }
131
+    }
132
+    return $GLOBALS['meta']['alea_ephemere'];
133 133
 }
134 134
 
135 135
 /**
136 136
  * Renouveller l'alea (utilisé pour sécuriser les scripts du répertoire `action/`)
137 137
  **/
138 138
 function renouvelle_alea() {
139
-	charger_aleas();
140
-	ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non');
141
-	$GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid());
142
-	ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non');
143
-	ecrire_meta('alea_ephemere_date', time(), 'non');
144
-	spip_log("renouvellement de l'alea_ephemere");
139
+    charger_aleas();
140
+    ecrire_meta('alea_ephemere_ancien', @$GLOBALS['meta']['alea_ephemere'], 'non');
141
+    $GLOBALS['meta']['alea_ephemere'] = md5(creer_uniqid());
142
+    ecrire_meta('alea_ephemere', $GLOBALS['meta']['alea_ephemere'], 'non');
143
+    ecrire_meta('alea_ephemere_date', time(), 'non');
144
+    spip_log("renouvellement de l'alea_ephemere");
145 145
 }
146 146
 
147 147
 
@@ -161,21 +161,21 @@  discard block
 block discarded – undo
161 161
  *     Clé de sécurité.
162 162
  **/
163 163
 function low_sec($id_auteur) {
164
-	// Pas d'id_auteur : low_sec
165
-	if (!$id_auteur = intval($id_auteur)) {
166
-		include_spip('inc/config');
167
-		if (!$low_sec = lire_config('low_sec')) {
168
-			ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
169
-		}
170
-	} else {
171
-		$low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . intval($id_auteur));
172
-		if (!$low_sec) {
173
-			$low_sec = creer_pass_aleatoire();
174
-			sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . intval($id_auteur));
175
-		}
176
-	}
177
-
178
-	return $low_sec;
164
+    // Pas d'id_auteur : low_sec
165
+    if (!$id_auteur = intval($id_auteur)) {
166
+        include_spip('inc/config');
167
+        if (!$low_sec = lire_config('low_sec')) {
168
+            ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
169
+        }
170
+    } else {
171
+        $low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . intval($id_auteur));
172
+        if (!$low_sec) {
173
+            $low_sec = creer_pass_aleatoire();
174
+            sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . intval($id_auteur));
175
+        }
176
+    }
177
+
178
+    return $low_sec;
179 179
 }
180 180
 
181 181
 
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
  * @filtre
209 209
  */
210 210
 function securiser_acces_low_sec($id_auteur, $cle, $dir, $op = '', $args = '') {
211
-	if ($op) {
212
-		$dir .= " $op $args";
213
-	}
211
+    if ($op) {
212
+        $dir .= " $op $args";
213
+    }
214 214
 
215
-	return verifier_low_sec($id_auteur, $cle, $dir);
215
+    return verifier_low_sec($id_auteur, $cle, $dir);
216 216
 }
217 217
 
218 218
 /**
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
  * @return string
228 228
  */
229 229
 function generer_url_api_low_sec(string $script, string $format, string $fond, string $path, string $args, bool $no_entities = false, ?bool $public = null) {
230
-	$id_auteur = $GLOBALS['visiteur_session']['id_auteur'] ?? 0;
231
-	$cle = afficher_low_sec($id_auteur, "$script/$format $fond $args");
232
-	$path = "$id_auteur/$cle/$format/$fond" . ($path ? "/$path" : '');
230
+    $id_auteur = $GLOBALS['visiteur_session']['id_auteur'] ?? 0;
231
+    $cle = afficher_low_sec($id_auteur, "$script/$format $fond $args");
232
+    $path = "$id_auteur/$cle/$format/$fond" . ($path ? "/$path" : '');
233 233
 
234
-	return generer_url_api($script, $path, $args, $no_entities = false, $public);
234
+    return generer_url_api($script, $path, $args, $no_entities = false, $public);
235 235
 }
236 236
 
237 237
 
@@ -249,27 +249,27 @@  discard block
 block discarded – undo
249 249
  * @deprecated 4.1
250 250
  */
251 251
 function param_low_sec($op, $args = [], $lang = '', $mime = 'rss') {
252
-	$a = $b = '';
253
-	foreach ($args as $val => $var) {
254
-		if ($var) {
255
-			if ($val <> 'statut') {
256
-				$a .= ':' . $val . '-' . $var;
257
-			}
258
-			$b .= $val . '=' . $var . '&';
259
-		}
260
-	}
261
-	$a = substr($a, 1);
262
-	$id = intval(@$GLOBALS['connect_id_auteur']);
263
-
264
-	return $b
265
-	. 'op='
266
-	. $op
267
-	. '&id='
268
-	. $id
269
-	. '&cle='
270
-	. afficher_low_sec($id, "$mime $op $a")
271
-	. (!$a ? '' : "&args=$a")
272
-	. (!$lang ? '' : "&lang=$lang");
252
+    $a = $b = '';
253
+    foreach ($args as $val => $var) {
254
+        if ($var) {
255
+            if ($val <> 'statut') {
256
+                $a .= ':' . $val . '-' . $var;
257
+            }
258
+            $b .= $val . '=' . $var . '&';
259
+        }
260
+    }
261
+    $a = substr($a, 1);
262
+    $id = intval(@$GLOBALS['connect_id_auteur']);
263
+
264
+    return $b
265
+    . 'op='
266
+    . $op
267
+    . '&id='
268
+    . $id
269
+    . '&cle='
270
+    . afficher_low_sec($id, "$mime $op $a")
271
+    . (!$a ? '' : "&args=$a")
272
+    . (!$lang ? '' : "&lang=$lang");
273 273
 }
274 274
 
275 275
 /**
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
  *     Clé
286 286
  **/
287 287
 function afficher_low_sec($id_auteur, $action = '') {
288
-	return substr(md5($action . low_sec($id_auteur)), 0, 8);
288
+    return substr(md5($action . low_sec($id_auteur)), 0, 8);
289 289
 }
290 290
 
291 291
 /**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
  *     true si les clés corresponde, false sinon
304 304
  **/
305 305
 function verifier_low_sec($id_auteur, $cle, $action = '') {
306
-	return ($cle == afficher_low_sec($id_auteur, $action));
306
+    return ($cle == afficher_low_sec($id_auteur, $action));
307 307
 }
308 308
 
309 309
 /**
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
  *     Identifiant de l'auteur
314 314
  **/
315 315
 function effacer_low_sec($id_auteur) {
316
-	if (!$id_auteur = intval($id_auteur)) {
317
-		return;
318
-	} // jamais trop prudent ;)
319
-	sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . intval($id_auteur));
316
+    if (!$id_auteur = intval($id_auteur)) {
317
+        return;
318
+    } // jamais trop prudent ;)
319
+    sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . intval($id_auteur));
320 320
 }
321 321
 
322 322
 
@@ -334,31 +334,31 @@  discard block
 block discarded – undo
334 334
  *     - void sinon.
335 335
  **/
336 336
 function ecrire_acces() {
337
-	$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
338
-	$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
339
-
340
-	// Cette variable de configuration peut etre posee par un plugin
341
-	// par exemple acces_restreint ;
342
-	// si .htaccess existe, outrepasser spip_meta
343
-	if (
344
-		(!isset($GLOBALS['meta']['creer_htpasswd'])
345
-			or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
346
-		and !@file_exists($htaccess)
347
-	) {
348
-		spip_unlink($htpasswd);
349
-		spip_unlink($htpasswd . '-admin');
350
-		return;
351
-	}
352
-
353
-	# remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
354
-	# de devenir redacteur le cas echeant (auth http)... a nettoyer
355
-	// attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
356
-	// TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test auth_ldap_connect()
357
-	if (include_spip('auth/ldap') and auth_ldap_connect()) {
358
-		return;
359
-	}
360
-
361
-	generer_htpasswd_files($htpasswd, "$htpasswd-admin");
337
+    $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
338
+    $htpasswd = _DIR_TMP . _AUTH_USER_FILE;
339
+
340
+    // Cette variable de configuration peut etre posee par un plugin
341
+    // par exemple acces_restreint ;
342
+    // si .htaccess existe, outrepasser spip_meta
343
+    if (
344
+        (!isset($GLOBALS['meta']['creer_htpasswd'])
345
+            or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
346
+        and !@file_exists($htaccess)
347
+    ) {
348
+        spip_unlink($htpasswd);
349
+        spip_unlink($htpasswd . '-admin');
350
+        return;
351
+    }
352
+
353
+    # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
354
+    # de devenir redacteur le cas echeant (auth http)... a nettoyer
355
+    // attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
356
+    // TODO: factoriser avec auth/spip qui fait deja ce job et generaliser le test auth_ldap_connect()
357
+    if (include_spip('auth/ldap') and auth_ldap_connect()) {
358
+        return;
359
+    }
360
+
361
+    generer_htpasswd_files($htpasswd, "$htpasswd-admin");
362 362
 }
363 363
 
364 364
 /**
@@ -367,29 +367,29 @@  discard block
 block discarded – undo
367 367
  * @param $htpasswd_admin
368 368
  */
369 369
 function generer_htpasswd_files($htpasswd, $htpasswd_admin) {
370
-	if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) {
371
-		$generer_htpasswd($htpasswd, $htpasswd_admin);
372
-	}
373
-
374
-	$pwd_all = ''; // login:htpass pour tous
375
-	$pwd_admin = ''; // login:htpass pour les admins
376
-
377
-	$res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
378
-	while ($row = sql_fetch($res)) {
379
-		if (strlen($row['login']) and strlen($row['htpass'])) {
380
-			$ligne = $row['login'] . ':' . $row['htpass'] . "\n";
381
-			$pwd_all .= $ligne;
382
-			if ($row['statut'] == '0minirezo') {
383
-				$pwd_admin .= $ligne;
384
-			}
385
-		}
386
-	}
387
-
388
-	if ($pwd_all) {
389
-		ecrire_fichier($htpasswd, $pwd_all);
390
-		ecrire_fichier($htpasswd_admin, $pwd_admin);
391
-		spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass');
392
-	}
370
+    if ($generer_htpasswd = charger_fonction('generer_htpasswd_files', 'inc', true)) {
371
+        $generer_htpasswd($htpasswd, $htpasswd_admin);
372
+    }
373
+
374
+    $pwd_all = ''; // login:htpass pour tous
375
+    $pwd_admin = ''; // login:htpass pour les admins
376
+
377
+    $res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
378
+    while ($row = sql_fetch($res)) {
379
+        if (strlen($row['login']) and strlen($row['htpass'])) {
380
+            $ligne = $row['login'] . ':' . $row['htpass'] . "\n";
381
+            $pwd_all .= $ligne;
382
+            if ($row['statut'] == '0minirezo') {
383
+                $pwd_admin .= $ligne;
384
+            }
385
+        }
386
+    }
387
+
388
+    if ($pwd_all) {
389
+        ecrire_fichier($htpasswd, $pwd_all);
390
+        ecrire_fichier($htpasswd_admin, $pwd_admin);
391
+        spip_log("Ecriture de $htpasswd et $htpasswd_admin", 'htpass');
392
+    }
393 393
 }
394 394
 
395 395
 /**
@@ -403,11 +403,11 @@  discard block
 block discarded – undo
403 403
  *  La chaîne hachée si fonction crypt présente, rien sinon.
404 404
  */
405 405
 function generer_htpass($pass) {
406
-	if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) {
407
-		return $generer_htpass($pass);
408
-	}
406
+    if ($generer_htpass = charger_fonction('generer_htpass', 'inc', true)) {
407
+        return $generer_htpass($pass);
408
+    }
409 409
 
410
-	return '';
410
+    return '';
411 411
 }
412 412
 
413 413
 /**
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
  * @return boolean
421 421
  */
422 422
 function verifier_htaccess($rep, $force = false) {
423
-	$htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
424
-	if (((@file_exists($htaccess)) or defined('_TEST_DIRS')) and !$force) {
425
-		return true;
426
-	}
427
-
428
-	// directive deny compatible Apache 2.0+
429
-	$deny =
430
-		'# Deny all requests from Apache 2.4+.
423
+    $htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
424
+    if (((@file_exists($htaccess)) or defined('_TEST_DIRS')) and !$force) {
425
+        return true;
426
+    }
427
+
428
+    // directive deny compatible Apache 2.0+
429
+    $deny =
430
+        '# Deny all requests from Apache 2.4+.
431 431
 <IfModule mod_authz_core.c>
432 432
   Require all denied
433 433
 </IfModule>
@@ -436,32 +436,32 @@  discard block
 block discarded – undo
436 436
   Deny from all
437 437
 </IfModule>
438 438
 ';
439
-	// support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD)
440
-	if (
441
-		function_exists('apache_get_version')
442
-		and $v = apache_get_version()
443
-		and strncmp($v, 'Apache/1.', 9) == 0
444
-	) {
445
-		$deny = "deny from all\n";
446
-	}
447
-
448
-	if ($ht = @fopen($htaccess, 'w')) {
449
-		fputs($ht, $deny);
450
-		fclose($ht);
451
-		@chmod($htaccess, _SPIP_CHMOD & 0666);
452
-		$t = rtrim($rep, '/') . '/.ok';
453
-		if ($ht = @fopen($t, 'w')) {
454
-			@fclose($ht);
455
-			include_spip('inc/distant');
456
-			$t = substr($t, strlen(_DIR_RACINE));
457
-			$t = url_de_base() . $t;
458
-			$ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
459
-			$ht = ($ht['status'] ?? null) === 403;
460
-		}
461
-	}
462
-	spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
463
-
464
-	return $ht;
439
+    // support des vieilles versions Apache 1.x mais uniquement si elles l'annoncent (pas en mode PROD)
440
+    if (
441
+        function_exists('apache_get_version')
442
+        and $v = apache_get_version()
443
+        and strncmp($v, 'Apache/1.', 9) == 0
444
+    ) {
445
+        $deny = "deny from all\n";
446
+    }
447
+
448
+    if ($ht = @fopen($htaccess, 'w')) {
449
+        fputs($ht, $deny);
450
+        fclose($ht);
451
+        @chmod($htaccess, _SPIP_CHMOD & 0666);
452
+        $t = rtrim($rep, '/') . '/.ok';
453
+        if ($ht = @fopen($t, 'w')) {
454
+            @fclose($ht);
455
+            include_spip('inc/distant');
456
+            $t = substr($t, strlen(_DIR_RACINE));
457
+            $t = url_de_base() . $t;
458
+            $ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
459
+            $ht = ($ht['status'] ?? null) === 403;
460
+        }
461
+    }
462
+    spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
463
+
464
+    return $ht;
465 465
 }
466 466
 
467 467
 /**
@@ -479,20 +479,20 @@  discard block
 block discarded – undo
479 479
  *         Valeur de la configuration `creer_htaccess`
480 480
  */
481 481
 function gerer_htaccess() {
482
-	// Cette variable de configuration peut etre posee par un plugin
483
-	// par exemple acces_restreint
484
-	$f = (isset($GLOBALS['meta']['creer_htaccess']) and ($GLOBALS['meta']['creer_htaccess'] === 'oui'));
485
-	$dirs = sql_allfetsel('extension', 'spip_types_documents');
486
-	$dirs[] = ['extension' => 'distant'];
487
-	foreach ($dirs as $e) {
488
-		if (is_dir($dir = _DIR_IMG . $e['extension'])) {
489
-			if ($f) {
490
-				verifier_htaccess($dir);
491
-			} else {
492
-				spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
493
-			}
494
-		}
495
-	}
496
-
497
-	return $GLOBALS['meta']['creer_htaccess'] ?? '';
482
+    // Cette variable de configuration peut etre posee par un plugin
483
+    // par exemple acces_restreint
484
+    $f = (isset($GLOBALS['meta']['creer_htaccess']) and ($GLOBALS['meta']['creer_htaccess'] === 'oui'));
485
+    $dirs = sql_allfetsel('extension', 'spip_types_documents');
486
+    $dirs[] = ['extension' => 'distant'];
487
+    foreach ($dirs as $e) {
488
+        if (is_dir($dir = _DIR_IMG . $e['extension'])) {
489
+            if ($f) {
490
+                verifier_htaccess($dir);
491
+            } else {
492
+                spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
493
+            }
494
+        }
495
+    }
496
+
497
+    return $GLOBALS['meta']['creer_htaccess'] ?? '';
498 498
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  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());
34
+	$seed = (int) round(((float) microtime() + 1) * time());
35 35
 
36 36
 	mt_srand($seed);
37 37
 	$s = '';
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 			if (!$s) {
43 43
 				$s = random_int(0, mt_getrandmax());
44 44
 			}
45
-			$s = substr(md5(uniqid($s) . $sel), 0, 16);
45
+			$s = substr(md5(uniqid($s).$sel), 0, 16);
46 46
 		}
47
-		$r = unpack('Cr', pack('H2', $s . $s));
47
+		$r = unpack('Cr', pack('H2', $s.$s));
48 48
 		$x = $r['r'] & 63;
49 49
 		if ($x < 10) {
50 50
 			$x = chr($x + 48);
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	static $seeded;
83 83
 
84 84
 	if (!$seeded) {
85
-		$seed = (int)round(((float)microtime() + 1) * time());
85
+		$seed = (int) round(((float) microtime() + 1) * time());
86 86
 		mt_srand($seed);
87 87
 		$seeded = true;
88 88
 	}
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 			ecrire_meta('low_sec', $low_sec = creer_pass_aleatoire());
169 169
 		}
170 170
 	} else {
171
-		$low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = ' . intval($id_auteur));
171
+		$low_sec = sql_getfetsel('low_sec', 'spip_auteurs', 'id_auteur = '.intval($id_auteur));
172 172
 		if (!$low_sec) {
173 173
 			$low_sec = creer_pass_aleatoire();
174
-			sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = ' . intval($id_auteur));
174
+			sql_updateq('spip_auteurs', ['low_sec' => $low_sec], 'id_auteur = '.intval($id_auteur));
175 175
 		}
176 176
 	}
177 177
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 function generer_url_api_low_sec(string $script, string $format, string $fond, string $path, string $args, bool $no_entities = false, ?bool $public = null) {
230 230
 	$id_auteur = $GLOBALS['visiteur_session']['id_auteur'] ?? 0;
231 231
 	$cle = afficher_low_sec($id_auteur, "$script/$format $fond $args");
232
-	$path = "$id_auteur/$cle/$format/$fond" . ($path ? "/$path" : '');
232
+	$path = "$id_auteur/$cle/$format/$fond".($path ? "/$path" : '');
233 233
 
234 234
 	return generer_url_api($script, $path, $args, $no_entities = false, $public);
235 235
 }
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 	foreach ($args as $val => $var) {
254 254
 		if ($var) {
255 255
 			if ($val <> 'statut') {
256
-				$a .= ':' . $val . '-' . $var;
256
+				$a .= ':'.$val.'-'.$var;
257 257
 			}
258
-			$b .= $val . '=' . $var . '&';
258
+			$b .= $val.'='.$var.'&';
259 259
 		}
260 260
 	}
261 261
 	$a = substr($a, 1);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
  *     Clé
286 286
  **/
287 287
 function afficher_low_sec($id_auteur, $action = '') {
288
-	return substr(md5($action . low_sec($id_auteur)), 0, 8);
288
+	return substr(md5($action.low_sec($id_auteur)), 0, 8);
289 289
 }
290 290
 
291 291
 /**
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	if (!$id_auteur = intval($id_auteur)) {
317 317
 		return;
318 318
 	} // jamais trop prudent ;)
319
-	sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = ' . intval($id_auteur));
319
+	sql_updateq('spip_auteurs', ['low_sec' => ''], 'id_auteur = '.intval($id_auteur));
320 320
 }
321 321
 
322 322
 
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
  *     - void sinon.
335 335
  **/
336 336
 function ecrire_acces() {
337
-	$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
338
-	$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
337
+	$htaccess = _DIR_RESTREINT._ACCESS_FILE_NAME;
338
+	$htpasswd = _DIR_TMP._AUTH_USER_FILE;
339 339
 
340 340
 	// Cette variable de configuration peut etre posee par un plugin
341 341
 	// par exemple acces_restreint ;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		and !@file_exists($htaccess)
347 347
 	) {
348 348
 		spip_unlink($htpasswd);
349
-		spip_unlink($htpasswd . '-admin');
349
+		spip_unlink($htpasswd.'-admin');
350 350
 		return;
351 351
 	}
352 352
 
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
 	$pwd_all = ''; // login:htpass pour tous
375 375
 	$pwd_admin = ''; // login:htpass pour les admins
376 376
 
377
-	$res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND " . sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
377
+	$res = sql_select('login, htpass, statut', 'spip_auteurs', "htpass!='' AND login!='' AND ".sql_in('statut', ['1comite', '0minirezo', 'nouveau']));
378 378
 	while ($row = sql_fetch($res)) {
379 379
 		if (strlen($row['login']) and strlen($row['htpass'])) {
380
-			$ligne = $row['login'] . ':' . $row['htpass'] . "\n";
380
+			$ligne = $row['login'].':'.$row['htpass']."\n";
381 381
 			$pwd_all .= $ligne;
382 382
 			if ($row['statut'] == '0minirezo') {
383 383
 				$pwd_admin .= $ligne;
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
  * @return boolean
421 421
  */
422 422
 function verifier_htaccess($rep, $force = false) {
423
-	$htaccess = rtrim($rep, '/') . '/' . _ACCESS_FILE_NAME;
423
+	$htaccess = rtrim($rep, '/').'/'._ACCESS_FILE_NAME;
424 424
 	if (((@file_exists($htaccess)) or defined('_TEST_DIRS')) and !$force) {
425 425
 		return true;
426 426
 	}
@@ -449,17 +449,17 @@  discard block
 block discarded – undo
449 449
 		fputs($ht, $deny);
450 450
 		fclose($ht);
451 451
 		@chmod($htaccess, _SPIP_CHMOD & 0666);
452
-		$t = rtrim($rep, '/') . '/.ok';
452
+		$t = rtrim($rep, '/').'/.ok';
453 453
 		if ($ht = @fopen($t, 'w')) {
454 454
 			@fclose($ht);
455 455
 			include_spip('inc/distant');
456 456
 			$t = substr($t, strlen(_DIR_RACINE));
457
-			$t = url_de_base() . $t;
457
+			$t = url_de_base().$t;
458 458
 			$ht = recuperer_url($t, ['methode' => 'HEAD', 'taille_max' => 0, 'follow_location' => false]);
459 459
 			$ht = ($ht['status'] ?? null) === 403;
460 460
 		}
461 461
 	}
462
-	spip_log("Creation de $htaccess " . ($ht ? ' reussie' : ' manquee'));
462
+	spip_log("Creation de $htaccess ".($ht ? ' reussie' : ' manquee'));
463 463
 
464 464
 	return $ht;
465 465
 }
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
 	$dirs = sql_allfetsel('extension', 'spip_types_documents');
486 486
 	$dirs[] = ['extension' => 'distant'];
487 487
 	foreach ($dirs as $e) {
488
-		if (is_dir($dir = _DIR_IMG . $e['extension'])) {
488
+		if (is_dir($dir = _DIR_IMG.$e['extension'])) {
489 489
 			if ($f) {
490 490
 				verifier_htaccess($dir);
491 491
 			} else {
492
-				spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
492
+				spip_unlink($dir.'/'._ACCESS_FILE_NAME);
493 493
 			}
494 494
 		}
495 495
 	}
Please login to merge, or discard this patch.
ecrire/inc/config.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -312,8 +312,7 @@
 block discarded – undo
312 312
 					ecrire_meta($casier, $serialized_store, null, $table);
313 313
 				}
314 314
 			}
315
-		}
316
-		else {
315
+		} else {
317 316
 			ecrire_meta($casier, $store, null, $table);
318 317
 		}
319 318
 	}
Please login to merge, or discard this patch.
Indentation   +352 added lines, -352 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
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  * @return void
29 29
  */
30 30
 function inc_config_dist() {
31
-	actualise_metas(liste_metas());
31
+    actualise_metas(liste_metas());
32 32
 }
33 33
 
34 34
 /**
@@ -45,34 +45,34 @@  discard block
 block discarded – undo
45 45
  *     Liste (table, casier, sous_casier)
46 46
  */
47 47
 function expliquer_config($cfg) {
48
-	// par defaut, sur la table des meta
49
-	$table = 'meta';
50
-	$casier = null;
51
-	$sous_casier = [];
52
-	$cfg = explode('/', $cfg);
53
-
54
-	// si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide ''
55
-	if (!reset($cfg) and count($cfg) > 1) {
56
-		array_shift($cfg);
57
-		$table = array_shift($cfg);
58
-		if (!isset($GLOBALS[$table])) {
59
-			lire_metas($table);
60
-		}
61
-	}
62
-
63
-	// si on a demande #CONFIG{/meta,'',0}
64
-	if (count($cfg)) {
65
-		// pas sur un appel vide ''
66
-		if ('' !== ($c = array_shift($cfg))) {
67
-			$casier = $c;
68
-		}
69
-	}
70
-
71
-	if (count($cfg)) {
72
-		$sous_casier = $cfg;
73
-	}
74
-
75
-	return [$table, $casier, $sous_casier];
48
+    // par defaut, sur la table des meta
49
+    $table = 'meta';
50
+    $casier = null;
51
+    $sous_casier = [];
52
+    $cfg = explode('/', $cfg);
53
+
54
+    // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide ''
55
+    if (!reset($cfg) and count($cfg) > 1) {
56
+        array_shift($cfg);
57
+        $table = array_shift($cfg);
58
+        if (!isset($GLOBALS[$table])) {
59
+            lire_metas($table);
60
+        }
61
+    }
62
+
63
+    // si on a demande #CONFIG{/meta,'',0}
64
+    if (count($cfg)) {
65
+        // pas sur un appel vide ''
66
+        if ('' !== ($c = array_shift($cfg))) {
67
+            $casier = $c;
68
+        }
69
+    }
70
+
71
+    if (count($cfg)) {
72
+        $sous_casier = $cfg;
73
+    }
74
+
75
+    return [$table, $casier, $sous_casier];
76 76
 }
77 77
 
78 78
 /**
@@ -100,65 +100,65 @@  discard block
 block discarded – undo
100 100
  *    Contenu de la configuration obtenue
101 101
  */
102 102
 function lire_config($cfg = '', $def = null, $unserialize = true) {
103
-	// lire le stockage sous la forme /table/valeur
104
-	// ou valeur qui est en fait implicitement /meta/valeur
105
-	// ou casier/valeur qui est en fait implicitement /meta/casier/valeur
106
-
107
-	// traiter en priorite le cas simple et frequent
108
-	// de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni :
109
-	if ($cfg and strpbrk($cfg, '/:') === false) {
110
-		$r = isset($GLOBALS['meta'][$cfg]) ?
111
-			((!$unserialize
112
-				// ne pas essayer de deserialiser autre chose qu'une chaine
113
-				or !is_string($GLOBALS['meta'][$cfg])
114
-				// ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee
115
-				or strpos($GLOBALS['meta'][$cfg], ':') === false
116
-				or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t)
117
-			: $def;
118
-
119
-		return $r;
120
-	}
121
-
122
-	// Brancher sur methodes externes si besoin
123
-	if ($cfg and $p = strpos($cfg, '::')) {
124
-		$methode = substr($cfg, 0, $p);
125
-		$lire_config = charger_fonction($methode, 'lire_config');
126
-
127
-		return $lire_config(substr($cfg, $p + 2), $def, $unserialize);
128
-	}
129
-
130
-	[$table, $casier, $sous_casier] = expliquer_config($cfg);
131
-
132
-	if (!isset($GLOBALS[$table])) {
133
-		return $def;
134
-	}
135
-
136
-	$r = $GLOBALS[$table];
137
-
138
-	// si on a demande #CONFIG{/meta,'',0}
139
-	if (!$casier) {
140
-		return $unserialize ? $r : serialize($r);
141
-	}
142
-
143
-	// casier principal :
144
-	// le deserializer si demande
145
-	// ou si on a besoin
146
-	// d'un sous casier
147
-	$r = $r[$casier] ?? null;
148
-	if (($unserialize or is_countable($sous_casier) ? count($sous_casier) : 0) and $r and is_string($r)) {
149
-		$r = (($t = @unserialize($r)) === false ? $r : $t);
150
-	}
151
-
152
-	// aller chercher le sous_casier
153
-	while (!is_null($r) and $casier = array_shift($sous_casier)) {
154
-		$r = $r[$casier] ?? null;
155
-	}
156
-
157
-	if (is_null($r)) {
158
-		return $def;
159
-	}
160
-
161
-	return $r;
103
+    // lire le stockage sous la forme /table/valeur
104
+    // ou valeur qui est en fait implicitement /meta/valeur
105
+    // ou casier/valeur qui est en fait implicitement /meta/casier/valeur
106
+
107
+    // traiter en priorite le cas simple et frequent
108
+    // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni :
109
+    if ($cfg and strpbrk($cfg, '/:') === false) {
110
+        $r = isset($GLOBALS['meta'][$cfg]) ?
111
+            ((!$unserialize
112
+                // ne pas essayer de deserialiser autre chose qu'une chaine
113
+                or !is_string($GLOBALS['meta'][$cfg])
114
+                // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee
115
+                or strpos($GLOBALS['meta'][$cfg], ':') === false
116
+                or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t)
117
+            : $def;
118
+
119
+        return $r;
120
+    }
121
+
122
+    // Brancher sur methodes externes si besoin
123
+    if ($cfg and $p = strpos($cfg, '::')) {
124
+        $methode = substr($cfg, 0, $p);
125
+        $lire_config = charger_fonction($methode, 'lire_config');
126
+
127
+        return $lire_config(substr($cfg, $p + 2), $def, $unserialize);
128
+    }
129
+
130
+    [$table, $casier, $sous_casier] = expliquer_config($cfg);
131
+
132
+    if (!isset($GLOBALS[$table])) {
133
+        return $def;
134
+    }
135
+
136
+    $r = $GLOBALS[$table];
137
+
138
+    // si on a demande #CONFIG{/meta,'',0}
139
+    if (!$casier) {
140
+        return $unserialize ? $r : serialize($r);
141
+    }
142
+
143
+    // casier principal :
144
+    // le deserializer si demande
145
+    // ou si on a besoin
146
+    // d'un sous casier
147
+    $r = $r[$casier] ?? null;
148
+    if (($unserialize or is_countable($sous_casier) ? count($sous_casier) : 0) and $r and is_string($r)) {
149
+        $r = (($t = @unserialize($r)) === false ? $r : $t);
150
+    }
151
+
152
+    // aller chercher le sous_casier
153
+    while (!is_null($r) and $casier = array_shift($sous_casier)) {
154
+        $r = $r[$casier] ?? null;
155
+    }
156
+
157
+    if (is_null($r)) {
158
+        return $def;
159
+    }
160
+
161
+    return $r;
162 162
 }
163 163
 
164 164
 /**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
  * @return mixed
173 173
  */
174 174
 function lire_config_metapack_dist($cfg = '', $def = null, $unserialize = true) {
175
-	return lire_config($cfg, $def, $unserialize);
175
+    return lire_config($cfg, $def, $unserialize);
176 176
 }
177 177
 
178 178
 
@@ -184,144 +184,144 @@  discard block
 block discarded – undo
184 184
  * @return bool
185 185
  */
186 186
 function ecrire_config($cfg, $store) {
187
-	// Brancher sur methodes externes si besoin
188
-	if ($cfg and $p = strpos($cfg, '::')) {
189
-		$methode = substr($cfg, 0, $p);
190
-		$ecrire_config = charger_fonction($methode, 'ecrire_config');
191
-
192
-		return $ecrire_config(substr($cfg, $p + 2), $store);
193
-	}
194
-
195
-	[$table, $casier, $sous_casier] = expliquer_config($cfg);
196
-	// il faut au moins un casier pour ecrire
197
-	if (!$casier) {
198
-		return false;
199
-	}
200
-
201
-	// trouvons ou creons le pointeur sur le casier
202
-	$st = $GLOBALS[$table][$casier] ?? null;
203
-	if (!is_array($st) and ($sous_casier or is_array($store))) {
204
-		if ($st === null) {
205
-			// ne rien creer si c'est une demande d'effacement
206
-			if ($store === null) {
207
-				return false;
208
-			}
209
-			$st = [];
210
-		} else {
211
-			$st = unserialize($st);
212
-			if ($st === false) {
213
-				// ne rien creer si c'est une demande d'effacement
214
-				if ($store === null) {
215
-					return false;
216
-				}
217
-				$st = [];
218
-			}
219
-		}
220
-	}
221
-
222
-	$has_planes = false;
223
-	// si on a affaire a un sous caiser
224
-	// il faut ecrire au bon endroit sans perdre les autres sous casier freres
225
-	if ($c = $sous_casier) {
226
-		$sc = &$st;
227
-		$pointeurs = [];
228
-		while (is_countable($c) ? count($c) : 0 and $cc = array_shift($c)) {
229
-			// creer l'entree si elle n'existe pas
230
-			if (!isset($sc[$cc])) {
231
-				// si on essaye d'effacer une config qui n'existe pas
232
-				// ne rien creer mais sortir
233
-				if (is_null($store)) {
234
-					return false;
235
-				}
236
-				$sc[$cc] = [];
237
-			}
238
-			$pointeurs[$cc] = &$sc;
239
-			$sc = &$sc[$cc];
240
-		}
241
-
242
-		// si c'est une demande d'effacement
243
-		if (is_null($store)) {
244
-			$c = $sous_casier;
245
-			$sous = array_pop($c);
246
-			// effacer, et remonter pour effacer les parents vides
247
-			do {
248
-				unset($pointeurs[$sous][$sous]);
249
-			} while ($sous = array_pop($c) and !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0));
250
-
251
-			// si on a vide tous les sous casiers,
252
-			// et que le casier est vide
253
-			// vider aussi la meta
254
-			if (!$sous and !(is_countable($st) ? count($st) : 0)) {
255
-				$st = null;
256
-			}
257
-		} // dans tous les autres cas, on ecrase
258
-		else {
259
-			if (
260
-					defined('_MYSQL_NOPLANES')
261
-				and _MYSQL_NOPLANES
262
-				and !empty($GLOBALS['meta']['charset_sql_connexion'])
263
-				and $GLOBALS['meta']['charset_sql_connexion'] == 'utf8'
264
-			) {
265
-				// detecter si la valeur qu'on veut ecrire a des planes
266
-				// @see utf8_noplanes
267
-				$serialized_store = (is_string($store) ? $store : serialize($store));
268
-				// un preg_match rapide pour voir si ca vaut le coup de lancer utf8_noplanes
269
-				if (preg_match(',[\xF0-\xF4],ms', $serialized_store)) {
270
-					if (!function_exists('utf8_noplanes')) {
271
-						include_spip('inc/charsets');
272
-					}
273
-					if ($serialized_store !== utf8_noplanes($serialized_store)) {
274
-						$has_planes = true;
275
-					}
276
-				}
277
-			}
278
-
279
-			$sc = $store;
280
-		}
281
-
282
-		// Maintenant que $st est modifiee
283
-		// reprenons la comme valeur a stocker dans le casier principal
284
-		$store = $st;
285
-	}
286
-
287
-	if (is_null($store)) {
288
-		if (is_null($st) and !$sous_casier) {
289
-			return false;
290
-		} // la config n'existait deja pas !
291
-		effacer_meta($casier, $table);
292
-		supprimer_table_meta($table); // supprimons la table (si elle est bien vide)
293
-	} // les meta ne peuvent etre que des chaines : il faut serializer le reste
294
-	else {
295
-		if (!isset($GLOBALS[$table])) {
296
-			installer_table_meta($table);
297
-		}
298
-		// si ce n'est pas une chaine
299
-		// il faut serializer
300
-		if (!is_string($store)) {
301
-			$serialized_store = serialize($store);
302
-			ecrire_meta($casier, $serialized_store, null, $table);
303
-			// et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine
304
-			// car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4)
305
-			if ($has_planes) {
306
-				$check_store = sql_getfetsel('valeur', 'spip_' . $table, 'nom=' . sql_quote($casier));
307
-				if ($check_store !== $serialized_store) {
308
-					array_walk_recursive($store, function (&$value, $key) {
309
-						if (is_string($value)) {
310
-							$value = utf8_noplanes($value);
311
-						}
312
-					});
313
-					$serialized_store = serialize($store);
314
-					ecrire_meta($casier, $serialized_store, null, $table);
315
-				}
316
-			}
317
-		}
318
-		else {
319
-			ecrire_meta($casier, $store, null, $table);
320
-		}
321
-	}
322
-
323
-	// verifier que lire_config($cfg)==$store ?
324
-	return true;
187
+    // Brancher sur methodes externes si besoin
188
+    if ($cfg and $p = strpos($cfg, '::')) {
189
+        $methode = substr($cfg, 0, $p);
190
+        $ecrire_config = charger_fonction($methode, 'ecrire_config');
191
+
192
+        return $ecrire_config(substr($cfg, $p + 2), $store);
193
+    }
194
+
195
+    [$table, $casier, $sous_casier] = expliquer_config($cfg);
196
+    // il faut au moins un casier pour ecrire
197
+    if (!$casier) {
198
+        return false;
199
+    }
200
+
201
+    // trouvons ou creons le pointeur sur le casier
202
+    $st = $GLOBALS[$table][$casier] ?? null;
203
+    if (!is_array($st) and ($sous_casier or is_array($store))) {
204
+        if ($st === null) {
205
+            // ne rien creer si c'est une demande d'effacement
206
+            if ($store === null) {
207
+                return false;
208
+            }
209
+            $st = [];
210
+        } else {
211
+            $st = unserialize($st);
212
+            if ($st === false) {
213
+                // ne rien creer si c'est une demande d'effacement
214
+                if ($store === null) {
215
+                    return false;
216
+                }
217
+                $st = [];
218
+            }
219
+        }
220
+    }
221
+
222
+    $has_planes = false;
223
+    // si on a affaire a un sous caiser
224
+    // il faut ecrire au bon endroit sans perdre les autres sous casier freres
225
+    if ($c = $sous_casier) {
226
+        $sc = &$st;
227
+        $pointeurs = [];
228
+        while (is_countable($c) ? count($c) : 0 and $cc = array_shift($c)) {
229
+            // creer l'entree si elle n'existe pas
230
+            if (!isset($sc[$cc])) {
231
+                // si on essaye d'effacer une config qui n'existe pas
232
+                // ne rien creer mais sortir
233
+                if (is_null($store)) {
234
+                    return false;
235
+                }
236
+                $sc[$cc] = [];
237
+            }
238
+            $pointeurs[$cc] = &$sc;
239
+            $sc = &$sc[$cc];
240
+        }
241
+
242
+        // si c'est une demande d'effacement
243
+        if (is_null($store)) {
244
+            $c = $sous_casier;
245
+            $sous = array_pop($c);
246
+            // effacer, et remonter pour effacer les parents vides
247
+            do {
248
+                unset($pointeurs[$sous][$sous]);
249
+            } while ($sous = array_pop($c) and !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0));
250
+
251
+            // si on a vide tous les sous casiers,
252
+            // et que le casier est vide
253
+            // vider aussi la meta
254
+            if (!$sous and !(is_countable($st) ? count($st) : 0)) {
255
+                $st = null;
256
+            }
257
+        } // dans tous les autres cas, on ecrase
258
+        else {
259
+            if (
260
+                    defined('_MYSQL_NOPLANES')
261
+                and _MYSQL_NOPLANES
262
+                and !empty($GLOBALS['meta']['charset_sql_connexion'])
263
+                and $GLOBALS['meta']['charset_sql_connexion'] == 'utf8'
264
+            ) {
265
+                // detecter si la valeur qu'on veut ecrire a des planes
266
+                // @see utf8_noplanes
267
+                $serialized_store = (is_string($store) ? $store : serialize($store));
268
+                // un preg_match rapide pour voir si ca vaut le coup de lancer utf8_noplanes
269
+                if (preg_match(',[\xF0-\xF4],ms', $serialized_store)) {
270
+                    if (!function_exists('utf8_noplanes')) {
271
+                        include_spip('inc/charsets');
272
+                    }
273
+                    if ($serialized_store !== utf8_noplanes($serialized_store)) {
274
+                        $has_planes = true;
275
+                    }
276
+                }
277
+            }
278
+
279
+            $sc = $store;
280
+        }
281
+
282
+        // Maintenant que $st est modifiee
283
+        // reprenons la comme valeur a stocker dans le casier principal
284
+        $store = $st;
285
+    }
286
+
287
+    if (is_null($store)) {
288
+        if (is_null($st) and !$sous_casier) {
289
+            return false;
290
+        } // la config n'existait deja pas !
291
+        effacer_meta($casier, $table);
292
+        supprimer_table_meta($table); // supprimons la table (si elle est bien vide)
293
+    } // les meta ne peuvent etre que des chaines : il faut serializer le reste
294
+    else {
295
+        if (!isset($GLOBALS[$table])) {
296
+            installer_table_meta($table);
297
+        }
298
+        // si ce n'est pas une chaine
299
+        // il faut serializer
300
+        if (!is_string($store)) {
301
+            $serialized_store = serialize($store);
302
+            ecrire_meta($casier, $serialized_store, null, $table);
303
+            // et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine
304
+            // car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4)
305
+            if ($has_planes) {
306
+                $check_store = sql_getfetsel('valeur', 'spip_' . $table, 'nom=' . sql_quote($casier));
307
+                if ($check_store !== $serialized_store) {
308
+                    array_walk_recursive($store, function (&$value, $key) {
309
+                        if (is_string($value)) {
310
+                            $value = utf8_noplanes($value);
311
+                        }
312
+                    });
313
+                    $serialized_store = serialize($store);
314
+                    ecrire_meta($casier, $serialized_store, null, $table);
315
+                }
316
+            }
317
+        }
318
+        else {
319
+            ecrire_meta($casier, $store, null, $table);
320
+        }
321
+    }
322
+
323
+    // verifier que lire_config($cfg)==$store ?
324
+    return true;
325 325
 }
326 326
 
327 327
 
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
  * @return bool
336 336
  */
337 337
 function ecrire_config_metapack_dist($cfg, $store) {
338
-	// cas particulier en metapack::
339
-	// si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre
340
-	// intacte en sortie ...
341
-	if (is_string($store) and strpos($store, ':') and unserialize($store)) {
342
-		$store = serialize($store);
343
-	}
344
-
345
-	return ecrire_config($cfg, $store);
338
+    // cas particulier en metapack::
339
+    // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre
340
+    // intacte en sortie ...
341
+    if (is_string($store) and strpos($store, ':') and unserialize($store)) {
342
+        $store = serialize($store);
343
+    }
344
+
345
+    return ecrire_config($cfg, $store);
346 346
 }
347 347
 
348 348
 /**
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
  * @return bool
353 353
  */
354 354
 function effacer_config($cfg) {
355
-	ecrire_config($cfg, null);
355
+    ecrire_config($cfg, null);
356 356
 
357
-	return true;
357
+    return true;
358 358
 }
359 359
 
360 360
 /**
@@ -371,58 +371,58 @@  discard block
 block discarded – undo
371 371
  *    Couples nom de la `meta` => valeur par défaut
372 372
  */
373 373
 function liste_metas() {
374
-	return pipeline('configurer_liste_metas', [
375
-		'nom_site' => _T('info_mon_site_spip'),
376
-		'slogan_site' => '',
377
-		'adresse_site' => preg_replace(',/$,', '', url_de_base()),
378
-		'descriptif_site' => '',
379
-		'activer_logos' => 'oui',
380
-		'activer_logos_survol' => 'non',
381
-		'articles_surtitre' => 'non',
382
-		'articles_soustitre' => 'non',
383
-		'articles_descriptif' => 'non',
384
-		'articles_chapeau' => 'non',
385
-		'articles_texte' => 'oui',
386
-		'articles_ps' => 'non',
387
-		'articles_redac' => 'non',
388
-		'post_dates' => 'non',
389
-		'articles_urlref' => 'non',
390
-		'articles_redirection' => 'non',
391
-		'creer_preview' => 'non',
392
-		'taille_preview' => 150,
393
-		'articles_modif' => 'non',
394
-
395
-		'rubriques_descriptif' => 'non',
396
-		'rubriques_texte' => 'oui',
397
-
398
-		'accepter_inscriptions' => 'non',
399
-		'accepter_visiteurs' => 'non',
400
-		'prevenir_auteurs' => 'non',
401
-		'suivi_edito' => 'non',
402
-		'adresse_suivi' => '',
403
-		'adresse_suivi_inscription' => '',
404
-		'adresse_neuf' => '',
405
-		'jours_neuf' => '',
406
-		'quoi_de_neuf' => 'non',
407
-		'preview' => ',0minirezo,1comite,',
408
-
409
-		'syndication_integrale' => 'oui',
410
-		'charset' => _DEFAULT_CHARSET,
411
-		'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)),
412
-
413
-		'multi_rubriques' => 'non',
414
-		'multi_secteurs' => 'non',
415
-		'gerer_trad' => 'non',
416
-		'langues_multilingue' => '',
417
-
418
-		'version_html_max' => 'html4',
419
-
420
-		'type_urls' => 'page',
421
-
422
-		'email_envoi' => '',
423
-		'email_webmaster' => '',
424
-		'auto_compress_http' => 'non',
425
-	]);
374
+    return pipeline('configurer_liste_metas', [
375
+        'nom_site' => _T('info_mon_site_spip'),
376
+        'slogan_site' => '',
377
+        'adresse_site' => preg_replace(',/$,', '', url_de_base()),
378
+        'descriptif_site' => '',
379
+        'activer_logos' => 'oui',
380
+        'activer_logos_survol' => 'non',
381
+        'articles_surtitre' => 'non',
382
+        'articles_soustitre' => 'non',
383
+        'articles_descriptif' => 'non',
384
+        'articles_chapeau' => 'non',
385
+        'articles_texte' => 'oui',
386
+        'articles_ps' => 'non',
387
+        'articles_redac' => 'non',
388
+        'post_dates' => 'non',
389
+        'articles_urlref' => 'non',
390
+        'articles_redirection' => 'non',
391
+        'creer_preview' => 'non',
392
+        'taille_preview' => 150,
393
+        'articles_modif' => 'non',
394
+
395
+        'rubriques_descriptif' => 'non',
396
+        'rubriques_texte' => 'oui',
397
+
398
+        'accepter_inscriptions' => 'non',
399
+        'accepter_visiteurs' => 'non',
400
+        'prevenir_auteurs' => 'non',
401
+        'suivi_edito' => 'non',
402
+        'adresse_suivi' => '',
403
+        'adresse_suivi_inscription' => '',
404
+        'adresse_neuf' => '',
405
+        'jours_neuf' => '',
406
+        'quoi_de_neuf' => 'non',
407
+        'preview' => ',0minirezo,1comite,',
408
+
409
+        'syndication_integrale' => 'oui',
410
+        'charset' => _DEFAULT_CHARSET,
411
+        'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)),
412
+
413
+        'multi_rubriques' => 'non',
414
+        'multi_secteurs' => 'non',
415
+        'gerer_trad' => 'non',
416
+        'langues_multilingue' => '',
417
+
418
+        'version_html_max' => 'html4',
419
+
420
+        'type_urls' => 'page',
421
+
422
+        'email_envoi' => '',
423
+        'email_webmaster' => '',
424
+        'auto_compress_http' => 'non',
425
+    ]);
426 426
 }
427 427
 
428 428
 /**
@@ -433,43 +433,43 @@  discard block
 block discarded – undo
433 433
  * @return void
434 434
  */
435 435
 function actualise_metas($liste_meta) {
436
-	$meta_serveur =
437
-		[
438
-			'version_installee',
439
-			'adresse_site',
440
-			'alea_ephemere_ancien',
441
-			'alea_ephemere',
442
-			'alea_ephemere_date',
443
-			'langue_site',
444
-			'langues_proposees',
445
-			'date_calcul_rubriques',
446
-			'derniere_modif',
447
-			'optimiser_table',
448
-			'drapeau_edition',
449
-			'creer_preview',
450
-			'taille_preview',
451
-			'creer_htpasswd',
452
-			'creer_htaccess',
453
-			'gd_formats_read',
454
-			'gd_formats',
455
-			'netpbm_formats',
456
-			'formats_graphiques',
457
-			'image_process',
458
-			'plugin_header',
459
-			'plugin'
460
-		];
461
-	// verifier le impt=non
462
-	sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur));
463
-
464
-	foreach ($liste_meta as $nom => $valeur) {
465
-		if (empty($GLOBALS['meta'][$nom])) {
466
-			ecrire_meta($nom, $valeur);
467
-		}
468
-	}
469
-
470
-	include_spip('inc/rubriques');
471
-	$langues = calculer_langues_utilisees();
472
-	ecrire_meta('langues_utilisees', $langues);
436
+    $meta_serveur =
437
+        [
438
+            'version_installee',
439
+            'adresse_site',
440
+            'alea_ephemere_ancien',
441
+            'alea_ephemere',
442
+            'alea_ephemere_date',
443
+            'langue_site',
444
+            'langues_proposees',
445
+            'date_calcul_rubriques',
446
+            'derniere_modif',
447
+            'optimiser_table',
448
+            'drapeau_edition',
449
+            'creer_preview',
450
+            'taille_preview',
451
+            'creer_htpasswd',
452
+            'creer_htaccess',
453
+            'gd_formats_read',
454
+            'gd_formats',
455
+            'netpbm_formats',
456
+            'formats_graphiques',
457
+            'image_process',
458
+            'plugin_header',
459
+            'plugin'
460
+        ];
461
+    // verifier le impt=non
462
+    sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur));
463
+
464
+    foreach ($liste_meta as $nom => $valeur) {
465
+        if (empty($GLOBALS['meta'][$nom])) {
466
+            ecrire_meta($nom, $valeur);
467
+        }
468
+    }
469
+
470
+    include_spip('inc/rubriques');
471
+    $langues = calculer_langues_utilisees();
472
+    ecrire_meta('langues_utilisees', $langues);
473 473
 }
474 474
 
475 475
 
@@ -491,18 +491,18 @@  discard block
 block discarded – undo
491 491
  */
492 492
 function appliquer_modifs_config($purger_skel = false) {
493 493
 
494
-	foreach (liste_metas() as $i => $v) {
495
-		if (($x = _request($i)) !== null) {
496
-			ecrire_meta($i, $x);
497
-		} elseif (!isset($GLOBALS['meta'][$i])) {
498
-			ecrire_meta($i, $v);
499
-		}
500
-	}
501
-
502
-	if ($purger_skel) {
503
-		include_spip('inc/invalideur');
504
-		purger_repertoire(_DIR_SKELS);
505
-	}
494
+    foreach (liste_metas() as $i => $v) {
495
+        if (($x = _request($i)) !== null) {
496
+            ecrire_meta($i, $x);
497
+        } elseif (!isset($GLOBALS['meta'][$i])) {
498
+            ecrire_meta($i, $v);
499
+        }
500
+    }
501
+
502
+    if ($purger_skel) {
503
+        include_spip('inc/invalideur');
504
+        purger_repertoire(_DIR_SKELS);
505
+    }
506 506
 }
507 507
 
508 508
 /**
@@ -513,21 +513,21 @@  discard block
 block discarded – undo
513 513
  * @return string
514 514
  */
515 515
 function appliquer_adresse_site($adresse_site) {
516
-	if ($adresse_site !== null) {
517
-		if (!strlen($adresse_site)) {
518
-			$GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1;
519
-			$adresse_site = url_de_base();
520
-		}
521
-		$adresse_site = preg_replace(',/?\s*$,', '', $adresse_site);
516
+    if ($adresse_site !== null) {
517
+        if (!strlen($adresse_site)) {
518
+            $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1;
519
+            $adresse_site = url_de_base();
520
+        }
521
+        $adresse_site = preg_replace(',/?\s*$,', '', $adresse_site);
522 522
 
523
-		if (!tester_url_absolue($adresse_site)) {
524
-			$adresse_site = "http://$adresse_site";
525
-		}
523
+        if (!tester_url_absolue($adresse_site)) {
524
+            $adresse_site = "http://$adresse_site";
525
+        }
526 526
 
527
-		$adresse_site = entites_html($adresse_site);
527
+        $adresse_site = entites_html($adresse_site);
528 528
 
529
-		ecrire_meta('adresse_site', $adresse_site);
530
-	}
529
+        ecrire_meta('adresse_site', $adresse_site);
530
+    }
531 531
 
532
-	return $adresse_site;
532
+    return $adresse_site;
533 533
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -303,9 +303,9 @@
 block discarded – undo
303 303
 			// et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine
304 304
 			// car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4)
305 305
 			if ($has_planes) {
306
-				$check_store = sql_getfetsel('valeur', 'spip_' . $table, 'nom=' . sql_quote($casier));
306
+				$check_store = sql_getfetsel('valeur', 'spip_'.$table, 'nom='.sql_quote($casier));
307 307
 				if ($check_store !== $serialized_store) {
308
-					array_walk_recursive($store, function (&$value, $key) {
308
+					array_walk_recursive($store, function(&$value, $key) {
309 309
 						if (is_string($value)) {
310 310
 							$value = utf8_noplanes($value);
311 311
 						}
Please login to merge, or discard this patch.
prive/objets/liste/auteurs_fonctions.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Fonctions
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -29,29 +29,29 @@  discard block
 block discarded – undo
29 29
  * @param bool $left
30 30
  */
31 31
 function critere_compteur_articles_filtres_dist($idb, &$boucles, $crit, $left = false) {
32
-	$boucle = &$boucles[$idb];
32
+    $boucle = &$boucles[$idb];
33 33
 
34
-	$_statut = calculer_liste($crit->param[0], [], $boucles, $boucle->id_parent);
34
+    $_statut = calculer_liste($crit->param[0], [], $boucles, $boucle->id_parent);
35 35
 
36
-	$not = '';
37
-	if ($crit->not) {
38
-		$not = ", 'NOT'";
39
-	}
40
-	$boucle->from['LAA'] = 'spip_auteurs_liens';
41
-	$boucle->from_type['LAA'] = 'left';
42
-	$boucle->join['LAA'] = ["'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''"];
36
+    $not = '';
37
+    if ($crit->not) {
38
+        $not = ", 'NOT'";
39
+    }
40
+    $boucle->from['LAA'] = 'spip_auteurs_liens';
41
+    $boucle->from_type['LAA'] = 'left';
42
+    $boucle->join['LAA'] = ["'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''"];
43 43
 
44
-	$boucle->from['articles'] = 'spip_articles';
45
-	$boucle->from_type['articles'] = 'left';
46
-	$boucle->join['articles'] = [
47
-		"'LAA'",
48
-		"'id_article'",
49
-		"'id_objet'",
50
-		"'(articles.statut IS NULL OR '.sql_in_quote('articles.statut',[$_statut]$not).')'"
51
-	];
44
+    $boucle->from['articles'] = 'spip_articles';
45
+    $boucle->from_type['articles'] = 'left';
46
+    $boucle->join['articles'] = [
47
+        "'LAA'",
48
+        "'id_article'",
49
+        "'id_objet'",
50
+        "'(articles.statut IS NULL OR '.sql_in_quote('articles.statut',[$_statut]$not).')'"
51
+    ];
52 52
 
53
-	$boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles';
54
-	$boucle->group[] = 'auteurs.id_auteur';
53
+    $boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles';
54
+    $boucle->group[] = 'auteurs.id_auteur';
55 55
 }
56 56
 
57 57
 /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  *     Pile complétée par le code à générer
70 70
  */
71 71
 function balise_COMPTEUR_ARTICLES_dist($p) {
72
-	return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres');
72
+    return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres');
73 73
 }
74 74
 
75 75
 
@@ -85,44 +85,44 @@  discard block
 block discarded – undo
85 85
  * @return string
86 86
  */
87 87
 function afficher_initiale($url, $initiale, $compteur, $debut, $pas) {
88
-	static $memo = null;
89
-	static $res = [];
90
-	$out = '';
91
-	if (
92
-		!$memo
93
-		or (!$initiale and !$url)
94
-		or ($initiale !== $memo['initiale'])
95
-	) {
96
-		$newcompt = intval(floor(($compteur - 1) / $pas) * $pas);
97
-		// si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien
98
-		if (!$initiale and !$url and !$memo['compteur']) {
99
-			$memo = null;
100
-		}
101
-		if ($memo) {
102
-			$on = (($memo['compteur'] <= $debut)
103
-				and (
104
-					$newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur'])
105
-				));
106
-			$res[] = "<li class='pagination-item'>" . lien_ou_expose($memo['url'], $memo['initiale'], $on ? 'span.pagination-item-label' : '', 'pagination-item-label lien_pagination') . '</li>';
107
-		}
108
-		if ($initiale) {
109
-			$memo = [
110
-				'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0,
111
-				'initiale' => $initiale,
112
-				'url' => parametre_url($url, 'i', $initiale),
113
-				'compteur' => $newcompt
114
-			];
115
-		}
116
-	}
117
-	if (!$initiale and !$url) {
118
-		if ((is_countable($res) ? count($res) : 0) > 1) {
119
-			$out = "<ul class='pagination-items'>" . implode(' ', $res) . '</ul>';
120
-		}
121
-		$memo = null;
122
-		$res = [];
123
-	}
88
+    static $memo = null;
89
+    static $res = [];
90
+    $out = '';
91
+    if (
92
+        !$memo
93
+        or (!$initiale and !$url)
94
+        or ($initiale !== $memo['initiale'])
95
+    ) {
96
+        $newcompt = intval(floor(($compteur - 1) / $pas) * $pas);
97
+        // si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien
98
+        if (!$initiale and !$url and !$memo['compteur']) {
99
+            $memo = null;
100
+        }
101
+        if ($memo) {
102
+            $on = (($memo['compteur'] <= $debut)
103
+                and (
104
+                    $newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur'])
105
+                ));
106
+            $res[] = "<li class='pagination-item'>" . lien_ou_expose($memo['url'], $memo['initiale'], $on ? 'span.pagination-item-label' : '', 'pagination-item-label lien_pagination') . '</li>';
107
+        }
108
+        if ($initiale) {
109
+            $memo = [
110
+                'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0,
111
+                'initiale' => $initiale,
112
+                'url' => parametre_url($url, 'i', $initiale),
113
+                'compteur' => $newcompt
114
+            ];
115
+        }
116
+    }
117
+    if (!$initiale and !$url) {
118
+        if ((is_countable($res) ? count($res) : 0) > 1) {
119
+            $out = "<ul class='pagination-items'>" . implode(' ', $res) . '</ul>';
120
+        }
121
+        $memo = null;
122
+        $res = [];
123
+    }
124 124
 
125
-	return $out;
125
+    return $out;
126 126
 }
127 127
 
128 128
 /**
@@ -141,24 +141,24 @@  discard block
 block discarded – undo
141 141
  * @return string
142 142
  */
143 143
 function auteur_lien_messagerie($id_auteur, $en_ligne, $statut, $imessage, $email = '') {
144
-	static $time = null;
145
-	if (!in_array($statut, ['0minirezo', '1comite'])) {
146
-		return '';
147
-	}
144
+    static $time = null;
145
+    if (!in_array($statut, ['0minirezo', '1comite'])) {
146
+        return '';
147
+    }
148 148
 
149
-	if (is_null($time)) {
150
-		$time = time();
151
-	}
152
-	$parti = (($time - strtotime($en_ligne)) > 15 * 60);
149
+    if (is_null($time)) {
150
+        $time = time();
151
+    }
152
+    $parti = (($time - strtotime($en_ligne)) > 15 * 60);
153 153
 
154
-	if (
155
-		$imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ?
156
-		and $GLOBALS['meta']['messagerie_agenda'] != 'non'
157
-	) {
158
-		return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self());
159
-	} elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) {
160
-		return 'mailto:' . $email;
161
-	} else {
162
-		return '';
163
-	}
154
+    if (
155
+        $imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ?
156
+        and $GLOBALS['meta']['messagerie_agenda'] != 'non'
157
+    ) {
158
+        return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self());
159
+    } elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) {
160
+        return 'mailto:' . $email;
161
+    } else {
162
+        return '';
163
+    }
164 164
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 				and (
104 104
 					$newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur'])
105 105
 				));
106
-			$res[] = "<li class='pagination-item'>" . lien_ou_expose($memo['url'], $memo['initiale'], $on ? 'span.pagination-item-label' : '', 'pagination-item-label lien_pagination') . '</li>';
106
+			$res[] = "<li class='pagination-item'>".lien_ou_expose($memo['url'], $memo['initiale'], $on ? 'span.pagination-item-label' : '', 'pagination-item-label lien_pagination').'</li>';
107 107
 		}
108 108
 		if ($initiale) {
109 109
 			$memo = [
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	}
117 117
 	if (!$initiale and !$url) {
118 118
 		if ((is_countable($res) ? count($res) : 0) > 1) {
119
-			$out = "<ul class='pagination-items'>" . implode(' ', $res) . '</ul>';
119
+			$out = "<ul class='pagination-items'>".implode(' ', $res).'</ul>';
120 120
 		}
121 121
 		$memo = null;
122 122
 		$res = [];
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	) {
158 158
 		return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self());
159 159
 	} elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) {
160
-		return 'mailto:' . $email;
160
+		return 'mailto:'.$email;
161 161
 	} else {
162 162
 		return '';
163 163
 	}
Please login to merge, or discard this patch.
ecrire/exec/admin_plugin.php 2 patches
Indentation   +203 added lines, -203 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
 include_spip('inc/config');
@@ -37,26 +37,26 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function exec_admin_plugin_dist($retour = '') {
39 39
 
40
-	if (!autoriser('configurer', '_plugins')) {
41
-		include_spip('inc/minipres');
42
-		echo minipres();
43
-	} else {
44
-		// on fait la verif du path avant tout,
45
-		// et l'installation des qu'on est dans la colonne principale
46
-		// si jamais la liste des plugins actifs change, il faut faire un refresh du hit
47
-		// pour etre sur que les bons fichiers seront charges lors de l'install
48
-		$new = actualise_plugins_actifs();
49
-		if ($new and _request('actualise') < 2) {
50
-			include_spip('inc/headers');
51
-			if (isset($GLOBALS['fichier_php_compile_recent'])) {
52
-				// attendre eventuellement l'invalidation du cache opcode
53
-				spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
54
-			}
55
-			redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&'));
56
-		} else {
57
-			admin_plug_args(_request('voir'), _request('erreur'), _request('format'));
58
-		}
59
-	}
40
+    if (!autoriser('configurer', '_plugins')) {
41
+        include_spip('inc/minipres');
42
+        echo minipres();
43
+    } else {
44
+        // on fait la verif du path avant tout,
45
+        // et l'installation des qu'on est dans la colonne principale
46
+        // si jamais la liste des plugins actifs change, il faut faire un refresh du hit
47
+        // pour etre sur que les bons fichiers seront charges lors de l'install
48
+        $new = actualise_plugins_actifs();
49
+        if ($new and _request('actualise') < 2) {
50
+            include_spip('inc/headers');
51
+            if (isset($GLOBALS['fichier_php_compile_recent'])) {
52
+                // attendre eventuellement l'invalidation du cache opcode
53
+                spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
54
+            }
55
+            redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&'));
56
+        } else {
57
+            admin_plug_args(_request('voir'), _request('erreur'), _request('format'));
58
+        }
59
+    }
60 60
 }
61 61
 
62 62
 /**
@@ -81,132 +81,132 @@  discard block
 block discarded – undo
81 81
  *     Format d'affichage (liste ou arborescence)
82 82
  **/
83 83
 function admin_plug_args($quoi, $erreur, $format) {
84
-	$lpf = null;
85
-	$lcpas = null;
86
-	$lcpaffichesup = null;
87
-	if (!$quoi) {
88
-		$quoi = 'actifs';
89
-	}
90
-	// empecher l'affichage des erreurs dans le bandeau, on le donne ensuite
91
-	// format brut par plugin
92
-	$GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false);
93
-	// format resume mis en forme
94
-	$erreur_activation = plugin_donne_erreurs();
95
-	$commencer_page = charger_fonction('commencer_page', 'inc');
96
-	echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin');
97
-
98
-	echo debut_gauche();
99
-	echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']);
100
-
101
-	echo pipeline(
102
-		'affiche_gauche',
103
-		[
104
-			'args' => ['exec' => 'admin_plugin'],
105
-			'data' => afficher_librairies()
106
-		]
107
-	);
108
-
109
-	echo debut_droite();
110
-	echo gros_titre(_T('icone_admin_plugin'), '');
111
-
112
-	// Barre d'onglets de premier niveau
113
-	echo barre_onglets('plugins', 'plugins_actifs');
114
-	// Barre d'onglets de second niveau
115
-	$onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin';
116
-	echo debut_onglet('onglets_simple second');
117
-	echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2);
118
-	echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2);
119
-	echo fin_onglet();
120
-
121
-	// message d'erreur au retour d'une operation
122
-	if ($erreur) {
123
-		echo "<div class='error'>" . spip_htmlspecialchars($erreur) . '</div>';
124
-	}
125
-	if ($erreur_activation) {
126
-		echo "<div class='error'>$erreur_activation</div>";
127
-	}
128
-
129
-	// la mise a jour de cette meta a ete faite par ecrire_plugin_actifs
130
-	$actifs = (array) unserialize($GLOBALS['meta']['plugin']);
131
-	$lcpa = $actifs + (array) unserialize($GLOBALS['meta']['plugin_attente']);
132
-
133
-	// Les affichages se basent sur le repertoire, pas sur le nom
134
-	$actifs = liste_chemin_plugin($actifs, '');
135
-	if (defined('_DIR_PLUGINS_SUPPL')) {
136
-		$lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL);
137
-	}
138
-	$lcpa = liste_chemin_plugin($lcpa);
139
-
140
-	// on installe les plugins maintenant,
141
-	// cela permet aux scripts d'install de faire des affichages (moches...)
142
-	plugin_installes_meta();
143
-
144
-	echo "<div class='liste-plugins formulaire_spip'>";
145
-	echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins');
146
-
147
-	if ($quoi !== 'actifs') {
148
-		$lpf = liste_plugin_files();
149
-		if ($lpf) {
150
-			echo '<p>' . _T('texte_presente_plugin') . '</p>';
151
-		} else {
152
-			if (!@is_dir(_DIR_PLUGINS)) {
153
-				echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
154
-					. ' &mdash; ' . _T('plugin_info_automatique_creer') . '</p>';
155
-			}
156
-		}
157
-		$lcpaffiche = $lpf;
158
-		if (defined('_DIR_PLUGINS_SUPPL')) {
159
-			$lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL);
160
-		}
161
-	} else {
162
-		// la liste
163
-		// $quoi=='actifs'
164
-		$lcpaffiche = $lcpa;
165
-		if (defined('_DIR_PLUGINS_SUPPL')) {
166
-			$lcpaffichesup = $lcpas;
167
-		}
168
-	}
169
-
170
-	if ($quoi == 'actifs' or $lpf) {
171
-		$nb = is_countable($lcpa) ? count($lcpa) : 0;
172
-		if (defined('_DIR_PLUGINS_SUPPL')) {
173
-			$nb += is_countable($lcpas) ? count($lcpas) : 0;
174
-		}
175
-		echo '<h3>' . sinon(
176
-			singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'),
177
-			_T('plugins_actif_aucun')
178
-		) . '</h3>';
179
-	}
180
-
181
-	if (empty($format)) {
182
-		$format = 'liste';
183
-	} elseif (!in_array($format, ['liste', 'repertoires'])) {
184
-		$format = 'repertoires';
185
-	}
186
-
187
-	$afficher = charger_fonction("afficher_$format", 'plugins');
188
-	$corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs);
189
-	if (defined('_DIR_PLUGINS_SUPPL')) {
190
-		$corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL);
191
-	}
192
-
193
-	if ($corps) {
194
-		$corps .= "\n<div class='boutons' style='display:none;'>"
195
-			. "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer')
196
-			. "' />"
197
-			. '</div>';
198
-	}
199
-
200
-	echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps);
201
-
202
-	echo fin_cadre_trait_couleur();
203
-
204
-	if ($quoi == 'actifs') {
205
-		echo affiche_les_plugins_verrouilles($actifs);
206
-	}
207
-	echo '</div>';
208
-
209
-	echo http_script("
84
+    $lpf = null;
85
+    $lcpas = null;
86
+    $lcpaffichesup = null;
87
+    if (!$quoi) {
88
+        $quoi = 'actifs';
89
+    }
90
+    // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite
91
+    // format brut par plugin
92
+    $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false);
93
+    // format resume mis en forme
94
+    $erreur_activation = plugin_donne_erreurs();
95
+    $commencer_page = charger_fonction('commencer_page', 'inc');
96
+    echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin');
97
+
98
+    echo debut_gauche();
99
+    echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']);
100
+
101
+    echo pipeline(
102
+        'affiche_gauche',
103
+        [
104
+            'args' => ['exec' => 'admin_plugin'],
105
+            'data' => afficher_librairies()
106
+        ]
107
+    );
108
+
109
+    echo debut_droite();
110
+    echo gros_titre(_T('icone_admin_plugin'), '');
111
+
112
+    // Barre d'onglets de premier niveau
113
+    echo barre_onglets('plugins', 'plugins_actifs');
114
+    // Barre d'onglets de second niveau
115
+    $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin';
116
+    echo debut_onglet('onglets_simple second');
117
+    echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2);
118
+    echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2);
119
+    echo fin_onglet();
120
+
121
+    // message d'erreur au retour d'une operation
122
+    if ($erreur) {
123
+        echo "<div class='error'>" . spip_htmlspecialchars($erreur) . '</div>';
124
+    }
125
+    if ($erreur_activation) {
126
+        echo "<div class='error'>$erreur_activation</div>";
127
+    }
128
+
129
+    // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs
130
+    $actifs = (array) unserialize($GLOBALS['meta']['plugin']);
131
+    $lcpa = $actifs + (array) unserialize($GLOBALS['meta']['plugin_attente']);
132
+
133
+    // Les affichages se basent sur le repertoire, pas sur le nom
134
+    $actifs = liste_chemin_plugin($actifs, '');
135
+    if (defined('_DIR_PLUGINS_SUPPL')) {
136
+        $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL);
137
+    }
138
+    $lcpa = liste_chemin_plugin($lcpa);
139
+
140
+    // on installe les plugins maintenant,
141
+    // cela permet aux scripts d'install de faire des affichages (moches...)
142
+    plugin_installes_meta();
143
+
144
+    echo "<div class='liste-plugins formulaire_spip'>";
145
+    echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins');
146
+
147
+    if ($quoi !== 'actifs') {
148
+        $lpf = liste_plugin_files();
149
+        if ($lpf) {
150
+            echo '<p>' . _T('texte_presente_plugin') . '</p>';
151
+        } else {
152
+            if (!@is_dir(_DIR_PLUGINS)) {
153
+                echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
154
+                    . ' &mdash; ' . _T('plugin_info_automatique_creer') . '</p>';
155
+            }
156
+        }
157
+        $lcpaffiche = $lpf;
158
+        if (defined('_DIR_PLUGINS_SUPPL')) {
159
+            $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL);
160
+        }
161
+    } else {
162
+        // la liste
163
+        // $quoi=='actifs'
164
+        $lcpaffiche = $lcpa;
165
+        if (defined('_DIR_PLUGINS_SUPPL')) {
166
+            $lcpaffichesup = $lcpas;
167
+        }
168
+    }
169
+
170
+    if ($quoi == 'actifs' or $lpf) {
171
+        $nb = is_countable($lcpa) ? count($lcpa) : 0;
172
+        if (defined('_DIR_PLUGINS_SUPPL')) {
173
+            $nb += is_countable($lcpas) ? count($lcpas) : 0;
174
+        }
175
+        echo '<h3>' . sinon(
176
+            singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'),
177
+            _T('plugins_actif_aucun')
178
+        ) . '</h3>';
179
+    }
180
+
181
+    if (empty($format)) {
182
+        $format = 'liste';
183
+    } elseif (!in_array($format, ['liste', 'repertoires'])) {
184
+        $format = 'repertoires';
185
+    }
186
+
187
+    $afficher = charger_fonction("afficher_$format", 'plugins');
188
+    $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs);
189
+    if (defined('_DIR_PLUGINS_SUPPL')) {
190
+        $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL);
191
+    }
192
+
193
+    if ($corps) {
194
+        $corps .= "\n<div class='boutons' style='display:none;'>"
195
+            . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer')
196
+            . "' />"
197
+            . '</div>';
198
+    }
199
+
200
+    echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps);
201
+
202
+    echo fin_cadre_trait_couleur();
203
+
204
+    if ($quoi == 'actifs') {
205
+        echo affiche_les_plugins_verrouilles($actifs);
206
+    }
207
+    echo '</div>';
208
+
209
+    echo http_script("
210 210
 	jQuery(function(){
211 211
 		jQuery('.plugins li.item a[rel=info]').click(function(){
212 212
 			var li = jQuery(this).parents('li').eq(0);
@@ -232,15 +232,15 @@  discard block
 block discarded – undo
232 232
 	});
233 233
 	");
234 234
 
235
-	echo pipeline(
236
-		'affiche_milieu',
237
-		[
238
-			'args' => ['exec' => 'admin_plugin'],
239
-			'data' => ''
240
-		]
241
-	);
235
+    echo pipeline(
236
+        'affiche_milieu',
237
+        [
238
+            'args' => ['exec' => 'admin_plugin'],
239
+            'data' => ''
240
+        ]
241
+    );
242 242
 
243
-	echo fin_gauche(), fin_page();
243
+    echo fin_gauche(), fin_page();
244 244
 }
245 245
 
246 246
 /**
@@ -254,23 +254,23 @@  discard block
 block discarded – undo
254 254
  *     Code HTML
255 255
  **/
256 256
 function affiche_les_plugins_verrouilles($actifs) {
257
-	if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) {
258
-		return '';
259
-	}
260
-
261
-	$afficher = charger_fonction('afficher_liste', 'plugins');
262
-	$liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST);
263
-
264
-	return
265
-		"<div id='plugins_dist'>"
266
-		. debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist')
267
-		. '<p>'
268
-		. _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)])
269
-		. '<br />' . _T('plugin_info_plugins_dist_2')
270
-		. '</p>'
271
-		. $liste
272
-		. fin_cadre_trait_couleur()
273
-		. "</div>\n";
257
+    if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) {
258
+        return '';
259
+    }
260
+
261
+    $afficher = charger_fonction('afficher_liste', 'plugins');
262
+    $liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST);
263
+
264
+    return
265
+        "<div id='plugins_dist'>"
266
+        . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist')
267
+        . '<p>'
268
+        . _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)])
269
+        . '<br />' . _T('plugin_info_plugins_dist_2')
270
+        . '</p>'
271
+        . $liste
272
+        . fin_cadre_trait_couleur()
273
+        . "</div>\n";
274 274
 }
275 275
 
276 276
 /**
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
  */
283 283
 function afficher_librairies() {
284 284
 
285
-	if (!$libs = liste_librairies()) {
286
-		return '';
287
-	}
288
-	ksort($libs);
289
-	$res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees'));
290
-	$res .= '<dl>';
291
-	foreach ($libs as $lib => $rep) {
292
-		$res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n";
293
-	}
294
-	$res .= '</dl>';
295
-	$res .= fin_cadre_enfonce();
296
-
297
-	return $res;
285
+    if (!$libs = liste_librairies()) {
286
+        return '';
287
+    }
288
+    ksort($libs);
289
+    $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees'));
290
+    $res .= '<dl>';
291
+    foreach ($libs as $lib => $rep) {
292
+        $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n";
293
+    }
294
+    $res .= '</dl>';
295
+    $res .= fin_cadre_enfonce();
296
+
297
+    return $res;
298 298
 }
299 299
 
300 300
 
@@ -305,22 +305,22 @@  discard block
 block discarded – undo
305 305
  *     Tableau (nom de la lib => repertoire , ...)
306 306
  */
307 307
 function liste_librairies() {
308
-	$libs = [];
309
-	foreach (array_reverse(creer_chemin()) as $d) {
310
-		if (
311
-			is_dir($dir = $d . 'lib/')
312
-			and $t = opendir($dir)
313
-		) {
314
-			while (($f = readdir($t)) !== false) {
315
-				if (
316
-					$f[0] != '.'
317
-					and is_dir("$dir/$f")
318
-				) {
319
-					$libs[$f] = $dir;
320
-				}
321
-			}
322
-		}
323
-	}
324
-
325
-	return $libs;
308
+    $libs = [];
309
+    foreach (array_reverse(creer_chemin()) as $d) {
310
+        if (
311
+            is_dir($dir = $d . 'lib/')
312
+            and $t = opendir($dir)
313
+        ) {
314
+            while (($f = readdir($t)) !== false) {
315
+                if (
316
+                    $f[0] != '.'
317
+                    and is_dir("$dir/$f")
318
+                ) {
319
+                    $libs[$f] = $dir;
320
+                }
321
+            }
322
+        }
323
+    }
324
+
325
+    return $libs;
326 326
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
 	// message d'erreur au retour d'une operation
122 122
 	if ($erreur) {
123
-		echo "<div class='error'>" . spip_htmlspecialchars($erreur) . '</div>';
123
+		echo "<div class='error'>".spip_htmlspecialchars($erreur).'</div>';
124 124
 	}
125 125
 	if ($erreur_activation) {
126 126
 		echo "<div class='error'>$erreur_activation</div>";
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	if ($quoi !== 'actifs') {
148 148
 		$lpf = liste_plugin_files();
149 149
 		if ($lpf) {
150
-			echo '<p>' . _T('texte_presente_plugin') . '</p>';
150
+			echo '<p>'._T('texte_presente_plugin').'</p>';
151 151
 		} else {
152 152
 			if (!@is_dir(_DIR_PLUGINS)) {
153
-				echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
154
-					. ' &mdash; ' . _T('plugin_info_automatique_creer') . '</p>';
153
+				echo '<p>'._T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
154
+					. ' &mdash; '._T('plugin_info_automatique_creer').'</p>';
155 155
 			}
156 156
 		}
157 157
 		$lcpaffiche = $lpf;
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 		if (defined('_DIR_PLUGINS_SUPPL')) {
173 173
 			$nb += is_countable($lcpas) ? count($lcpas) : 0;
174 174
 		}
175
-		echo '<h3>' . sinon(
175
+		echo '<h3>'.sinon(
176 176
 			singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'),
177 177
 			_T('plugins_actif_aucun')
178
-		) . '</h3>';
178
+		).'</h3>';
179 179
 	}
180 180
 
181 181
 	if (empty($format)) {
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 	if ($corps) {
194 194
 		$corps .= "\n<div class='boutons' style='display:none;'>"
195
-			. "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer')
195
+			. "<input type='submit' class='submit save' value='"._T('bouton_enregistrer')
196 196
 			. "' />"
197 197
 			. '</div>';
198 198
 	}
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		. debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist')
267 267
 		. '<p>'
268 268
 		. _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)])
269
-		. '<br />' . _T('plugin_info_plugins_dist_2')
269
+		. '<br />'._T('plugin_info_plugins_dist_2')
270 270
 		. '</p>'
271 271
 		. $liste
272 272
 		. fin_cadre_trait_couleur()
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	$res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees'));
290 290
 	$res .= '<dl>';
291 291
 	foreach ($libs as $lib => $rep) {
292
-		$res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n";
292
+		$res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n";
293 293
 	}
294 294
 	$res .= '</dl>';
295 295
 	$res .= fin_cadre_enfonce();
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	$libs = [];
309 309
 	foreach (array_reverse(creer_chemin()) as $d) {
310 310
 		if (
311
-			is_dir($dir = $d . 'lib/')
311
+			is_dir($dir = $d.'lib/')
312 312
 			and $t = opendir($dir)
313 313
 		) {
314 314
 			while (($f = readdir($t)) !== false) {
Please login to merge, or discard this patch.