Completed
Push — master ( fb0017...92433c )
by cam
01:14
created
ecrire/inc/rubriques.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 		sql_updateq(
136 136
 			'spip_rubriques',
137 137
 			['statut' => 'publie', 'date' => date('Y-m-d H:i:s')],
138
-			'id_rubrique=' . intval($id_rubrique)
138
+			'id_rubrique='.intval($id_rubrique)
139 139
 		);
140
-		$id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique));
140
+		$id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique='.intval($id_rubrique));
141 141
 		if (!$id_parent) {
142 142
 			break;
143 143
 		}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 			return $id_pred != $id_rubrique;
173 173
 		}
174 174
 		// passer au parent si on a depublie
175
-		$r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred));
175
+		$r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id_pred));
176 176
 		$id_pred = $r['id_parent'];
177 177
 	}
178 178
 
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 		$date = date('Y-m-d H:i:s');
198 198
 	}
199 199
 	$postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
200
-		' AND date <= ' . sql_quote($date) : '';
200
+		' AND date <= '.sql_quote($date) : '';
201 201
 
202 202
 	if (!$id_rubrique = intval($id_rubrique)) {
203 203
 		return false;
204 204
 	}
205 205
 
206 206
 	// verifier qu'elle existe et est bien publiee
207
-	$r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
207
+	$r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique));
208 208
 	if (!$r or $r['statut'] !== 'publie') {
209 209
 		return false;
210 210
 	}
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
 	$compte = [
215 215
 		'articles' => sql_countsel(
216 216
 			'spip_articles',
217
-			'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates"
217
+			'id_rubrique='.intval($id_rubrique)." AND statut='publie'$postdates"
218 218
 		),
219
-		'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"),
219
+		'rubriques' => sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)." AND statut='publie'"),
220 220
 		'documents' => sql_countsel(
221 221
 			'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document',
222
-			'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') "
222
+			'L.id_objet='.intval($id_rubrique)." AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') "
223 223
 		)
224 224
 	];
225 225
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		}
245 245
 	}
246 246
 
247
-	sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique));
247
+	sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique='.intval($id_rubrique));
248 248
 
249 249
 #		spip_log("depublier_rubrique $id_pred");
250 250
 	return true;
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 
308 308
 	// Afficher les articles post-dates ?
309 309
 	$postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
310
-		'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
310
+		'AND A.date <= '.sql_quote(date('Y-m-d H:i:s')) : '';
311 311
 
312 312
 	$r = sql_select(
313 313
 		'R.id_rubrique AS id, max(A.date) AS date_h',
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		sql_updateq(
320 320
 			'spip_rubriques',
321 321
 			['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
322
-			'id_rubrique=' . intval($row['id'])
322
+			'id_rubrique='.intval($row['id'])
323 323
 		);
324 324
 	}
325 325
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 			sql_updateq(
346 346
 				'spip_rubriques',
347 347
 				['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
348
-				'id_rubrique=' . intval($row['id'])
348
+				'id_rubrique='.intval($row['id'])
349 349
 			);
350 350
 			$continuer = true;
351 351
 		}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 			and $rows = sql_allfetsel(
399 399
 				'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur',
400 400
 				'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique',
401
-				'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)',
401
+				'R.profondeur='.intval($prof).' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)',
402 402
 				'',
403 403
 				'R.id_secteur',
404 404
 				'0,100'
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 			and $rows = sql_allfetsel(
438 438
 				'id_rubrique as id',
439 439
 				'spip_rubriques',
440
-				'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select(
440
+				'profondeur='.intval($prof + 1).' AND id_parent NOT IN ('.sql_get_select(
441 441
 					'zzz.id_rubrique',
442 442
 					'spip_rubriques AS zzz',
443
-					'zzz.profondeur=' . intval($prof)
444
-				) . ')',
443
+					'zzz.profondeur='.intval($prof)
444
+				).')',
445 445
 				'',
446 446
 				'',
447 447
 				'0,100'
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 		// si pas de rubrique a profondeur $prof+1 pas la peine de continuer
456 456
 		// si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse)
457 457
 		// on arrete les frais
458
-		if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) {
458
+		if (sql_countsel('spip_rubriques', 'profondeur='.intval($prof + 1))) {
459 459
 			$prof++;
460 460
 			$continuer = true;
461 461
 		}
@@ -463,12 +463,12 @@  discard block
 block discarded – undo
463 463
 
464 464
 	// loger si la table des rubriques semble foireuse
465 465
 	// et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles
466
-	if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) {
466
+	if (sql_countsel('spip_rubriques', 'profondeur>'.intval($prof + 1))) {
467 467
 		spip_log(
468
-			'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)',
468
+			'Les rubriques de profondeur>'.($prof + 1).' semblent suspectes (branches morte ou reference circulaire dans les parents)',
469 469
 			_LOG_CRITIQUE
470 470
 		);
471
-		sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1));
471
+		sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>'.intval($prof + 1));
472 472
 	}
473 473
 
474 474
 	// reparer les articles
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	);
480 480
 
481 481
 	while ($row = sql_fetch($r)) {
482
-		sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id']));
482
+		sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article='.intval($row['id']));
483 483
 	}
484 484
 
485 485
 	// avertir les plugins qui peuvent faire leur mises a jour egalement
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 		$t = sql_updateq(
511 511
 			'spip_rubriques',
512 512
 			['lang' => $row['lang'], 'langue_choisie' => 'non'],
513
-			'id_rubrique=' . intval($id_rubrique)
513
+			'id_rubrique='.intval($id_rubrique)
514 514
 		);
515 515
 	}
516 516
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		sql_updateq(
556 556
 			'spip_articles',
557 557
 			['lang' => $row['lang'], 'langue_choisie' => 'non'],
558
-			'id_article=' . intval($id_article)
558
+			'id_article='.intval($id_article)
559 559
 		);
560 560
 	}
561 561
 
@@ -630,11 +630,11 @@  discard block
 block discarded – undo
630 630
 				];
631 631
 				// generer un nom de fonction "anonyme" unique
632 632
 				do {
633
-					$functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . random_int(0, mt_getrandmax());
633
+					$functionname = 'f_calculer_langues_utilisees_'.$boucle->id_table.'_'.time().'_'.random_int(0, mt_getrandmax());
634 634
 				} while (function_exists($functionname));
635 635
 				$code = calculer_boucle('calculer_langues_utilisees', $boucles);
636
-				$code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code;
637
-				$code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();';
636
+				$code = '$SP=0; $command=array();$command["connect"] = $connect = "'.$serveur.'"; $Pile=array(0=>array());'."\n".$code;
637
+				$code = 'function '.$functionname.'(){'.$code.'};$res = '.$functionname.'();';
638 638
 				$res = '';
639 639
 				eval($code);
640 640
 				$res = explode(',', $res);
@@ -736,11 +736,11 @@  discard block
 block discarded – undo
736 736
 		$maxiter-- and $filles = sql_allfetsel(
737 737
 			'id_rubrique',
738 738
 			'spip_rubriques',
739
-			sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT')
739
+			sql_in('id_parent', $r).' AND '.sql_in('id_rubrique', $r, 'NOT')
740 740
 		)
741 741
 	) {
742 742
 		$r = join(',', array_column($filles, 'id_rubrique'));
743
-		$branche .= ',' . $r;
743
+		$branche .= ','.$r;
744 744
 	}
745 745
 
746 746
 	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 
781 781
 	if (isset($b[$id])) {
782 782
 		// Notre branche commence par la rubrique de depart si $tout=true
783
-		return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id];
783
+		return $tout ? (strlen($b[$id]) ? $b[$id].",$id" : $id) : $b[$id];
784 784
 	}
785 785
 
786 786
 	$hier = '';
@@ -793,11 +793,11 @@  discard block
 block discarded – undo
793 793
 		$maxiter-- and $parents = sql_allfetsel(
794 794
 			'id_parent',
795 795
 			'spip_rubriques',
796
-			sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT')
796
+			sql_in('id_rubrique', $ids_nouveaux_parents).' AND '.sql_in('id_parent', $hier, 'NOT')
797 797
 		)
798 798
 	) {
799 799
 		$ids_nouveaux_parents = join(',', array_column($parents, 'id_parent'));
800
-		$hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : '');
800
+		$hier = $ids_nouveaux_parents.(strlen($hier) ? ','.$hier : '');
801 801
 	}
802 802
 
803 803
 	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 	include_spip('base/abstract_sql');
830 830
 	if ($check) {
831 831
 		$postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
832
-			'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
832
+			'AND A.date <= '.sql_quote(date('Y-m-d H:i:s')) : '';
833 833
 
834 834
 		$r = sql_select(
835 835
 			'DISTINCT A.id_rubrique AS id',
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 	$t = sql_fetsel(
847 847
 		'date',
848 848
 		'spip_articles',
849
-		"statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')),
849
+		"statut='publie' AND date > ".sql_quote(date('Y-m-d H:i:s')),
850 850
 		'',
851 851
 		'date',
852 852
 		'1'
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 		$r = sql_getfetsel(
903 903
 			'id_rubrique',
904 904
 			'spip_rubriques',
905
-			'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent),
905
+			'titre = '.sql_quote($titre).' AND id_parent='.intval($id_parent),
906 906
 			$groupby = [],
907 907
 			$orderby = [],
908 908
 			$limit = '',
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 			sql_updateq(
939 939
 				'spip_rubriques',
940 940
 				['id_secteur' => $id_secteur, 'lang' => $lang],
941
-				'id_rubrique=' . intval($id_rubrique),
941
+				'id_rubrique='.intval($id_rubrique),
942 942
 				[],
943 943
 				$serveur
944 944
 			);
Please login to merge, or discard this patch.
Indentation   +621 added lines, -621 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  */
20 20
 
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 
@@ -55,65 +55,65 @@  discard block
 block discarded – undo
55 55
  * @return void
56 56
  **/
57 57
 function calculer_rubriques_if($id_rubrique, $modifs, $infos = [], $postdate = false) {
58
-	$statuts_publies = null;
59
-	$neuf = false;
60
-
61
-	// Compat avec l'ancienne signature
62
-	if (is_string($infos)) {
63
-		$infos = ['statut_ancien' => $infos];
64
-	}
65
-	if (!isset($infos['statut_ancien'])) {
66
-		$infos['statut_ancien'] = '';
67
-	}
68
-
69
-	// On recherche quels statuts tester
70
-	if (
71
-		isset($infos['objet'])
72
-		and include_spip('inc/filtres')
73
-		and $declaration_statut = objet_info($infos['objet'], 'statut')
74
-		and is_array($declaration_statut)
75
-	) {
76
-		foreach ($declaration_statut as $champ_statut) {
77
-			if ($champ_statut['champ'] == 'statut') {
78
-				$statuts_publies = array_map('trim', explode(',', $champ_statut['publie']));
79
-				break; // stop on a trouvé le bon champ
80
-			}
81
-		}
82
-	} else {
83
-		$statuts_publies = ['publie'];
84
-	}
85
-
86
-	if (in_array($infos['statut_ancien'], $statuts_publies)) {
87
-		if (
88
-			isset($modifs['statut'])
89
-			or isset($modifs['id_rubrique'])
90
-			or ($postdate and strtotime($postdate) > time())
91
-		) {
92
-			$neuf |= depublier_branche_rubrique_if($id_rubrique);
93
-		}
94
-		// ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur
95
-		if ($postdate) {
96
-			calculer_prochain_postdate(true);
97
-			$neuf |= (strtotime($postdate) <= time()); // par securite
98
-		} elseif (isset($modifs['id_rubrique'])) {
99
-			$neuf |= publier_branche_rubrique($modifs['id_rubrique']);
100
-		}
101
-	} elseif (isset($modifs['statut']) and in_array($modifs['statut'], $statuts_publies)) {
102
-		if ($postdate) {
103
-			calculer_prochain_postdate(true);
104
-			$neuf |= (strtotime($postdate) <= time()); // par securite
105
-		} else {
106
-			$neuf |= publier_branche_rubrique($id_rubrique);
107
-		}
108
-	}
109
-
110
-	if ($neuf) {
111
-		// Sauver la date de la derniere mise a jour (pour menu_rubriques)
112
-		ecrire_meta('date_calcul_rubriques', date('U'));
113
-	}
114
-
115
-	$langues = calculer_langues_utilisees();
116
-	ecrire_meta('langues_utilisees', $langues);
58
+    $statuts_publies = null;
59
+    $neuf = false;
60
+
61
+    // Compat avec l'ancienne signature
62
+    if (is_string($infos)) {
63
+        $infos = ['statut_ancien' => $infos];
64
+    }
65
+    if (!isset($infos['statut_ancien'])) {
66
+        $infos['statut_ancien'] = '';
67
+    }
68
+
69
+    // On recherche quels statuts tester
70
+    if (
71
+        isset($infos['objet'])
72
+        and include_spip('inc/filtres')
73
+        and $declaration_statut = objet_info($infos['objet'], 'statut')
74
+        and is_array($declaration_statut)
75
+    ) {
76
+        foreach ($declaration_statut as $champ_statut) {
77
+            if ($champ_statut['champ'] == 'statut') {
78
+                $statuts_publies = array_map('trim', explode(',', $champ_statut['publie']));
79
+                break; // stop on a trouvé le bon champ
80
+            }
81
+        }
82
+    } else {
83
+        $statuts_publies = ['publie'];
84
+    }
85
+
86
+    if (in_array($infos['statut_ancien'], $statuts_publies)) {
87
+        if (
88
+            isset($modifs['statut'])
89
+            or isset($modifs['id_rubrique'])
90
+            or ($postdate and strtotime($postdate) > time())
91
+        ) {
92
+            $neuf |= depublier_branche_rubrique_if($id_rubrique);
93
+        }
94
+        // ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur
95
+        if ($postdate) {
96
+            calculer_prochain_postdate(true);
97
+            $neuf |= (strtotime($postdate) <= time()); // par securite
98
+        } elseif (isset($modifs['id_rubrique'])) {
99
+            $neuf |= publier_branche_rubrique($modifs['id_rubrique']);
100
+        }
101
+    } elseif (isset($modifs['statut']) and in_array($modifs['statut'], $statuts_publies)) {
102
+        if ($postdate) {
103
+            calculer_prochain_postdate(true);
104
+            $neuf |= (strtotime($postdate) <= time()); // par securite
105
+        } else {
106
+            $neuf |= publier_branche_rubrique($id_rubrique);
107
+        }
108
+    }
109
+
110
+    if ($neuf) {
111
+        // Sauver la date de la derniere mise a jour (pour menu_rubriques)
112
+        ecrire_meta('date_calcul_rubriques', date('U'));
113
+    }
114
+
115
+    $langues = calculer_langues_utilisees();
116
+    ecrire_meta('langues_utilisees', $langues);
117 117
 }
118 118
 
119 119
 
@@ -131,22 +131,22 @@  discard block
 block discarded – undo
131 131
  *     true si le statut change effectivement
132 132
  */
133 133
 function publier_branche_rubrique($id_rubrique) {
134
-	$id_pred = $id_rubrique;
135
-	while (true) {
136
-		sql_updateq(
137
-			'spip_rubriques',
138
-			['statut' => 'publie', 'date' => date('Y-m-d H:i:s')],
139
-			'id_rubrique=' . intval($id_rubrique)
140
-		);
141
-		$id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique));
142
-		if (!$id_parent) {
143
-			break;
144
-		}
145
-		$id_rubrique = $id_parent;
146
-	}
134
+    $id_pred = $id_rubrique;
135
+    while (true) {
136
+        sql_updateq(
137
+            'spip_rubriques',
138
+            ['statut' => 'publie', 'date' => date('Y-m-d H:i:s')],
139
+            'id_rubrique=' . intval($id_rubrique)
140
+        );
141
+        $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique));
142
+        if (!$id_parent) {
143
+            break;
144
+        }
145
+        $id_rubrique = $id_parent;
146
+    }
147 147
 
148 148
 #	spip_log(" publier_branche_rubrique($id_rubrique $id_pred");
149
-	return $id_pred != $id_rubrique;
149
+    return $id_pred != $id_rubrique;
150 150
 }
151 151
 
152 152
 /**
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
  *     true si le statut change effectivement
165 165
  */
166 166
 function depublier_branche_rubrique_if($id_rubrique) {
167
-	$date = date('Y-m-d H:i:s'); // figer la date
168
-
169
-	#	spip_log("depublier_branche_rubrique($id_rubrique ?");
170
-	$id_pred = $id_rubrique;
171
-	while ($id_pred) {
172
-		if (!depublier_rubrique_if($id_pred, $date)) {
173
-			return $id_pred != $id_rubrique;
174
-		}
175
-		// passer au parent si on a depublie
176
-		$r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred));
177
-		$id_pred = $r['id_parent'];
178
-	}
179
-
180
-	return $id_pred != $id_rubrique;
167
+    $date = date('Y-m-d H:i:s'); // figer la date
168
+
169
+    #	spip_log("depublier_branche_rubrique($id_rubrique ?");
170
+    $id_pred = $id_rubrique;
171
+    while ($id_pred) {
172
+        if (!depublier_rubrique_if($id_pred, $date)) {
173
+            return $id_pred != $id_rubrique;
174
+        }
175
+        // passer au parent si on a depublie
176
+        $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred));
177
+        $id_pred = $r['id_parent'];
178
+    }
179
+
180
+    return $id_pred != $id_rubrique;
181 181
 }
182 182
 
183 183
 /**
@@ -194,61 +194,61 @@  discard block
 block discarded – undo
194 194
  *    true si la rubrique a été dépubliée
195 195
  */
196 196
 function depublier_rubrique_if($id_rubrique, $date = null) {
197
-	if (is_null($date)) {
198
-		$date = date('Y-m-d H:i:s');
199
-	}
200
-	$postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
201
-		' AND date <= ' . sql_quote($date) : '';
202
-
203
-	if (!$id_rubrique = intval($id_rubrique)) {
204
-		return false;
205
-	}
206
-
207
-	// verifier qu'elle existe et est bien publiee
208
-	$r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
209
-	if (!$r or $r['statut'] !== 'publie') {
210
-		return false;
211
-	}
212
-
213
-	// On met le nombre de chaque type d'enfants dans un tableau
214
-	// Le type de l'objet est au pluriel
215
-	$compte = [
216
-		'articles' => sql_countsel(
217
-			'spip_articles',
218
-			'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates"
219
-		),
220
-		'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"),
221
-		'documents' => sql_countsel(
222
-			'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document',
223
-			'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') "
224
-		)
225
-	];
226
-
227
-	// On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants
228
-	$compte = pipeline(
229
-		'objet_compte_enfants',
230
-		[
231
-			'args' => [
232
-				'objet' => 'rubrique',
233
-				'id_objet' => $id_rubrique,
234
-				'statut' => 'publie',
235
-				'date' => $date
236
-			],
237
-			'data' => $compte
238
-		]
239
-	);
240
-
241
-	// S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas
242
-	foreach ($compte as $objet => $n) {
243
-		if ($n) {
244
-			return false;
245
-		}
246
-	}
247
-
248
-	sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique));
197
+    if (is_null($date)) {
198
+        $date = date('Y-m-d H:i:s');
199
+    }
200
+    $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
201
+        ' AND date <= ' . sql_quote($date) : '';
202
+
203
+    if (!$id_rubrique = intval($id_rubrique)) {
204
+        return false;
205
+    }
206
+
207
+    // verifier qu'elle existe et est bien publiee
208
+    $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
209
+    if (!$r or $r['statut'] !== 'publie') {
210
+        return false;
211
+    }
212
+
213
+    // On met le nombre de chaque type d'enfants dans un tableau
214
+    // Le type de l'objet est au pluriel
215
+    $compte = [
216
+        'articles' => sql_countsel(
217
+            'spip_articles',
218
+            'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates"
219
+        ),
220
+        'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"),
221
+        'documents' => sql_countsel(
222
+            'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document',
223
+            'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') "
224
+        )
225
+    ];
226
+
227
+    // On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants
228
+    $compte = pipeline(
229
+        'objet_compte_enfants',
230
+        [
231
+            'args' => [
232
+                'objet' => 'rubrique',
233
+                'id_objet' => $id_rubrique,
234
+                'statut' => 'publie',
235
+                'date' => $date
236
+            ],
237
+            'data' => $compte
238
+        ]
239
+    );
240
+
241
+    // S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas
242
+    foreach ($compte as $objet => $n) {
243
+        if ($n) {
244
+            return false;
245
+        }
246
+    }
247
+
248
+    sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique));
249 249
 
250 250
 #		spip_log("depublier_rubrique $id_pred");
251
-	return true;
251
+    return true;
252 252
 }
253 253
 
254 254
 
@@ -271,18 +271,18 @@  discard block
 block discarded – undo
271 271
  **/
272 272
 function calculer_rubriques() {
273 273
 
274
-	calculer_rubriques_publiees();
274
+    calculer_rubriques_publiees();
275 275
 
276
-	// Apres chaque (de)publication
277
-	// recalculer les langues utilisees sur le site
278
-	$langues = calculer_langues_utilisees();
279
-	ecrire_meta('langues_utilisees', $langues);
276
+    // Apres chaque (de)publication
277
+    // recalculer les langues utilisees sur le site
278
+    $langues = calculer_langues_utilisees();
279
+    ecrire_meta('langues_utilisees', $langues);
280 280
 
281
-	// Sauver la date de la derniere mise a jour (pour menu_rubriques)
282
-	ecrire_meta('date_calcul_rubriques', date('U'));
281
+    // Sauver la date de la derniere mise a jour (pour menu_rubriques)
282
+    ecrire_meta('date_calcul_rubriques', date('U'));
283 283
 
284
-	// on calcule la date du prochain article post-date
285
-	calculer_prochain_postdate();
284
+    // on calcule la date du prochain article post-date
285
+    calculer_prochain_postdate();
286 286
 }
287 287
 
288 288
 
@@ -299,61 +299,61 @@  discard block
 block discarded – undo
299 299
  **/
300 300
 function calculer_rubriques_publiees() {
301 301
 
302
-	// Mettre les compteurs a zero
303
-	sql_updateq('spip_rubriques', ['date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa']);
304
-
305
-	//
306
-	// Publier et dater les rubriques qui ont un article publie
307
-	//
308
-
309
-	// Afficher les articles post-dates ?
310
-	$postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
311
-		'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
312
-
313
-	$r = sql_select(
314
-		'R.id_rubrique AS id, max(A.date) AS date_h',
315
-		'spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique',
316
-		"A.date>R.date_tmp AND A.statut='publie' $postdates ",
317
-		'R.id_rubrique'
318
-	);
319
-	while ($row = sql_fetch($r)) {
320
-		sql_updateq(
321
-			'spip_rubriques',
322
-			['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
323
-			'id_rubrique=' . intval($row['id'])
324
-		);
325
-	}
326
-
327
-	// point d'entree pour permettre a des plugins de gerer le statut
328
-	// autrement (par ex: toute rubrique est publiee des sa creation)
329
-	// Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates
330
-	// c'est statut_tmp/date_tmp qu'il doit modifier
331
-	// [C'est un trigger... a renommer en trig_calculer_rubriques ?]
332
-	pipeline('calculer_rubriques', null);
333
-
334
-
335
-	// Les rubriques qui ont une rubrique fille plus recente
336
-	// on tourne tant que les donnees remontent vers la racine.
337
-	do {
338
-		$continuer = false;
339
-		$r = sql_select(
340
-			'R.id_rubrique AS id, max(SR.date_tmp) AS date_h',
341
-			'spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent',
342
-			"(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ",
343
-			'R.id_rubrique'
344
-		);
345
-		while ($row = sql_fetch($r)) {
346
-			sql_updateq(
347
-				'spip_rubriques',
348
-				['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
349
-				'id_rubrique=' . intval($row['id'])
350
-			);
351
-			$continuer = true;
352
-		}
353
-	} while ($continuer);
354
-
355
-	// Enregistrement des modifs
356
-	sql_update('spip_rubriques', ['date' => 'date_tmp', 'statut' => 'statut_tmp']);
302
+    // Mettre les compteurs a zero
303
+    sql_updateq('spip_rubriques', ['date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa']);
304
+
305
+    //
306
+    // Publier et dater les rubriques qui ont un article publie
307
+    //
308
+
309
+    // Afficher les articles post-dates ?
310
+    $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
311
+        'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
312
+
313
+    $r = sql_select(
314
+        'R.id_rubrique AS id, max(A.date) AS date_h',
315
+        'spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique',
316
+        "A.date>R.date_tmp AND A.statut='publie' $postdates ",
317
+        'R.id_rubrique'
318
+    );
319
+    while ($row = sql_fetch($r)) {
320
+        sql_updateq(
321
+            'spip_rubriques',
322
+            ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
323
+            'id_rubrique=' . intval($row['id'])
324
+        );
325
+    }
326
+
327
+    // point d'entree pour permettre a des plugins de gerer le statut
328
+    // autrement (par ex: toute rubrique est publiee des sa creation)
329
+    // Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates
330
+    // c'est statut_tmp/date_tmp qu'il doit modifier
331
+    // [C'est un trigger... a renommer en trig_calculer_rubriques ?]
332
+    pipeline('calculer_rubriques', null);
333
+
334
+
335
+    // Les rubriques qui ont une rubrique fille plus recente
336
+    // on tourne tant que les donnees remontent vers la racine.
337
+    do {
338
+        $continuer = false;
339
+        $r = sql_select(
340
+            'R.id_rubrique AS id, max(SR.date_tmp) AS date_h',
341
+            'spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent',
342
+            "(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ",
343
+            'R.id_rubrique'
344
+        );
345
+        while ($row = sql_fetch($r)) {
346
+            sql_updateq(
347
+                'spip_rubriques',
348
+                ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']],
349
+                'id_rubrique=' . intval($row['id'])
350
+            );
351
+            $continuer = true;
352
+        }
353
+    } while ($continuer);
354
+
355
+    // Enregistrement des modifs
356
+    sql_update('spip_rubriques', ['date' => 'date_tmp', 'statut' => 'statut_tmp']);
357 357
 }
358 358
 
359 359
 /**
@@ -368,123 +368,123 @@  discard block
 block discarded – undo
368 368
  * @return void
369 369
  **/
370 370
 function propager_les_secteurs() {
371
-	// Profondeur 0
372
-	// Toutes les rubriques racines sont de profondeur 0
373
-	// et fixer les id_secteur des rubriques racines
374
-	sql_update('spip_rubriques', ['id_secteur' => 'id_rubrique', 'profondeur' => 0], 'id_parent=0');
375
-	// Toute rubrique non racine est de profondeur >0
376
-	sql_updateq('spip_rubriques', ['profondeur' => 1], 'id_parent<>0 AND profondeur=0');
377
-
378
-	// securite : pas plus d'iteration que de rubriques dans la base
379
-	$maxiter = sql_countsel('spip_rubriques');
380
-
381
-	// reparer les rubriques qui n'ont pas l'id_secteur de leur parent
382
-	// on fait profondeur par profondeur
383
-
384
-	$prof = 0;
385
-	do {
386
-		$continuer = false;
387
-
388
-		// Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes
389
-		// on fixe le profondeur $prof+1
390
-
391
-		// Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1
392
-		// on teste A.profondeur > $prof+1 car :
393
-		// - toutes les rubriques de profondeur 0 à $prof sont bonnes
394
-		// - si A.profondeur = $prof+1 c'est bon
395
-		// - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques
396
-		$maxiter2 = $maxiter;
397
-		while (
398
-			$maxiter2--
399
-			and $rows = sql_allfetsel(
400
-				'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur',
401
-				'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique',
402
-				'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)',
403
-				'',
404
-				'R.id_secteur',
405
-				'0,100'
406
-			)
407
-		) {
408
-			$id_secteur = null;
409
-			$ids = [];
410
-			while ($row = array_shift($rows)) {
411
-				if ($row['id_secteur'] !== $id_secteur) {
412
-					if (count($ids)) {
413
-						sql_updateq(
414
-							'spip_rubriques',
415
-							['id_secteur' => $id_secteur, 'profondeur' => $prof + 1],
416
-							sql_in('id_rubrique', $ids)
417
-						);
418
-					}
419
-					$id_secteur = $row['id_secteur'];
420
-					$ids = [];
421
-				}
422
-				$ids[] = $row['id'];
423
-			}
424
-			if (count($ids)) {
425
-				sql_updateq(
426
-					'spip_rubriques',
427
-					['id_secteur' => $id_secteur, 'profondeur' => $prof + 1],
428
-					sql_in('id_rubrique', $ids)
429
-				);
430
-			}
431
-		}
432
-
433
-
434
-		// Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees
435
-		$maxiter2 = $maxiter;
436
-		while (
437
-			$maxiter2--
438
-			and $rows = sql_allfetsel(
439
-				'id_rubrique as id',
440
-				'spip_rubriques',
441
-				'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select(
442
-					'zzz.id_rubrique',
443
-					'spip_rubriques AS zzz',
444
-					'zzz.profondeur=' . intval($prof)
445
-				) . ')',
446
-				'',
447
-				'',
448
-				'0,100'
449
-			)
450
-		) {
451
-			$rows = array_column($rows, 'id');
452
-			sql_updateq('spip_rubriques', ['profondeur' => $prof + 2], sql_in('id_rubrique', $rows));
453
-		}
454
-
455
-		// ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK
456
-		// si pas de rubrique a profondeur $prof+1 pas la peine de continuer
457
-		// si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse)
458
-		// on arrete les frais
459
-		if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) {
460
-			$prof++;
461
-			$continuer = true;
462
-		}
463
-	} while ($continuer and $maxiter--);
464
-
465
-	// loger si la table des rubriques semble foireuse
466
-	// et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles
467
-	if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) {
468
-		spip_log(
469
-			'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)',
470
-			_LOG_CRITIQUE
471
-		);
472
-		sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1));
473
-	}
474
-
475
-	// reparer les articles
476
-	$r = sql_select(
477
-		'A.id_article AS id, R.id_secteur AS secteur',
478
-		'spip_articles AS A, spip_rubriques AS R',
479
-		'A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur'
480
-	);
481
-
482
-	while ($row = sql_fetch($r)) {
483
-		sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id']));
484
-	}
485
-
486
-	// avertir les plugins qui peuvent faire leur mises a jour egalement
487
-	pipeline('trig_propager_les_secteurs', '');
371
+    // Profondeur 0
372
+    // Toutes les rubriques racines sont de profondeur 0
373
+    // et fixer les id_secteur des rubriques racines
374
+    sql_update('spip_rubriques', ['id_secteur' => 'id_rubrique', 'profondeur' => 0], 'id_parent=0');
375
+    // Toute rubrique non racine est de profondeur >0
376
+    sql_updateq('spip_rubriques', ['profondeur' => 1], 'id_parent<>0 AND profondeur=0');
377
+
378
+    // securite : pas plus d'iteration que de rubriques dans la base
379
+    $maxiter = sql_countsel('spip_rubriques');
380
+
381
+    // reparer les rubriques qui n'ont pas l'id_secteur de leur parent
382
+    // on fait profondeur par profondeur
383
+
384
+    $prof = 0;
385
+    do {
386
+        $continuer = false;
387
+
388
+        // Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes
389
+        // on fixe le profondeur $prof+1
390
+
391
+        // Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1
392
+        // on teste A.profondeur > $prof+1 car :
393
+        // - toutes les rubriques de profondeur 0 à $prof sont bonnes
394
+        // - si A.profondeur = $prof+1 c'est bon
395
+        // - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques
396
+        $maxiter2 = $maxiter;
397
+        while (
398
+            $maxiter2--
399
+            and $rows = sql_allfetsel(
400
+                'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur',
401
+                'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique',
402
+                'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)',
403
+                '',
404
+                'R.id_secteur',
405
+                '0,100'
406
+            )
407
+        ) {
408
+            $id_secteur = null;
409
+            $ids = [];
410
+            while ($row = array_shift($rows)) {
411
+                if ($row['id_secteur'] !== $id_secteur) {
412
+                    if (count($ids)) {
413
+                        sql_updateq(
414
+                            'spip_rubriques',
415
+                            ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1],
416
+                            sql_in('id_rubrique', $ids)
417
+                        );
418
+                    }
419
+                    $id_secteur = $row['id_secteur'];
420
+                    $ids = [];
421
+                }
422
+                $ids[] = $row['id'];
423
+            }
424
+            if (count($ids)) {
425
+                sql_updateq(
426
+                    'spip_rubriques',
427
+                    ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1],
428
+                    sql_in('id_rubrique', $ids)
429
+                );
430
+            }
431
+        }
432
+
433
+
434
+        // Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees
435
+        $maxiter2 = $maxiter;
436
+        while (
437
+            $maxiter2--
438
+            and $rows = sql_allfetsel(
439
+                'id_rubrique as id',
440
+                'spip_rubriques',
441
+                'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select(
442
+                    'zzz.id_rubrique',
443
+                    'spip_rubriques AS zzz',
444
+                    'zzz.profondeur=' . intval($prof)
445
+                ) . ')',
446
+                '',
447
+                '',
448
+                '0,100'
449
+            )
450
+        ) {
451
+            $rows = array_column($rows, 'id');
452
+            sql_updateq('spip_rubriques', ['profondeur' => $prof + 2], sql_in('id_rubrique', $rows));
453
+        }
454
+
455
+        // ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK
456
+        // si pas de rubrique a profondeur $prof+1 pas la peine de continuer
457
+        // si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse)
458
+        // on arrete les frais
459
+        if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) {
460
+            $prof++;
461
+            $continuer = true;
462
+        }
463
+    } while ($continuer and $maxiter--);
464
+
465
+    // loger si la table des rubriques semble foireuse
466
+    // et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles
467
+    if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) {
468
+        spip_log(
469
+            'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)',
470
+            _LOG_CRITIQUE
471
+        );
472
+        sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1));
473
+    }
474
+
475
+    // reparer les articles
476
+    $r = sql_select(
477
+        'A.id_article AS id, R.id_secteur AS secteur',
478
+        'spip_articles AS A, spip_rubriques AS R',
479
+        'A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur'
480
+    );
481
+
482
+    while ($row = sql_fetch($r)) {
483
+        sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id']));
484
+    }
485
+
486
+    // avertir les plugins qui peuvent faire leur mises a jour egalement
487
+    pipeline('trig_propager_les_secteurs', '');
488 488
 }
489 489
 
490 490
 
@@ -499,23 +499,23 @@  discard block
 block discarded – undo
499 499
  *     true si un changement a eu lieu
500 500
  **/
501 501
 function calculer_langues_rubriques_etape() {
502
-	$s = sql_select(
503
-		'A.id_rubrique AS id_rubrique, R.lang AS lang',
504
-		'spip_rubriques AS A, spip_rubriques AS R',
505
-		"A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang"
506
-	);
507
-
508
-	$t = false;
509
-	while ($row = sql_fetch($s)) {
510
-		$id_rubrique = $row['id_rubrique'];
511
-		$t = sql_updateq(
512
-			'spip_rubriques',
513
-			['lang' => $row['lang'], 'langue_choisie' => 'non'],
514
-			'id_rubrique=' . intval($id_rubrique)
515
-		);
516
-	}
517
-
518
-	return $t;
502
+    $s = sql_select(
503
+        'A.id_rubrique AS id_rubrique, R.lang AS lang',
504
+        'spip_rubriques AS A, spip_rubriques AS R',
505
+        "A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang"
506
+    );
507
+
508
+    $t = false;
509
+    while ($row = sql_fetch($s)) {
510
+        $id_rubrique = $row['id_rubrique'];
511
+        $t = sql_updateq(
512
+            'spip_rubriques',
513
+            ['lang' => $row['lang'], 'langue_choisie' => 'non'],
514
+            'id_rubrique=' . intval($id_rubrique)
515
+        );
516
+    }
517
+
518
+    return $t;
519 519
 }
520 520
 
521 521
 /**
@@ -535,38 +535,38 @@  discard block
 block discarded – undo
535 535
  **/
536 536
 function calculer_langues_rubriques() {
537 537
 
538
-	// rubriques (recursivite)
539
-	sql_updateq(
540
-		'spip_rubriques',
541
-		['lang' => $GLOBALS['meta']['langue_site'], 'langue_choisie' => 'non'],
542
-		"id_parent=0 AND langue_choisie != 'oui'"
543
-	);
544
-	while (calculer_langues_rubriques_etape()) {
545
-		;
546
-	}
547
-
548
-	// articles
549
-	$s = sql_select(
550
-		'A.id_article AS id_article, R.lang AS lang',
551
-		'spip_articles AS A, spip_rubriques AS R',
552
-		"A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang"
553
-	);
554
-	while ($row = sql_fetch($s)) {
555
-		$id_article = $row['id_article'];
556
-		sql_updateq(
557
-			'spip_articles',
558
-			['lang' => $row['lang'], 'langue_choisie' => 'non'],
559
-			'id_article=' . intval($id_article)
560
-		);
561
-	}
562
-
563
-	if ($GLOBALS['meta']['multi_rubriques'] == 'oui') {
564
-		$langues = calculer_langues_utilisees();
565
-		ecrire_meta('langues_utilisees', $langues);
566
-	}
567
-
568
-	// avertir les plugins qui peuvent faire leur mises a jour egalement
569
-	pipeline('trig_calculer_langues_rubriques', '');
538
+    // rubriques (recursivite)
539
+    sql_updateq(
540
+        'spip_rubriques',
541
+        ['lang' => $GLOBALS['meta']['langue_site'], 'langue_choisie' => 'non'],
542
+        "id_parent=0 AND langue_choisie != 'oui'"
543
+    );
544
+    while (calculer_langues_rubriques_etape()) {
545
+        ;
546
+    }
547
+
548
+    // articles
549
+    $s = sql_select(
550
+        'A.id_article AS id_article, R.lang AS lang',
551
+        'spip_articles AS A, spip_rubriques AS R',
552
+        "A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang"
553
+    );
554
+    while ($row = sql_fetch($s)) {
555
+        $id_article = $row['id_article'];
556
+        sql_updateq(
557
+            'spip_articles',
558
+            ['lang' => $row['lang'], 'langue_choisie' => 'non'],
559
+            'id_article=' . intval($id_article)
560
+        );
561
+    }
562
+
563
+    if ($GLOBALS['meta']['multi_rubriques'] == 'oui') {
564
+        $langues = calculer_langues_utilisees();
565
+        ecrire_meta('langues_utilisees', $langues);
566
+    }
567
+
568
+    // avertir les plugins qui peuvent faire leur mises a jour egalement
569
+    pipeline('trig_calculer_langues_rubriques', '');
570 570
 }
571 571
 
572 572
 
@@ -583,80 +583,80 @@  discard block
 block discarded – undo
583 583
  *    Liste des langues utilisées séparées par des virgules
584 584
  **/
585 585
 function calculer_langues_utilisees($serveur = '') {
586
-	include_spip('public/interfaces');
587
-	include_spip('public/compiler');
588
-	include_spip('public/composer');
589
-	include_spip('public/phraser_html');
590
-	$langues = [];
591
-
592
-	$langues[$GLOBALS['meta']['langue_site']] = 1;
593
-
594
-	include_spip('base/objets');
595
-	$tables = lister_tables_objets_sql();
596
-	$trouver_table = charger_fonction('trouver_table', 'base');
597
-
598
-	foreach (array_keys($tables) as $t) {
599
-		$desc = $trouver_table($t, $serveur);
600
-		// c'est une table avec des langues
601
-		if (
602
-			$desc['exist']
603
-			and isset($desc['field']['lang'])
604
-			and isset($desc['field']['langue_choisie'])
605
-		) {
606
-			$boucle = new Boucle();
607
-			$boucle->show = $desc;
608
-			$boucle->nom = 'calculer_langues_utilisees';
609
-			$boucle->id_boucle = $desc['table_objet'];
610
-			$boucle->id_table = $desc['table_objet'];
611
-			$boucle->primary = $desc['key']['PRIMARY KEY'] ?? '';
612
-			$boucle->sql_serveur = $serveur;
613
-			$boucle->select[] = 'DISTINCT lang';
614
-			$boucle->from[$desc['table_objet']] = $t;
615
-			$boucle->separateur[] = ',';
616
-			$boucle->return = '$Pile[$SP][\'lang\']';
617
-			$boucle->iterateur = 'sql';
618
-
619
-			$boucle->descr['nom'] = 'calculer_langues_utilisees'; // eviter notice php
620
-			$boucle->descr['sourcefile'] = 'internal';
621
-			$boucle->descr['gram'] = 'html';
622
-
623
-			$boucle = pipeline('pre_boucle', $boucle);
624
-
625
-			if (
626
-				isset($desc['statut'])
627
-				and $desc['statut']
628
-			) {
629
-				$boucles = [
630
-					'calculer_langues_utilisees' => $boucle,
631
-				];
632
-				// generer un nom de fonction "anonyme" unique
633
-				do {
634
-					$functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . random_int(0, mt_getrandmax());
635
-				} while (function_exists($functionname));
636
-				$code = calculer_boucle('calculer_langues_utilisees', $boucles);
637
-				$code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code;
638
-				$code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();';
639
-				$res = '';
640
-				eval($code);
641
-				$res = explode(',', $res);
642
-				foreach ($res as $lang) {
643
-					$langues[$lang] = 1;
644
-				}
645
-			} else {
646
-				$res = sql_select(implode(',', $boucle->select), $boucle->from);
647
-				while ($row = sql_fetch($res)) {
648
-					$langues[$row['lang']] = 1;
649
-				}
650
-			}
651
-		}
652
-	}
653
-
654
-	$langues = array_filter(array_keys($langues));
655
-	sort($langues);
656
-	$langues = join(',', $langues);
657
-	spip_log("langues utilisees: $langues");
658
-
659
-	return $langues;
586
+    include_spip('public/interfaces');
587
+    include_spip('public/compiler');
588
+    include_spip('public/composer');
589
+    include_spip('public/phraser_html');
590
+    $langues = [];
591
+
592
+    $langues[$GLOBALS['meta']['langue_site']] = 1;
593
+
594
+    include_spip('base/objets');
595
+    $tables = lister_tables_objets_sql();
596
+    $trouver_table = charger_fonction('trouver_table', 'base');
597
+
598
+    foreach (array_keys($tables) as $t) {
599
+        $desc = $trouver_table($t, $serveur);
600
+        // c'est une table avec des langues
601
+        if (
602
+            $desc['exist']
603
+            and isset($desc['field']['lang'])
604
+            and isset($desc['field']['langue_choisie'])
605
+        ) {
606
+            $boucle = new Boucle();
607
+            $boucle->show = $desc;
608
+            $boucle->nom = 'calculer_langues_utilisees';
609
+            $boucle->id_boucle = $desc['table_objet'];
610
+            $boucle->id_table = $desc['table_objet'];
611
+            $boucle->primary = $desc['key']['PRIMARY KEY'] ?? '';
612
+            $boucle->sql_serveur = $serveur;
613
+            $boucle->select[] = 'DISTINCT lang';
614
+            $boucle->from[$desc['table_objet']] = $t;
615
+            $boucle->separateur[] = ',';
616
+            $boucle->return = '$Pile[$SP][\'lang\']';
617
+            $boucle->iterateur = 'sql';
618
+
619
+            $boucle->descr['nom'] = 'calculer_langues_utilisees'; // eviter notice php
620
+            $boucle->descr['sourcefile'] = 'internal';
621
+            $boucle->descr['gram'] = 'html';
622
+
623
+            $boucle = pipeline('pre_boucle', $boucle);
624
+
625
+            if (
626
+                isset($desc['statut'])
627
+                and $desc['statut']
628
+            ) {
629
+                $boucles = [
630
+                    'calculer_langues_utilisees' => $boucle,
631
+                ];
632
+                // generer un nom de fonction "anonyme" unique
633
+                do {
634
+                    $functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . random_int(0, mt_getrandmax());
635
+                } while (function_exists($functionname));
636
+                $code = calculer_boucle('calculer_langues_utilisees', $boucles);
637
+                $code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code;
638
+                $code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();';
639
+                $res = '';
640
+                eval($code);
641
+                $res = explode(',', $res);
642
+                foreach ($res as $lang) {
643
+                    $langues[$lang] = 1;
644
+                }
645
+            } else {
646
+                $res = sql_select(implode(',', $boucle->select), $boucle->from);
647
+                while ($row = sql_fetch($res)) {
648
+                    $langues[$row['lang']] = 1;
649
+                }
650
+            }
651
+        }
652
+    }
653
+
654
+    $langues = array_filter(array_keys($langues));
655
+    sort($langues);
656
+    $langues = join(',', $langues);
657
+    spip_log("langues utilisees: $langues");
658
+
659
+    return $langues;
660 660
 }
661 661
 
662 662
 /**
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
  *     incluant les rubriques noeuds et toutes leurs descendances
674 674
  */
675 675
 function calcul_branche_in($id) {
676
-	$calcul_branche_in = charger_fonction('calcul_branche_in', 'inc');
676
+    $calcul_branche_in = charger_fonction('calcul_branche_in', 'inc');
677 677
 
678
-	return $calcul_branche_in($id);
678
+    return $calcul_branche_in($id);
679 679
 }
680 680
 
681 681
 /**
@@ -693,9 +693,9 @@  discard block
 block discarded – undo
693 693
  *     incluant les rubriques transmises et toutes leurs parentées
694 694
  */
695 695
 function calcul_hierarchie_in($id, $tout = true) {
696
-	$calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc');
696
+    $calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc');
697 697
 
698
-	return $calcul_hierarchie_in($id, $tout);
698
+    return $calcul_hierarchie_in($id, $tout);
699 699
 }
700 700
 
701 701
 
@@ -716,40 +716,40 @@  discard block
 block discarded – undo
716 716
  *     incluant les rubriques noeuds et toutes leurs descendances
717 717
  */
718 718
 function inc_calcul_branche_in_dist($id) {
719
-	static $b = [];
720
-
721
-	// normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
722
-	if (!is_array($id)) {
723
-		$id = explode(',', $id);
724
-	}
725
-	$id = join(',', array_map('intval', $id));
726
-	if (isset($b[$id])) {
727
-		return $b[$id];
728
-	}
729
-
730
-	// Notre branche commence par la rubrique de depart
731
-	$branche = $r = $id;
732
-
733
-	// On ajoute une generation (les filles de la generation precedente)
734
-	// jusqu'a epuisement, en se protegeant des references circulaires
735
-	$maxiter = 10000;
736
-	while (
737
-		$maxiter-- and $filles = sql_allfetsel(
738
-			'id_rubrique',
739
-			'spip_rubriques',
740
-			sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT')
741
-		)
742
-	) {
743
-		$r = join(',', array_column($filles, 'id_rubrique'));
744
-		$branche .= ',' . $r;
745
-	}
746
-
747
-	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
748
-	if (strlen($branche) < 10000) {
749
-		$b[$id] = $branche;
750
-	}
751
-
752
-	return $branche;
719
+    static $b = [];
720
+
721
+    // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
722
+    if (!is_array($id)) {
723
+        $id = explode(',', $id);
724
+    }
725
+    $id = join(',', array_map('intval', $id));
726
+    if (isset($b[$id])) {
727
+        return $b[$id];
728
+    }
729
+
730
+    // Notre branche commence par la rubrique de depart
731
+    $branche = $r = $id;
732
+
733
+    // On ajoute une generation (les filles de la generation precedente)
734
+    // jusqu'a epuisement, en se protegeant des references circulaires
735
+    $maxiter = 10000;
736
+    while (
737
+        $maxiter-- and $filles = sql_allfetsel(
738
+            'id_rubrique',
739
+            'spip_rubriques',
740
+            sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT')
741
+        )
742
+    ) {
743
+        $r = join(',', array_column($filles, 'id_rubrique'));
744
+        $branche .= ',' . $r;
745
+    }
746
+
747
+    # securite pour ne pas plomber la conso memoire sur les sites prolifiques
748
+    if (strlen($branche) < 10000) {
749
+        $b[$id] = $branche;
750
+    }
751
+
752
+    return $branche;
753 753
 }
754 754
 
755 755
 
@@ -771,45 +771,45 @@  discard block
 block discarded – undo
771 771
  *     incluant les rubriques transmises et toutes leurs parentées
772 772
  */
773 773
 function inc_calcul_hierarchie_in_dist($id, $tout = true) {
774
-	static $b = [];
775
-
776
-	// normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
777
-	if (!is_array($id)) {
778
-		$id = explode(',', $id);
779
-	}
780
-	$id = join(',', array_map('intval', $id));
781
-
782
-	if (isset($b[$id])) {
783
-		// Notre branche commence par la rubrique de depart si $tout=true
784
-		return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id];
785
-	}
786
-
787
-	$hier = '';
788
-
789
-	// On ajoute une generation (les filles de la generation precedente)
790
-	// jusqu'a epuisement, en se protegeant des references circulaires
791
-	$ids_nouveaux_parents = $id;
792
-	$maxiter = 10000;
793
-	while (
794
-		$maxiter-- and $parents = sql_allfetsel(
795
-			'id_parent',
796
-			'spip_rubriques',
797
-			sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT')
798
-		)
799
-	) {
800
-		$ids_nouveaux_parents = join(',', array_column($parents, 'id_parent'));
801
-		$hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : '');
802
-	}
803
-
804
-	# securite pour ne pas plomber la conso memoire sur les sites prolifiques
805
-	if (strlen($hier) < 10000) {
806
-		$b[$id] = $hier;
807
-	}
808
-
809
-	// Notre branche commence par la rubrique de depart si $tout=true
810
-	$hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier;
811
-
812
-	return $hier;
774
+    static $b = [];
775
+
776
+    // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN
777
+    if (!is_array($id)) {
778
+        $id = explode(',', $id);
779
+    }
780
+    $id = join(',', array_map('intval', $id));
781
+
782
+    if (isset($b[$id])) {
783
+        // Notre branche commence par la rubrique de depart si $tout=true
784
+        return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id];
785
+    }
786
+
787
+    $hier = '';
788
+
789
+    // On ajoute une generation (les filles de la generation precedente)
790
+    // jusqu'a epuisement, en se protegeant des references circulaires
791
+    $ids_nouveaux_parents = $id;
792
+    $maxiter = 10000;
793
+    while (
794
+        $maxiter-- and $parents = sql_allfetsel(
795
+            'id_parent',
796
+            'spip_rubriques',
797
+            sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT')
798
+        )
799
+    ) {
800
+        $ids_nouveaux_parents = join(',', array_column($parents, 'id_parent'));
801
+        $hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : '');
802
+    }
803
+
804
+    # securite pour ne pas plomber la conso memoire sur les sites prolifiques
805
+    if (strlen($hier) < 10000) {
806
+        $b[$id] = $hier;
807
+    }
808
+
809
+    // Notre branche commence par la rubrique de depart si $tout=true
810
+    $hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier;
811
+
812
+    return $hier;
813 813
 }
814 814
 
815 815
 
@@ -827,47 +827,47 @@  discard block
 block discarded – undo
827 827
  * @return void
828 828
  **/
829 829
 function calculer_prochain_postdate($check = false) {
830
-	include_spip('base/abstract_sql');
831
-	if ($check) {
832
-		$postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
833
-			'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
834
-
835
-		$r = sql_select(
836
-			'DISTINCT A.id_rubrique AS id',
837
-			'spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique',
838
-			"R.statut != 'publie' AND A.statut='publie'$postdates"
839
-		);
840
-		while ($row = sql_fetch($r)) {
841
-			publier_branche_rubrique($row['id']);
842
-		}
843
-
844
-		pipeline('trig_calculer_prochain_postdate', '');
845
-	}
846
-
847
-	$t = sql_fetsel(
848
-		'date',
849
-		'spip_articles',
850
-		"statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')),
851
-		'',
852
-		'date',
853
-		'1'
854
-	);
855
-
856
-	if ($t) {
857
-		$t = $t['date'];
858
-		if (
859
-			!isset($GLOBALS['meta']['date_prochain_postdate'])
860
-			or $t <> $GLOBALS['meta']['date_prochain_postdate']
861
-		) {
862
-			ecrire_meta('date_prochain_postdate', strtotime($t));
863
-			ecrire_meta('derniere_modif', time());
864
-		}
865
-	} else {
866
-		effacer_meta('date_prochain_postdate');
867
-		ecrire_meta('derniere_modif', time());
868
-	}
869
-
870
-	spip_log("prochain postdate: $t");
830
+    include_spip('base/abstract_sql');
831
+    if ($check) {
832
+        $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ?
833
+            'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : '';
834
+
835
+        $r = sql_select(
836
+            'DISTINCT A.id_rubrique AS id',
837
+            'spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique',
838
+            "R.statut != 'publie' AND A.statut='publie'$postdates"
839
+        );
840
+        while ($row = sql_fetch($r)) {
841
+            publier_branche_rubrique($row['id']);
842
+        }
843
+
844
+        pipeline('trig_calculer_prochain_postdate', '');
845
+    }
846
+
847
+    $t = sql_fetsel(
848
+        'date',
849
+        'spip_articles',
850
+        "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')),
851
+        '',
852
+        'date',
853
+        '1'
854
+    );
855
+
856
+    if ($t) {
857
+        $t = $t['date'];
858
+        if (
859
+            !isset($GLOBALS['meta']['date_prochain_postdate'])
860
+            or $t <> $GLOBALS['meta']['date_prochain_postdate']
861
+        ) {
862
+            ecrire_meta('date_prochain_postdate', strtotime($t));
863
+            ecrire_meta('derniere_modif', time());
864
+        }
865
+    } else {
866
+        effacer_meta('date_prochain_postdate');
867
+        ecrire_meta('derniere_modif', time());
868
+    }
869
+
870
+    spip_log("prochain postdate: $t");
871 871
 }
872 872
 
873 873
 /**
@@ -892,62 +892,62 @@  discard block
 block discarded – undo
892 892
  */
893 893
 function creer_rubrique_nommee($titre, $id_parent = 0, $serveur = '') {
894 894
 
895
-	// eclater l'arborescence demandee
896
-	// echapper les </multi> et autres balises fermantes html
897
-	$titre = preg_replace(',</([a-z][^>]*)>,ims', "<@\\1>", $titre);
898
-	$arbo = explode('/', preg_replace(',^/,', '', $titre));
899
-	include_spip('base/abstract_sql');
900
-	foreach ($arbo as $titre) {
901
-		// retablir les </multi> et autres balises fermantes html
902
-		$titre = preg_replace(',<@([a-z][^>]*)>,ims', "</\\1>", $titre);
903
-		$r = sql_getfetsel(
904
-			'id_rubrique',
905
-			'spip_rubriques',
906
-			'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent),
907
-			$groupby = [],
908
-			$orderby = [],
909
-			$limit = '',
910
-			$having = [],
911
-			$serveur
912
-		);
913
-		if ($r !== null) {
914
-			$id_parent = $r;
915
-		} else {
916
-			$id_rubrique = sql_insertq('spip_rubriques', [
917
-					'titre' => $titre,
918
-					'id_parent' => $id_parent,
919
-					'statut' => 'prepa'
920
-				], $desc = [], $serveur);
921
-			if ($id_parent > 0) {
922
-				$data = sql_fetsel(
923
-					'id_secteur,lang',
924
-					'spip_rubriques',
925
-					"id_rubrique=$id_parent",
926
-					$groupby = [],
927
-					$orderby = [],
928
-					$limit = '',
929
-					$having = [],
930
-					$serveur
931
-				);
932
-				$id_secteur = $data['id_secteur'];
933
-				$lang = $data['lang'];
934
-			} else {
935
-				$id_secteur = $id_rubrique;
936
-				$lang = $GLOBALS['meta']['langue_site'];
937
-			}
938
-
939
-			sql_updateq(
940
-				'spip_rubriques',
941
-				['id_secteur' => $id_secteur, 'lang' => $lang],
942
-				'id_rubrique=' . intval($id_rubrique),
943
-				[],
944
-				$serveur
945
-			);
946
-
947
-			// pour la recursion
948
-			$id_parent = $id_rubrique;
949
-		}
950
-	}
951
-
952
-	return intval($id_parent);
895
+    // eclater l'arborescence demandee
896
+    // echapper les </multi> et autres balises fermantes html
897
+    $titre = preg_replace(',</([a-z][^>]*)>,ims', "<@\\1>", $titre);
898
+    $arbo = explode('/', preg_replace(',^/,', '', $titre));
899
+    include_spip('base/abstract_sql');
900
+    foreach ($arbo as $titre) {
901
+        // retablir les </multi> et autres balises fermantes html
902
+        $titre = preg_replace(',<@([a-z][^>]*)>,ims', "</\\1>", $titre);
903
+        $r = sql_getfetsel(
904
+            'id_rubrique',
905
+            'spip_rubriques',
906
+            'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent),
907
+            $groupby = [],
908
+            $orderby = [],
909
+            $limit = '',
910
+            $having = [],
911
+            $serveur
912
+        );
913
+        if ($r !== null) {
914
+            $id_parent = $r;
915
+        } else {
916
+            $id_rubrique = sql_insertq('spip_rubriques', [
917
+                    'titre' => $titre,
918
+                    'id_parent' => $id_parent,
919
+                    'statut' => 'prepa'
920
+                ], $desc = [], $serveur);
921
+            if ($id_parent > 0) {
922
+                $data = sql_fetsel(
923
+                    'id_secteur,lang',
924
+                    'spip_rubriques',
925
+                    "id_rubrique=$id_parent",
926
+                    $groupby = [],
927
+                    $orderby = [],
928
+                    $limit = '',
929
+                    $having = [],
930
+                    $serveur
931
+                );
932
+                $id_secteur = $data['id_secteur'];
933
+                $lang = $data['lang'];
934
+            } else {
935
+                $id_secteur = $id_rubrique;
936
+                $lang = $GLOBALS['meta']['langue_site'];
937
+            }
938
+
939
+            sql_updateq(
940
+                'spip_rubriques',
941
+                ['id_secteur' => $id_secteur, 'lang' => $lang],
942
+                'id_rubrique=' . intval($id_rubrique),
943
+                [],
944
+                $serveur
945
+            );
946
+
947
+            // pour la recursion
948
+            $id_parent = $id_rubrique;
949
+        }
950
+    }
951
+
952
+    return intval($id_parent);
953 953
 }
Please login to merge, or discard this patch.
ecrire/exec/puce_statut.php 1 patch
Indentation   +24 added lines, -24 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/presentation');
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @uses exec_puce_statut_args()
32 32
  **/
33 33
 function exec_puce_statut_dist(): void {
34
-	exec_puce_statut_args(_request('id'), _request('type'));
34
+    exec_puce_statut_args(_request('id'), _request('type'));
35 35
 }
36 36
 
37 37
 /**
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
  *     Type d'objet
51 51
  **/
52 52
 function exec_puce_statut_args($id, $type): void {
53
-	$id = intval($id);
54
-	if (
55
-		$table_objet_sql = table_objet_sql($type)
56
-		and $d = lister_tables_objets_sql($table_objet_sql)
57
-		and isset($d['statut_textes_instituer'])
58
-		and $d['statut_textes_instituer']
59
-	) {
60
-		$prim = id_table_objet($type);
61
-		if (isset($d['field']['id_rubrique'])) {
62
-			$select = 'id_rubrique,statut';
63
-		} else {
64
-			$select = '0 as id_rubrique,statut';
65
-		}
66
-		$r = sql_fetsel($select, $table_objet_sql, "$prim=$id");
67
-		$statut = $r['statut'];
68
-		$id_rubrique = $r['id_rubrique'];
69
-	} else {
70
-		$id_rubrique = $id;
71
-		$statut = 'prop'; // arbitraire
72
-	}
73
-	$puce_statut = charger_fonction('puce_statut', 'inc');
74
-	ajax_retour($puce_statut($id, $statut, $id_rubrique, $type, true));
53
+    $id = intval($id);
54
+    if (
55
+        $table_objet_sql = table_objet_sql($type)
56
+        and $d = lister_tables_objets_sql($table_objet_sql)
57
+        and isset($d['statut_textes_instituer'])
58
+        and $d['statut_textes_instituer']
59
+    ) {
60
+        $prim = id_table_objet($type);
61
+        if (isset($d['field']['id_rubrique'])) {
62
+            $select = 'id_rubrique,statut';
63
+        } else {
64
+            $select = '0 as id_rubrique,statut';
65
+        }
66
+        $r = sql_fetsel($select, $table_objet_sql, "$prim=$id");
67
+        $statut = $r['statut'];
68
+        $id_rubrique = $r['id_rubrique'];
69
+    } else {
70
+        $id_rubrique = $id;
71
+        $statut = 'prop'; // arbitraire
72
+    }
73
+    $puce_statut = charger_fonction('puce_statut', 'inc');
74
+    ajax_retour($puce_statut($id, $statut, $id_rubrique, $type, true));
75 75
 }
Please login to merge, or discard this patch.
ecrire/charsets/translit.php 1 patch
Indentation   +358 added lines, -358 removed lines patch added patch discarded remove patch
@@ -9,384 +9,384 @@
 block discarded – undo
9 9
 
10 10
 $GLOBALS['CHARSET']['translit'] = [
11 11
 // latin [fausse plage]
12
-	128 => 'EUR',
13
-	131 => 'f',
14
-	140 => 'OE',
15
-	147 => '\'\'',
16
-	148 => '\'\'',
17
-	153 => '(TM)',
18
-	156 => 'oe',
19
-	159 => 'Y',
12
+    128 => 'EUR',
13
+    131 => 'f',
14
+    140 => 'OE',
15
+    147 => '\'\'',
16
+    148 => '\'\'',
17
+    153 => '(TM)',
18
+    156 => 'oe',
19
+    159 => 'Y',
20 20
 
21 21
 // latin [legal]
22
-	160 => ' ',
23
-	161 => '!',
24
-	162 => 'c',
25
-	163 => 'L',
26
-	164 => 'O',
27
-	165 => 'yen',
28
-	166 => '|',
29
-	167 => 'p',
30
-	169 => '(c)',
31
-	171 => '<<',
32
-	172 => '-',
33
-	173 => '-',
34
-	174 => '(R)',
35
-	176 => 'o',
36
-	177 => '+-',
37
-	181 => 'mu',
38
-	182 => 'p',
39
-	183 => '.',
40
-	186 => 'o ',
41
-	187 => '>>',
42
-	191 => '?',
43
-	192 => 'A',
44
-	193 => 'A',
45
-	194 => 'A',
46
-	195 => 'A',
47
-	196 => 'A',
48
-	197 => 'A',
49
-	198 => 'AE',
50
-	199 => 'C',
51
-	200 => 'E',
52
-	201 => 'E',
53
-	202 => 'E',
54
-	203 => 'E',
55
-	204 => 'I',
56
-	205 => 'I',
57
-	206 => 'I',
58
-	207 => 'I',
59
-	209 => 'N',
60
-	210 => 'O',
61
-	211 => 'O',
62
-	212 => 'O',
63
-	213 => 'O',
64
-	214 => 'O',
65
-	216 => 'O',
66
-	217 => 'U',
67
-	218 => 'U',
68
-	219 => 'U',
69
-	220 => 'U',
70
-	223 => 'ss',
71
-	224 => 'a',
72
-	225 => 'a',
73
-	226 => 'a',
74
-	227 => 'a',
75
-	228 => 'a',
76
-	229 => 'a',
77
-	230 => 'ae',
78
-	231 => 'c',
79
-	232 => 'e',
80
-	233 => 'e',
81
-	234 => 'e',
82
-	235 => 'e',
83
-	236 => 'i',
84
-	237 => 'i',
85
-	238 => 'i',
86
-	239 => 'i',
87
-	241 => 'n',
88
-	242 => 'o',
89
-	243 => 'o',
90
-	244 => 'o',
91
-	245 => 'o',
92
-	246 => 'o',
93
-	248 => 'o',
94
-	249 => 'u',
95
-	250 => 'u',
96
-	251 => 'u',
97
-	252 => 'u',
98
-	255 => 'y',
22
+    160 => ' ',
23
+    161 => '!',
24
+    162 => 'c',
25
+    163 => 'L',
26
+    164 => 'O',
27
+    165 => 'yen',
28
+    166 => '|',
29
+    167 => 'p',
30
+    169 => '(c)',
31
+    171 => '<<',
32
+    172 => '-',
33
+    173 => '-',
34
+    174 => '(R)',
35
+    176 => 'o',
36
+    177 => '+-',
37
+    181 => 'mu',
38
+    182 => 'p',
39
+    183 => '.',
40
+    186 => 'o ',
41
+    187 => '>>',
42
+    191 => '?',
43
+    192 => 'A',
44
+    193 => 'A',
45
+    194 => 'A',
46
+    195 => 'A',
47
+    196 => 'A',
48
+    197 => 'A',
49
+    198 => 'AE',
50
+    199 => 'C',
51
+    200 => 'E',
52
+    201 => 'E',
53
+    202 => 'E',
54
+    203 => 'E',
55
+    204 => 'I',
56
+    205 => 'I',
57
+    206 => 'I',
58
+    207 => 'I',
59
+    209 => 'N',
60
+    210 => 'O',
61
+    211 => 'O',
62
+    212 => 'O',
63
+    213 => 'O',
64
+    214 => 'O',
65
+    216 => 'O',
66
+    217 => 'U',
67
+    218 => 'U',
68
+    219 => 'U',
69
+    220 => 'U',
70
+    223 => 'ss',
71
+    224 => 'a',
72
+    225 => 'a',
73
+    226 => 'a',
74
+    227 => 'a',
75
+    228 => 'a',
76
+    229 => 'a',
77
+    230 => 'ae',
78
+    231 => 'c',
79
+    232 => 'e',
80
+    233 => 'e',
81
+    234 => 'e',
82
+    235 => 'e',
83
+    236 => 'i',
84
+    237 => 'i',
85
+    238 => 'i',
86
+    239 => 'i',
87
+    241 => 'n',
88
+    242 => 'o',
89
+    243 => 'o',
90
+    244 => 'o',
91
+    245 => 'o',
92
+    246 => 'o',
93
+    248 => 'o',
94
+    249 => 'u',
95
+    250 => 'u',
96
+    251 => 'u',
97
+    252 => 'u',
98
+    255 => 'y',
99 99
 
100 100
 // turc
101
-	286 => 'G',
102
-	287 => 'g',
103
-	304 => 'I',
104
-	305 => 'i',
101
+    286 => 'G',
102
+    287 => 'g',
103
+    304 => 'I',
104
+    305 => 'i',
105 105
 
106 106
 // esperanto
107
-	264 => 'Cx',
108
-	265 => 'cx',
109
-	284 => 'Gx',
110
-	285 => 'gx',
111
-	292 => 'Hx',
112
-	293 => 'hx',
113
-	308 => 'Jx',
114
-	309 => 'jx',
115
-	348 => 'Sx',
116
-	349 => 'sx',
117
-	364 => 'Ux',
118
-	365 => 'ux',
107
+    264 => 'Cx',
108
+    265 => 'cx',
109
+    284 => 'Gx',
110
+    285 => 'gx',
111
+    292 => 'Hx',
112
+    293 => 'hx',
113
+    308 => 'Jx',
114
+    309 => 'jx',
115
+    348 => 'Sx',
116
+    349 => 'sx',
117
+    364 => 'Ux',
118
+    365 => 'ux',
119 119
 
120 120
 
121 121
 // latin2 [Czech]
122
-	283 => 'e',
123
-	353 => 's',
124
-	269 => 'c',
125
-	345 => 'r',
126
-	382 => 'z',
127
-	367 => 'u',
128
-	328 => 'n',
129
-	357 => 't',
130
-	271 => 'd',
131
-	449 => 'o',
132
-	282 => 'E',
133
-	352 => 'S',
134
-	268 => 'C',
135
-	344 => 'R',
136
-	381 => 'Z',
137
-	366 => 'U',
138
-	327 => 'N',
139
-	356 => 'T',
140
-	270 => 'D',
141
-	467 => 'O',
122
+    283 => 'e',
123
+    353 => 's',
124
+    269 => 'c',
125
+    345 => 'r',
126
+    382 => 'z',
127
+    367 => 'u',
128
+    328 => 'n',
129
+    357 => 't',
130
+    271 => 'd',
131
+    449 => 'o',
132
+    282 => 'E',
133
+    352 => 'S',
134
+    268 => 'C',
135
+    344 => 'R',
136
+    381 => 'Z',
137
+    366 => 'U',
138
+    327 => 'N',
139
+    356 => 'T',
140
+    270 => 'D',
141
+    467 => 'O',
142 142
 
143 143
 // francais
144
-	338 => 'OE',
145
-	339 => 'oe',
146
-	376 => 'Y',
147
-	402 => 'f',
144
+    338 => 'OE',
145
+    339 => 'oe',
146
+    376 => 'Y',
147
+    402 => 'f',
148 148
 
149 149
 //polskie
150
-	260 => 'A',
151
-	261 => 'a',
152
-	262 => 'C',
153
-	263 => 'c',
154
-	280 => 'E',
155
-	281 => 'e',
156
-	321 => 'L',
157
-	322 => 'l',
158
-	323 => 'N',
159
-	324 => 'n',
160
-	346 => 'S',
161
-	347 => 's',
162
-	377 => 'Z',
163
-	378 => 'z',
164
-	379 => 'Z',
165
-	380 => 'z',
150
+    260 => 'A',
151
+    261 => 'a',
152
+    262 => 'C',
153
+    263 => 'c',
154
+    280 => 'E',
155
+    281 => 'e',
156
+    321 => 'L',
157
+    322 => 'l',
158
+    323 => 'N',
159
+    324 => 'n',
160
+    346 => 'S',
161
+    347 => 's',
162
+    377 => 'Z',
163
+    378 => 'z',
164
+    379 => 'Z',
165
+    380 => 'z',
166 166
 
167 167
 //roumain
168
-	258 => 'A',
169
-	259 => 'a',
170
-	354 => 'T',
171
-	355 => 't',
168
+    258 => 'A',
169
+    259 => 'a',
170
+    354 => 'T',
171
+    355 => 't',
172 172
 
173 173
 //turc & roumain
174
-	350 => 'S',
175
-	351 => 's',
174
+    350 => 'S',
175
+    351 => 's',
176 176
 
177 177
 // cyrillique
178
-	1026 => 'D%',
179
-	1027 => 'G%',
180
-	8218 => '\'',
181
-	1107 => 'g%',
182
-	8222 => '"',
183
-	8230 => '...',
184
-	8224 => '/-',
185
-	8225 => '/=',
186
-	8364 => 'EUR',
187
-	8240 => '0/00',
188
-	1033 => 'LJ',
189
-	8249 => '<',
190
-	1034 => 'NJ',
191
-	1036 => 'KJ',
192
-	1035 => 'Ts',
193
-	1039 => 'DZ',
194
-	1106 => 'd%',
195
-	8216 => '`',
196
-	8217 => '\'',
197
-	8220 => '"',
198
-	8221 => '"',
199
-	8226 => ' o ',
200
-	8211 => '-',
201
-	8212 => '~',
202
-	8482 => '(TM)',
203
-	1113 => 'lj',
204
-	8250 => '>',
205
-	1114 => 'nj',
206
-	1116 => 'kj',
207
-	1115 => 'ts',
208
-	1119 => 'dz',
209
-	1038 => 'V%',
210
-	1118 => 'v%',
211
-	1032 => 'J%',
212
-	1168 => 'G3',
213
-	1025 => 'IO',
214
-	1028 => 'IE',
215
-	1031 => 'YI',
216
-	1030 => 'II',
217
-	1110 => 'ii',
218
-	1169 => 'g3',
219
-	1105 => 'io',
220
-	8470 => 'No.',
221
-	1108 => 'ie',
222
-	1112 => 'j%',
223
-	1029 => 'DS',
224
-	1109 => 'ds',
225
-	1111 => 'yi',
226
-	1040 => 'A',
227
-	1041 => 'B',
228
-	1042 => 'V',
229
-	1043 => 'G',
230
-	1044 => 'D',
231
-	1045 => 'E',
232
-	1046 => 'ZH',
233
-	1047 => 'Z',
234
-	1048 => 'I',
235
-	1049 => 'J',
236
-	1050 => 'K',
237
-	1051 => 'L',
238
-	1052 => 'M',
239
-	1053 => 'N',
240
-	1054 => 'O',
241
-	1055 => 'P',
242
-	1056 => 'R',
243
-	1057 => 'S',
244
-	1058 => 'T',
245
-	1059 => 'U',
246
-	1060 => 'F',
247
-	1061 => 'H',
248
-	1062 => 'C',
249
-	1063 => 'CH',
250
-	1064 => 'SH',
251
-	1065 => 'SCH',
252
-	1066 => '"',
253
-	1067 => 'Y',
254
-	1068 => '\'',
255
-	1069 => '`E',
256
-	1070 => 'YU',
257
-	1071 => 'YA',
258
-	1072 => 'a',
259
-	1073 => 'b',
260
-	1074 => 'v',
261
-	1075 => 'g',
262
-	1076 => 'd',
263
-	1077 => 'e',
264
-	1078 => 'zh',
265
-	1079 => 'z',
266
-	1080 => 'i',
267
-	1081 => 'j',
268
-	1082 => 'k',
269
-	1083 => 'l',
270
-	1084 => 'm',
271
-	1085 => 'n',
272
-	1086 => 'o',
273
-	1087 => 'p',
274
-	1088 => 'r',
275
-	1089 => 's',
276
-	1090 => 't',
277
-	1091 => 'u',
278
-	1092 => 'f',
279
-	1093 => 'h',
280
-	1094 => 'c',
281
-	1095 => 'ch',
282
-	1096 => 'sh',
283
-	1097 => 'sch',
284
-	1098 => '"',
285
-	1099 => 'y',
286
-	1100 => '\'',
287
-	1101 => '`e',
288
-	1102 => 'yu',
289
-	1103 => 'ya',
178
+    1026 => 'D%',
179
+    1027 => 'G%',
180
+    8218 => '\'',
181
+    1107 => 'g%',
182
+    8222 => '"',
183
+    8230 => '...',
184
+    8224 => '/-',
185
+    8225 => '/=',
186
+    8364 => 'EUR',
187
+    8240 => '0/00',
188
+    1033 => 'LJ',
189
+    8249 => '<',
190
+    1034 => 'NJ',
191
+    1036 => 'KJ',
192
+    1035 => 'Ts',
193
+    1039 => 'DZ',
194
+    1106 => 'd%',
195
+    8216 => '`',
196
+    8217 => '\'',
197
+    8220 => '"',
198
+    8221 => '"',
199
+    8226 => ' o ',
200
+    8211 => '-',
201
+    8212 => '~',
202
+    8482 => '(TM)',
203
+    1113 => 'lj',
204
+    8250 => '>',
205
+    1114 => 'nj',
206
+    1116 => 'kj',
207
+    1115 => 'ts',
208
+    1119 => 'dz',
209
+    1038 => 'V%',
210
+    1118 => 'v%',
211
+    1032 => 'J%',
212
+    1168 => 'G3',
213
+    1025 => 'IO',
214
+    1028 => 'IE',
215
+    1031 => 'YI',
216
+    1030 => 'II',
217
+    1110 => 'ii',
218
+    1169 => 'g3',
219
+    1105 => 'io',
220
+    8470 => 'No.',
221
+    1108 => 'ie',
222
+    1112 => 'j%',
223
+    1029 => 'DS',
224
+    1109 => 'ds',
225
+    1111 => 'yi',
226
+    1040 => 'A',
227
+    1041 => 'B',
228
+    1042 => 'V',
229
+    1043 => 'G',
230
+    1044 => 'D',
231
+    1045 => 'E',
232
+    1046 => 'ZH',
233
+    1047 => 'Z',
234
+    1048 => 'I',
235
+    1049 => 'J',
236
+    1050 => 'K',
237
+    1051 => 'L',
238
+    1052 => 'M',
239
+    1053 => 'N',
240
+    1054 => 'O',
241
+    1055 => 'P',
242
+    1056 => 'R',
243
+    1057 => 'S',
244
+    1058 => 'T',
245
+    1059 => 'U',
246
+    1060 => 'F',
247
+    1061 => 'H',
248
+    1062 => 'C',
249
+    1063 => 'CH',
250
+    1064 => 'SH',
251
+    1065 => 'SCH',
252
+    1066 => '"',
253
+    1067 => 'Y',
254
+    1068 => '\'',
255
+    1069 => '`E',
256
+    1070 => 'YU',
257
+    1071 => 'YA',
258
+    1072 => 'a',
259
+    1073 => 'b',
260
+    1074 => 'v',
261
+    1075 => 'g',
262
+    1076 => 'd',
263
+    1077 => 'e',
264
+    1078 => 'zh',
265
+    1079 => 'z',
266
+    1080 => 'i',
267
+    1081 => 'j',
268
+    1082 => 'k',
269
+    1083 => 'l',
270
+    1084 => 'm',
271
+    1085 => 'n',
272
+    1086 => 'o',
273
+    1087 => 'p',
274
+    1088 => 'r',
275
+    1089 => 's',
276
+    1090 => 't',
277
+    1091 => 'u',
278
+    1092 => 'f',
279
+    1093 => 'h',
280
+    1094 => 'c',
281
+    1095 => 'ch',
282
+    1096 => 'sh',
283
+    1097 => 'sch',
284
+    1098 => '"',
285
+    1099 => 'y',
286
+    1100 => '\'',
287
+    1101 => '`e',
288
+    1102 => 'yu',
289
+    1103 => 'ya',
290 290
 
291 291
 // vietnamien en translitteration de base
292
-	7843 => 'a',
293
-	7841 => 'a',
294
-	7845 => 'a',
295
-	7847 => 'a',
296
-	7849 => 'a',
297
-	7851 => 'a',
298
-	7853 => 'a',
299
-	7855 => 'a',
300
-	7857 => 'a',
301
-	7859 => 'a',
302
-	7861 => 'a',
303
-	7863 => 'a',
304
-	7842 => 'A',
305
-	7840 => 'A',
306
-	7844 => 'A',
307
-	7846 => 'A',
308
-	7848 => 'A',
309
-	7850 => 'A',
310
-	7852 => 'A',
311
-	7854 => 'A',
312
-	7856 => 'A',
313
-	7858 => 'A',
314
-	7860 => 'A',
315
-	7862 => 'A',
316
-	7867 => 'e',
317
-	7869 => 'e',
318
-	7865 => 'e',
319
-	7871 => 'e',
320
-	7873 => 'e',
321
-	7875 => 'e',
322
-	7877 => 'e',
323
-	7879 => 'e',
324
-	7866 => 'E',
325
-	7868 => 'E',
326
-	7864 => 'E',
327
-	7870 => 'E',
328
-	7872 => 'E',
329
-	7874 => 'E',
330
-	7876 => 'E',
331
-	7878 => 'E',
332
-	7881 => 'i',
333
-	7883 => 'i',
334
-	7880 => 'I',
335
-	7882 => 'I',
336
-	7887 => 'o',
337
-	7885 => 'o',
338
-	7889 => 'o',
339
-	7891 => 'o',
340
-	7893 => 'o',
341
-	7895 => 'o',
342
-	7897 => 'o',
343
-	417 => 'o',
344
-	7899 => 'o',
345
-	7901 => 'o',
346
-	7903 => 'o',
347
-	7905 => 'o',
348
-	7907 => 'o',
349
-	7886 => 'O',
350
-	7884 => 'O',
351
-	7888 => 'O',
352
-	7890 => 'O',
353
-	7892 => 'O',
354
-	7894 => 'O',
355
-	7896 => 'O',
356
-	416 => 'O',
357
-	7898 => 'O',
358
-	7900 => 'O',
359
-	7902 => 'O',
360
-	7904 => 'O',
361
-	7906 => 'O',
362
-	7911 => 'u',
363
-	361 => 'u',
364
-	7909 => 'u',
365
-	432 => 'u',
366
-	7913 => 'u',
367
-	7915 => 'u',
368
-	7917 => 'u',
369
-	7919 => 'u',
370
-	7921 => 'u',
371
-	7910 => 'U',
372
-	360 => 'U',
373
-	7908 => 'U',
374
-	431 => 'U',
375
-	7912 => 'U',
376
-	7914 => 'U',
377
-	7916 => 'U',
378
-	7918 => 'U',
379
-	7920 => 'U',
380
-	253 => 'y',
381
-	7923 => 'y',
382
-	7927 => 'y',
383
-	7929 => 'y',
384
-	7925 => 'y',
385
-	221 => 'Y',
386
-	7922 => 'Y',
387
-	7926 => 'Y',
388
-	7928 => 'Y',
389
-	7924 => 'Y',
390
-	273 => 'd'
292
+    7843 => 'a',
293
+    7841 => 'a',
294
+    7845 => 'a',
295
+    7847 => 'a',
296
+    7849 => 'a',
297
+    7851 => 'a',
298
+    7853 => 'a',
299
+    7855 => 'a',
300
+    7857 => 'a',
301
+    7859 => 'a',
302
+    7861 => 'a',
303
+    7863 => 'a',
304
+    7842 => 'A',
305
+    7840 => 'A',
306
+    7844 => 'A',
307
+    7846 => 'A',
308
+    7848 => 'A',
309
+    7850 => 'A',
310
+    7852 => 'A',
311
+    7854 => 'A',
312
+    7856 => 'A',
313
+    7858 => 'A',
314
+    7860 => 'A',
315
+    7862 => 'A',
316
+    7867 => 'e',
317
+    7869 => 'e',
318
+    7865 => 'e',
319
+    7871 => 'e',
320
+    7873 => 'e',
321
+    7875 => 'e',
322
+    7877 => 'e',
323
+    7879 => 'e',
324
+    7866 => 'E',
325
+    7868 => 'E',
326
+    7864 => 'E',
327
+    7870 => 'E',
328
+    7872 => 'E',
329
+    7874 => 'E',
330
+    7876 => 'E',
331
+    7878 => 'E',
332
+    7881 => 'i',
333
+    7883 => 'i',
334
+    7880 => 'I',
335
+    7882 => 'I',
336
+    7887 => 'o',
337
+    7885 => 'o',
338
+    7889 => 'o',
339
+    7891 => 'o',
340
+    7893 => 'o',
341
+    7895 => 'o',
342
+    7897 => 'o',
343
+    417 => 'o',
344
+    7899 => 'o',
345
+    7901 => 'o',
346
+    7903 => 'o',
347
+    7905 => 'o',
348
+    7907 => 'o',
349
+    7886 => 'O',
350
+    7884 => 'O',
351
+    7888 => 'O',
352
+    7890 => 'O',
353
+    7892 => 'O',
354
+    7894 => 'O',
355
+    7896 => 'O',
356
+    416 => 'O',
357
+    7898 => 'O',
358
+    7900 => 'O',
359
+    7902 => 'O',
360
+    7904 => 'O',
361
+    7906 => 'O',
362
+    7911 => 'u',
363
+    361 => 'u',
364
+    7909 => 'u',
365
+    432 => 'u',
366
+    7913 => 'u',
367
+    7915 => 'u',
368
+    7917 => 'u',
369
+    7919 => 'u',
370
+    7921 => 'u',
371
+    7910 => 'U',
372
+    360 => 'U',
373
+    7908 => 'U',
374
+    431 => 'U',
375
+    7912 => 'U',
376
+    7914 => 'U',
377
+    7916 => 'U',
378
+    7918 => 'U',
379
+    7920 => 'U',
380
+    253 => 'y',
381
+    7923 => 'y',
382
+    7927 => 'y',
383
+    7929 => 'y',
384
+    7925 => 'y',
385
+    221 => 'Y',
386
+    7922 => 'Y',
387
+    7926 => 'Y',
388
+    7928 => 'Y',
389
+    7924 => 'Y',
390
+    273 => 'd'
391 391
 
392 392
 ];
Please login to merge, or discard this patch.
ecrire/lang/public_de.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -4,123 +4,123 @@
 block discarded – undo
4 4
 // ** ne pas modifier le fichier **
5 5
 
6 6
 if (!defined('_ECRIRE_INC_VERSION')) {
7
-	return;
7
+    return;
8 8
 }
9 9
 
10 10
 $GLOBALS[$GLOBALS['idx_lang']] = array(
11 11
 
12
-	// A
13
-	'accueil_site' => 'Startseite',
14
-	'article' => 'Artikel',
15
-	'articles' => 'Artikel',
16
-	'articles_auteur' => 'Artikel dieses Autors',
17
-	'articles_populaires' => 'Die beliebtesten Artikel',
18
-	'articles_rubrique' => 'Artikel dieser Rubrik',
19
-	'aucun_article' => 'Unter dieser Adresse gibt es keinen Artikel.',
20
-	'aucun_auteur' => 'Unter dieser Adresse gibt es keinen Autor.',
21
-	'aucun_site' => 'Unter dieser Adresse gibt es keien Website.',
22
-	'aucune_breve' => 'Unter dieser Adresse gibt es keine Meldung.',
23
-	'aucune_rubrique' => 'Unter dieser Adresse gibt es keine Rubrik.',
24
-	'auteur' => 'Autor',
25
-	'autres' => 'Andere',
26
-	'autres_breves' => 'Weitere Meldungen.',
27
-	'autres_groupes_mots_clefs' => 'Weitere Schlagwortgruppen',
28
-	'autres_sites' => 'Weitere Websites',
29
-
30
-	// B
31
-	'bonjour' => 'Hallo',
32
-
33
-	// C
34
-	'commenter_site' => 'Website kommentieren',
35
-	'contact' => 'Kontakt',
36
-	'copie_document_impossible' => 'Dokument kann nicht kopiert werden',
37
-
38
-	// D
39
-	'date' => 'Datum',
40
-	'dernier_ajout' => 'Neuester Eintrag',
41
-	'dernieres_breves' => 'Neue Meldungen',
42
-	'derniers_articles' => 'Neueste Artikel',
43
-	'derniers_commentaires' => 'Neueste Kommentare',
44
-	'derniers_messages_forum' => 'Neue Forumsbeiträge',
45
-
46
-	// E
47
-	'edition_mode_texte' => 'Im Textmodus bearbeiten ',
48
-	'en_reponse' => 'Antwort auf:',
49
-	'en_resume' => 'Als Zusammenfassung',
50
-	'envoyer_message' => 'Nachricht senden',
51
-	'espace_prive' => 'Redaktion',
52
-
53
-	// F
54
-	'formats_acceptes' => 'Akzeptierte Formate: @formats@.',
55
-
56
-	// H
57
-	'hierarchie_site' => 'Baumstruktur der Website',
58
-
59
-	// J
60
-	'jours' => 'Tage',
61
-
62
-	// L
63
-	'lien_connecter' => 'Login',
64
-
65
-	// M
66
-	'meme_auteur' => 'Vom gleichen Autor',
67
-	'meme_rubrique' => 'In der gleichen Rubrik',
68
-	'memes_auteurs' => 'Von den gleichen Autoren',
69
-	'message' => 'Nachricht',
70
-	'messages_forum' => 'Nachrichten',
71
-	'messages_recents' => 'Neue Forumsbeiträge',
72
-	'mots_clef' => 'Schlagwort',
73
-	'mots_clefs' => 'Schlagworte',
74
-	'mots_clefs_meme_groupe' => 'Schlagworte der gleichen Kategorie',
75
-
76
-	// N
77
-	'navigation' => 'Navigation',
78
-	'nom' => 'Name',
79
-	'nouveautes' => 'Neuigkeiten',
80
-	'nouveautes_web' => 'Neues im WWW',
81
-	'nouveaux_articles' => 'Neue Artikel',
82
-	'nouvelles_breves' => 'Neue Meldungen',
83
-
84
-	// P
85
-	'page_precedente' => 'vorige Seite',
86
-	'page_suivante' => 'nächste Seite',
87
-	'par_auteur' => 'von ',
88
-	'participer_site' => 'Sie können bei dieser Website mitmachen, wenn Sie sich anmelden. Sie erhalten sofort eine E-Mail mit den Zugangsdaten zum Redaktionssystem.',
89
-	'plan_site' => 'Sitemap',
90
-	'popularite' => 'Beliebtheit',
91
-	'poster_message' => 'Nachricht senden',
92
-	'proposer_site' => 'Sie können in dieser Rubrik eine Seite vorschlagen :',
93
-
94
-	// R
95
-	'repondre_article' => 'auf diesen Artikel antworten',
96
-	'repondre_breve' => 'auf diese Meldung antworten',
97
-	'resultats_recherche' => 'Suchergebnis(se)',
98
-	'retour_debut_forums' => 'Zurück zum Beginn des Forums',
99
-	'rss_abonnement' => 'Kopieren Sie die folgende URL in Ihren Feedreader:',
100
-	'rss_abonnement_titre' => 'Abonnieren',
101
-	'rss_abonnement_titre_page' => 'Abonnieren von',
102
-	'rss_explication' => 'Ein RSS-Feed sammelt Informationen über die Aktualisierungen einer Website. Er liefert den Inhalt von Einträgen oder Kommentaren oder einen Auszug daraus sowie einen Link zu den Vollversionen und einige andere Informationen. Der Feed ist dazu gedacht, von einem RSS-Aggregator (Feedreader) gelesen zu werden',
103
-	'rss_explication_titre' => 'Was ist ein RSS-Feed ?',
104
-	'rubrique' => 'Rubrik',
105
-	'rubriques' => 'Rubriken',
106
-
107
-	// S
108
-	'signatures_petition' => 'Unterschrift',
109
-	'site_realise_avec_spip' => 'Realisiert mit SPIP',
110
-	'sites_web' => 'Websites',
111
-	'sous_rubriques' => 'Unterrubriken',
112
-	'spam' => 'SPAM',
113
-	'suite' => 'weiter',
114
-	'sur_web' => 'Im WWW',
115
-	'syndiquer_rubrique' => 'Diese Rubrik per RSS einbinden',
116
-	'syndiquer_site' => 'Die ganze Website mit RSS einbinden',
117
-
118
-	// T
119
-	'texte_lettre_information' => 'Dies ist der Newsletter der Website ',
120
-	'texte_lettre_information_2' => 'Diese Mail informiert über die Neuerscheinungen der letzten',
121
-
122
-	// V
123
-	'ver_imprimer' => 'Druckversion',
124
-	'voir_en_ligne' => 'Online ansehen',
125
-	'voir_squelette' => 'Layoutvorlage dieser Seite ansehen'
12
+    // A
13
+    'accueil_site' => 'Startseite',
14
+    'article' => 'Artikel',
15
+    'articles' => 'Artikel',
16
+    'articles_auteur' => 'Artikel dieses Autors',
17
+    'articles_populaires' => 'Die beliebtesten Artikel',
18
+    'articles_rubrique' => 'Artikel dieser Rubrik',
19
+    'aucun_article' => 'Unter dieser Adresse gibt es keinen Artikel.',
20
+    'aucun_auteur' => 'Unter dieser Adresse gibt es keinen Autor.',
21
+    'aucun_site' => 'Unter dieser Adresse gibt es keien Website.',
22
+    'aucune_breve' => 'Unter dieser Adresse gibt es keine Meldung.',
23
+    'aucune_rubrique' => 'Unter dieser Adresse gibt es keine Rubrik.',
24
+    'auteur' => 'Autor',
25
+    'autres' => 'Andere',
26
+    'autres_breves' => 'Weitere Meldungen.',
27
+    'autres_groupes_mots_clefs' => 'Weitere Schlagwortgruppen',
28
+    'autres_sites' => 'Weitere Websites',
29
+
30
+    // B
31
+    'bonjour' => 'Hallo',
32
+
33
+    // C
34
+    'commenter_site' => 'Website kommentieren',
35
+    'contact' => 'Kontakt',
36
+    'copie_document_impossible' => 'Dokument kann nicht kopiert werden',
37
+
38
+    // D
39
+    'date' => 'Datum',
40
+    'dernier_ajout' => 'Neuester Eintrag',
41
+    'dernieres_breves' => 'Neue Meldungen',
42
+    'derniers_articles' => 'Neueste Artikel',
43
+    'derniers_commentaires' => 'Neueste Kommentare',
44
+    'derniers_messages_forum' => 'Neue Forumsbeiträge',
45
+
46
+    // E
47
+    'edition_mode_texte' => 'Im Textmodus bearbeiten ',
48
+    'en_reponse' => 'Antwort auf:',
49
+    'en_resume' => 'Als Zusammenfassung',
50
+    'envoyer_message' => 'Nachricht senden',
51
+    'espace_prive' => 'Redaktion',
52
+
53
+    // F
54
+    'formats_acceptes' => 'Akzeptierte Formate: @formats@.',
55
+
56
+    // H
57
+    'hierarchie_site' => 'Baumstruktur der Website',
58
+
59
+    // J
60
+    'jours' => 'Tage',
61
+
62
+    // L
63
+    'lien_connecter' => 'Login',
64
+
65
+    // M
66
+    'meme_auteur' => 'Vom gleichen Autor',
67
+    'meme_rubrique' => 'In der gleichen Rubrik',
68
+    'memes_auteurs' => 'Von den gleichen Autoren',
69
+    'message' => 'Nachricht',
70
+    'messages_forum' => 'Nachrichten',
71
+    'messages_recents' => 'Neue Forumsbeiträge',
72
+    'mots_clef' => 'Schlagwort',
73
+    'mots_clefs' => 'Schlagworte',
74
+    'mots_clefs_meme_groupe' => 'Schlagworte der gleichen Kategorie',
75
+
76
+    // N
77
+    'navigation' => 'Navigation',
78
+    'nom' => 'Name',
79
+    'nouveautes' => 'Neuigkeiten',
80
+    'nouveautes_web' => 'Neues im WWW',
81
+    'nouveaux_articles' => 'Neue Artikel',
82
+    'nouvelles_breves' => 'Neue Meldungen',
83
+
84
+    // P
85
+    'page_precedente' => 'vorige Seite',
86
+    'page_suivante' => 'nächste Seite',
87
+    'par_auteur' => 'von ',
88
+    'participer_site' => 'Sie können bei dieser Website mitmachen, wenn Sie sich anmelden. Sie erhalten sofort eine E-Mail mit den Zugangsdaten zum Redaktionssystem.',
89
+    'plan_site' => 'Sitemap',
90
+    'popularite' => 'Beliebtheit',
91
+    'poster_message' => 'Nachricht senden',
92
+    'proposer_site' => 'Sie können in dieser Rubrik eine Seite vorschlagen :',
93
+
94
+    // R
95
+    'repondre_article' => 'auf diesen Artikel antworten',
96
+    'repondre_breve' => 'auf diese Meldung antworten',
97
+    'resultats_recherche' => 'Suchergebnis(se)',
98
+    'retour_debut_forums' => 'Zurück zum Beginn des Forums',
99
+    'rss_abonnement' => 'Kopieren Sie die folgende URL in Ihren Feedreader:',
100
+    'rss_abonnement_titre' => 'Abonnieren',
101
+    'rss_abonnement_titre_page' => 'Abonnieren von',
102
+    'rss_explication' => 'Ein RSS-Feed sammelt Informationen über die Aktualisierungen einer Website. Er liefert den Inhalt von Einträgen oder Kommentaren oder einen Auszug daraus sowie einen Link zu den Vollversionen und einige andere Informationen. Der Feed ist dazu gedacht, von einem RSS-Aggregator (Feedreader) gelesen zu werden',
103
+    'rss_explication_titre' => 'Was ist ein RSS-Feed ?',
104
+    'rubrique' => 'Rubrik',
105
+    'rubriques' => 'Rubriken',
106
+
107
+    // S
108
+    'signatures_petition' => 'Unterschrift',
109
+    'site_realise_avec_spip' => 'Realisiert mit SPIP',
110
+    'sites_web' => 'Websites',
111
+    'sous_rubriques' => 'Unterrubriken',
112
+    'spam' => 'SPAM',
113
+    'suite' => 'weiter',
114
+    'sur_web' => 'Im WWW',
115
+    'syndiquer_rubrique' => 'Diese Rubrik per RSS einbinden',
116
+    'syndiquer_site' => 'Die ganze Website mit RSS einbinden',
117
+
118
+    // T
119
+    'texte_lettre_information' => 'Dies ist der Newsletter der Website ',
120
+    'texte_lettre_information_2' => 'Diese Mail informiert über die Neuerscheinungen der letzten',
121
+
122
+    // V
123
+    'ver_imprimer' => 'Druckversion',
124
+    'voir_en_ligne' => 'Online ansehen',
125
+    'voir_squelette' => 'Layoutvorlage dieser Seite ansehen'
126 126
 );
Please login to merge, or discard this patch.
ecrire/install/etape_3b.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 		$cles = \Spip\Chiffrer\SpipCles::instance();
92 92
 		$secret = $cles->getSecretAuth();
93 93
 
94
-		$id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login));
94
+		$id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login='.sql_quote($login));
95 95
 		if ($id_auteur !== null) {
96 96
 			// c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe
97 97
 			// pour restaurer la copie des cles
98 98
 			if (!$secret and !auth_spip_initialiser_secret()) {
99
-				$row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
99
+				$row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur='.intval($id_auteur));
100 100
 				if (empty($row['backup_cles']) or !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) {
101 101
 					$echec = _T('avis_connexion_erreur_fichier_cle_manquant_1');
102 102
 					echouer_etape_3b($echec);
103 103
 				}
104
-				spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth' . _LOG_INFO_IMPORTANTE);
104
+				spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth'._LOG_INFO_IMPORTANTE);
105 105
 				$cles->save();
106 106
 			}
107 107
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 				'email' => $email,
111 111
 				'login' => $login,
112 112
 				'statut' => '0minirezo'
113
-			], 'id_auteur=' . intval($id_auteur));
113
+			], 'id_auteur='.intval($id_auteur));
114 114
 			// le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne
115 115
 			@sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur");
116 116
 			if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) {
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			!$auteur = auth_identifier_login($login, $pass)
153 153
 			or !auth_loger($auteur)
154 154
 		) {
155
-			spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0));
155
+			spip_log("login automatique impossible $auth_spip $session".(is_countable($row) ? count($row) : 0));
156 156
 		}
157 157
 	}
158 158
 
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 function echouer_etape_3b($echec) {
175 175
 	echo minipres(
176 176
 		'AUTO',
177
-		info_progression_etape(3, 'etape_', 'install/', true) .
178
-		"<div class='error'><h3>$echec</h3>\n" .
179
-		'<p>' . _T('avis_connexion_echec_2') . '</p>' .
177
+		info_progression_etape(3, 'etape_', 'install/', true).
178
+		"<div class='error'><h3>$echec</h3>\n".
179
+		'<p>'._T('avis_connexion_echec_2').'</p>'.
180 180
 		'</div>'
181 181
 	);
182 182
 	exit;
Please login to merge, or discard this patch.
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -10,169 +10,169 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/headers');
17 17
 
18 18
 function install_etape_3b_dist() {
19
-	$auth_spip = null;
20
-	$session = null;
21
-	$row = null;
22
-	$login = _request('login');
23
-	$email = _request('email');
24
-	$nom = _request('nom');
25
-	$pass = _request('pass');
26
-	$pass_verif = _request('pass_verif');
27
-
28
-	$server_db = defined('_INSTALL_SERVER_DB')
29
-		? _INSTALL_SERVER_DB
30
-		: _request('server_db');
31
-
32
-	if (!defined('_PASS_LONGUEUR_MINI')) {
33
-		define('_PASS_LONGUEUR_MINI', 6);
34
-	}
35
-	if (!defined('_LOGIN_TROP_COURT')) {
36
-		define('_LOGIN_TROP_COURT', 4);
37
-	}
38
-	if ($login) {
39
-		$echec = ($pass != $pass_verif) ?
40
-			_T('info_passes_identiques')
41
-			: ((strlen($pass) < _PASS_LONGUEUR_MINI) ?
42
-				_T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI])
43
-				: ((strlen($login) < _LOGIN_TROP_COURT) ?
44
-					_T('info_login_trop_court')
45
-					: ''));
46
-		include_spip('inc/filtres');
47
-		if (!$echec and $email and !email_valide($email)) {
48
-			$echec = _T('form_email_non_valide');
49
-		}
50
-		if ($echec) {
51
-			echouer_etape_3b($echec);
52
-		}
53
-	}
54
-
55
-	if (@file_exists(_FILE_CHMOD_TMP)) {
56
-		include(_FILE_CHMOD_TMP);
57
-	} else {
58
-		redirige_url_ecrire('install');
59
-	}
60
-
61
-	if (!@file_exists(_FILE_CONNECT_TMP)) {
62
-		redirige_url_ecrire('install');
63
-	}
64
-
65
-	# maintenant on connait le vrai charset du site s'il est deja configure
66
-	# sinon par defaut lire_meta reglera _DEFAULT_CHARSET
67
-	# (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET)
68
-
69
-	lire_metas();
70
-	if ($login) {
71
-		include_spip('inc/charsets');
72
-
73
-		$nom = (importer_charset($nom, _DEFAULT_CHARSET));
74
-		$login = (importer_charset($login, _DEFAULT_CHARSET));
75
-		$email = (importer_charset($email, _DEFAULT_CHARSET));
76
-
77
-		include_spip('auth/spip');
78
-		// prelablement, creer le champ webmestre si il n'existe pas (install neuve
79
-		// sur une vieille base
80
-		$t = sql_showtable('spip_auteurs', true);
81
-		if (!isset($t['field']['webmestre'])) {
82
-			@sql_alter("TABLE spip_auteurs ADD webmestre varchar(3)  DEFAULT 'non' NOT NULL");
83
-		}
84
-
85
-		// il faut avoir une cle des auth valide pour creer un nouvel auteur webmestre
86
-		$cles = \Spip\Chiffrer\SpipCles::instance();
87
-		$secret = $cles->getSecretAuth();
88
-
89
-		$id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login));
90
-		if ($id_auteur !== null) {
91
-			// c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe
92
-			// pour restaurer la copie des cles
93
-			if (!$secret and !auth_spip_initialiser_secret()) {
94
-				$row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
95
-				if (empty($row['backup_cles']) or !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) {
96
-					$echec = _T('avis_connexion_erreur_fichier_cle_manquant_1');
97
-					echouer_etape_3b($echec);
98
-				}
99
-				spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth' . _LOG_INFO_IMPORTANTE);
100
-				$cles->save();
101
-			}
102
-
103
-			sql_updateq('spip_auteurs', [
104
-				'nom' => $nom,
105
-				'email' => $email,
106
-				'login' => $login,
107
-				'statut' => '0minirezo'
108
-			], 'id_auteur=' . intval($id_auteur));
109
-			// le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne
110
-			@sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur");
111
-			if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) {
112
-				$echec = _T('avis_erreur_creation_compte');
113
-				echouer_etape_3b($echec);
114
-			}
115
-		} else {
116
-			// Si on a pas de cle et qu'on ne sait pas la creer, on ne peut pas creer de nouveau compte :
117
-			// il faut qu'un webmestre avec un backup fasse l'install
118
-			if (!$secret and !auth_spip_initialiser_secret()) {
119
-				$echec = _T('avis_connexion_erreur_fichier_cle_manquant_2');
120
-				echouer_etape_3b($echec);
121
-			}
122
-
123
-			$id_auteur = sql_insertq('spip_auteurs', [
124
-				'nom' => $nom,
125
-				'email' => $email,
126
-				'login' => $login,
127
-				'statut' => '0minirezo'
128
-			]);
129
-			// le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne
130
-			@sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur");
131
-			if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) {
132
-				$echec = _T('avis_erreur_creation_compte');
133
-				echouer_etape_3b($echec);
134
-			}
135
-		}
136
-
137
-		// inserer email comme email webmaster principal
138
-		// (sauf s'il est vide: cas de la re-installation)
139
-		if ($email) {
140
-			ecrire_meta('email_webmaster', $email);
141
-		}
142
-
143
-		// Connecter directement celui qui vient de (re)donner son login
144
-		// mais sans cookie d'admin ni connexion longue
145
-		include_spip('inc/auth');
146
-		if (
147
-			!$auteur = auth_identifier_login($login, $pass)
148
-			or !auth_loger($auteur)
149
-		) {
150
-			spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0));
151
-		}
152
-	}
153
-
154
-	// installer les metas
155
-	$config = charger_fonction('config', 'inc');
156
-	$config();
157
-
158
-	// activer les plugins
159
-	// leur installation ne peut pas se faire sur le meme hit, il faudra donc
160
-	// poursuivre au hit suivant
161
-	include_spip('inc/plugin');
162
-	actualise_plugins_actifs();
163
-
164
-
165
-	include_spip('inc/distant');
166
-	redirige_par_entete(parametre_url(self(), 'etape', '4', '&'));
19
+    $auth_spip = null;
20
+    $session = null;
21
+    $row = null;
22
+    $login = _request('login');
23
+    $email = _request('email');
24
+    $nom = _request('nom');
25
+    $pass = _request('pass');
26
+    $pass_verif = _request('pass_verif');
27
+
28
+    $server_db = defined('_INSTALL_SERVER_DB')
29
+        ? _INSTALL_SERVER_DB
30
+        : _request('server_db');
31
+
32
+    if (!defined('_PASS_LONGUEUR_MINI')) {
33
+        define('_PASS_LONGUEUR_MINI', 6);
34
+    }
35
+    if (!defined('_LOGIN_TROP_COURT')) {
36
+        define('_LOGIN_TROP_COURT', 4);
37
+    }
38
+    if ($login) {
39
+        $echec = ($pass != $pass_verif) ?
40
+            _T('info_passes_identiques')
41
+            : ((strlen($pass) < _PASS_LONGUEUR_MINI) ?
42
+                _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI])
43
+                : ((strlen($login) < _LOGIN_TROP_COURT) ?
44
+                    _T('info_login_trop_court')
45
+                    : ''));
46
+        include_spip('inc/filtres');
47
+        if (!$echec and $email and !email_valide($email)) {
48
+            $echec = _T('form_email_non_valide');
49
+        }
50
+        if ($echec) {
51
+            echouer_etape_3b($echec);
52
+        }
53
+    }
54
+
55
+    if (@file_exists(_FILE_CHMOD_TMP)) {
56
+        include(_FILE_CHMOD_TMP);
57
+    } else {
58
+        redirige_url_ecrire('install');
59
+    }
60
+
61
+    if (!@file_exists(_FILE_CONNECT_TMP)) {
62
+        redirige_url_ecrire('install');
63
+    }
64
+
65
+    # maintenant on connait le vrai charset du site s'il est deja configure
66
+    # sinon par defaut lire_meta reglera _DEFAULT_CHARSET
67
+    # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET)
68
+
69
+    lire_metas();
70
+    if ($login) {
71
+        include_spip('inc/charsets');
72
+
73
+        $nom = (importer_charset($nom, _DEFAULT_CHARSET));
74
+        $login = (importer_charset($login, _DEFAULT_CHARSET));
75
+        $email = (importer_charset($email, _DEFAULT_CHARSET));
76
+
77
+        include_spip('auth/spip');
78
+        // prelablement, creer le champ webmestre si il n'existe pas (install neuve
79
+        // sur une vieille base
80
+        $t = sql_showtable('spip_auteurs', true);
81
+        if (!isset($t['field']['webmestre'])) {
82
+            @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3)  DEFAULT 'non' NOT NULL");
83
+        }
84
+
85
+        // il faut avoir une cle des auth valide pour creer un nouvel auteur webmestre
86
+        $cles = \Spip\Chiffrer\SpipCles::instance();
87
+        $secret = $cles->getSecretAuth();
88
+
89
+        $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login));
90
+        if ($id_auteur !== null) {
91
+            // c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe
92
+            // pour restaurer la copie des cles
93
+            if (!$secret and !auth_spip_initialiser_secret()) {
94
+                $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
95
+                if (empty($row['backup_cles']) or !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) {
96
+                    $echec = _T('avis_connexion_erreur_fichier_cle_manquant_1');
97
+                    echouer_etape_3b($echec);
98
+                }
99
+                spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth' . _LOG_INFO_IMPORTANTE);
100
+                $cles->save();
101
+            }
102
+
103
+            sql_updateq('spip_auteurs', [
104
+                'nom' => $nom,
105
+                'email' => $email,
106
+                'login' => $login,
107
+                'statut' => '0minirezo'
108
+            ], 'id_auteur=' . intval($id_auteur));
109
+            // le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne
110
+            @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur");
111
+            if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) {
112
+                $echec = _T('avis_erreur_creation_compte');
113
+                echouer_etape_3b($echec);
114
+            }
115
+        } else {
116
+            // Si on a pas de cle et qu'on ne sait pas la creer, on ne peut pas creer de nouveau compte :
117
+            // il faut qu'un webmestre avec un backup fasse l'install
118
+            if (!$secret and !auth_spip_initialiser_secret()) {
119
+                $echec = _T('avis_connexion_erreur_fichier_cle_manquant_2');
120
+                echouer_etape_3b($echec);
121
+            }
122
+
123
+            $id_auteur = sql_insertq('spip_auteurs', [
124
+                'nom' => $nom,
125
+                'email' => $email,
126
+                'login' => $login,
127
+                'statut' => '0minirezo'
128
+            ]);
129
+            // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne
130
+            @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur");
131
+            if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) {
132
+                $echec = _T('avis_erreur_creation_compte');
133
+                echouer_etape_3b($echec);
134
+            }
135
+        }
136
+
137
+        // inserer email comme email webmaster principal
138
+        // (sauf s'il est vide: cas de la re-installation)
139
+        if ($email) {
140
+            ecrire_meta('email_webmaster', $email);
141
+        }
142
+
143
+        // Connecter directement celui qui vient de (re)donner son login
144
+        // mais sans cookie d'admin ni connexion longue
145
+        include_spip('inc/auth');
146
+        if (
147
+            !$auteur = auth_identifier_login($login, $pass)
148
+            or !auth_loger($auteur)
149
+        ) {
150
+            spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0));
151
+        }
152
+    }
153
+
154
+    // installer les metas
155
+    $config = charger_fonction('config', 'inc');
156
+    $config();
157
+
158
+    // activer les plugins
159
+    // leur installation ne peut pas se faire sur le meme hit, il faudra donc
160
+    // poursuivre au hit suivant
161
+    include_spip('inc/plugin');
162
+    actualise_plugins_actifs();
163
+
164
+
165
+    include_spip('inc/distant');
166
+    redirige_par_entete(parametre_url(self(), 'etape', '4', '&'));
167 167
 }
168 168
 
169 169
 function echouer_etape_3b($echec) {
170
-	echo minipres(
171
-		'AUTO',
172
-		info_progression_etape(3, 'etape_', 'install/', true) .
173
-		"<div class='error'><h3>$echec</h3>\n" .
174
-		'<p>' . _T('avis_connexion_echec_2') . '</p>' .
175
-		'</div>'
176
-	);
177
-	exit;
170
+    echo minipres(
171
+        'AUTO',
172
+        info_progression_etape(3, 'etape_', 'install/', true) .
173
+        "<div class='error'><h3>$echec</h3>\n" .
174
+        '<p>' . _T('avis_connexion_echec_2') . '</p>' .
175
+        '</div>'
176
+    );
177
+    exit;
178 178
 }
Please login to merge, or discard this patch.
ecrire/src/Chiffrer/Password.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -14,57 +14,57 @@
 block discarded – undo
14 14
 
15 15
 /** Vérification et hachage de mot de passe */
16 16
 class Password {
17
-	/**
18
-	 * verifier qu'un mot de passe en clair est correct a l'aide de son hash
19
-	 *
20
-	 * Le mot de passe est poivre via la cle secret_des_auth
21
-	 *
22
-	 * @param string $password_clair
23
-	 * @param string $password_hash
24
-	 * @param string $key
25
-	 * @return bool
26
-	 */
27
-	public static function verifier(
28
-		#[\SensitiveParameter]
29
-		string $password_clair,
30
-		#[\SensitiveParameter]
31
-		string $password_hash,
32
-		#[\SensitiveParameter]
33
-		?string $key = null
34
-	): bool {
35
-		$key ??= self::getDefaultKey();
36
-		if ($key) {
37
-			$pass_poivre = hash_hmac('sha256', $password_clair, $key);
38
-			return password_verify($pass_poivre, $password_hash);
39
-		}
40
-		spip_log('Aucune clé pour vérifier le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE);
41
-		return false;
42
-	}
17
+    /**
18
+     * verifier qu'un mot de passe en clair est correct a l'aide de son hash
19
+     *
20
+     * Le mot de passe est poivre via la cle secret_des_auth
21
+     *
22
+     * @param string $password_clair
23
+     * @param string $password_hash
24
+     * @param string $key
25
+     * @return bool
26
+     */
27
+    public static function verifier(
28
+        #[\SensitiveParameter]
29
+        string $password_clair,
30
+        #[\SensitiveParameter]
31
+        string $password_hash,
32
+        #[\SensitiveParameter]
33
+        ?string $key = null
34
+    ): bool {
35
+        $key ??= self::getDefaultKey();
36
+        if ($key) {
37
+            $pass_poivre = hash_hmac('sha256', $password_clair, $key);
38
+            return password_verify($pass_poivre, $password_hash);
39
+        }
40
+        spip_log('Aucune clé pour vérifier le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE);
41
+        return false;
42
+    }
43 43
 
44
-	/**
45
-	 * Calculer un hash salé du mot de passe
46
-	 * @param string $password_clair
47
-	 * @param string $salt
48
-	 * @return string
49
-	 */
50
-	public static function hacher(
51
-		#[\SensitiveParameter]
52
-		string $password_clair,
53
-		#[\SensitiveParameter]
54
-		?string $key = null
55
-	): ?string {
56
-		$key ??= self::getDefaultKey();
57
-		// ne pas fournir un hash errone si la cle nous manque
58
-		if ($key) {
59
-			$pass_poivre = hash_hmac('sha256', $password_clair, $key);
60
-			return password_hash($pass_poivre, PASSWORD_DEFAULT);
61
-		}
62
-		spip_log('Aucune clé pour chiffrer le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE);
63
-		return null;
64
-	}
44
+    /**
45
+     * Calculer un hash salé du mot de passe
46
+     * @param string $password_clair
47
+     * @param string $salt
48
+     * @return string
49
+     */
50
+    public static function hacher(
51
+        #[\SensitiveParameter]
52
+        string $password_clair,
53
+        #[\SensitiveParameter]
54
+        ?string $key = null
55
+    ): ?string {
56
+        $key ??= self::getDefaultKey();
57
+        // ne pas fournir un hash errone si la cle nous manque
58
+        if ($key) {
59
+            $pass_poivre = hash_hmac('sha256', $password_clair, $key);
60
+            return password_hash($pass_poivre, PASSWORD_DEFAULT);
61
+        }
62
+        spip_log('Aucune clé pour chiffrer le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE);
63
+        return null;
64
+    }
65 65
 
66
-	private static function getDefaultKey(): ?string {
67
-		$keys = SpipCles::instance();
68
-		return $keys->getSecretAuth();
69
-	}
66
+    private static function getDefaultKey(): ?string {
67
+        $keys = SpipCles::instance();
68
+        return $keys->getSecretAuth();
69
+    }
70 70
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			$pass_poivre = hash_hmac('sha256', $password_clair, $key);
38 38
 			return password_verify($pass_poivre, $password_hash);
39 39
 		}
40
-		spip_log('Aucune clé pour vérifier le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE);
40
+		spip_log('Aucune clé pour vérifier le mot de passe', 'chiffrer'._LOG_INFO_IMPORTANTE);
41 41
 		return false;
42 42
 	}
43 43
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			$pass_poivre = hash_hmac('sha256', $password_clair, $key);
60 60
 			return password_hash($pass_poivre, PASSWORD_DEFAULT);
61 61
 		}
62
-		spip_log('Aucune clé pour chiffrer le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE);
62
+		spip_log('Aucune clé pour chiffrer le mot de passe', 'chiffrer'._LOG_INFO_IMPORTANTE);
63 63
 		return null;
64 64
 	}
65 65
 
Please login to merge, or discard this patch.
ecrire/src/Chiffrer/Cles.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 	public function generate(string $name): string {
31 31
 		$key = Chiffrement::keygen();
32 32
 		$this->keys[$name] = $key;
33
-		spip_log("Création de la cle $name", 'chiffrer' . _LOG_INFO_IMPORTANTE);
33
+		spip_log("Création de la cle $name", 'chiffrer'._LOG_INFO_IMPORTANTE);
34 34
 		return $key;
35 35
 	}
36 36
 
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -14,48 +14,48 @@
 block discarded – undo
14 14
 
15 15
 /** Conteneur de clés (chiffrement, authentification) */
16 16
 class Cles implements \Countable /* , ContainerInterface */ {
17
-	private array $keys;
18
-	public function __construct(array $keys) {
19
-		$this->keys = $keys;
20
-	}
21
-
22
-	public function has(string $name): bool {
23
-		return array_key_exists($name, $this->keys);
24
-	}
25
-
26
-	public function get(string $name): ?string {
27
-		return $this->keys[$name] ?? null;
28
-	}
29
-
30
-	public function generate(string $name): string {
31
-		$key = Chiffrement::keygen();
32
-		$this->keys[$name] = $key;
33
-		spip_log("Création de la cle $name", 'chiffrer' . _LOG_INFO_IMPORTANTE);
34
-		return $key;
35
-	}
36
-
37
-	public function set(
38
-		string $name,
39
-		#[\SensitiveParameter]
40
-		string $key
41
-	): void {
42
-		$this->keys[$name] = $key;
43
-	}
44
-
45
-	public function delete(string $name): bool {
46
-		if (isset($this->keys[$name])) {
47
-			unset($this->keys[$name]);
48
-			return true;
49
-		};
50
-		return false;
51
-	}
52
-
53
-	public function count(): int {
54
-		return count($this->keys);
55
-	}
56
-
57
-	public function toJson(): string {
58
-		$json = array_map('base64_encode', $this->keys);
59
-		return \json_encode($json);
60
-	}
17
+    private array $keys;
18
+    public function __construct(array $keys) {
19
+        $this->keys = $keys;
20
+    }
21
+
22
+    public function has(string $name): bool {
23
+        return array_key_exists($name, $this->keys);
24
+    }
25
+
26
+    public function get(string $name): ?string {
27
+        return $this->keys[$name] ?? null;
28
+    }
29
+
30
+    public function generate(string $name): string {
31
+        $key = Chiffrement::keygen();
32
+        $this->keys[$name] = $key;
33
+        spip_log("Création de la cle $name", 'chiffrer' . _LOG_INFO_IMPORTANTE);
34
+        return $key;
35
+    }
36
+
37
+    public function set(
38
+        string $name,
39
+        #[\SensitiveParameter]
40
+        string $key
41
+    ): void {
42
+        $this->keys[$name] = $key;
43
+    }
44
+
45
+    public function delete(string $name): bool {
46
+        if (isset($this->keys[$name])) {
47
+            unset($this->keys[$name]);
48
+            return true;
49
+        };
50
+        return false;
51
+    }
52
+
53
+    public function count(): int {
54
+        return count($this->keys);
55
+    }
56
+
57
+    public function toJson(): string {
58
+        $json = array_map('base64_encode', $this->keys);
59
+        return \json_encode($json);
60
+    }
61 61
 }
Please login to merge, or discard this patch.
ecrire/inc/presenter_enfants.php 2 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/autoriser');
@@ -30,80 +30,80 @@  discard block
 block discarded – undo
30 30
  *  Un tableau des sous rubriques
31 31
  */
32 32
 function enfant_rub($collection, $debut = 0, $limite = 500) {
33
-	$voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non');
34
-	$logo = '';
35
-
36
-	if ($voir_logo) {
37
-		$chercher_logo = charger_fonction('chercher_logo', 'inc');
38
-		include_spip('inc/filtres_images_mini');
39
-	}
40
-
41
-	$res = [];
42
-
43
-	$result = sql_select(
44
-		'id_rubrique, id_parent, titre, descriptif, lang',
45
-		'spip_rubriques',
46
-		'id_parent=' . intval($collection),
47
-		'',
48
-		'0+titre,titre',
49
-		$debut == -1 ? '' : "$debut,$limite"
50
-	);
51
-	while ($row = sql_fetch($result)) {
52
-		$id_rubrique = $row['id_rubrique'];
53
-		$id_parent = $row['id_parent'];
54
-		// pour etre sur de passer par tous les traitements
55
-		$titre = generer_objet_info($id_rubrique, 'rubrique', 'titre');
56
-		if ('' !== ($rang = recuperer_numero($row['titre']))) {
57
-			$rang = "<span class='rang'>$rang.</span> ";
58
-		}
59
-
60
-		if (autoriser('voir', 'rubrique', $id_rubrique)) {
61
-			$les_sous_enfants = sous_enfant_rub($id_rubrique);
62
-
63
-			changer_typo($row['lang']);
64
-			$lang_dir = lang_dir($row['lang']);
65
-			$descriptif = propre($row['descriptif']);
66
-
67
-			if ($voir_logo) {
68
-				if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) {
69
-					[$fid, $dir, $nom, $format] = $logo;
70
-					$logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
71
-					if ($logo) {
72
-						$logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">');
73
-					}
74
-				}
75
-			}
76
-
77
-			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
78
-					http_img_pack(
79
-						'auteur-0minirezo-16.png',
80
-						'',
81
-						" width='16' height='16'",
82
-						_T('image_administrer_rubrique')
83
-					)) .
84
-				" <a class='titremlien' dir='$lang_dir'" .
85
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
86
-				" href='" .
87
-				generer_objet_url($id_rubrique, 'rubrique') .
88
-				"'><span class='titre'>" .
89
-				$rang . $titre
90
-				. '</span>'
91
-				. (is_string($logo) ? $logo : '')
92
-				. '</a>';
93
-
94
-			$titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
95
-				. (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>")
96
-				;
97
-
98
-			$res[] =
99
-				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
100
-				$les_sous_enfants .
101
-				fin_cadre_sous_rub();
102
-		}
103
-	}
104
-
105
-	changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
106
-	return $res;
33
+    $voir_logo = (isset($GLOBALS['meta']['image_process']) and $GLOBALS['meta']['image_process'] != 'non');
34
+    $logo = '';
35
+
36
+    if ($voir_logo) {
37
+        $chercher_logo = charger_fonction('chercher_logo', 'inc');
38
+        include_spip('inc/filtres_images_mini');
39
+    }
40
+
41
+    $res = [];
42
+
43
+    $result = sql_select(
44
+        'id_rubrique, id_parent, titre, descriptif, lang',
45
+        'spip_rubriques',
46
+        'id_parent=' . intval($collection),
47
+        '',
48
+        '0+titre,titre',
49
+        $debut == -1 ? '' : "$debut,$limite"
50
+    );
51
+    while ($row = sql_fetch($result)) {
52
+        $id_rubrique = $row['id_rubrique'];
53
+        $id_parent = $row['id_parent'];
54
+        // pour etre sur de passer par tous les traitements
55
+        $titre = generer_objet_info($id_rubrique, 'rubrique', 'titre');
56
+        if ('' !== ($rang = recuperer_numero($row['titre']))) {
57
+            $rang = "<span class='rang'>$rang.</span> ";
58
+        }
59
+
60
+        if (autoriser('voir', 'rubrique', $id_rubrique)) {
61
+            $les_sous_enfants = sous_enfant_rub($id_rubrique);
62
+
63
+            changer_typo($row['lang']);
64
+            $lang_dir = lang_dir($row['lang']);
65
+            $descriptif = propre($row['descriptif']);
66
+
67
+            if ($voir_logo) {
68
+                if ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on')) {
69
+                    [$fid, $dir, $nom, $format] = $logo;
70
+                    $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
71
+                    if ($logo) {
72
+                        $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">');
73
+                    }
74
+                }
75
+            }
76
+
77
+            $lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
78
+                    http_img_pack(
79
+                        'auteur-0minirezo-16.png',
80
+                        '',
81
+                        " width='16' height='16'",
82
+                        _T('image_administrer_rubrique')
83
+                    )) .
84
+                " <a class='titremlien' dir='$lang_dir'" .
85
+                ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
86
+                " href='" .
87
+                generer_objet_url($id_rubrique, 'rubrique') .
88
+                "'><span class='titre'>" .
89
+                $rang . $titre
90
+                . '</span>'
91
+                . (is_string($logo) ? $logo : '')
92
+                . '</a>';
93
+
94
+            $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
95
+                . (!$descriptif ? '' : "\n<div class='descriptif'>$descriptif</div>")
96
+                ;
97
+
98
+            $res[] =
99
+                debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
100
+                $les_sous_enfants .
101
+                fin_cadre_sous_rub();
102
+        }
103
+    }
104
+
105
+    changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
106
+    return $res;
107 107
 }
108 108
 
109 109
 /**
@@ -116,71 +116,71 @@  discard block
 block discarded – undo
116 116
  *  Le contenu du bloc dépliable
117 117
  */
118 118
 function sous_enfant_rub($collection2) {
119
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2));
120
-
121
-	$retour = '';
122
-	$pagination = '';
123
-	$debut = 0;
124
-	$limite = 500;
125
-
126
-	/**
127
-	 * On ne va afficher que 500 résultats max
128
-	 * Si > 500 on affiche une pagination
129
-	 */
130
-	if ($nb > $limite) {
131
-		$debut = _request('debut_rubrique' . $collection2) ?: $debut;
132
-		$pagination = chercher_filtre('pagination');
133
-		$pagination = '<nav class="pagination">' . $pagination(
134
-			$nb,
135
-			'_rubrique' . $collection2,
136
-			$debut,
137
-			$limite,
138
-			true,
139
-			'prive'
140
-		) . '</nav>';
141
-		$limite = $debut + $limite;
142
-	}
143
-
144
-	$result = sql_select(
145
-		'id_rubrique, id_parent, titre, lang',
146
-		'spip_rubriques',
147
-		'id_parent=' . intval($collection2),
148
-		'',
149
-		'0+titre,titre',
150
-		$debut == -1 ? '' : "$debut,$limite"
151
-	);
152
-
153
-	while ($row = sql_fetch($result)) {
154
-		$id_rubrique2 = $row['id_rubrique'];
155
-		$titre2 = generer_objet_info(
156
-			$id_rubrique2,
157
-			'rubrique',
158
-			'titre'
159
-		); // pour etre sur de passer par tous les traitements
160
-		if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
161
-			$rang2 = "<span class='rang'>$rang2.</span> ";
162
-		}
163
-
164
-		changer_typo($row['lang']);
165
-		$lang_dir = lang_dir($row['lang']);
166
-		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
167
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url(
168
-				$id_rubrique2,
169
-				'rubrique'
170
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
171
-		}
172
-	}
173
-
174
-	$retour = $pagination . $retour . $pagination;
175
-
176
-	if (!$retour) {
177
-		return '';
178
-	}
179
-
180
-	return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
181
-	. "\n<ul class='liste-items sous-sous-rub'>\n"
182
-	. $retour
183
-	. "</ul>\n" . fin_block() . "\n\n";
119
+    $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2));
120
+
121
+    $retour = '';
122
+    $pagination = '';
123
+    $debut = 0;
124
+    $limite = 500;
125
+
126
+    /**
127
+     * On ne va afficher que 500 résultats max
128
+     * Si > 500 on affiche une pagination
129
+     */
130
+    if ($nb > $limite) {
131
+        $debut = _request('debut_rubrique' . $collection2) ?: $debut;
132
+        $pagination = chercher_filtre('pagination');
133
+        $pagination = '<nav class="pagination">' . $pagination(
134
+            $nb,
135
+            '_rubrique' . $collection2,
136
+            $debut,
137
+            $limite,
138
+            true,
139
+            'prive'
140
+        ) . '</nav>';
141
+        $limite = $debut + $limite;
142
+    }
143
+
144
+    $result = sql_select(
145
+        'id_rubrique, id_parent, titre, lang',
146
+        'spip_rubriques',
147
+        'id_parent=' . intval($collection2),
148
+        '',
149
+        '0+titre,titre',
150
+        $debut == -1 ? '' : "$debut,$limite"
151
+    );
152
+
153
+    while ($row = sql_fetch($result)) {
154
+        $id_rubrique2 = $row['id_rubrique'];
155
+        $titre2 = generer_objet_info(
156
+            $id_rubrique2,
157
+            'rubrique',
158
+            'titre'
159
+        ); // pour etre sur de passer par tous les traitements
160
+        if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
161
+            $rang2 = "<span class='rang'>$rang2.</span> ";
162
+        }
163
+
164
+        changer_typo($row['lang']);
165
+        $lang_dir = lang_dir($row['lang']);
166
+        if (autoriser('voir', 'rubrique', $id_rubrique2)) {
167
+            $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url(
168
+                $id_rubrique2,
169
+                'rubrique'
170
+            ) . "'>" . $rang2 . $titre2 . "</a></li>\n";
171
+        }
172
+    }
173
+
174
+    $retour = $pagination . $retour . $pagination;
175
+
176
+    if (!$retour) {
177
+        return '';
178
+    }
179
+
180
+    return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
181
+    . "\n<ul class='liste-items sous-sous-rub'>\n"
182
+    . $retour
183
+    . "</ul>\n" . fin_block() . "\n\n";
184 184
 }
185 185
 
186 186
 /**
@@ -195,44 +195,44 @@  discard block
 block discarded – undo
195 195
  *  Le contenu textuel affiché, la liste des sous rubriques
196 196
  */
197 197
 function afficher_enfant_rub($id_rubrique = 0) {
198
-	$pagination = '';
199
-	$debut = 0;
200
-	$limite = 500;
201
-
202
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique));
203
-
204
-	if ($nb > $limite) {
205
-		$debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
206
-		$pagination = chercher_filtre('pagination');
207
-		$pagination = '<br class="nettoyeur"><nav class="pagination">' .
208
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
209
-		'</nav>';
210
-	}
211
-
212
-	$les_enfants = enfant_rub($id_rubrique, $debut, $limite);
213
-
214
-	if (!$n = count($les_enfants)) {
215
-		return '';
216
-	}
217
-
218
-	if ($n == 1) {
219
-		$les_enfants = reset($les_enfants);
220
-		$les_enfants2 = '';
221
-	} else {
222
-		$n = ceil($n / 2);
223
-		$les_enfants2 = implode('', array_slice($les_enfants, $n));
224
-		$les_enfants = implode('', array_slice($les_enfants, 0, $n));
225
-	}
226
-
227
-	$res =
228
-		$pagination
229
-		. "<div class='gauche'>"
230
-		. $les_enfants
231
-		. '</div>'
232
-		. "<div class='droite'>"
233
-		. $les_enfants2
234
-		. '</div>'
235
-		. $pagination;
236
-
237
-	return $res;
198
+    $pagination = '';
199
+    $debut = 0;
200
+    $limite = 500;
201
+
202
+    $nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique));
203
+
204
+    if ($nb > $limite) {
205
+        $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
206
+        $pagination = chercher_filtre('pagination');
207
+        $pagination = '<br class="nettoyeur"><nav class="pagination">' .
208
+            $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
209
+        '</nav>';
210
+    }
211
+
212
+    $les_enfants = enfant_rub($id_rubrique, $debut, $limite);
213
+
214
+    if (!$n = count($les_enfants)) {
215
+        return '';
216
+    }
217
+
218
+    if ($n == 1) {
219
+        $les_enfants = reset($les_enfants);
220
+        $les_enfants2 = '';
221
+    } else {
222
+        $n = ceil($n / 2);
223
+        $les_enfants2 = implode('', array_slice($les_enfants, $n));
224
+        $les_enfants = implode('', array_slice($les_enfants, 0, $n));
225
+    }
226
+
227
+    $res =
228
+        $pagination
229
+        . "<div class='gauche'>"
230
+        . $les_enfants
231
+        . '</div>'
232
+        . "<div class='droite'>"
233
+        . $les_enfants2
234
+        . '</div>'
235
+        . $pagination;
236
+
237
+    return $res;
238 238
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -26 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	$result = sql_select(
44 44
 		'id_rubrique, id_parent, titre, descriptif, lang',
45 45
 		'spip_rubriques',
46
-		'id_parent=' . intval($collection),
46
+		'id_parent='.intval($collection),
47 47
 		'',
48 48
 		'0+titre,titre',
49 49
 		$debut == -1 ? '' : "$debut,$limite"
@@ -74,19 +74,18 @@  discard block
 block discarded – undo
74 74
 				}
75 75
 			}
76 76
 
77
-			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' :
78
-					http_img_pack(
77
+			$lib_bouton = (!acces_restreint_rubrique($id_rubrique) ? '' : http_img_pack(
79 78
 						'auteur-0minirezo-16.png',
80 79
 						'',
81 80
 						" width='16' height='16'",
82 81
 						_T('image_administrer_rubrique')
83
-					)) .
84
-				" <a class='titremlien' dir='$lang_dir'" .
85
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
86
-				" href='" .
87
-				generer_objet_url($id_rubrique, 'rubrique') .
88
-				"'><span class='titre'>" .
89
-				$rang . $titre
82
+					)).
83
+				" <a class='titremlien' dir='$lang_dir'".
84
+				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='".$row['lang']."'" : '').
85
+				" href='".
86
+				generer_objet_url($id_rubrique, 'rubrique').
87
+				"'><span class='titre'>".
88
+				$rang.$titre
90 89
 				. '</span>'
91 90
 				. (is_string($logo) ? $logo : '')
92 91
 				. '</a>';
@@ -96,8 +95,8 @@  discard block
 block discarded – undo
96 95
 				;
97 96
 
98 97
 			$res[] =
99
-				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
100
-				$les_sous_enfants .
98
+				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre).
99
+				$les_sous_enfants.
101 100
 				fin_cadre_sous_rub();
102 101
 		}
103 102
 	}
@@ -116,7 +115,7 @@  discard block
 block discarded – undo
116 115
  *  Le contenu du bloc dépliable
117 116
  */
118 117
 function sous_enfant_rub($collection2) {
119
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($collection2));
118
+	$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($collection2));
120 119
 
121 120
 	$retour = '';
122 121
 	$pagination = '';
@@ -128,23 +127,23 @@  discard block
 block discarded – undo
128 127
 	 * Si > 500 on affiche une pagination
129 128
 	 */
130 129
 	if ($nb > $limite) {
131
-		$debut = _request('debut_rubrique' . $collection2) ?: $debut;
130
+		$debut = _request('debut_rubrique'.$collection2) ?: $debut;
132 131
 		$pagination = chercher_filtre('pagination');
133
-		$pagination = '<nav class="pagination">' . $pagination(
132
+		$pagination = '<nav class="pagination">'.$pagination(
134 133
 			$nb,
135
-			'_rubrique' . $collection2,
134
+			'_rubrique'.$collection2,
136 135
 			$debut,
137 136
 			$limite,
138 137
 			true,
139 138
 			'prive'
140
-		) . '</nav>';
139
+		).'</nav>';
141 140
 		$limite = $debut + $limite;
142 141
 	}
143 142
 
144 143
 	$result = sql_select(
145 144
 		'id_rubrique, id_parent, titre, lang',
146 145
 		'spip_rubriques',
147
-		'id_parent=' . intval($collection2),
146
+		'id_parent='.intval($collection2),
148 147
 		'',
149 148
 		'0+titre,titre',
150 149
 		$debut == -1 ? '' : "$debut,$limite"
@@ -164,14 +163,14 @@  discard block
 block discarded – undo
164 163
 		changer_typo($row['lang']);
165 164
 		$lang_dir = lang_dir($row['lang']);
166 165
 		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
167
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url(
166
+			$retour .= "\n<li class='item' dir='$lang_dir'><a href='".generer_objet_url(
168 167
 				$id_rubrique2,
169 168
 				'rubrique'
170
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
169
+			)."'>".$rang2.$titre2."</a></li>\n";
171 170
 		}
172 171
 	}
173 172
 
174
-	$retour = $pagination . $retour . $pagination;
173
+	$retour = $pagination.$retour.$pagination;
175 174
 
176 175
 	if (!$retour) {
177 176
 		return '';
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 	return debut_block_depliable($debut > 0 ? true : false, "enfants$collection2")
181 180
 	. "\n<ul class='liste-items sous-sous-rub'>\n"
182 181
 	. $retour
183
-	. "</ul>\n" . fin_block() . "\n\n";
182
+	. "</ul>\n".fin_block()."\n\n";
184 183
 }
185 184
 
186 185
 /**
@@ -199,13 +198,13 @@  discard block
 block discarded – undo
199 198
 	$debut = 0;
200 199
 	$limite = 500;
201 200
 
202
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique));
201
+	$nb = sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique));
203 202
 
204 203
 	if ($nb > $limite) {
205
-		$debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
204
+		$debut = _request('debut_rubrique'.$id_rubrique) ?: $debut;
206 205
 		$pagination = chercher_filtre('pagination');
207
-		$pagination = '<br class="nettoyeur"><nav class="pagination">' .
208
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
206
+		$pagination = '<br class="nettoyeur"><nav class="pagination">'.
207
+			$pagination($nb, '_rubrique'.$id_rubrique, $debut, $limite, true, 'prive').
209 208
 		'</nav>';
210 209
 	}
211 210
 
Please login to merge, or discard this patch.
ecrire/public/decompiler.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -11,129 +11,129 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 // Decompilation de l'arbre de syntaxe abstraite d'un squelette SPIP
18 18
 
19 19
 function decompiler_boucle($struct, $fmt = '', $prof = 0) {
20
-	$nom = $struct->id_boucle;
21
-	$preaff = decompiler_($struct->preaff, $fmt, $prof);
22
-	$avant = decompiler_($struct->avant, $fmt, $prof);
23
-	$apres = decompiler_($struct->apres, $fmt, $prof);
24
-	$altern = decompiler_($struct->altern, $fmt, $prof);
25
-	$milieu = decompiler_($struct->milieu, $fmt, $prof);
26
-	$postaff = decompiler_($struct->postaff, $fmt, $prof);
27
-
28
-	$type = $struct->sql_serveur ? "$struct->sql_serveur:" : '';
29
-	$type .= ($struct->type_requete ?: $struct->table_optionnelle);
30
-
31
-	if ($struct->jointures_explicites) {
32
-		$type .= ' ' . $struct->jointures_explicites;
33
-	}
34
-	if ($struct->table_optionnelle) {
35
-		$type .= '?';
36
-	}
37
-	// Revoir le cas de la boucle recursive
38
-
39
-	$crit = $struct->param;
40
-	if ($crit and !is_array($crit[0])) {
41
-		$type = strtolower($type) . array_shift($crit);
42
-	}
43
-	$crit = decompiler_criteres($struct, $fmt, $prof);
44
-
45
-	$f = 'format_boucle_' . $fmt;
46
-
47
-	return $f($preaff, $avant, $nom, $type, $crit, $milieu, $apres, $altern, $postaff, $prof);
20
+    $nom = $struct->id_boucle;
21
+    $preaff = decompiler_($struct->preaff, $fmt, $prof);
22
+    $avant = decompiler_($struct->avant, $fmt, $prof);
23
+    $apres = decompiler_($struct->apres, $fmt, $prof);
24
+    $altern = decompiler_($struct->altern, $fmt, $prof);
25
+    $milieu = decompiler_($struct->milieu, $fmt, $prof);
26
+    $postaff = decompiler_($struct->postaff, $fmt, $prof);
27
+
28
+    $type = $struct->sql_serveur ? "$struct->sql_serveur:" : '';
29
+    $type .= ($struct->type_requete ?: $struct->table_optionnelle);
30
+
31
+    if ($struct->jointures_explicites) {
32
+        $type .= ' ' . $struct->jointures_explicites;
33
+    }
34
+    if ($struct->table_optionnelle) {
35
+        $type .= '?';
36
+    }
37
+    // Revoir le cas de la boucle recursive
38
+
39
+    $crit = $struct->param;
40
+    if ($crit and !is_array($crit[0])) {
41
+        $type = strtolower($type) . array_shift($crit);
42
+    }
43
+    $crit = decompiler_criteres($struct, $fmt, $prof);
44
+
45
+    $f = 'format_boucle_' . $fmt;
46
+
47
+    return $f($preaff, $avant, $nom, $type, $crit, $milieu, $apres, $altern, $postaff, $prof);
48 48
 }
49 49
 
50 50
 function decompiler_include($struct, $fmt = '', $prof = 0) {
51
-	$res = [];
52
-	foreach ($struct->param ?: [] as $couple) {
53
-		array_shift($couple);
54
-		foreach ($couple as $v) {
55
-			$res[] = decompiler_($v, $fmt, $prof);
56
-		}
57
-	}
58
-	$file = is_string($struct->texte) ? $struct->texte :
59
-		decompiler_($struct->texte, $fmt, $prof);
60
-	$f = 'format_inclure_' . $fmt;
61
-
62
-	return $f($file, $res, $prof);
51
+    $res = [];
52
+    foreach ($struct->param ?: [] as $couple) {
53
+        array_shift($couple);
54
+        foreach ($couple as $v) {
55
+            $res[] = decompiler_($v, $fmt, $prof);
56
+        }
57
+    }
58
+    $file = is_string($struct->texte) ? $struct->texte :
59
+        decompiler_($struct->texte, $fmt, $prof);
60
+    $f = 'format_inclure_' . $fmt;
61
+
62
+    return $f($file, $res, $prof);
63 63
 }
64 64
 
65 65
 function decompiler_texte($struct, $fmt = '', $prof = 0) {
66
-	$f = 'format_texte_' . $fmt;
66
+    $f = 'format_texte_' . $fmt;
67 67
 
68
-	return strlen($struct->texte) ? $f($struct->texte, $prof) : '';
68
+    return strlen($struct->texte) ? $f($struct->texte, $prof) : '';
69 69
 }
70 70
 
71 71
 function decompiler_polyglotte($struct, $fmt = '', $prof = 0) {
72
-	$f = 'format_polyglotte_' . $fmt;
72
+    $f = 'format_polyglotte_' . $fmt;
73 73
 
74
-	return $f($struct->traductions, $prof);
74
+    return $f($struct->traductions, $prof);
75 75
 }
76 76
 
77 77
 function decompiler_idiome($struct, $fmt = '', $prof = 0) {
78
-	$args = [];
79
-	foreach ($struct->arg as $k => $v) {
80
-		$args[$k] = public_decompiler($v, $fmt, $prof);
81
-	}
78
+    $args = [];
79
+    foreach ($struct->arg as $k => $v) {
80
+        $args[$k] = public_decompiler($v, $fmt, $prof);
81
+    }
82 82
 
83
-	$filtres = decompiler_liste($struct->param, $fmt, $prof);
83
+    $filtres = decompiler_liste($struct->param, $fmt, $prof);
84 84
 
85
-	$f = 'format_idiome_' . $fmt;
85
+    $f = 'format_idiome_' . $fmt;
86 86
 
87
-	return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof);
87
+    return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof);
88 88
 }
89 89
 
90 90
 function decompiler_champ($struct, $fmt = '', $prof = 0) {
91
-	$avant = decompiler_($struct->avant, $fmt, $prof);
92
-	$apres = decompiler_($struct->apres, $fmt, $prof);
93
-	$args = $filtres = '';
94
-	if ($p = $struct->param) {
95
-		if ($p[0][0] === '') {
96
-			$args = decompiler_liste([array_shift($p)], $fmt, $prof);
97
-		}
98
-		$filtres = decompiler_liste($p, $fmt, $prof);
99
-	}
100
-	$f = 'format_champ_' . $fmt;
101
-
102
-	return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof);
91
+    $avant = decompiler_($struct->avant, $fmt, $prof);
92
+    $apres = decompiler_($struct->apres, $fmt, $prof);
93
+    $args = $filtres = '';
94
+    if ($p = $struct->param) {
95
+        if ($p[0][0] === '') {
96
+            $args = decompiler_liste([array_shift($p)], $fmt, $prof);
97
+        }
98
+        $filtres = decompiler_liste($p, $fmt, $prof);
99
+    }
100
+    $f = 'format_champ_' . $fmt;
101
+
102
+    return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof);
103 103
 }
104 104
 
105 105
 function decompiler_liste($sources, $fmt = '', $prof = 0) {
106
-	if (!is_array($sources)) {
107
-		return '';
108
-	}
109
-	$f = 'format_liste_' . $fmt;
110
-	$res = '';
111
-	foreach ($sources as $arg) {
112
-		if (!is_array($arg)) {
113
-			continue; // ne devrait pas arriver.
114
-		} else {
115
-			$r = array_shift($arg);
116
-		}
117
-		$args = [];
118
-		foreach ($arg as $v) {
119
-			// cas des arguments entoures de ' ou "
120
-			if (
121
-				((is_countable($v) ? count($v) : 0) == 1)
122
-				and $v[0]->type == 'texte'
123
-				and (strlen($v[0]->apres) == 1)
124
-				and $v[0]->apres == $v[0]->avant
125
-			) {
126
-				$args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres;
127
-			} else {
128
-				$args[] = decompiler_($v, $fmt, 0 - $prof);
129
-			}
130
-		}
131
-		if (($r !== '') or $args) {
132
-			$res .= $f($r, $args, $prof);
133
-		}
134
-	}
135
-
136
-	return $res;
106
+    if (!is_array($sources)) {
107
+        return '';
108
+    }
109
+    $f = 'format_liste_' . $fmt;
110
+    $res = '';
111
+    foreach ($sources as $arg) {
112
+        if (!is_array($arg)) {
113
+            continue; // ne devrait pas arriver.
114
+        } else {
115
+            $r = array_shift($arg);
116
+        }
117
+        $args = [];
118
+        foreach ($arg as $v) {
119
+            // cas des arguments entoures de ' ou "
120
+            if (
121
+                ((is_countable($v) ? count($v) : 0) == 1)
122
+                and $v[0]->type == 'texte'
123
+                and (strlen($v[0]->apres) == 1)
124
+                and $v[0]->apres == $v[0]->avant
125
+            ) {
126
+                $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres;
127
+            } else {
128
+                $args[] = decompiler_($v, $fmt, 0 - $prof);
129
+            }
130
+        }
131
+        if (($r !== '') or $args) {
132
+            $res .= $f($r, $args, $prof);
133
+        }
134
+    }
135
+
136
+    return $res;
137 137
 }
138 138
 
139 139
 // Decompilation des criteres: on triche et on deroge:
@@ -141,93 +141,93 @@  discard block
 block discarded – undo
141 141
 // - le champ apres signale le critere {"separateur"} ou {'separateur'}
142 142
 // - les champs sont implicitement etendus (crochets implicites mais interdits)
143 143
 function decompiler_criteres($boucle, $fmt = '', $prof = 0) {
144
-	$sources = $boucle->param;
145
-	if (!is_array($sources)) {
146
-		return '';
147
-	}
148
-	$res = '';
149
-	$f = 'format_critere_' . $fmt;
150
-	foreach ($sources as $crit) {
151
-		if (!is_array($crit)) {
152
-			continue;
153
-		} // boucle recursive
154
-		array_shift($crit);
155
-		$args = [];
156
-		foreach ($crit as $i => $v) {
157
-			if (
158
-				((is_countable($v) ? count($v) : 0) == 1)
159
-				and $v[0]->type == 'texte'
160
-				and $v[0]->apres
161
-			) {
162
-				$args[] = [['texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres)]];
163
-			} else {
164
-				$res2 = [];
165
-				foreach ($v as $k => $p) {
166
-					if (
167
-						isset($p->type)
168
-						and function_exists($d = 'decompiler_' . $p->type)
169
-					) {
170
-						$r = $d($p, $fmt, (0 - $prof));
171
-						$res2[] = [$p->type, $r];
172
-					} else {
173
-						spip_log("critere $i / $k mal forme");
174
-					}
175
-				}
176
-				$args[] = $res2;
177
-			}
178
-		}
179
-		$res .= $f($args);
180
-	}
181
-
182
-	return $res;
144
+    $sources = $boucle->param;
145
+    if (!is_array($sources)) {
146
+        return '';
147
+    }
148
+    $res = '';
149
+    $f = 'format_critere_' . $fmt;
150
+    foreach ($sources as $crit) {
151
+        if (!is_array($crit)) {
152
+            continue;
153
+        } // boucle recursive
154
+        array_shift($crit);
155
+        $args = [];
156
+        foreach ($crit as $i => $v) {
157
+            if (
158
+                ((is_countable($v) ? count($v) : 0) == 1)
159
+                and $v[0]->type == 'texte'
160
+                and $v[0]->apres
161
+            ) {
162
+                $args[] = [['texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres)]];
163
+            } else {
164
+                $res2 = [];
165
+                foreach ($v as $k => $p) {
166
+                    if (
167
+                        isset($p->type)
168
+                        and function_exists($d = 'decompiler_' . $p->type)
169
+                    ) {
170
+                        $r = $d($p, $fmt, (0 - $prof));
171
+                        $res2[] = [$p->type, $r];
172
+                    } else {
173
+                        spip_log("critere $i / $k mal forme");
174
+                    }
175
+                }
176
+                $args[] = $res2;
177
+            }
178
+        }
179
+        $res .= $f($args);
180
+    }
181
+
182
+    return $res;
183 183
 }
184 184
 
185 185
 
186 186
 function decompiler_($liste, $fmt = '', $prof = 0) {
187
-	if (!is_array($liste)) {
188
-		return '';
189
-	}
190
-	$prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1);
191
-	$contenu = [];
192
-	foreach ($liste as $k => $p) {
193
-		if (!isset($p->type)) {
194
-			continue;
195
-		} #??????
196
-		$d = 'decompiler_' . $p->type;
197
-		$next = $liste[$k + 1] ?? false;
198
-		// Forcer le champ etendu si son source (pas les reecritures)
199
-		// contenait des args et s'il est suivi d'espaces,
200
-		// le champ simple les eliminant est un bug helas perenne.
201
-
202
-		if (
203
-			$next
204
-			and ($next->type == 'texte')
205
-			and $p->type == 'champ'
206
-			and !$p->apres
207
-			and !$p->avant
208
-			and $p->fonctions
209
-		) {
210
-			$n = strlen($next->texte) - strlen(ltrim($next->texte));
211
-			if ($n) {
212
-				$champ = new Texte();
213
-				$champ->texte = substr($next->texte, 0, $n);
214
-				$champ->ligne = $p->ligne;
215
-				$p->apres = [$champ];
216
-				$next->texte = substr($next->texte, $n);
217
-			}
218
-		}
219
-		$contenu[] = [$d($p, $fmt, $prof2), $p->type];
220
-	}
221
-	$f = 'format_suite_' . $fmt;
222
-
223
-	return $f($contenu);
187
+    if (!is_array($liste)) {
188
+        return '';
189
+    }
190
+    $prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1);
191
+    $contenu = [];
192
+    foreach ($liste as $k => $p) {
193
+        if (!isset($p->type)) {
194
+            continue;
195
+        } #??????
196
+        $d = 'decompiler_' . $p->type;
197
+        $next = $liste[$k + 1] ?? false;
198
+        // Forcer le champ etendu si son source (pas les reecritures)
199
+        // contenait des args et s'il est suivi d'espaces,
200
+        // le champ simple les eliminant est un bug helas perenne.
201
+
202
+        if (
203
+            $next
204
+            and ($next->type == 'texte')
205
+            and $p->type == 'champ'
206
+            and !$p->apres
207
+            and !$p->avant
208
+            and $p->fonctions
209
+        ) {
210
+            $n = strlen($next->texte) - strlen(ltrim($next->texte));
211
+            if ($n) {
212
+                $champ = new Texte();
213
+                $champ->texte = substr($next->texte, 0, $n);
214
+                $champ->ligne = $p->ligne;
215
+                $p->apres = [$champ];
216
+                $next->texte = substr($next->texte, $n);
217
+            }
218
+        }
219
+        $contenu[] = [$d($p, $fmt, $prof2), $p->type];
220
+    }
221
+    $f = 'format_suite_' . $fmt;
222
+
223
+    return $f($contenu);
224 224
 }
225 225
 
226 226
 function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') {
227
-	if (!include_spip('public/format_' . $fmt)) {
228
-		return "'$fmt'?";
229
-	}
230
-	$f = 'decompiler_' . $quoi;
227
+    if (!include_spip('public/format_' . $fmt)) {
228
+        return "'$fmt'?";
229
+    }
230
+    $f = 'decompiler_' . $quoi;
231 231
 
232
-	return $f($liste, $fmt, $prof);
232
+    return $f($liste, $fmt, $prof);
233 233
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -19 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	$type .= ($struct->type_requete ?: $struct->table_optionnelle);
30 30
 
31 31
 	if ($struct->jointures_explicites) {
32
-		$type .= ' ' . $struct->jointures_explicites;
32
+		$type .= ' '.$struct->jointures_explicites;
33 33
 	}
34 34
 	if ($struct->table_optionnelle) {
35 35
 		$type .= '?';
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 
39 39
 	$crit = $struct->param;
40 40
 	if ($crit and !is_array($crit[0])) {
41
-		$type = strtolower($type) . array_shift($crit);
41
+		$type = strtolower($type).array_shift($crit);
42 42
 	}
43 43
 	$crit = decompiler_criteres($struct, $fmt, $prof);
44 44
 
45
-	$f = 'format_boucle_' . $fmt;
45
+	$f = 'format_boucle_'.$fmt;
46 46
 
47 47
 	return $f($preaff, $avant, $nom, $type, $crit, $milieu, $apres, $altern, $postaff, $prof);
48 48
 }
@@ -55,21 +55,20 @@  discard block
 block discarded – undo
55 55
 			$res[] = decompiler_($v, $fmt, $prof);
56 56
 		}
57 57
 	}
58
-	$file = is_string($struct->texte) ? $struct->texte :
59
-		decompiler_($struct->texte, $fmt, $prof);
60
-	$f = 'format_inclure_' . $fmt;
58
+	$file = is_string($struct->texte) ? $struct->texte : decompiler_($struct->texte, $fmt, $prof);
59
+	$f = 'format_inclure_'.$fmt;
61 60
 
62 61
 	return $f($file, $res, $prof);
63 62
 }
64 63
 
65 64
 function decompiler_texte($struct, $fmt = '', $prof = 0) {
66
-	$f = 'format_texte_' . $fmt;
65
+	$f = 'format_texte_'.$fmt;
67 66
 
68 67
 	return strlen($struct->texte) ? $f($struct->texte, $prof) : '';
69 68
 }
70 69
 
71 70
 function decompiler_polyglotte($struct, $fmt = '', $prof = 0) {
72
-	$f = 'format_polyglotte_' . $fmt;
71
+	$f = 'format_polyglotte_'.$fmt;
73 72
 
74 73
 	return $f($struct->traductions, $prof);
75 74
 }
@@ -82,7 +81,7 @@  discard block
 block discarded – undo
82 81
 
83 82
 	$filtres = decompiler_liste($struct->param, $fmt, $prof);
84 83
 
85
-	$f = 'format_idiome_' . $fmt;
84
+	$f = 'format_idiome_'.$fmt;
86 85
 
87 86
 	return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof);
88 87
 }
@@ -97,7 +96,7 @@  discard block
 block discarded – undo
97 96
 		}
98 97
 		$filtres = decompiler_liste($p, $fmt, $prof);
99 98
 	}
100
-	$f = 'format_champ_' . $fmt;
99
+	$f = 'format_champ_'.$fmt;
101 100
 
102 101
 	return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof);
103 102
 }
@@ -106,7 +105,7 @@  discard block
 block discarded – undo
106 105
 	if (!is_array($sources)) {
107 106
 		return '';
108 107
 	}
109
-	$f = 'format_liste_' . $fmt;
108
+	$f = 'format_liste_'.$fmt;
110 109
 	$res = '';
111 110
 	foreach ($sources as $arg) {
112 111
 		if (!is_array($arg)) {
@@ -123,7 +122,7 @@  discard block
 block discarded – undo
123 122
 				and (strlen($v[0]->apres) == 1)
124 123
 				and $v[0]->apres == $v[0]->avant
125 124
 			) {
126
-				$args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres;
125
+				$args[] = $v[0]->avant.$v[0]->texte.$v[0]->apres;
127 126
 			} else {
128 127
 				$args[] = decompiler_($v, $fmt, 0 - $prof);
129 128
 			}
@@ -146,7 +145,7 @@  discard block
 block discarded – undo
146 145
 		return '';
147 146
 	}
148 147
 	$res = '';
149
-	$f = 'format_critere_' . $fmt;
148
+	$f = 'format_critere_'.$fmt;
150 149
 	foreach ($sources as $crit) {
151 150
 		if (!is_array($crit)) {
152 151
 			continue;
@@ -159,13 +158,13 @@  discard block
 block discarded – undo
159 158
 				and $v[0]->type == 'texte'
160 159
 				and $v[0]->apres
161 160
 			) {
162
-				$args[] = [['texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres)]];
161
+				$args[] = [['texte', ($v[0]->apres.$v[0]->texte.$v[0]->apres)]];
163 162
 			} else {
164 163
 				$res2 = [];
165 164
 				foreach ($v as $k => $p) {
166 165
 					if (
167 166
 						isset($p->type)
168
-						and function_exists($d = 'decompiler_' . $p->type)
167
+						and function_exists($d = 'decompiler_'.$p->type)
169 168
 					) {
170 169
 						$r = $d($p, $fmt, (0 - $prof));
171 170
 						$res2[] = [$p->type, $r];
@@ -193,7 +192,7 @@  discard block
 block discarded – undo
193 192
 		if (!isset($p->type)) {
194 193
 			continue;
195 194
 		} #??????
196
-		$d = 'decompiler_' . $p->type;
195
+		$d = 'decompiler_'.$p->type;
197 196
 		$next = $liste[$k + 1] ?? false;
198 197
 		// Forcer le champ etendu si son source (pas les reecritures)
199 198
 		// contenait des args et s'il est suivi d'espaces,
@@ -218,16 +217,16 @@  discard block
 block discarded – undo
218 217
 		}
219 218
 		$contenu[] = [$d($p, $fmt, $prof2), $p->type];
220 219
 	}
221
-	$f = 'format_suite_' . $fmt;
220
+	$f = 'format_suite_'.$fmt;
222 221
 
223 222
 	return $f($contenu);
224 223
 }
225 224
 
226 225
 function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') {
227
-	if (!include_spip('public/format_' . $fmt)) {
226
+	if (!include_spip('public/format_'.$fmt)) {
228 227
 		return "'$fmt'?";
229 228
 	}
230
-	$f = 'decompiler_' . $quoi;
229
+	$f = 'decompiler_'.$quoi;
231 230
 
232 231
 	return $f($liste, $fmt, $prof);
233 232
 }
Please login to merge, or discard this patch.