Completed
Push — master ( 4fa0dc...b74578 )
by cam
01:19
created
ecrire/inc/roles.php 2 patches
Indentation   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  */
28 28
 
29 29
 if (!defined('_ECRIRE_INC_VERSION')) {
30
-	return;
30
+    return;
31 31
 }
32 32
 
33 33
 
@@ -47,55 +47,55 @@  discard block
 block discarded – undo
47 47
  *     array : description des roles applicables dans 3 index : colonne, titres, roles
48 48
  **/
49 49
 function roles_presents($objet, $objet_destination = '') {
50
-	$desc = lister_tables_objets_sql(table_objet_sql($objet));
51
-
52
-	// pas de liste de roles, on sort
53
-	if (!isset($desc['roles_titres']) || !($titres = $desc['roles_titres'])) {
54
-		return false;
55
-	}
56
-
57
-	// on vérifie que la table de liaison existe
58
-	include_spip('action/editer_liens');
59
-	if (!$lien = objet_associable($objet)) {
60
-		return false;
61
-	}
62
-
63
-	// on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
64
-	$colonne = $desc['roles_colonne'] ?? 'role';
65
-	$trouver_table = charger_fonction('trouver_table', 'base');
66
-	[, $table_lien] = $lien;
67
-	$desc_lien = $trouver_table($table_lien);
68
-	if (!isset($desc_lien['field'][$colonne])) {
69
-		return false;
70
-	}
71
-
72
-	// sur quoi peuvent s'appliquer nos rôles
73
-	if (!$application = $desc['roles_objets']) {
74
-		return false;
75
-	}
76
-
77
-	// destination presente, on restreint si possible
78
-	if ($objet_destination) {
79
-		$objet_destination = table_objet($objet_destination);
80
-
81
-		// pour l'objet
82
-		if (isset($application[$objet_destination])) {
83
-			$application = $application[$objet_destination];
84
-			// sinon pour tous les objets
85
-		} elseif (isset($application['*'])) {
86
-			$application = $application['*'];
87
-		} // sinon tant pis
88
-		else {
89
-			return false;
90
-		}
91
-	}
92
-
93
-	// tout est ok
94
-	return [
95
-		'titres' => $titres,
96
-		'roles' => $application,
97
-		'colonne' => $colonne
98
-	];
50
+    $desc = lister_tables_objets_sql(table_objet_sql($objet));
51
+
52
+    // pas de liste de roles, on sort
53
+    if (!isset($desc['roles_titres']) || !($titres = $desc['roles_titres'])) {
54
+        return false;
55
+    }
56
+
57
+    // on vérifie que la table de liaison existe
58
+    include_spip('action/editer_liens');
59
+    if (!$lien = objet_associable($objet)) {
60
+        return false;
61
+    }
62
+
63
+    // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
64
+    $colonne = $desc['roles_colonne'] ?? 'role';
65
+    $trouver_table = charger_fonction('trouver_table', 'base');
66
+    [, $table_lien] = $lien;
67
+    $desc_lien = $trouver_table($table_lien);
68
+    if (!isset($desc_lien['field'][$colonne])) {
69
+        return false;
70
+    }
71
+
72
+    // sur quoi peuvent s'appliquer nos rôles
73
+    if (!$application = $desc['roles_objets']) {
74
+        return false;
75
+    }
76
+
77
+    // destination presente, on restreint si possible
78
+    if ($objet_destination) {
79
+        $objet_destination = table_objet($objet_destination);
80
+
81
+        // pour l'objet
82
+        if (isset($application[$objet_destination])) {
83
+            $application = $application[$objet_destination];
84
+            // sinon pour tous les objets
85
+        } elseif (isset($application['*'])) {
86
+            $application = $application['*'];
87
+        } // sinon tant pis
88
+        else {
89
+            return false;
90
+        }
91
+    }
92
+
93
+    // tout est ok
94
+    return [
95
+        'titres' => $titres,
96
+        'roles' => $application,
97
+        'colonne' => $colonne
98
+    ];
99 99
 }
100 100
 
101 101
 /**
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
  *     Nom de la colonne, sinon vide
110 110
  **/
111 111
 function roles_colonne($objet, $objet_destination) {
112
-	if ($roles = roles_presents($objet, $objet_destination)) {
113
-		return $roles['colonne'];
114
-	}
112
+    if ($roles = roles_presents($objet, $objet_destination)) {
113
+        return $roles['colonne'];
114
+    }
115 115
 
116
-	return '';
116
+    return '';
117 117
 }
118 118
 
119 119
 
@@ -135,21 +135,21 @@  discard block
 block discarded – undo
135 135
  *     Liste ('', '', array()) sinon.
136 136
  **/
137 137
 function roles_trouver_dans_qualif($objet, $objet_destination, $qualif = []) {
138
-	// si des rôles sont possibles, on les utilise
139
-	$role = $colonne_role = ''; # role défini
140
-	// condition du where par defaut
141
-	$cond = [];
142
-	if ($roles = roles_presents($objet, $objet_destination)) {
143
-		$colonne_role = $roles['colonne'];
144
-		// qu'il n'est pas défini
145
-		if (!isset($qualif[$colonne_role]) || !($role = $qualif[$colonne_role])) {
146
-			$role = $roles['roles']['defaut'];
147
-		}
148
-		// where
149
-		$cond = ["$colonne_role=" . sql_quote($role)];
150
-	}
151
-
152
-	return [$role, $colonne_role, $cond];
138
+    // si des rôles sont possibles, on les utilise
139
+    $role = $colonne_role = ''; # role défini
140
+    // condition du where par defaut
141
+    $cond = [];
142
+    if ($roles = roles_presents($objet, $objet_destination)) {
143
+        $colonne_role = $roles['colonne'];
144
+        // qu'il n'est pas défini
145
+        if (!isset($qualif[$colonne_role]) || !($role = $qualif[$colonne_role])) {
146
+            $role = $roles['roles']['defaut'];
147
+        }
148
+        // where
149
+        $cond = ["$colonne_role=" . sql_quote($role)];
150
+    }
151
+
152
+    return [$role, $colonne_role, $cond];
153 153
 }
154 154
 
155 155
 /**
@@ -171,18 +171,18 @@  discard block
 block discarded – undo
171 171
  *     Liste (Tableau de conditions where complété du role, Colonne du role, role utilisé)
172 172
  **/
173 173
 function roles_creer_condition_role($objet_source, $objet, $cond, $tous_si_absent = false) {
174
-	// role par défaut, colonne
175
-	[$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet);
176
-
177
-	// chercher d'eventuels rôles transmis
178
-	$role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut));
179
-	unset($cond['role']); // cette condition est particuliere...
180
-	// on ajoute la condition du role aux autres conditions.
181
-	if ($colonne_role && $role != '*') {
182
-		$cond[] = "$colonne_role=" . sql_quote($role);
183
-	}
184
-
185
-	return [$cond, $colonne_role, $role];
174
+    // role par défaut, colonne
175
+    [$role_defaut, $colonne_role] = roles_trouver_dans_qualif($objet_source, $objet);
176
+
177
+    // chercher d'eventuels rôles transmis
178
+    $role = ($cond['role'] ?? ($tous_si_absent ? '*' : $role_defaut));
179
+    unset($cond['role']); // cette condition est particuliere...
180
+    // on ajoute la condition du role aux autres conditions.
181
+    if ($colonne_role && $role != '*') {
182
+        $cond[] = "$colonne_role=" . sql_quote($role);
183
+    }
184
+
185
+    return [$cond, $colonne_role, $role];
186 186
 }
187 187
 
188 188
 /**
@@ -204,28 +204,28 @@  discard block
 block discarded – undo
204 204
  */
205 205
 function roles_complets($objet_source, $objet, $id_objet, $objet_lien) {
206 206
 
207
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
208
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
209
-	if ($presents === false) {
210
-		return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
211
-	}
212
-
213
-	// types de roles possibles
214
-	$roles_possibles = $presents['roles']['roles']['choix'];
215
-	// couples id / roles
216
-	$ids = $presents['ids'];
217
-
218
-	// pour chaque groupe, on fait le diff entre tous les roles possibles
219
-	// et les roles attribués à l'élément : s'il en reste, c'est que l'élément
220
-	// n'est pas complet
221
-	$complets = [];
222
-	foreach ($ids as $id => $roles_presents) {
223
-		if (!array_diff($roles_possibles, $roles_presents)) {
224
-			$complets[] = $id;
225
-		}
226
-	}
227
-
228
-	return $complets;
207
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
208
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
209
+    if ($presents === false) {
210
+        return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
211
+    }
212
+
213
+    // types de roles possibles
214
+    $roles_possibles = $presents['roles']['roles']['choix'];
215
+    // couples id / roles
216
+    $ids = $presents['ids'];
217
+
218
+    // pour chaque groupe, on fait le diff entre tous les roles possibles
219
+    // et les roles attribués à l'élément : s'il en reste, c'est que l'élément
220
+    // n'est pas complet
221
+    $complets = [];
222
+    foreach ($ids as $id => $roles_presents) {
223
+        if (!array_diff($roles_possibles, $roles_presents)) {
224
+            $complets[] = $id;
225
+        }
226
+    }
227
+
228
+    return $complets;
229 229
 }
230 230
 
231 231
 
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
  */
243 243
 function roles_presents_sur_id($id_objet_source, $objet_source, $objet, $id_objet, $objet_lien) {
244 244
 
245
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
246
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
247
-	if ($presents === false) {
248
-		return [];
249
-	}
245
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
246
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
247
+    if ($presents === false) {
248
+        return [];
249
+    }
250 250
 
251
-	if (!isset($presents['ids'][$id_objet_source])) {
252
-		return [];
253
-	}
251
+    if (!isset($presents['ids'][$id_objet_source])) {
252
+        return [];
253
+    }
254 254
 
255
-	return $presents['ids'][$id_objet_source];
255
+    return $presents['ids'][$id_objet_source];
256 256
 }
257 257
 
258 258
 
@@ -280,47 +280,47 @@  discard block
 block discarded – undo
280 280
  *     - False si pas de role déclarés
281 281
  */
282 282
 function roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien) {
283
-	static $done = [];
284
-
285
-	// stocker le résultat
286
-	$hash = "$objet_source-$objet-$id_objet-$objet_lien";
287
-	if (isset($done[$hash])) {
288
-		return $done[$hash];
289
-	}
290
-
291
-	// pas de roles sur ces objets, on sort
292
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
293
-	if (!$roles) {
294
-		return $done[$hash] = false;
295
-	}
296
-
297
-	// inspiré de lister_objets_lies()
298
-	if ($objet_lien == $objet) {
299
-		$res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']);
300
-	} else {
301
-		$res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]);
302
-	}
303
-
304
-	// types de roles possibles
305
-	$roles_possibles = $roles['roles']['choix'];
306
-	// colonne du role
307
-	$colonne = $roles['colonne'];
308
-
309
-	// on recupere par id, et role existant
310
-	$ids = [];
311
-	while ($row = array_shift($res)) {
312
-		$id = $row[$objet_source];
313
-		if (!isset($ids[$id])) {
314
-			$ids[$id] = [];
315
-		}
316
-		// tableau des roles présents
317
-		$ids[$id][] = $row[$colonne];
318
-	}
319
-
320
-	return $done[$hash] = [
321
-		'roles' => $roles,
322
-		'ids' => $ids
323
-	];
283
+    static $done = [];
284
+
285
+    // stocker le résultat
286
+    $hash = "$objet_source-$objet-$id_objet-$objet_lien";
287
+    if (isset($done[$hash])) {
288
+        return $done[$hash];
289
+    }
290
+
291
+    // pas de roles sur ces objets, on sort
292
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
293
+    if (!$roles) {
294
+        return $done[$hash] = false;
295
+    }
296
+
297
+    // inspiré de lister_objets_lies()
298
+    if ($objet_lien == $objet) {
299
+        $res = objet_trouver_liens([$objet => $id_objet], [$objet_source => '*']);
300
+    } else {
301
+        $res = objet_trouver_liens([$objet_source => '*'], [$objet => $id_objet]);
302
+    }
303
+
304
+    // types de roles possibles
305
+    $roles_possibles = $roles['roles']['choix'];
306
+    // colonne du role
307
+    $colonne = $roles['colonne'];
308
+
309
+    // on recupere par id, et role existant
310
+    $ids = [];
311
+    while ($row = array_shift($res)) {
312
+        $id = $row[$objet_source];
313
+        if (!isset($ids[$id])) {
314
+            $ids[$id] = [];
315
+        }
316
+        // tableau des roles présents
317
+        $ids[$id][] = $row[$colonne];
318
+    }
319
+
320
+    return $done[$hash] = [
321
+        'roles' => $roles,
322
+        'ids' => $ids
323
+    ];
324 324
 }
325 325
 
326 326
 
@@ -338,33 +338,33 @@  discard block
 block discarded – undo
338 338
  *     - false si pas de role déclarés
339 339
  */
340 340
 function roles_connus_en_base($objet_source, $objet, $objet_lien) {
341
-	static $done = [];
342
-
343
-	// stocker le résultat
344
-	$hash = "$objet_source-$objet-$objet_lien";
345
-	if (isset($done[$hash])) {
346
-		return $done[$hash];
347
-	}
348
-
349
-	if (!$lien = objet_associable($objet_lien)) {
350
-		return $done[$hash] = false;
351
-	}
352
-
353
-	// pas de roles sur ces objets, on sort
354
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
355
-	if (!$roles) {
356
-		return $done[$hash] = false;
357
-	}
358
-
359
-	[$primary, $l] = $lien;
360
-	$colone_role = $roles['colonne'];
361
-
362
-	$all = sql_allfetsel(
363
-		"DISTINCT $colone_role",
364
-		$l,
365
-		'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
366
-	);
367
-	$done[$hash] = array_map('reset', $all);
368
-
369
-	return $done[$hash];
341
+    static $done = [];
342
+
343
+    // stocker le résultat
344
+    $hash = "$objet_source-$objet-$objet_lien";
345
+    if (isset($done[$hash])) {
346
+        return $done[$hash];
347
+    }
348
+
349
+    if (!$lien = objet_associable($objet_lien)) {
350
+        return $done[$hash] = false;
351
+    }
352
+
353
+    // pas de roles sur ces objets, on sort
354
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
355
+    if (!$roles) {
356
+        return $done[$hash] = false;
357
+    }
358
+
359
+    [$primary, $l] = $lien;
360
+    $colone_role = $roles['colonne'];
361
+
362
+    $all = sql_allfetsel(
363
+        "DISTINCT $colone_role",
364
+        $l,
365
+        'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
366
+    );
367
+    $done[$hash] = array_map('reset', $all);
368
+
369
+    return $done[$hash];
370 370
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			$role = $roles['roles']['defaut'];
147 147
 		}
148 148
 		// where
149
-		$cond = ["$colonne_role=" . sql_quote($role)];
149
+		$cond = ["$colonne_role=".sql_quote($role)];
150 150
 	}
151 151
 
152 152
 	return [$role, $colonne_role, $cond];
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	unset($cond['role']); // cette condition est particuliere...
180 180
 	// on ajoute la condition du role aux autres conditions.
181 181
 	if ($colonne_role && $role != '*') {
182
-		$cond[] = "$colonne_role=" . sql_quote($role);
182
+		$cond[] = "$colonne_role=".sql_quote($role);
183 183
 	}
184 184
 
185 185
 	return [$cond, $colonne_role, $role];
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	$all = sql_allfetsel(
363 363
 		"DISTINCT $colone_role",
364 364
 		$l,
365
-		'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
365
+		'objet='.sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
366 366
 	);
367 367
 	$done[$hash] = array_map('reset', $all);
368 368
 
Please login to merge, or discard this patch.
ecrire/inc/filtres_mime.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  **/
22 22
 
23 23
 if (!defined('_ECRIRE_INC_VERSION')) {
24
-	return;
24
+    return;
25 25
 }
26 26
 include_spip('inc/filtres');
27 27
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  * @return string Rien.
39 39
  **/
40 40
 function filtre_image_dist($t) {
41
-	return '';
41
+    return '';
42 42
 }
43 43
 
44 44
 /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
  * @return string Rien.
52 52
  **/
53 53
 function filtre_audio_dist($t) {
54
-	return '';
54
+    return '';
55 55
 }
56 56
 
57 57
 /**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
  * @return string Rien.
65 65
  **/
66 66
 function filtre_video_dist($t) {
67
-	return '';
67
+    return '';
68 68
 }
69 69
 
70 70
 /**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
  * @return string Rien.
78 78
  **/
79 79
 function filtre_application_dist($t) {
80
-	return '';
80
+    return '';
81 81
 }
82 82
 
83 83
 /**
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
  * @return string Rien.
91 91
  **/
92 92
 function filtre_message_dist($t) {
93
-	return '';
93
+    return '';
94 94
 }
95 95
 
96 96
 /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
  * @return string Rien.
104 104
  **/
105 105
 function filtre_multipart_dist($t) {
106
-	return '';
106
+    return '';
107 107
 }
108 108
 
109 109
 /**
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
  * @return string Contenu échappé.
117 117
  **/
118 118
 function filtre_text_dist($t) {
119
-	static $t1 = ['&', '<', '>'];
120
-	static $t2 = ['&amp;', '&lt;', '&gt;'];
119
+    static $t1 = ['&', '<', '>'];
120
+    static $t2 = ['&amp;', '&lt;', '&gt;'];
121 121
 
122
-	return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>';
122
+    return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>';
123 123
 }
124 124
 
125 125
 /**
@@ -134,21 +134,21 @@  discard block
 block discarded – undo
134 134
  *     Tableau (formaté en SPIP)
135 135
  **/
136 136
 function filtre_text_csv_dist($t) {
137
-	include_spip('inc/csv');
138
-	[$entete, $lignes, $caption] = analyse_csv($t);
139
-	foreach ($lignes as &$l) {
140
-		$l = implode('|', $l);
141
-	}
142
-	$corps = implode("\n", $lignes) . "\n";
143
-	$corps = $caption .
144
-		"\n|{{" .
145
-		implode('}}|{{', $entete) .
146
-		'}}|' .
147
-		"\n|" .
148
-		str_replace("\n", "|\n|", $corps);
149
-	include_spip('inc/texte');
150
-
151
-	return propre($corps);
137
+    include_spip('inc/csv');
138
+    [$entete, $lignes, $caption] = analyse_csv($t);
139
+    foreach ($lignes as &$l) {
140
+        $l = implode('|', $l);
141
+    }
142
+    $corps = implode("\n", $lignes) . "\n";
143
+    $corps = $caption .
144
+        "\n|{{" .
145
+        implode('}}|{{', $entete) .
146
+        '}}|' .
147
+        "\n|" .
148
+        str_replace("\n", "|\n|", $corps);
149
+    include_spip('inc/texte');
150
+
151
+    return propre($corps);
152 152
 }
153 153
 
154 154
 /**
@@ -162,33 +162,33 @@  discard block
 block discarded – undo
162 162
  * @return string Code html sécurisé ou texte échappé
163 163
  **/
164 164
 function filtre_text_html_dist($t) {
165
-	if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) {
166
-		return appliquer_filtre($t, 'text/plain');
167
-	}
168
-
169
-	[, $h, $t] = $r;
170
-
171
-	$style = '';
172
-	// recuperer les styles internes
173
-	if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) {
174
-		$style = implode("\n", $r[1]);
175
-	}
176
-	// ... et externes
177
-
178
-	include_spip('inc/distant');
179
-	if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) {
180
-		foreach ($r[0] as $l) {
181
-			preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m);
182
-			$page = recuperer_url($m[1]);
183
-			$page = $page['page'] ?? '';
184
-			$style .= "\n/* $l */\n"
185
-				. str_replace('<', '', $page);
186
-		}
187
-	}
188
-	// Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ?
189
-	$t = safehtml(preg_replace(',<script.*?</script>,is', '', $t));
190
-
191
-	return ($style ? "\n<style>" . $style . '</style>' : '') . $t;
165
+    if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) {
166
+        return appliquer_filtre($t, 'text/plain');
167
+    }
168
+
169
+    [, $h, $t] = $r;
170
+
171
+    $style = '';
172
+    // recuperer les styles internes
173
+    if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) {
174
+        $style = implode("\n", $r[1]);
175
+    }
176
+    // ... et externes
177
+
178
+    include_spip('inc/distant');
179
+    if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) {
180
+        foreach ($r[0] as $l) {
181
+            preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m);
182
+            $page = recuperer_url($m[1]);
183
+            $page = $page['page'] ?? '';
184
+            $style .= "\n/* $l */\n"
185
+                . str_replace('<', '', $page);
186
+        }
187
+    }
188
+    // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ?
189
+    $t = safehtml(preg_replace(',<script.*?</script>,is', '', $t));
190
+
191
+    return ($style ? "\n<style>" . $style . '</style>' : '') . $t;
192 192
 }
193 193
 
194 194
 /**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  * @return string Code HTML des balises `<param>`
202 202
  **/
203 203
 function filtre_audio_x_pn_realaudio($id) {
204
-	return "
204
+    return "
205 205
 	<param name='controls' value='PositionSlider' />
206 206
 	<param name='controls' value='ImageWindow' />
207 207
 	<param name='controls' value='PlayButton' />
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	static $t1 = ['&', '<', '>'];
120 120
 	static $t2 = ['&amp;', '&lt;', '&gt;'];
121 121
 
122
-	return '<pre>' . str_replace($t1, $t2, (string) $t) . '</pre>';
122
+	return '<pre>'.str_replace($t1, $t2, (string) $t).'</pre>';
123 123
 }
124 124
 
125 125
 /**
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 	foreach ($lignes as &$l) {
140 140
 		$l = implode('|', $l);
141 141
 	}
142
-	$corps = implode("\n", $lignes) . "\n";
143
-	$corps = $caption .
144
-		"\n|{{" .
145
-		implode('}}|{{', $entete) .
146
-		'}}|' .
147
-		"\n|" .
142
+	$corps = implode("\n", $lignes)."\n";
143
+	$corps = $caption.
144
+		"\n|{{".
145
+		implode('}}|{{', $entete).
146
+		'}}|'.
147
+		"\n|".
148 148
 		str_replace("\n", "|\n|", $corps);
149 149
 	include_spip('inc/texte');
150 150
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	// Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ?
189 189
 	$t = safehtml(preg_replace(',<script.*?</script>,is', '', $t));
190 190
 
191
-	return ($style ? "\n<style>" . $style . '</style>' : '') . $t;
191
+	return ($style ? "\n<style>".$style.'</style>' : '').$t;
192 192
 }
193 193
 
194 194
 /**
Please login to merge, or discard this patch.
ecrire/inc/texte_mini.php 3 patches
Indentation   +517 added lines, -517 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 include_spip('inc/filtres');
22 22
 include_spip('inc/lang');
@@ -38,21 +38,21 @@  discard block
 block discarded – undo
38 38
  **/
39 39
 function definir_puce() {
40 40
 
41
-	// Attention au sens, qui n'est pas defini de la meme facon dans
42
-	// l'espace prive (spip_lang est la langue de l'interface, lang_dir
43
-	// celle du texte) et public (spip_lang est la langue du texte)
44
-	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
41
+    // Attention au sens, qui n'est pas defini de la meme facon dans
42
+    // l'espace prive (spip_lang est la langue de l'interface, lang_dir
43
+    // celle du texte) et public (spip_lang est la langue du texte)
44
+    $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
45 45
 
46
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
47
-	if ($dir == 'rtl') {
48
-		$p .= '_rtl';
49
-	}
46
+    $p = 'puce' . (test_espace_prive() ? '_prive' : '');
47
+    if ($dir == 'rtl') {
48
+        $p .= '_rtl';
49
+    }
50 50
 
51
-	if (!isset($GLOBALS[$p])) {
52
-		$GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
53
-	}
51
+    if (!isset($GLOBALS[$p])) {
52
+        $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
53
+    }
54 54
 
55
-	return $GLOBALS[$p];
55
+    return $GLOBALS[$p];
56 56
 }
57 57
 
58 58
 /**
@@ -66,31 +66,31 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function spip_balisage_code(string $corps, bool $bloc = false, string $attributs = '', string $langage = '') {
68 68
 
69
-	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
70
-	$class = 'spip_code ' . ($bloc ? 'spip_code_block' : 'spip_code_inline');
71
-	if ($attributs) {
72
-		$attributs = ' ' . trim($attributs);
73
-	}
74
-	if ($langage) {
75
-		$class .= " language-$langage";
76
-		$attributs .= ' data-language="' . $langage . '"';
77
-	}
78
-	if ($bloc) {
79
-		$html = '<div class="precode">'
80
-		  . "<pre class=\"$class\" dir=\"ltr\" style=\"text-align: left;\"$attributs>"
81
-		  . '<code>'
82
-		  . $echap
83
-		  . '</code>'
84
-		  . '</pre>'
85
-		  . '</div>';
86
-	}
87
-	else {
88
-		$echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
89
-		$echap = str_replace('  ', ' &nbsp;', $echap);
90
-		$html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>';
91
-	}
92
-
93
-	return $html;
69
+    $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
70
+    $class = 'spip_code ' . ($bloc ? 'spip_code_block' : 'spip_code_inline');
71
+    if ($attributs) {
72
+        $attributs = ' ' . trim($attributs);
73
+    }
74
+    if ($langage) {
75
+        $class .= " language-$langage";
76
+        $attributs .= ' data-language="' . $langage . '"';
77
+    }
78
+    if ($bloc) {
79
+        $html = '<div class="precode">'
80
+            . "<pre class=\"$class\" dir=\"ltr\" style=\"text-align: left;\"$attributs>"
81
+            . '<code>'
82
+            . $echap
83
+            . '</code>'
84
+            . '</pre>'
85
+            . '</div>';
86
+    }
87
+    else {
88
+        $echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
89
+        $echap = str_replace('  ', ' &nbsp;', $echap);
90
+        $html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>';
91
+    }
92
+
93
+    return $html;
94 94
 }
95 95
 
96 96
 
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 // dont on souhaite qu'ils provoquent un saut de paragraphe
99 99
 
100 100
 if (!defined('_BALISES_BLOCS')) {
101
-	define(
102
-		'_BALISES_BLOCS',
103
-		'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
104
-	);
101
+    define(
102
+        '_BALISES_BLOCS',
103
+        'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
104
+    );
105 105
 }
106 106
 
107 107
 if (!defined('_BALISES_BLOCS_REGEXP')) {
108
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
108
+    define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
109 109
 }
110 110
 
111 111
 //
@@ -116,100 +116,100 @@  discard block
 block discarded – undo
116 116
 // une $source differente ; le script detecte automagiquement si ce qu'on
117 117
 // echappe est un div ou un span
118 118
 function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) {
119
-	if (!strlen($rempl)) {
120
-		return '';
121
-	}
122
-
123
-	// Tester si on echappe en span ou en div
124
-	if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
125
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
126
-	}
127
-
128
-	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
129
-	$taille = 30000;
130
-	$return = '';
131
-	for ($i = 0; $i < strlen($rempl); $i += $taille) {
132
-		// Convertir en base64 et cacher dans un attribut
133
-		// utiliser les " pour eviter le re-encodage de ' et &#8217
134
-		$base64 = base64_encode(substr($rempl, $i, $taille));
135
-		$return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
136
-	}
137
-
138
-	return $return;
119
+    if (!strlen($rempl)) {
120
+        return '';
121
+    }
122
+
123
+    // Tester si on echappe en span ou en div
124
+    if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
125
+        $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
126
+    }
127
+
128
+    // Decouper en morceaux, base64 a des probleme selon la taille de la pile
129
+    $taille = 30000;
130
+    $return = '';
131
+    for ($i = 0; $i < strlen($rempl); $i += $taille) {
132
+        // Convertir en base64 et cacher dans un attribut
133
+        // utiliser les " pour eviter le re-encodage de ' et &#8217
134
+        $base64 = base64_encode(substr($rempl, $i, $taille));
135
+        $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
136
+    }
137
+
138
+    return $return;
139 139
 }
140 140
 
141 141
 
142 142
 // Echapper les <html>...</ html>
143 143
 function traiter_echap_html_dist($regs, $options = []) {
144
-	return $regs[3];
144
+    return $regs[3];
145 145
 }
146 146
 
147 147
 // Echapper les <pre>...</ pre>
148 148
 function traiter_echap_pre_dist($regs, $options = []) {
149
-	// echapper les <code> dans <pre>
150
-	$pre = $regs[3];
151
-
152
-	// echapper les < dans <code>
153
-	// on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
154
-	if (
155
-		strpos($pre, '<') !== false
156
-		and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)
157
-	) {
158
-		foreach ($matches as $m) {
159
-			if ($m[1] === 'code') {
160
-				$code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
161
-				$pre = str_replace($m[0], $code, $pre);
162
-			}
163
-		}
164
-	}
165
-	return "<pre>$pre</pre>";
149
+    // echapper les <code> dans <pre>
150
+    $pre = $regs[3];
151
+
152
+    // echapper les < dans <code>
153
+    // on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
154
+    if (
155
+        strpos($pre, '<') !== false
156
+        and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)
157
+    ) {
158
+        foreach ($matches as $m) {
159
+            if ($m[1] === 'code') {
160
+                $code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
161
+                $pre = str_replace($m[0], $code, $pre);
162
+            }
163
+        }
164
+    }
165
+    return "<pre>$pre</pre>";
166 166
 }
167 167
 
168 168
 // Echapper les <code>...</ code>
169 169
 function traiter_echap_code_dist($regs, $options = []) {
170
-	[, , $att, $corps] = $regs;
170
+    [, , $att, $corps] = $regs;
171 171
 
172
-	// ne pas mettre le <div...> s'il n'y a qu'une ligne
173
-	if (strpos($corps, "\n") !== false) {
174
-		// supprimer les sauts de ligne debut/fin
175
-		// (mais pas les espaces => ascii art).
176
-		$corps = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $corps);
172
+    // ne pas mettre le <div...> s'il n'y a qu'une ligne
173
+    if (strpos($corps, "\n") !== false) {
174
+        // supprimer les sauts de ligne debut/fin
175
+        // (mais pas les espaces => ascii art).
176
+        $corps = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $corps);
177 177
 
178
-		$echap = spip_balisage_code($corps, true, $att);
179
-	} else {
180
-		$echap = spip_balisage_code($corps, false, $att);
181
-	}
178
+        $echap = spip_balisage_code($corps, true, $att);
179
+    } else {
180
+        $echap = spip_balisage_code($corps, false, $att);
181
+    }
182 182
 
183
-	return $echap;
183
+    return $echap;
184 184
 }
185 185
 
186 186
 // Echapper les <cadre>...</ cadre> aka <frame>...</ frame>
187 187
 function traiter_echap_cadre_dist($regs, $options = []) {
188
-	$echap = trim(entites_html($regs[3]));
189
-	// compter les lignes un peu plus finement qu'avec les \n
190
-	$lignes = explode("\n", trim($echap));
191
-	$n = 0;
192
-	foreach ($lignes as $l) {
193
-		$n += floor(strlen($l) / 60) + 1;
194
-	}
195
-	$n = max($n, 2);
196
-	$echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre spip_cadre_block' dir='ltr'>$echap</textarea>";
197
-
198
-	return $echap;
188
+    $echap = trim(entites_html($regs[3]));
189
+    // compter les lignes un peu plus finement qu'avec les \n
190
+    $lignes = explode("\n", trim($echap));
191
+    $n = 0;
192
+    foreach ($lignes as $l) {
193
+        $n += floor(strlen($l) / 60) + 1;
194
+    }
195
+    $n = max($n, 2);
196
+    $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre spip_cadre_block' dir='ltr'>$echap</textarea>";
197
+
198
+    return $echap;
199 199
 }
200 200
 
201 201
 function traiter_echap_frame_dist($regs, $options = []) {
202
-	return traiter_echap_cadre_dist($regs);
202
+    return traiter_echap_cadre_dist($regs);
203 203
 }
204 204
 
205 205
 function traiter_echap_script_dist($regs, $options = []) {
206
-	// rendre joli (et inactif) si c'est un script language=php
207
-	if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
208
-		return highlight_string($regs[0], true);
209
-	}
206
+    // rendre joli (et inactif) si c'est un script language=php
207
+    if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
208
+        return highlight_string($regs[0], true);
209
+    }
210 210
 
211
-	// Cas normal : le script passe tel quel
212
-	return $regs[0];
211
+    // Cas normal : le script passe tel quel
212
+    return $regs[0];
213 213
 }
214 214
 
215 215
 define('_PROTEGE_BLOCS', ',<(html|pre|code|cadre|frame|script|style)(\b[^>]*)?>(.*)</\1>,UimsS');
@@ -228,74 +228,74 @@  discard block
 block discarded – undo
228 228
  * @return string|string[]
229 229
  */
230 230
 function echappe_html(
231
-	$letexte,
232
-	$source = '',
233
-	$no_transform = false,
234
-	$preg = '',
235
-	$callback_prefix = '',
236
-	$callback_options = []
231
+    $letexte,
232
+    $source = '',
233
+    $no_transform = false,
234
+    $preg = '',
235
+    $callback_prefix = '',
236
+    $callback_options = []
237 237
 ) {
238
-	if (!is_string($letexte) or !strlen($letexte)) {
239
-		return $letexte;
240
-	}
241
-
242
-	if (
243
-		($preg or str_contains($letexte, '<'))
244
-		and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
245
-	) {
246
-		foreach ($matches as $regs) {
247
-			$echap = '';
248
-			// echappements tels quels ?
249
-			if ($no_transform) {
250
-				$echap = $regs[0];
251
-			} else {
252
-				// sinon les traiter selon le cas
253
-				$callback_secure_prefix = ($callback_options['secure_prefix'] ?? '');
254
-				if (
255
-					function_exists($f = $callback_prefix . $callback_secure_prefix . 'traiter_echap_' . strtolower($regs[1]))
256
-					or function_exists($f = $f . '_dist')
257
-					or ($callback_secure_prefix and (
258
-						function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
259
-						or function_exists($f = $f . '_dist')
260
-					))
261
-				) {
262
-					$echap = $f($regs, $callback_options);
263
-				}
264
-			}
265
-
266
-			$p = strpos($letexte, (string) $regs[0]);
267
-			$letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
268
-		}
269
-	}
270
-
271
-	if ($no_transform) {
272
-		return $letexte;
273
-	}
274
-
275
-	// Echapper le php pour faire joli (ici, c'est pas pour la securite)
276
-	// seulement si on a echappe les <script>
277
-	// (derogatoire car on ne peut pas faire passer < ? ... ? >
278
-	// dans une callback autonommee
279
-	if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
280
-		if (
281
-			strpos($letexte, '<' . '?') !== false and preg_match_all(
282
-				',<[?].*($|[?]>),UisS',
283
-				$letexte,
284
-				$matches,
285
-				PREG_SET_ORDER
286
-			)
287
-		) {
288
-			foreach ($matches as $regs) {
289
-				$letexte = str_replace(
290
-					$regs[0],
291
-					code_echappement(highlight_string($regs[0], true), $source),
292
-					$letexte
293
-				);
294
-			}
295
-		}
296
-	}
297
-
298
-	return $letexte;
238
+    if (!is_string($letexte) or !strlen($letexte)) {
239
+        return $letexte;
240
+    }
241
+
242
+    if (
243
+        ($preg or str_contains($letexte, '<'))
244
+        and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
245
+    ) {
246
+        foreach ($matches as $regs) {
247
+            $echap = '';
248
+            // echappements tels quels ?
249
+            if ($no_transform) {
250
+                $echap = $regs[0];
251
+            } else {
252
+                // sinon les traiter selon le cas
253
+                $callback_secure_prefix = ($callback_options['secure_prefix'] ?? '');
254
+                if (
255
+                    function_exists($f = $callback_prefix . $callback_secure_prefix . 'traiter_echap_' . strtolower($regs[1]))
256
+                    or function_exists($f = $f . '_dist')
257
+                    or ($callback_secure_prefix and (
258
+                        function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
259
+                        or function_exists($f = $f . '_dist')
260
+                    ))
261
+                ) {
262
+                    $echap = $f($regs, $callback_options);
263
+                }
264
+            }
265
+
266
+            $p = strpos($letexte, (string) $regs[0]);
267
+            $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
268
+        }
269
+    }
270
+
271
+    if ($no_transform) {
272
+        return $letexte;
273
+    }
274
+
275
+    // Echapper le php pour faire joli (ici, c'est pas pour la securite)
276
+    // seulement si on a echappe les <script>
277
+    // (derogatoire car on ne peut pas faire passer < ? ... ? >
278
+    // dans une callback autonommee
279
+    if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
280
+        if (
281
+            strpos($letexte, '<' . '?') !== false and preg_match_all(
282
+                ',<[?].*($|[?]>),UisS',
283
+                $letexte,
284
+                $matches,
285
+                PREG_SET_ORDER
286
+            )
287
+        ) {
288
+            foreach ($matches as $regs) {
289
+                $letexte = str_replace(
290
+                    $regs[0],
291
+                    code_echappement(highlight_string($regs[0], true), $source),
292
+                    $letexte
293
+                );
294
+            }
295
+        }
296
+    }
297
+
298
+    return $letexte;
299 299
 }
300 300
 
301 301
 //
@@ -303,57 +303,57 @@  discard block
 block discarded – undo
303 303
 // Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes
304 304
 // par propre() : exemple dans multi et dans typo()
305 305
 function echappe_retour($letexte, $source = '', $filtre = '') {
306
-	if (strpos($letexte, (string) "base64$source")) {
307
-		# spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
308
-		$max_prof = 5;
309
-		while (
310
-			strpos($letexte, '<') !== false
311
-			and
312
-			preg_match_all(
313
-				',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
314
-				$letexte,
315
-				$regs,
316
-				PREG_SET_ORDER
317
-			)
318
-			and $max_prof--
319
-		) {
320
-			foreach ($regs as $reg) {
321
-				$rempl = base64_decode(extraire_attribut($reg[0], 'title'));
322
-				// recherche d'attributs supplementaires
323
-				$at = [];
324
-				foreach (['lang', 'dir'] as $attr) {
325
-					if ($a = extraire_attribut($reg[0], $attr)) {
326
-						$at[$attr] = $a;
327
-					}
328
-				}
329
-				if ($at) {
330
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
331
-					foreach ($at as $attr => $a) {
332
-						$rempl = inserer_attribut($rempl, $attr, $a);
333
-					}
334
-				}
335
-				if ($filtre) {
336
-					$rempl = $filtre($rempl);
337
-				}
338
-				$letexte = str_replace($reg[0], $rempl, $letexte);
339
-			}
340
-		}
341
-	}
342
-
343
-	return $letexte;
306
+    if (strpos($letexte, (string) "base64$source")) {
307
+        # spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
308
+        $max_prof = 5;
309
+        while (
310
+            strpos($letexte, '<') !== false
311
+            and
312
+            preg_match_all(
313
+                ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
314
+                $letexte,
315
+                $regs,
316
+                PREG_SET_ORDER
317
+            )
318
+            and $max_prof--
319
+        ) {
320
+            foreach ($regs as $reg) {
321
+                $rempl = base64_decode(extraire_attribut($reg[0], 'title'));
322
+                // recherche d'attributs supplementaires
323
+                $at = [];
324
+                foreach (['lang', 'dir'] as $attr) {
325
+                    if ($a = extraire_attribut($reg[0], $attr)) {
326
+                        $at[$attr] = $a;
327
+                    }
328
+                }
329
+                if ($at) {
330
+                    $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
331
+                    foreach ($at as $attr => $a) {
332
+                        $rempl = inserer_attribut($rempl, $attr, $a);
333
+                    }
334
+                }
335
+                if ($filtre) {
336
+                    $rempl = $filtre($rempl);
337
+                }
338
+                $letexte = str_replace($reg[0], $rempl, $letexte);
339
+            }
340
+        }
341
+    }
342
+
343
+    return $letexte;
344 344
 }
345 345
 
346 346
 // Reinserer le javascript de confiance (venant des modeles)
347 347
 
348 348
 function echappe_retour_modeles($letexte, $interdire_scripts = false) {
349
-	$letexte = echappe_retour($letexte);
349
+    $letexte = echappe_retour($letexte);
350 350
 
351
-	// Dans les appels directs hors squelette, securiser aussi ici
352
-	if ($interdire_scripts) {
353
-		$letexte = interdire_scripts($letexte);
354
-	}
351
+    // Dans les appels directs hors squelette, securiser aussi ici
352
+    if ($interdire_scripts) {
353
+        $letexte = interdire_scripts($letexte);
354
+    }
355 355
 
356
-	return trim($letexte);
356
+    return trim($letexte);
357 357
 }
358 358
 
359 359
 
@@ -381,128 +381,128 @@  discard block
 block discarded – undo
381 381
  *     texte coupé
382 382
  **/
383 383
 function couper($texte, $taille = 50, $suite = null) {
384
-	if (!($length = strlen($texte)) or $taille <= 0) {
385
-		return '';
386
-	}
387
-	$offset = 400 + 2 * $taille;
388
-	while (
389
-		$offset < $length
390
-		and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
391
-	) {
392
-		$offset = 2 * $offset;
393
-	}
394
-	if (
395
-		$offset < $length
396
-		&& ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
397
-	) {
398
-		$p_tag_fermant = strpos($texte, '>', $offset);
399
-		if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
400
-			$offset = $p_tag_fermant + 1;
401
-		} // prolonger la coupe jusqu'au tag fermant suivant eventuel
402
-	}
403
-	$texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
404
-
405
-	if (!function_exists('nettoyer_raccourcis_typo')) {
406
-		include_spip('inc/lien');
407
-	}
408
-	$texte = nettoyer_raccourcis_typo($texte);
409
-
410
-	// balises de sauts de ligne et paragraphe
411
-	$texte = preg_replace('/<p( [^>]*)?' . '>/', "\r\r", $texte);
412
-	$texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
413
-
414
-	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
415
-	$texte = str_replace("\n\n", "\r\r", $texte);
416
-
417
-	// supprimer les tags
418
-	$texte = supprimer_tags($texte);
419
-	$texte = trim(str_replace("\n", ' ', $texte));
420
-
421
-	// tester s'il est nécessaire de couper le texte
422
-	if (spip_strlen($texte) <= $taille) {
423
-		$points = '';
424
-	} else {
425
-		// points de suite
426
-		if (is_null($suite)) {
427
-			$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
428
-		}
429
-		$taille_suite = spip_strlen(filtrer_entites($suite));
430
-
431
-		// couper au mot precedent (ou au début de la chaîne si c'est le premier mot)
432
-		// on coupe avec un caractère de plus que la taille demandée afin de pouvoir
433
-		// détecter si le dernier mot du texte coupé est complet ou non. ce caractère
434
-		// excédentaire est ensuite supprimé par l'appel à preg_replace()
435
-		$long = spip_substr($texte, 0, max($taille + 1 - $taille_suite, 1));
436
-		$u = $GLOBALS['meta']['pcre_u'];
437
-		$court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long);
438
-		$points = $suite;
439
-
440
-		// trop court ? ne pas faire de (...)
441
-		if (spip_strlen($court) < max(0.75 * $taille, 2)) {
442
-			$points = '';
443
-			$long = spip_substr($texte, 0, $taille + 1);
444
-			preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, $long, $m);
445
-			$texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long);
446
-			// encore trop court ? couper au caractere
447
-			if (spip_strlen($texte) < 0.75 * $taille) {
448
-				$texte = spip_substr($long, 0, $taille);
449
-			}
450
-		} else {
451
-			$texte = $court;
452
-		}
453
-	}
454
-
455
-	// remettre les paragraphes
456
-	$texte = preg_replace("/\r\r+/", "\n\n", $texte);
457
-
458
-	// supprimer l'eventuelle entite finale mal coupee
459
-	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
460
-
461
-	return quote_amp(trim($texte)) . $points;
384
+    if (!($length = strlen($texte)) or $taille <= 0) {
385
+        return '';
386
+    }
387
+    $offset = 400 + 2 * $taille;
388
+    while (
389
+        $offset < $length
390
+        and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
391
+    ) {
392
+        $offset = 2 * $offset;
393
+    }
394
+    if (
395
+        $offset < $length
396
+        && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
397
+    ) {
398
+        $p_tag_fermant = strpos($texte, '>', $offset);
399
+        if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
400
+            $offset = $p_tag_fermant + 1;
401
+        } // prolonger la coupe jusqu'au tag fermant suivant eventuel
402
+    }
403
+    $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
404
+
405
+    if (!function_exists('nettoyer_raccourcis_typo')) {
406
+        include_spip('inc/lien');
407
+    }
408
+    $texte = nettoyer_raccourcis_typo($texte);
409
+
410
+    // balises de sauts de ligne et paragraphe
411
+    $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r\r", $texte);
412
+    $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
413
+
414
+    // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
415
+    $texte = str_replace("\n\n", "\r\r", $texte);
416
+
417
+    // supprimer les tags
418
+    $texte = supprimer_tags($texte);
419
+    $texte = trim(str_replace("\n", ' ', $texte));
420
+
421
+    // tester s'il est nécessaire de couper le texte
422
+    if (spip_strlen($texte) <= $taille) {
423
+        $points = '';
424
+    } else {
425
+        // points de suite
426
+        if (is_null($suite)) {
427
+            $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
428
+        }
429
+        $taille_suite = spip_strlen(filtrer_entites($suite));
430
+
431
+        // couper au mot precedent (ou au début de la chaîne si c'est le premier mot)
432
+        // on coupe avec un caractère de plus que la taille demandée afin de pouvoir
433
+        // détecter si le dernier mot du texte coupé est complet ou non. ce caractère
434
+        // excédentaire est ensuite supprimé par l'appel à preg_replace()
435
+        $long = spip_substr($texte, 0, max($taille + 1 - $taille_suite, 1));
436
+        $u = $GLOBALS['meta']['pcre_u'];
437
+        $court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long);
438
+        $points = $suite;
439
+
440
+        // trop court ? ne pas faire de (...)
441
+        if (spip_strlen($court) < max(0.75 * $taille, 2)) {
442
+            $points = '';
443
+            $long = spip_substr($texte, 0, $taille + 1);
444
+            preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, $long, $m);
445
+            $texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long);
446
+            // encore trop court ? couper au caractere
447
+            if (spip_strlen($texte) < 0.75 * $taille) {
448
+                $texte = spip_substr($long, 0, $taille);
449
+            }
450
+        } else {
451
+            $texte = $court;
452
+        }
453
+    }
454
+
455
+    // remettre les paragraphes
456
+    $texte = preg_replace("/\r\r+/", "\n\n", $texte);
457
+
458
+    // supprimer l'eventuelle entite finale mal coupee
459
+    $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
460
+
461
+    return quote_amp(trim($texte)) . $points;
462 462
 }
463 463
 
464 464
 
465 465
 function protege_js_modeles($t) {
466
-	if (isset($GLOBALS['visiteur_session'])) {
467
-		if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
468
-			if (!defined('_PROTEGE_JS_MODELES')) {
469
-				include_spip('inc/acces');
470
-				define('_PROTEGE_JS_MODELES', creer_uniqid());
471
-			}
472
-			foreach ($r as $regs) {
473
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
474
-			}
475
-		}
476
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
477
-			if (!defined('_PROTEGE_PHP_MODELES')) {
478
-				include_spip('inc/acces');
479
-				define('_PROTEGE_PHP_MODELES', creer_uniqid());
480
-			}
481
-			foreach ($r as $regs) {
482
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
483
-			}
484
-		}
485
-	}
486
-
487
-	return $t;
466
+    if (isset($GLOBALS['visiteur_session'])) {
467
+        if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
468
+            if (!defined('_PROTEGE_JS_MODELES')) {
469
+                include_spip('inc/acces');
470
+                define('_PROTEGE_JS_MODELES', creer_uniqid());
471
+            }
472
+            foreach ($r as $regs) {
473
+                $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
474
+            }
475
+        }
476
+        if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
477
+            if (!defined('_PROTEGE_PHP_MODELES')) {
478
+                include_spip('inc/acces');
479
+                define('_PROTEGE_PHP_MODELES', creer_uniqid());
480
+            }
481
+            foreach ($r as $regs) {
482
+                $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
483
+            }
484
+        }
485
+    }
486
+
487
+    return $t;
488 488
 }
489 489
 
490 490
 
491 491
 function echapper_faux_tags($letexte) {
492
-	if (strpos($letexte, '<') === false) {
493
-		return $letexte;
494
-	}
495
-	$textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
496
-
497
-	$letexte = '';
498
-	while (is_countable($textMatches) ? count($textMatches) : 0) {
499
-		// un texte a echapper
500
-		$letexte .= str_replace('<', '&lt;', array_shift($textMatches));
501
-		// un tag html qui a servit a faite le split
502
-		$letexte .= array_shift($textMatches);
503
-	}
504
-
505
-	return $letexte;
492
+    if (strpos($letexte, '<') === false) {
493
+        return $letexte;
494
+    }
495
+    $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
496
+
497
+    $letexte = '';
498
+    while (is_countable($textMatches) ? count($textMatches) : 0) {
499
+        // un texte a echapper
500
+        $letexte .= str_replace('<', '&lt;', array_shift($textMatches));
501
+        // un tag html qui a servit a faite le split
502
+        $letexte .= array_shift($textMatches);
503
+    }
504
+
505
+    return $letexte;
506 506
 }
507 507
 
508 508
 /**
@@ -522,114 +522,114 @@  discard block
 block discarded – undo
522 522
  * @return string
523 523
  */
524 524
 function echapper_html_suspect($texte, $options = [], $connect = null, $env = []) {
525
-	static $echapper_html_suspect;
526
-	if (!$texte or !is_string($texte)) {
527
-		return $texte;
528
-	}
529
-
530
-	if (!isset($echapper_html_suspect)) {
531
-		$echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
532
-	}
533
-	// si fonction personalisee, on delegue
534
-	if ($echapper_html_suspect) {
535
-		// on collecte le tableau d'arg minimal pour ne pas casser un appel a une fonction inc_echapper_html_suspect() selon l'ancienne signature
536
-		$args = [$texte, $options];
537
-		if ($connect or !empty($env)) {
538
-			$args[] = $connect;
539
-		}
540
-		if (!empty($env)) {
541
-			$args[] = $env;
542
-		}
543
-		return $echapper_html_suspect(...$args);
544
-	}
545
-
546
-	if (is_bool($options)) {
547
-		$options = ['strict' => $options];
548
-	}
549
-	$strict = $options['strict'] ?? true;
550
-
551
-	// pas de balise html ou pas d'attribut sur les balises ? c'est OK
552
-	if (
553
-		strpos($texte, '<') === false
554
-		or !str_contains($texte, '=')
555
-	) {
556
-		return $texte;
557
-	}
558
-
559
-	// dans le prive, on veut afficher tout echappé pour la moderation
560
-	if (!isset($env['espace_prive'])) {
561
-		// conserver le comportement historique en cas d'appel court sans env
562
-		$env['espace_prive'] = test_espace_prive();
563
-	}
564
-	if (!empty($env['espace_prive']) or !empty($env['wysiwyg'])) {
565
-		// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
566
-		// car sinon on declenche sur les modeles ou ressources
567
-		if (
568
-			!$strict and
569
-			(strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
570
-		) {
571
-			return $texte;
572
-		}
573
-
574
-		include_spip('src/Texte/Collecteur/AbstractCollecteur');
575
-		include_spip('src/Texte/Collecteur/Modeles');
576
-		$collecteurModeles = new Spip\Texte\Collecteur\Modeles();
577
-		$texte = $collecteurModeles->echapper($texte);
578
-		$texte = echappe_js($texte);
579
-
580
-		$texte_to_check = $texte;
581
-		// si les raccourcis liens vont etre interprétés, il faut les expanser avant de vérifier que le html est safe
582
-		// car un raccourci peut etre utilisé pour faire un lien malin
583
-		// et un raccourci est potentiellement modifié par safehtml, ce qui fait un faux positif dans is_html_safe
584
-		if (!empty($options['expanser_liens'])) {
585
-			$texte_to_check = expanser_liens($texte_to_check, $env['connect'] ?? '', $env['env'] ?? []);
586
-		}
587
-		if (!is_html_safe($texte_to_check)) {
588
-			$texte = $options['texte_source_affiche'] ?? $texte;
589
-			$texte = preg_replace(",<(/?\w+\b[^>]*>),", "<tt>&lt;\\1</tt>", $texte);
590
-			$texte = str_replace('<', '&lt;', $texte);
591
-			$texte = str_replace('&lt;tt>', '<tt>', $texte);
592
-			$texte = str_replace('&lt;/tt>', '</tt>', $texte);
593
-			if (!function_exists('attribut_html')) {
594
-				include_spip('inc/filtres');
595
-			}
596
-			if (!empty($options['wrap_suspect'])) {
597
-				$texte = wrap($texte, $options['wrap_suspect']);
598
-			}
599
-			$texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
600
-		}
601
-
602
-		$texte = $collecteurModeles->retablir($texte);
603
-	}
604
-
605
-	// si on est là dans le public c'est le mode parano
606
-	// on veut donc un rendu propre et secure, et virer silencieusement ce qui est dangereux
607
-	else {
608
-		$collecteurLiens = $collecteurModeles = null;
609
-		if (!empty($options['expanser_liens'])) {
610
-			$texte = expanser_liens($texte, $env['connect'] ?? '', $env['env'] ?? []);
611
-		}
612
-		else {
613
-			include_spip('src/Texte/Collecteur/AbstractCollecteur');
614
-			include_spip('src/Texte/Collecteur/Liens');
615
-			include_spip('src/Texte/Collecteur/Modeles');
616
-
617
-			$collecteurLiens = new Spip\Texte\Collecteur\Liens();
618
-			$texte = $collecteurLiens->echapper($texte, ['sanitize_callback' => 'safehtml']);
619
-
620
-			$collecteurModeles = new Spip\Texte\Collecteur\Modeles();
621
-			$texte = $collecteurModeles->echapper($texte);
622
-		}
623
-		$texte = safehtml($texte);
624
-		if ($collecteurModeles) {
625
-			$texte = $collecteurModeles->retablir($texte);
626
-		}
627
-		if ($collecteurLiens) {
628
-			$texte = $collecteurLiens->retablir($texte);
629
-		}
630
-	}
631
-
632
-	return $texte;
525
+    static $echapper_html_suspect;
526
+    if (!$texte or !is_string($texte)) {
527
+        return $texte;
528
+    }
529
+
530
+    if (!isset($echapper_html_suspect)) {
531
+        $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
532
+    }
533
+    // si fonction personalisee, on delegue
534
+    if ($echapper_html_suspect) {
535
+        // on collecte le tableau d'arg minimal pour ne pas casser un appel a une fonction inc_echapper_html_suspect() selon l'ancienne signature
536
+        $args = [$texte, $options];
537
+        if ($connect or !empty($env)) {
538
+            $args[] = $connect;
539
+        }
540
+        if (!empty($env)) {
541
+            $args[] = $env;
542
+        }
543
+        return $echapper_html_suspect(...$args);
544
+    }
545
+
546
+    if (is_bool($options)) {
547
+        $options = ['strict' => $options];
548
+    }
549
+    $strict = $options['strict'] ?? true;
550
+
551
+    // pas de balise html ou pas d'attribut sur les balises ? c'est OK
552
+    if (
553
+        strpos($texte, '<') === false
554
+        or !str_contains($texte, '=')
555
+    ) {
556
+        return $texte;
557
+    }
558
+
559
+    // dans le prive, on veut afficher tout echappé pour la moderation
560
+    if (!isset($env['espace_prive'])) {
561
+        // conserver le comportement historique en cas d'appel court sans env
562
+        $env['espace_prive'] = test_espace_prive();
563
+    }
564
+    if (!empty($env['espace_prive']) or !empty($env['wysiwyg'])) {
565
+        // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
566
+        // car sinon on declenche sur les modeles ou ressources
567
+        if (
568
+            !$strict and
569
+            (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
570
+        ) {
571
+            return $texte;
572
+        }
573
+
574
+        include_spip('src/Texte/Collecteur/AbstractCollecteur');
575
+        include_spip('src/Texte/Collecteur/Modeles');
576
+        $collecteurModeles = new Spip\Texte\Collecteur\Modeles();
577
+        $texte = $collecteurModeles->echapper($texte);
578
+        $texte = echappe_js($texte);
579
+
580
+        $texte_to_check = $texte;
581
+        // si les raccourcis liens vont etre interprétés, il faut les expanser avant de vérifier que le html est safe
582
+        // car un raccourci peut etre utilisé pour faire un lien malin
583
+        // et un raccourci est potentiellement modifié par safehtml, ce qui fait un faux positif dans is_html_safe
584
+        if (!empty($options['expanser_liens'])) {
585
+            $texte_to_check = expanser_liens($texte_to_check, $env['connect'] ?? '', $env['env'] ?? []);
586
+        }
587
+        if (!is_html_safe($texte_to_check)) {
588
+            $texte = $options['texte_source_affiche'] ?? $texte;
589
+            $texte = preg_replace(",<(/?\w+\b[^>]*>),", "<tt>&lt;\\1</tt>", $texte);
590
+            $texte = str_replace('<', '&lt;', $texte);
591
+            $texte = str_replace('&lt;tt>', '<tt>', $texte);
592
+            $texte = str_replace('&lt;/tt>', '</tt>', $texte);
593
+            if (!function_exists('attribut_html')) {
594
+                include_spip('inc/filtres');
595
+            }
596
+            if (!empty($options['wrap_suspect'])) {
597
+                $texte = wrap($texte, $options['wrap_suspect']);
598
+            }
599
+            $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
600
+        }
601
+
602
+        $texte = $collecteurModeles->retablir($texte);
603
+    }
604
+
605
+    // si on est là dans le public c'est le mode parano
606
+    // on veut donc un rendu propre et secure, et virer silencieusement ce qui est dangereux
607
+    else {
608
+        $collecteurLiens = $collecteurModeles = null;
609
+        if (!empty($options['expanser_liens'])) {
610
+            $texte = expanser_liens($texte, $env['connect'] ?? '', $env['env'] ?? []);
611
+        }
612
+        else {
613
+            include_spip('src/Texte/Collecteur/AbstractCollecteur');
614
+            include_spip('src/Texte/Collecteur/Liens');
615
+            include_spip('src/Texte/Collecteur/Modeles');
616
+
617
+            $collecteurLiens = new Spip\Texte\Collecteur\Liens();
618
+            $texte = $collecteurLiens->echapper($texte, ['sanitize_callback' => 'safehtml']);
619
+
620
+            $collecteurModeles = new Spip\Texte\Collecteur\Modeles();
621
+            $texte = $collecteurModeles->echapper($texte);
622
+        }
623
+        $texte = safehtml($texte);
624
+        if ($collecteurModeles) {
625
+            $texte = $collecteurModeles->retablir($texte);
626
+        }
627
+        if ($collecteurLiens) {
628
+            $texte = $collecteurLiens->retablir($texte);
629
+        }
630
+    }
631
+
632
+    return $texte;
633 633
 }
634 634
 
635 635
 
@@ -650,52 +650,52 @@  discard block
 block discarded – undo
650 650
  *      texte sécurisé
651 651
  **/
652 652
 function safehtml($t) {
653
-	static $safehtml;
654
-
655
-	if (!$t or !is_string($t)) {
656
-		return $t;
657
-	}
658
-	# attention safehtml nettoie deux ou trois caracteres de plus. A voir
659
-	if (strpos($t, '<') === false) {
660
-		return str_replace("\x00", '', $t);
661
-	}
662
-
663
-	$collecteurIdiomes = null;
664
-	if (stripos($t, '<:') !== false) {
665
-		include_spip('src/Texte/Collecteur/AbstractCollecteur');
666
-		include_spip('src/Texte/Collecteur/Idiomes');
667
-		$collecteurIdiomes = new Spip\Texte\Collecteur\Idiomes();
668
-		$t = $collecteurIdiomes->echapper($t);
669
-	}
670
-	$collecteurMultis = null;
671
-	if (stripos($t, '<multi') !== false) {
672
-		include_spip('src/Texte/Collecteur/AbstractCollecteur');
673
-		include_spip('src/Texte/Collecteur/Multis');
674
-		$collecteurMultis = new Spip\Texte\Collecteur\Multis();
675
-		$t = $collecteurMultis->echapper($t, ['sanitize_callback' => 'safehtml']);
676
-	}
677
-
678
-	if (!function_exists('interdire_scripts')) {
679
-		include_spip('inc/texte');
680
-	}
681
-	$t = interdire_scripts($t); // jolifier le php
682
-	$t = echappe_js($t);
683
-
684
-	if (!isset($safehtml)) {
685
-		$safehtml = charger_fonction('safehtml', 'inc', true);
686
-	}
687
-	if ($safehtml) {
688
-		$t = $safehtml($t);
689
-	}
690
-
691
-	if ($collecteurMultis) {
692
-		$t = $collecteurMultis->retablir($t);
693
-	}
694
-	if ($collecteurIdiomes) {
695
-		$t = $collecteurIdiomes->retablir($t);
696
-	}
697
-
698
-	return interdire_scripts($t); // interdire le php (2 precautions)
653
+    static $safehtml;
654
+
655
+    if (!$t or !is_string($t)) {
656
+        return $t;
657
+    }
658
+    # attention safehtml nettoie deux ou trois caracteres de plus. A voir
659
+    if (strpos($t, '<') === false) {
660
+        return str_replace("\x00", '', $t);
661
+    }
662
+
663
+    $collecteurIdiomes = null;
664
+    if (stripos($t, '<:') !== false) {
665
+        include_spip('src/Texte/Collecteur/AbstractCollecteur');
666
+        include_spip('src/Texte/Collecteur/Idiomes');
667
+        $collecteurIdiomes = new Spip\Texte\Collecteur\Idiomes();
668
+        $t = $collecteurIdiomes->echapper($t);
669
+    }
670
+    $collecteurMultis = null;
671
+    if (stripos($t, '<multi') !== false) {
672
+        include_spip('src/Texte/Collecteur/AbstractCollecteur');
673
+        include_spip('src/Texte/Collecteur/Multis');
674
+        $collecteurMultis = new Spip\Texte\Collecteur\Multis();
675
+        $t = $collecteurMultis->echapper($t, ['sanitize_callback' => 'safehtml']);
676
+    }
677
+
678
+    if (!function_exists('interdire_scripts')) {
679
+        include_spip('inc/texte');
680
+    }
681
+    $t = interdire_scripts($t); // jolifier le php
682
+    $t = echappe_js($t);
683
+
684
+    if (!isset($safehtml)) {
685
+        $safehtml = charger_fonction('safehtml', 'inc', true);
686
+    }
687
+    if ($safehtml) {
688
+        $t = $safehtml($t);
689
+    }
690
+
691
+    if ($collecteurMultis) {
692
+        $t = $collecteurMultis->retablir($t);
693
+    }
694
+    if ($collecteurIdiomes) {
695
+        $t = $collecteurIdiomes->retablir($t);
696
+    }
697
+
698
+    return interdire_scripts($t); // interdire le php (2 precautions)
699 699
 }
700 700
 
701 701
 
@@ -703,25 +703,25 @@  discard block
 block discarded – undo
703 703
  * Detecter si un texte est "safe" ie non modifie significativement par safehtml()
704 704
  */
705 705
 function is_html_safe(string $texte): bool {
706
-	if ($is_html_safe = charger_fonction('is_html_safe', 'inc', true)) {
707
-		return $is_html_safe($texte);
708
-	}
709
-
710
-	// simplifier les retour ligne pour etre certain de ce que l'on compare
711
-	$texte = str_replace("\r\n", "\n", $texte);
712
-	// safehtml reduit aussi potentiellement les &nbsp;
713
-	$texte = str_replace('&nbsp;', ' ', $texte);
714
-	// safehtml remplace les entités numériques
715
-	if (strpos($texte, '&#') !== false) {
716
-		$texte = unicode2charset($texte);
717
-	}
718
-
719
-	$texte_safe = safehtml($texte);
720
-
721
-	// on teste sur strlen car safehtml supprime le contenu dangereux
722
-	// mais il peut aussi changer des ' en " sur les attributs html,
723
-	// donc un test d'egalite est trop strict
724
-	return strlen($texte_safe) === strlen($texte);
706
+    if ($is_html_safe = charger_fonction('is_html_safe', 'inc', true)) {
707
+        return $is_html_safe($texte);
708
+    }
709
+
710
+    // simplifier les retour ligne pour etre certain de ce que l'on compare
711
+    $texte = str_replace("\r\n", "\n", $texte);
712
+    // safehtml reduit aussi potentiellement les &nbsp;
713
+    $texte = str_replace('&nbsp;', ' ', $texte);
714
+    // safehtml remplace les entités numériques
715
+    if (strpos($texte, '&#') !== false) {
716
+        $texte = unicode2charset($texte);
717
+    }
718
+
719
+    $texte_safe = safehtml($texte);
720
+
721
+    // on teste sur strlen car safehtml supprime le contenu dangereux
722
+    // mais il peut aussi changer des ' en " sur les attributs html,
723
+    // donc un test d'egalite est trop strict
724
+    return strlen($texte_safe) === strlen($texte);
725 725
 }
726 726
 
727 727
 /**
@@ -742,13 +742,13 @@  discard block
 block discarded – undo
742 742
  *     texte sans les modèles d'image
743 743
  **/
744 744
 function supprime_img($letexte, $message = null) {
745
-	if ($message === null) {
746
-		$message = '(' . _T('img_indisponible') . ')';
747
-	}
748
-
749
-	return preg_replace(
750
-		',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
751
-		$message,
752
-		$letexte
753
-	);
745
+    if ($message === null) {
746
+        $message = '(' . _T('img_indisponible') . ')';
747
+    }
748
+
749
+    return preg_replace(
750
+        ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
751
+        $message,
752
+        $letexte
753
+    );
754 754
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 	// celle du texte) et public (spip_lang est la langue du texte)
44 44
 	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
45 45
 
46
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
46
+	$p = 'puce'.(test_espace_prive() ? '_prive' : '');
47 47
 	if ($dir == 'rtl') {
48 48
 		$p .= '_rtl';
49 49
 	}
50 50
 
51 51
 	if (!isset($GLOBALS[$p])) {
52
-		$GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
52
+		$GLOBALS[$p] = '<span class="spip-puce '.$dir.'"><b>–</b></span>';
53 53
 	}
54 54
 
55 55
 	return $GLOBALS[$p];
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 function spip_balisage_code(string $corps, bool $bloc = false, string $attributs = '', string $langage = '') {
68 68
 
69 69
 	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
70
-	$class = 'spip_code ' . ($bloc ? 'spip_code_block' : 'spip_code_inline');
70
+	$class = 'spip_code '.($bloc ? 'spip_code_block' : 'spip_code_inline');
71 71
 	if ($attributs) {
72
-		$attributs = ' ' . trim($attributs);
72
+		$attributs = ' '.trim($attributs);
73 73
 	}
74 74
 	if ($langage) {
75 75
 		$class .= " language-$langage";
76
-		$attributs .= ' data-language="' . $langage . '"';
76
+		$attributs .= ' data-language="'.$langage.'"';
77 77
 	}
78 78
 	if ($bloc) {
79 79
 		$html = '<div class="precode">'
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	else {
88 88
 		$echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
89 89
 		$echap = str_replace('  ', ' &nbsp;', $echap);
90
-		$html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>';
90
+		$html = "<code class=\"$class\" dir=\"ltr\"$attributs>".$echap.'</code>';
91 91
 	}
92 92
 
93 93
 	return $html;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 }
106 106
 
107 107
 if (!defined('_BALISES_BLOCS_REGEXP')) {
108
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
108
+	define('_BALISES_BLOCS_REGEXP', ',</?('._BALISES_BLOCS.')[>[:space:]],iS');
109 109
 }
110 110
 
111 111
 //
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
 	// Tester si on echappe en span ou en div
124 124
 	if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
125
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
125
+		$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $rempl) ? 'div' : 'span';
126 126
 	}
127 127
 
128 128
 	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	) {
158 158
 		foreach ($matches as $m) {
159 159
 			if ($m[1] === 'code') {
160
-				$code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
160
+				$code = '<code'.$m[2].'>'.spip_htmlspecialchars($m[3]).'</code>';
161 161
 				$pre = str_replace($m[0], $code, $pre);
162 162
 			}
163 163
 		}
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 // Echapper les <code>...</ code>
169 169
 function traiter_echap_code_dist($regs, $options = []) {
170
-	[, , $att, $corps] = $regs;
170
+	[,, $att, $corps] = $regs;
171 171
 
172 172
 	// ne pas mettre le <div...> s'il n'y a qu'une ligne
173 173
 	if (strpos($corps, "\n") !== false) {
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
 				// sinon les traiter selon le cas
253 253
 				$callback_secure_prefix = ($callback_options['secure_prefix'] ?? '');
254 254
 				if (
255
-					function_exists($f = $callback_prefix . $callback_secure_prefix . 'traiter_echap_' . strtolower($regs[1]))
256
-					or function_exists($f = $f . '_dist')
255
+					function_exists($f = $callback_prefix.$callback_secure_prefix.'traiter_echap_'.strtolower($regs[1]))
256
+					or function_exists($f = $f.'_dist')
257 257
 					or ($callback_secure_prefix and (
258
-						function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
259
-						or function_exists($f = $f . '_dist')
258
+						function_exists($f = $callback_prefix.'traiter_echap_'.strtolower($regs[1]))
259
+						or function_exists($f = $f.'_dist')
260 260
 					))
261 261
 				) {
262 262
 					$echap = $f($regs, $callback_options);
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	// dans une callback autonommee
279 279
 	if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
280 280
 		if (
281
-			strpos($letexte, '<' . '?') !== false and preg_match_all(
281
+			strpos($letexte, '<'.'?') !== false and preg_match_all(
282 282
 				',<[?].*($|[?]>),UisS',
283 283
 				$letexte,
284 284
 				$matches,
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			strpos($letexte, '<') !== false
311 311
 			and
312 312
 			preg_match_all(
313
-				',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
313
+				',<(span|div)\sclass=[\'"]base64'.$source.'[\'"]\s(.*)>\s*</\1>,UmsS',
314 314
 				$letexte,
315 315
 				$regs,
316 316
 				PREG_SET_ORDER
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 					}
328 328
 				}
329 329
 				if ($at) {
330
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
330
+					$rempl = '<'.$reg[1].'>'.$rempl.'</'.$reg[1].'>';
331 331
 					foreach ($at as $attr => $a) {
332 332
 						$rempl = inserer_attribut($rempl, $attr, $a);
333 333
 					}
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	$texte = nettoyer_raccourcis_typo($texte);
409 409
 
410 410
 	// balises de sauts de ligne et paragraphe
411
-	$texte = preg_replace('/<p( [^>]*)?' . '>/', "\r\r", $texte);
412
-	$texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
411
+	$texte = preg_replace('/<p( [^>]*)?'.'>/', "\r\r", $texte);
412
+	$texte = preg_replace('/<br( [^>]*)?'.'>/', "\n", $texte);
413 413
 
414 414
 	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
415 415
 	$texte = str_replace("\n\n", "\r\r", $texte);
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
 		// excédentaire est ensuite supprimé par l'appel à preg_replace()
435 435
 		$long = spip_substr($texte, 0, max($taille + 1 - $taille_suite, 1));
436 436
 		$u = $GLOBALS['meta']['pcre_u'];
437
-		$court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long);
437
+		$court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D'.$u, "\\2", $long);
438 438
 		$points = $suite;
439 439
 
440 440
 		// trop court ? ne pas faire de (...)
441 441
 		if (spip_strlen($court) < max(0.75 * $taille, 2)) {
442 442
 			$points = '';
443 443
 			$long = spip_substr($texte, 0, $taille + 1);
444
-			preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, $long, $m);
445
-			$texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long);
444
+			preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D'.$u, $long, $m);
445
+			$texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D'.$u, "\\2", $long);
446 446
 			// encore trop court ? couper au caractere
447 447
 			if (spip_strlen($texte) < 0.75 * $taille) {
448 448
 				$texte = spip_substr($long, 0, $taille);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 	// supprimer l'eventuelle entite finale mal coupee
459 459
 	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
460 460
 
461
-	return quote_amp(trim($texte)) . $points;
461
+	return quote_amp(trim($texte)).$points;
462 462
 }
463 463
 
464 464
 
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
 				define('_PROTEGE_JS_MODELES', creer_uniqid());
471 471
 			}
472 472
 			foreach ($r as $regs) {
473
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
473
+				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript'._PROTEGE_JS_MODELES), $t);
474 474
 			}
475 475
 		}
476
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
476
+		if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)) {
477 477
 			if (!defined('_PROTEGE_PHP_MODELES')) {
478 478
 				include_spip('inc/acces');
479 479
 				define('_PROTEGE_PHP_MODELES', creer_uniqid());
480 480
 			}
481 481
 			foreach ($r as $regs) {
482
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
482
+				$t = str_replace($regs[0], code_echappement($regs[0], 'php'._PROTEGE_PHP_MODELES), $t);
483 483
 			}
484 484
 		}
485 485
 	}
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 			if (!empty($options['wrap_suspect'])) {
597 597
 				$texte = wrap($texte, $options['wrap_suspect']);
598 598
 			}
599
-			$texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
599
+			$texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte;
600 600
 		}
601 601
 
602 602
 		$texte = $collecteurModeles->retablir($texte);
@@ -743,11 +743,11 @@  discard block
 block discarded – undo
743 743
  **/
744 744
 function supprime_img($letexte, $message = null) {
745 745
 	if ($message === null) {
746
-		$message = '(' . _T('img_indisponible') . ')';
746
+		$message = '('._T('img_indisponible').')';
747 747
 	}
748 748
 
749 749
 	return preg_replace(
750
-		',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
750
+		',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i',
751 751
 		$message,
752 752
 		$letexte
753 753
 	);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,8 +83,7 @@  discard block
 block discarded – undo
83 83
 		  . '</code>'
84 84
 		  . '</pre>'
85 85
 		  . '</div>';
86
-	}
87
-	else {
86
+	} else {
88 87
 		$echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
89 88
 		$echap = str_replace('  ', ' &nbsp;', $echap);
90 89
 		$html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>';
@@ -608,8 +607,7 @@  discard block
 block discarded – undo
608 607
 		$collecteurLiens = $collecteurModeles = null;
609 608
 		if (!empty($options['expanser_liens'])) {
610 609
 			$texte = expanser_liens($texte, $env['connect'] ?? '', $env['env'] ?? []);
611
-		}
612
-		else {
610
+		} else {
613 611
 			include_spip('src/Texte/Collecteur/AbstractCollecteur');
614 612
 			include_spip('src/Texte/Collecteur/Liens');
615 613
 			include_spip('src/Texte/Collecteur/Modeles');
Please login to merge, or discard this patch.
ecrire/inc/importer_csv.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 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/charsets');
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
  * @return array
42 42
  */
43 43
 function importer_csv_importcharset($texte, $definir_charset_source = false) {
44
-	// le plus frequent, en particulier avec les trucs de ms@@@
45
-	static $charset_source = 'iso-8859-1';
46
-	if ($definir_charset_source) {
47
-		$charset_source = $definir_charset_source === true ? 'iso-8859-1' : $definir_charset_source;
48
-	}
49
-	// mais open-office sait faire mieux, donc mefiance !
50
-	$charset = is_utf8($texte) ? 'utf-8' : $charset_source;
51
-	return importer_charset($texte, $charset);
44
+    // le plus frequent, en particulier avec les trucs de ms@@@
45
+    static $charset_source = 'iso-8859-1';
46
+    if ($definir_charset_source) {
47
+        $charset_source = $definir_charset_source === true ? 'iso-8859-1' : $definir_charset_source;
48
+    }
49
+    // mais open-office sait faire mieux, donc mefiance !
50
+    $charset = is_utf8($texte) ? 'utf-8' : $charset_source;
51
+    return importer_charset($texte, $charset);
52 52
 }
53 53
 
54 54
 /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  * @return string
60 60
  */
61 61
 function importer_csv_nettoie_key($key) {
62
-	return translitteration($key);
62
+    return translitteration($key);
63 63
 }
64 64
 
65 65
 /**
@@ -78,70 +78,70 @@  discard block
 block discarded – undo
78 78
  */
79 79
 function inc_importer_csv_dist($file, $options = []) {
80 80
 
81
-	// support ancienne syntaxe
82
-	// inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '')
83
-	if (!is_array($options)) {
84
-		$args = func_get_args();
85
-		$options = [];
86
-		foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) {
87
-			if (!empty($args[$k])) {
88
-				$options[$option] = $args[$k];
89
-			}
90
-		}
91
-	}
81
+    // support ancienne syntaxe
82
+    // inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '')
83
+    if (!is_array($options)) {
84
+        $args = func_get_args();
85
+        $options = [];
86
+        foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) {
87
+            if (!empty($args[$k])) {
88
+                $options[$option] = $args[$k];
89
+            }
90
+        }
91
+    }
92 92
 
93
-	$default_options = [
94
-		'head' => false,
95
-		'delim' => ',',
96
-		'enclos' => '"',
97
-		'len' => 10000,
98
-		'charset_source' => '',
99
-	];
100
-	$options = array_merge($default_options, $options);
93
+    $default_options = [
94
+        'head' => false,
95
+        'delim' => ',',
96
+        'enclos' => '"',
97
+        'len' => 10000,
98
+        'charset_source' => '',
99
+    ];
100
+    $options = array_merge($default_options, $options);
101 101
 
102 102
 
103
-	$return = [];
104
-	if (@file_exists($file) && ($handle = fopen($file, 'r'))) {
105
-		if ($options['charset_source']) {
106
-			importer_csv_importcharset('', $options['charset_source']);
107
-		}
108
-		if ($options['head']) {
109
-			$header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']);
110
-			if ($header) {
111
-				$header = array_map('importer_csv_importcharset', $header);
112
-				$header = array_map('importer_csv_nettoie_key', $header);
113
-				$header_type = [];
114
-				foreach ($header as $heading) {
115
-					$header_type[$heading] = isset($header_type[$heading]) ? 'array' : 'scalar';
116
-				}
117
-			}
118
-		}
103
+    $return = [];
104
+    if (@file_exists($file) && ($handle = fopen($file, 'r'))) {
105
+        if ($options['charset_source']) {
106
+            importer_csv_importcharset('', $options['charset_source']);
107
+        }
108
+        if ($options['head']) {
109
+            $header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']);
110
+            if ($header) {
111
+                $header = array_map('importer_csv_importcharset', $header);
112
+                $header = array_map('importer_csv_nettoie_key', $header);
113
+                $header_type = [];
114
+                foreach ($header as $heading) {
115
+                    $header_type[$heading] = isset($header_type[$heading]) ? 'array' : 'scalar';
116
+                }
117
+            }
118
+        }
119 119
 
120
-		while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) {
121
-			$data = array_map('importer_csv_importcharset', $data);
122
-			if ($options['head'] && isset($header)) {
123
-				$row = [];
124
-				foreach ($header as $key => $heading) {
125
-					if ($header_type[$heading] == 'array') {
126
-						if (!isset($row[$heading])) {
127
-							$row[$heading] = [];
128
-						}
129
-						if (isset($data[$key]) && strlen($data[$key])) {
130
-							$row[$heading][] = $data[$key];
131
-						}
132
-					} else {
133
-						$row[$heading] = $data[$key] ?? '';
134
-					}
135
-				}
136
-				$return[] = $row;
137
-			} else {
138
-				$return[] = $data;
139
-			}
140
-		}
141
-		if ($options['charset_source']) {
142
-			importer_csv_importcharset('', true);
143
-		}
144
-	}
120
+        while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) {
121
+            $data = array_map('importer_csv_importcharset', $data);
122
+            if ($options['head'] && isset($header)) {
123
+                $row = [];
124
+                foreach ($header as $key => $heading) {
125
+                    if ($header_type[$heading] == 'array') {
126
+                        if (!isset($row[$heading])) {
127
+                            $row[$heading] = [];
128
+                        }
129
+                        if (isset($data[$key]) && strlen($data[$key])) {
130
+                            $row[$heading][] = $data[$key];
131
+                        }
132
+                    } else {
133
+                        $row[$heading] = $data[$key] ?? '';
134
+                    }
135
+                }
136
+                $return[] = $row;
137
+            } else {
138
+                $return[] = $data;
139
+            }
140
+        }
141
+        if ($options['charset_source']) {
142
+            importer_csv_importcharset('', true);
143
+        }
144
+    }
145 145
 
146
-	return $return ?: false;
146
+    return $return ?: false;
147 147
 }
Please login to merge, or discard this patch.
ecrire/inc/minipres.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Minipres
16 16
  **/
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 
21 21
 /**
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function install_debut_html($titre = 'AUTO', $onLoad = '', $all_inline = false) {
37 37
 
38
-	if ($onLoad) {
39
-		include_spip('inc/filtres');
40
-		$onLoad = extraire_attribut("<body $onLoad>", 'onload');
41
-	}
38
+    if ($onLoad) {
39
+        include_spip('inc/filtres');
40
+        $onLoad = extraire_attribut("<body $onLoad>", 'onload');
41
+    }
42 42
 
43
-	$options = [
44
-		'all_inline' => $all_inline,
45
-		'onload' => $onLoad,
46
-		'titre' => $titre,
47
-	];
43
+    $options = [
44
+        'all_inline' => $all_inline,
45
+        'onload' => $onLoad,
46
+        'titre' => $titre,
47
+    ];
48 48
 
49
-	$minipage = new Spip\Afficher\Minipage\Admin();
50
-	return $minipage->installDebutPage($options);
49
+    $minipage = new Spip\Afficher\Minipage\Admin();
50
+    return $minipage->installDebutPage($options);
51 51
 }
52 52
 
53 53
 /**
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
  * @return string Code HTML
60 60
  */
61 61
 function install_fin_html() {
62
-	$minipage = new Spip\Afficher\Minipage\Admin();
63
-	return $minipage->installFinPage();
62
+    $minipage = new Spip\Afficher\Minipage\Admin();
63
+    return $minipage->installFinPage();
64 64
 }
65 65
 
66 66
 
@@ -99,23 +99,23 @@  discard block
 block discarded – undo
99 99
  */
100 100
 function minipres($titre = '', $corps = '', $options = []) {
101 101
 
102
-	// compat signature old
103
-	// minipres($titre='', $corps="", $onload='', $all_inline = false)
104
-	$args = func_get_args();
105
-	if (isset($args[2]) && is_string($args[2])) {
106
-		$options = ['onload' => $args[2]];
107
-	}
108
-	if (isset($args[3])) {
109
-		$options['all_inline'] = $args[3];
110
-	}
102
+    // compat signature old
103
+    // minipres($titre='', $corps="", $onload='', $all_inline = false)
104
+    $args = func_get_args();
105
+    if (isset($args[2]) && is_string($args[2])) {
106
+        $options = ['onload' => $args[2]];
107
+    }
108
+    if (isset($args[3])) {
109
+        $options['all_inline'] = $args[3];
110
+    }
111 111
 
112
-	$options = array_merge([
113
-		'onload' => '',
114
-		'all_inline' => false,
115
-	], $options);
112
+    $options = array_merge([
113
+        'onload' => '',
114
+        'all_inline' => false,
115
+    ], $options);
116 116
 
117
-	$options['titre'] = $titre;
117
+    $options['titre'] = $titre;
118 118
 
119
-	$minipage = new Spip\Afficher\Minipage\Admin();
120
-	return $minipage->page($corps, $options);
119
+    $minipage = new Spip\Afficher\Minipage\Admin();
120
+    return $minipage->page($corps, $options);
121 121
 }
Please login to merge, or discard this patch.
ecrire/inc/install.php 2 patches
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
  * @return void
43 43
  **/
44 44
 function install_fichier_connexion($nom, $texte) {
45
-	$texte = '<' . "?php\n"
46
-		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
47
-		. $texte;
45
+    $texte = '<' . "?php\n"
46
+        . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
47
+        . $texte;
48 48
 
49
-	ecrire_fichier($nom, $texte);
49
+    ecrire_fichier($nom, $texte);
50 50
 }
51 51
 
52 52
 
@@ -75,20 +75,20 @@  discard block
 block discarded – undo
75 75
  *
76 76
  **/
77 77
 function install_connexion($adr, $port, $login, #[\SensitiveParameter] $pass, $base, $type, $pref, $ldap = '', $charset = '') {
78
-	$adr = addcslashes($adr, "'\\");
79
-	$port = addcslashes($port, "'\\");
80
-	$login = addcslashes($login, "'\\");
81
-	$pass = addcslashes($pass, "'\\");
82
-	$base = addcslashes($base, "'\\");
83
-	$type = addcslashes($type, "'\\");
84
-	$pref = addcslashes($pref, "'\\");
85
-	$ldap = addcslashes($ldap, "'\\");
86
-	$charset = addcslashes($charset, "'\\");
87
-
88
-	return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
89
-	. 'spip_connect_db('
90
-	. "'$adr','$port','$login','$pass','$base'"
91
-	. ",'$type', '$pref','$ldap','$charset');\n";
78
+    $adr = addcslashes($adr, "'\\");
79
+    $port = addcslashes($port, "'\\");
80
+    $login = addcslashes($login, "'\\");
81
+    $pass = addcslashes($pass, "'\\");
82
+    $base = addcslashes($base, "'\\");
83
+    $type = addcslashes($type, "'\\");
84
+    $pref = addcslashes($pref, "'\\");
85
+    $ldap = addcslashes($ldap, "'\\");
86
+    $charset = addcslashes($charset, "'\\");
87
+
88
+    return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
89
+    . 'spip_connect_db('
90
+    . "'$adr','$port','$login','$pass','$base'"
91
+    . ",'$type', '$pref','$ldap','$charset');\n";
92 92
 }
93 93
 
94 94
 
@@ -104,29 +104,29 @@  discard block
 block discarded – undo
104 104
  *     Tableau des informations sur la connexion
105 105
  **/
106 106
 function analyse_fichier_connection(string $file): array {
107
-	if (!file_exists($file)) {
108
-		return [];
109
-	}
110
-	$s = file_get_contents($file);
111
-	if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
112
-		array_shift($regs);
113
-
114
-		return $regs;
115
-	} else {
116
-		$ar = '\s*\'([^\']*)\'';
117
-		$r = '\s*,' . $ar;
118
-		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
119
-		if (preg_match($r, $s, $regs)) {
120
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
121
-			array_shift($regs);
122
-			array_shift($regs);
123
-
124
-			return $regs;
125
-		}
126
-	}
127
-	spip_log("$file n'est pas un fichier de connexion");
128
-
129
-	return [];
107
+    if (!file_exists($file)) {
108
+        return [];
109
+    }
110
+    $s = file_get_contents($file);
111
+    if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
112
+        array_shift($regs);
113
+
114
+        return $regs;
115
+    } else {
116
+        $ar = '\s*\'([^\']*)\'';
117
+        $r = '\s*,' . $ar;
118
+        $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
119
+        if (preg_match($r, $s, $regs)) {
120
+            $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
121
+            array_shift($regs);
122
+            array_shift($regs);
123
+
124
+            return $regs;
125
+        }
126
+    }
127
+    spip_log("$file n'est pas un fichier de connexion");
128
+
129
+    return [];
130 130
 }
131 131
 
132 132
 /**
@@ -143,80 +143,80 @@  discard block
 block discarded – undo
143 143
  *     Liste des noms de connecteurs
144 144
  **/
145 145
 function bases_referencees($exclu = '') {
146
-	$tables = [];
147
-	foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
148
-		if ($f != $exclu and analyse_fichier_connection($f)) {
149
-			$tables[] = basename($f, '.php');
150
-		}
151
-	}
152
-
153
-	return $tables;
146
+    $tables = [];
147
+    foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
148
+        if ($f != $exclu and analyse_fichier_connection($f)) {
149
+            $tables[] = basename($f, '.php');
150
+        }
151
+    }
152
+
153
+    return $tables;
154 154
 }
155 155
 
156 156
 
157 157
 function install_mode_appel($server_db, $tout = true) {
158
-	return ($server_db != 'mysql') ? ''
159
-		: (($tout ? test_rappel_nom_base_mysql($server_db) : '')
160
-			. test_sql_mode_mysql($server_db));
158
+    return ($server_db != 'mysql') ? ''
159
+        : (($tout ? test_rappel_nom_base_mysql($server_db) : '')
160
+            . test_sql_mode_mysql($server_db));
161 161
 }
162 162
 
163 163
 //
164 164
 // Verifier que l'hebergement est compatible SPIP ... ou l'inverse :-)
165 165
 // (sert a l'etape 1 de l'installation)
166 166
 function tester_compatibilite_hebergement() {
167
-	$err = [];
168
-
169
-	$p = phpversion();
170
-	if (version_compare($p, _PHP_MIN, '<')) {
171
-		$err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
172
-	}
173
-	if (version_compare($p, _PHP_MAX, '>')) {
174
-		$err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]);
175
-	}
176
-
177
-	$diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions());
178
-	if (!empty($diff)) {
179
-		$err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]);
180
-	}
181
-
182
-	// Si on n'a pas la bonne version de PHP, c'est la fin
183
-	if ($err) {
184
-		die("<div class='error'>"
185
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
186
-			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
187
-	}
188
-
189
-	// Il faut une base de donnees tout de meme ...
190
-	$serveurs = install_select_serveur();
191
-	if (!$serveurs) {
192
-		$err[] = _T('install_extension_php_obligatoire')
193
-			. " <a href='http://www.php.net/mysql'>MYSQL</a>"
194
-			. "| <a href='http://www.php.net/sqlite'>SQLite</a>";
195
-	}
196
-
197
-	// et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0)
198
-	if ($a = @ini_get('mbstring.func_overload')) {
199
-		$err[] = _T('install_extension_mbstring')
200
-			. "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
201
-	}
202
-
203
-	if ($err) {
204
-		echo "<div class='error'>"
205
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
206
-		foreach ($err as $e) {
207
-			echo "<li><strong>$e</strong></li>\n";
208
-		}
209
-
210
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
211
-		# de forcer malgre tout (pour tester, ou si bug de detection)
212
-		echo "</ul></div>\n";
213
-	}
167
+    $err = [];
168
+
169
+    $p = phpversion();
170
+    if (version_compare($p, _PHP_MIN, '<')) {
171
+        $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
172
+    }
173
+    if (version_compare($p, _PHP_MAX, '>')) {
174
+        $err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]);
175
+    }
176
+
177
+    $diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions());
178
+    if (!empty($diff)) {
179
+        $err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]);
180
+    }
181
+
182
+    // Si on n'a pas la bonne version de PHP, c'est la fin
183
+    if ($err) {
184
+        die("<div class='error'>"
185
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
186
+            . "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
187
+    }
188
+
189
+    // Il faut une base de donnees tout de meme ...
190
+    $serveurs = install_select_serveur();
191
+    if (!$serveurs) {
192
+        $err[] = _T('install_extension_php_obligatoire')
193
+            . " <a href='http://www.php.net/mysql'>MYSQL</a>"
194
+            . "| <a href='http://www.php.net/sqlite'>SQLite</a>";
195
+    }
196
+
197
+    // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0)
198
+    if ($a = @ini_get('mbstring.func_overload')) {
199
+        $err[] = _T('install_extension_mbstring')
200
+            . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
201
+    }
202
+
203
+    if ($err) {
204
+        echo "<div class='error'>"
205
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
206
+        foreach ($err as $e) {
207
+            echo "<li><strong>$e</strong></li>\n";
208
+        }
209
+
210
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
211
+        # de forcer malgre tout (pour tester, ou si bug de detection)
212
+        echo "</ul></div>\n";
213
+    }
214 214
 }
215 215
 
216 216
 
217 217
 function info_etape($titre, $complement = '') {
218
-	return '<h2>' . $titre . "</h2>\n" .
219
-	($complement ? '' . $complement . "\n" : '');
218
+    return '<h2>' . $titre . "</h2>\n" .
219
+    ($complement ? '' . $complement . "\n" : '');
220 220
 }
221 221
 
222 222
 /**
@@ -226,148 +226,148 @@  discard block
 block discarded – undo
226 226
  * @return string Code HTML du bouton
227 227
  **/
228 228
 function bouton_suivant($code = '') {
229
-	if ($code == '') {
230
-		$code = _T('bouton_suivant');
231
-	}
232
-	static $suivant = 0;
233
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
234
-	$suivant += 1;
235
-
236
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
237
-	$code .
238
-	" >>\" /></p>\n";
229
+    if ($code == '') {
230
+        $code = _T('bouton_suivant');
231
+    }
232
+    static $suivant = 0;
233
+    $id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
234
+    $suivant += 1;
235
+
236
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
237
+    $code .
238
+    " >>\" /></p>\n";
239 239
 }
240 240
 
241 241
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
242
-	$intitule_etat = [];
243
-
244
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
245
-	$debut = 1;
246
-	$last = count($liste);
247
-
248
-	include_spip('inc/texte');
249
-	$intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
250
-	$intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
251
-	$intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
252
-	$intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
253
-
254
-	$intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
255
-	$intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
256
-	$intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
257
-	$intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
258
-	$intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
259
-
260
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
261
-
262
-	foreach ($liste as $etape => $fichier) {
263
-		if ($debut < $last) {
264
-			if ($debut == $en_cours && $erreur) {
265
-				$class = 'on erreur';
266
-			} else {
267
-				if ($debut == $en_cours) {
268
-					$class = 'on';
269
-				} else {
270
-					if ($debut > $en_cours) {
271
-						$class = 'prochains';
272
-					} else {
273
-						$class = 'valides';
274
-					}
275
-				}
276
-			}
277
-
278
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
279
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
280
-			$aff_etapes .= '<' . (($debut == $en_cours) ? 'strong' : 'span') . ' class="label_etape">' . $intitule_etat["$phase"][$debut] . '</' . (($debut == $en_cours) ? 'strong' : 'span') . '>';
281
-			$aff_etapes .= '</div></li>';
282
-		}
283
-		$debut++;
284
-	}
285
-	$aff_etapes .= '</ul>';
286
-
287
-	return $aff_etapes;
242
+    $intitule_etat = [];
243
+
244
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
245
+    $debut = 1;
246
+    $last = count($liste);
247
+
248
+    include_spip('inc/texte');
249
+    $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
250
+    $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
251
+    $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
252
+    $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
253
+
254
+    $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
255
+    $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
256
+    $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
257
+    $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
258
+    $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
259
+
260
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
261
+
262
+    foreach ($liste as $etape => $fichier) {
263
+        if ($debut < $last) {
264
+            if ($debut == $en_cours && $erreur) {
265
+                $class = 'on erreur';
266
+            } else {
267
+                if ($debut == $en_cours) {
268
+                    $class = 'on';
269
+                } else {
270
+                    if ($debut > $en_cours) {
271
+                        $class = 'prochains';
272
+                    } else {
273
+                        $class = 'valides';
274
+                    }
275
+                }
276
+            }
277
+
278
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
279
+            $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
280
+            $aff_etapes .= '<' . (($debut == $en_cours) ? 'strong' : 'span') . ' class="label_etape">' . $intitule_etat["$phase"][$debut] . '</' . (($debut == $en_cours) ? 'strong' : 'span') . '>';
281
+            $aff_etapes .= '</div></li>';
282
+        }
283
+        $debut++;
284
+    }
285
+    $aff_etapes .= '</ul>';
286
+
287
+    return $aff_etapes;
288 288
 }
289 289
 
290 290
 
291 291
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
292
-	return "<fieldset>\n" .
293
-	$avant .
294
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
295
-	fieldset_champs($champs) .
296
-	$apres .
297
-	"</fieldset>\n";
292
+    return "<fieldset>\n" .
293
+    $avant .
294
+    ($legend ? '<legend>' . $legend . "</legend>\n" : '') .
295
+    fieldset_champs($champs) .
296
+    $apres .
297
+    "</fieldset>\n";
298 298
 }
299 299
 
300 300
 function fieldset_champs($champs = []) {
301
-	$fieldset = '';
302
-	foreach ($champs as $nom => $contenu) {
303
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
304
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
305
-		if (isset($contenu['alternatives'])) {
306
-			$fieldset .= $contenu['label'] . "\n";
307
-			foreach ($contenu['alternatives'] as $valeur => $label) {
308
-				$fieldset .= "<input type='radio' name='" . $nom .
309
-					"' id='$nom-$valeur' value='$valeur'"
310
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
311
-					. "/>\n";
312
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
313
-			}
314
-			$fieldset .= "<br />\n";
315
-		} else {
316
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
317
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
318
-				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
319
-				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
320
-				. " />\n";
321
-		}
322
-	}
323
-
324
-	return $fieldset;
301
+    $fieldset = '';
302
+    foreach ($champs as $nom => $contenu) {
303
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
304
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
305
+        if (isset($contenu['alternatives'])) {
306
+            $fieldset .= $contenu['label'] . "\n";
307
+            foreach ($contenu['alternatives'] as $valeur => $label) {
308
+                $fieldset .= "<input type='radio' name='" . $nom .
309
+                    "' id='$nom-$valeur' value='$valeur'"
310
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
311
+                    . "/>\n";
312
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
313
+            }
314
+            $fieldset .= "<br />\n";
315
+        } else {
316
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
317
+            $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
318
+                . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
319
+                . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
320
+                . " />\n";
321
+        }
322
+    }
323
+
324
+    return $fieldset;
325 325
 }
326 326
 
327 327
 function install_select_serveur() {
328
-	$options = [];
329
-	$dir = _DIR_RESTREINT . 'req/';
330
-	$d = opendir($dir);
331
-	if (!$d) {
332
-		return [];
333
-	}
334
-	while (($f = readdir($d)) !== false) {
335
-		if (
336
-			(preg_match('/^(.*)[.]php$/', $f, $s))
337
-			and is_readable($f = $dir . $f)
338
-		) {
339
-			require_once($f);
340
-			$s = $s[1];
341
-			$v = 'spip_versions_' . $s;
342
-			if (function_exists($v) and $v()) {
343
-				$titre = _T("install_select_type_$s");
344
-				// proposer mysql par defaut si dispo
345
-				$checked = ($s == 'mysql' ? " checked='checked'" : '');
346
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
347
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
348
-			} else {
349
-				spip_log("$s: portage indisponible");
350
-			}
351
-		}
352
-	}
353
-	sort($options);
354
-
355
-	return $options;
328
+    $options = [];
329
+    $dir = _DIR_RESTREINT . 'req/';
330
+    $d = opendir($dir);
331
+    if (!$d) {
332
+        return [];
333
+    }
334
+    while (($f = readdir($d)) !== false) {
335
+        if (
336
+            (preg_match('/^(.*)[.]php$/', $f, $s))
337
+            and is_readable($f = $dir . $f)
338
+        ) {
339
+            require_once($f);
340
+            $s = $s[1];
341
+            $v = 'spip_versions_' . $s;
342
+            if (function_exists($v) and $v()) {
343
+                $titre = _T("install_select_type_$s");
344
+                // proposer mysql par defaut si dispo
345
+                $checked = ($s == 'mysql' ? " checked='checked'" : '');
346
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
347
+                    . "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
348
+            } else {
349
+                spip_log("$s: portage indisponible");
350
+            }
351
+        }
352
+    }
353
+    sort($options);
354
+
355
+    return $options;
356 356
 }
357 357
 
358 358
 function install_connexion_form($db, $login, #[\SensitiveParameter] $pass, $predef, $hidden, $etape, $jquery = true) {
359
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
360
-
361
-	return generer_form_ecrire('install', (
362
-		"\n<input type='hidden' name='etape' value='$etape' />"
363
-		. $hidden
364
-		. (_request('echec') ?
365
-			('<p><b>' . _T('avis_connexion_echec_1') .
366
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
367
-			: '')
368
-
369
-		. ($jquery ? http_script('', 'jquery.js') : '')
370
-		. http_script('
359
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
360
+
361
+    return generer_form_ecrire('install', (
362
+        "\n<input type='hidden' name='etape' value='$etape' />"
363
+        . $hidden
364
+        . (_request('echec') ?
365
+            ('<p><b>' . _T('avis_connexion_echec_1') .
366
+                '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
367
+            : '')
368
+
369
+        . ($jquery ? http_script('', 'jquery.js') : '')
370
+        . http_script('
371 371
 		jQuery(function($) {
372 372
 			$details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur");
373 373
 			$("input[type=hidden][name=server_db]").each(function(){
@@ -400,145 +400,145 @@  discard block
 block discarded – undo
400 400
 			});
401 401
 		});')
402 402
 
403
-		. ($server_db
404
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
405
-			. (($predef[0])
406
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
407
-				: '')
408
-			: ('<fieldset><legend>'
409
-				. _T('install_select_type_db')
410
-				. '</legend>'
411
-				. '<p class="explication">'
412
-				. _T('install_types_db_connus')
413
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
414
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
415
-				. '</p>'
416
-				. "\n<div class='p'>\n<ul>\n"
417
-				. join("\n", install_select_serveur())
418
-				. "\n</ul>\n</div></fieldset>")
419
-		)
420
-		. '<div id="install_adresse_base_hebergeur">'
421
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
422
-		. ($predef[1]
423
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
424
-			: fieldset(
425
-				_T('entree_base_donnee_1'),
426
-				[
427
-					'adresse_db' => [
428
-						'label' => $db[1],
429
-						'valeur' => $db[0]
430
-					],
431
-				]
432
-			)
433
-		)
434
-		. '</div>'
435
-
436
-		. '<div id="install_login_base_hebergeur">'
437
-		. ($predef[2]
438
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
439
-			: fieldset(
440
-				_T('entree_login_connexion_1'),
441
-				[
442
-					'login_db' => [
443
-						'label' => $login[1],
444
-						'valeur' => $login[0]
445
-					],
446
-				]
447
-			)
448
-		)
449
-		. '</div>'
450
-
451
-		. '<div id="install_pass_base_hebergeur">'
452
-		. ($predef[3]
453
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
454
-			: fieldset(
455
-				_T('entree_mot_passe_1'),
456
-				[
457
-					'pass_db' => [
458
-						'label' => $pass[1],
459
-						'valeur' => $pass[0]
460
-					],
461
-				]
462
-			)
463
-		)
464
-		. '</div>'
465
-
466
-		. bouton_suivant()));
403
+        . ($server_db
404
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
405
+            . (($predef[0])
406
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
407
+                : '')
408
+            : ('<fieldset><legend>'
409
+                . _T('install_select_type_db')
410
+                . '</legend>'
411
+                . '<p class="explication">'
412
+                . _T('install_types_db_connus')
413
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
414
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
415
+                . '</p>'
416
+                . "\n<div class='p'>\n<ul>\n"
417
+                . join("\n", install_select_serveur())
418
+                . "\n</ul>\n</div></fieldset>")
419
+        )
420
+        . '<div id="install_adresse_base_hebergeur">'
421
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
422
+        . ($predef[1]
423
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
424
+            : fieldset(
425
+                _T('entree_base_donnee_1'),
426
+                [
427
+                    'adresse_db' => [
428
+                        'label' => $db[1],
429
+                        'valeur' => $db[0]
430
+                    ],
431
+                ]
432
+            )
433
+        )
434
+        . '</div>'
435
+
436
+        . '<div id="install_login_base_hebergeur">'
437
+        . ($predef[2]
438
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
439
+            : fieldset(
440
+                _T('entree_login_connexion_1'),
441
+                [
442
+                    'login_db' => [
443
+                        'label' => $login[1],
444
+                        'valeur' => $login[0]
445
+                    ],
446
+                ]
447
+            )
448
+        )
449
+        . '</div>'
450
+
451
+        . '<div id="install_pass_base_hebergeur">'
452
+        . ($predef[3]
453
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
454
+            : fieldset(
455
+                _T('entree_mot_passe_1'),
456
+                [
457
+                    'pass_db' => [
458
+                        'label' => $pass[1],
459
+                        'valeur' => $pass[0]
460
+                    ],
461
+                ]
462
+            )
463
+        )
464
+        . '</div>'
465
+
466
+        . bouton_suivant()));
467 467
 }
468 468
 
469 469
 // 4 valeurs qu'on reconduit d'un script a l'autre
470 470
 // sauf s'ils sont predefinis.
471 471
 
472 472
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
473
-	return ((defined('_INSTALL_HOST_DB'))
474
-		? ''
475
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
476
-	)
477
-	. ((defined('_INSTALL_USER_DB'))
478
-		? ''
479
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
480
-	)
481
-	. ((defined('_INSTALL_PASS_DB'))
482
-		? ''
483
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
484
-	)
485
-
486
-	. ((defined('_INSTALL_SERVER_DB'))
487
-		? ''
488
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
489
-	);
473
+    return ((defined('_INSTALL_HOST_DB'))
474
+        ? ''
475
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
476
+    )
477
+    . ((defined('_INSTALL_USER_DB'))
478
+        ? ''
479
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
480
+    )
481
+    . ((defined('_INSTALL_PASS_DB'))
482
+        ? ''
483
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
484
+    )
485
+
486
+    . ((defined('_INSTALL_SERVER_DB'))
487
+        ? ''
488
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
489
+    );
490 490
 }
491 491
 
492 492
 // presentation des bases existantes
493 493
 
494 494
 function install_etape_liste_bases($server_db, $login_db, $disabled = []) {
495
-	$bases = $checked = [];
496
-	$noms = sql_listdbs($server_db);
497
-	if (!$noms) {
498
-		return '';
499
-	}
500
-
501
-	foreach ($noms as $nom) {
502
-		$id = spip_htmlspecialchars($nom);
503
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
504
-		$base = ' name="choix_db" value="'
505
-			. $nom
506
-			. '"'
507
-			. $dis
508
-			. " type='radio' id='$id'";
509
-		$label = "<label for='$id'>"
510
-			. ($dis ? "<i>$nom</i>" : $nom)
511
-			. '</label>';
512
-
513
-		if (
514
-			!$checked and !$dis and
515
-			(($nom == $login_db) or
516
-				($GLOBALS['table_prefix'] == $nom))
517
-		) {
518
-			$checked = "<input$base checked='checked' />\n$label";
519
-		} else {
520
-			$bases[] = "<input$base />\n$label";
521
-		}
522
-	}
523
-
524
-	if (!$bases && !$checked) {
525
-		return false;
526
-	}
527
-
528
-	if ($checked) {
529
-		array_unshift($bases, $checked);
530
-		$checked = true;
531
-	}
532
-
533
-	return [$checked, $bases];
495
+    $bases = $checked = [];
496
+    $noms = sql_listdbs($server_db);
497
+    if (!$noms) {
498
+        return '';
499
+    }
500
+
501
+    foreach ($noms as $nom) {
502
+        $id = spip_htmlspecialchars($nom);
503
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
504
+        $base = ' name="choix_db" value="'
505
+            . $nom
506
+            . '"'
507
+            . $dis
508
+            . " type='radio' id='$id'";
509
+        $label = "<label for='$id'>"
510
+            . ($dis ? "<i>$nom</i>" : $nom)
511
+            . '</label>';
512
+
513
+        if (
514
+            !$checked and !$dis and
515
+            (($nom == $login_db) or
516
+                ($GLOBALS['table_prefix'] == $nom))
517
+        ) {
518
+            $checked = "<input$base checked='checked' />\n$label";
519
+        } else {
520
+            $bases[] = "<input$base />\n$label";
521
+        }
522
+    }
523
+
524
+    if (!$bases && !$checked) {
525
+        return false;
526
+    }
527
+
528
+    if ($checked) {
529
+        array_unshift($bases, $checked);
530
+        $checked = true;
531
+    }
532
+
533
+    return [$checked, $bases];
534 534
 }
535 535
 
536 536
 function install_propager($hidden) {
537
-	$res = '';
538
-	foreach ($hidden as $k) {
539
-		$v = spip_htmlentities(_request($k));
540
-		$res .= "<input type='hidden' name='$k' value='$v' />";
541
-	}
537
+    $res = '';
538
+    foreach ($hidden as $k) {
539
+        $v = spip_htmlentities(_request($k));
540
+        $res .= "<input type='hidden' name='$k' value='$v' />";
541
+    }
542 542
 
543
-	return $res;
543
+    return $res;
544 544
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  * @return void
43 43
  **/
44 44
 function install_fichier_connexion($nom, $texte) {
45
-	$texte = '<' . "?php\n"
45
+	$texte = '<'."?php\n"
46 46
 		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
47 47
 		. $texte;
48 48
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 		return $regs;
115 115
 	} else {
116 116
 		$ar = '\s*\'([^\']*)\'';
117
-		$r = '\s*,' . $ar;
117
+		$r = '\s*,'.$ar;
118 118
 		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
119 119
 		if (preg_match($r, $s, $regs)) {
120
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
120
+			$regs[2] = $regs[1].(!$regs[2] ? '' : ':'.$regs[2].';');
121 121
 			array_shift($regs);
122 122
 			array_shift($regs);
123 123
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	// Si on n'a pas la bonne version de PHP, c'est la fin
183 183
 	if ($err) {
184 184
 		die("<div class='error'>"
185
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
185
+			. '<h3>'._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>"
186 186
 			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
187 187
 	}
188 188
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
 	if ($err) {
204 204
 		echo "<div class='error'>"
205
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
+			. '<h3>'._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>";
206 206
 		foreach ($err as $e) {
207 207
 			echo "<li><strong>$e</strong></li>\n";
208 208
 		}
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 
216 216
 
217 217
 function info_etape($titre, $complement = '') {
218
-	return '<h2>' . $titre . "</h2>\n" .
219
-	($complement ? '' . $complement . "\n" : '');
218
+	return '<h2>'.$titre."</h2>\n".
219
+	($complement ? ''.$complement."\n" : '');
220 220
 }
221 221
 
222 222
 /**
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
 		$code = _T('bouton_suivant');
231 231
 	}
232 232
 	static $suivant = 0;
233
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
233
+	$id = 'suivant'.(($suivant > 0) ? strval($suivant) : '');
234 234
 	$suivant += 1;
235 235
 
236
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
237
-	$code .
236
+	return "\n<p class='boutons suivant'><input id='".$id."' type='submit'\nvalue=\"".
237
+	$code.
238 238
 	" >>\" /></p>\n";
239 239
 }
240 240
 
241 241
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
242 242
 	$intitule_etat = [];
243 243
 
244
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
244
+	$liste = find_all_in_path($dir, $phase.'(([0-9])+|fin)[.]php$');
245 245
 	$debut = 1;
246 246
 	$last = count($liste);
247 247
 
@@ -276,8 +276,8 @@  discard block
 block discarded – undo
276 276
 			}
277 277
 
278 278
 			$aff_etapes .= "<li class='$class'><div class='fond'>";
279
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
280
-			$aff_etapes .= '<' . (($debut == $en_cours) ? 'strong' : 'span') . ' class="label_etape">' . $intitule_etat["$phase"][$debut] . '</' . (($debut == $en_cours) ? 'strong' : 'span') . '>';
279
+			$aff_etapes .= '<em>'._T('etape')." </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
280
+			$aff_etapes .= '<'.(($debut == $en_cours) ? 'strong' : 'span').' class="label_etape">'.$intitule_etat["$phase"][$debut].'</'.(($debut == $en_cours) ? 'strong' : 'span').'>';
281 281
 			$aff_etapes .= '</div></li>';
282 282
 		}
283 283
 		$debut++;
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
 
290 290
 
291 291
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
292
-	return "<fieldset>\n" .
293
-	$avant .
294
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
295
-	fieldset_champs($champs) .
296
-	$apres .
292
+	return "<fieldset>\n".
293
+	$avant.
294
+	($legend ? '<legend>'.$legend."</legend>\n" : '').
295
+	fieldset_champs($champs).
296
+	$apres.
297 297
 	"</fieldset>\n";
298 298
 }
299 299
 
@@ -303,18 +303,18 @@  discard block
 block discarded – undo
303 303
 		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
304 304
 		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
305 305
 		if (isset($contenu['alternatives'])) {
306
-			$fieldset .= $contenu['label'] . "\n";
306
+			$fieldset .= $contenu['label']."\n";
307 307
 			foreach ($contenu['alternatives'] as $valeur => $label) {
308
-				$fieldset .= "<input type='radio' name='" . $nom .
308
+				$fieldset .= "<input type='radio' name='".$nom.
309 309
 					"' id='$nom-$valeur' value='$valeur'"
310 310
 					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
311 311
 					. "/>\n";
312
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
312
+				$fieldset .= "<label for='$nom-$valeur'>".$label."</label>\n";
313 313
 			}
314 314
 			$fieldset .= "<br />\n";
315 315
 		} else {
316
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
317
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
316
+			$fieldset .= "<label for='".$nom."'>".$contenu['label']."</label>\n";
317
+			$fieldset .= '<input '.$class."type='".$type."' id='".$nom."' name='".$nom."'\nvalue='".$contenu['valeur']."'"
318 318
 				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
319 319
 				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
320 320
 				. " />\n";
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 
327 327
 function install_select_serveur() {
328 328
 	$options = [];
329
-	$dir = _DIR_RESTREINT . 'req/';
329
+	$dir = _DIR_RESTREINT.'req/';
330 330
 	$d = opendir($dir);
331 331
 	if (!$d) {
332 332
 		return [];
@@ -334,17 +334,17 @@  discard block
 block discarded – undo
334 334
 	while (($f = readdir($d)) !== false) {
335 335
 		if (
336 336
 			(preg_match('/^(.*)[.]php$/', $f, $s))
337
-			and is_readable($f = $dir . $f)
337
+			and is_readable($f = $dir.$f)
338 338
 		) {
339 339
 			require_once($f);
340 340
 			$s = $s[1];
341
-			$v = 'spip_versions_' . $s;
341
+			$v = 'spip_versions_'.$s;
342 342
 			if (function_exists($v) and $v()) {
343 343
 				$titre = _T("install_select_type_$s");
344 344
 				// proposer mysql par defaut si dispo
345 345
 				$checked = ($s == 'mysql' ? " checked='checked'" : '');
346 346
 				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
347
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
347
+					. "<label for='$s'>".($titre ?: $s).'</label></li>';
348 348
 			} else {
349 349
 				spip_log("$s: portage indisponible");
350 350
 			}
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 		"\n<input type='hidden' name='etape' value='$etape' />"
363 363
 		. $hidden
364 364
 		. (_request('echec') ?
365
-			('<p><b>' . _T('avis_connexion_echec_1') .
366
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
365
+			('<p><b>'._T('avis_connexion_echec_1').
366
+				'</b></p><p>'._T('avis_connexion_echec_2')."</p><p style='font-size: small;'>"._T('avis_connexion_echec_3').'</p>')
367 367
 			: '')
368 368
 
369 369
 		. ($jquery ? http_script('', 'jquery.js') : '')
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 		});')
402 402
 
403 403
 		. ($server_db
404
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
404
+			? '<input type="hidden" name="server_db" value="'.$server_db.'" />'
405 405
 			. (($predef[0])
406
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
406
+				? ('<h3>'._T('install_serveur_hebergeur').'</h3>')
407 407
 				: '')
408 408
 			: ('<fieldset><legend>'
409 409
 				. _T('install_select_type_db')
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 				. "\n</ul>\n</div></fieldset>")
419 419
 		)
420 420
 		. '<div id="install_adresse_base_hebergeur">'
421
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
421
+		. '<p>'._T('texte_connexion_mysql').'</p>'
422 422
 		. ($predef[1]
423
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
423
+			? '<h3>'._T('install_adresse_base_hebergeur').'</h3>'
424 424
 			: fieldset(
425 425
 				_T('entree_base_donnee_1'),
426 426
 				[
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 
436 436
 		. '<div id="install_login_base_hebergeur">'
437 437
 		. ($predef[2]
438
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
438
+			? '<h3>'._T('install_login_base_hebergeur').'</h3>'
439 439
 			: fieldset(
440 440
 				_T('entree_login_connexion_1'),
441 441
 				[
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 
451 451
 		. '<div id="install_pass_base_hebergeur">'
452 452
 		. ($predef[3]
453
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
453
+			? '<h3>'._T('install_pass_base_hebergeur').'</h3>'
454 454
 			: fieldset(
455 455
 				_T('entree_mot_passe_1'),
456 456
 				[
@@ -472,20 +472,20 @@  discard block
 block discarded – undo
472 472
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
473 473
 	return ((defined('_INSTALL_HOST_DB'))
474 474
 		? ''
475
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
475
+		: "\n<input type='hidden' name='adresse_db'  value=\"".spip_htmlspecialchars($adresse_db).'" />'
476 476
 	)
477 477
 	. ((defined('_INSTALL_USER_DB'))
478 478
 		? ''
479
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
479
+		: "\n<input type='hidden' name='login_db' value=\"".spip_htmlspecialchars($login_db).'" />'
480 480
 	)
481 481
 	. ((defined('_INSTALL_PASS_DB'))
482 482
 		? ''
483
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
483
+		: "\n<input type='hidden' name='pass_db' value=\"".spip_htmlspecialchars($pass_db).'" />'
484 484
 	)
485 485
 
486 486
 	. ((defined('_INSTALL_SERVER_DB'))
487 487
 		? ''
488
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
488
+		: "\n<input type='hidden' name='server_db' value=\"".spip_htmlspecialchars($server_db).'" />'
489 489
 	);
490 490
 }
491 491
 
Please login to merge, or discard this patch.
ecrire/inc/modeles.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 /**
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function traiter_modeles($texte, $doublons = false, $echap = '', string $connect = '', ?Spip\Texte\Collecteur\Liens $collecteurLiens = null, $env = []) {
27 27
 
28
-	include_spip('src/Texte/Collecteur/AbstractCollecteur');
29
-	include_spip('src/Texte/Collecteur/Modeles');
30
-	$collecteurModeles = new Spip\Texte\Collecteur\Modeles();
28
+    include_spip('src/Texte/Collecteur/AbstractCollecteur');
29
+    include_spip('src/Texte/Collecteur/Modeles');
30
+    $collecteurModeles = new Spip\Texte\Collecteur\Modeles();
31 31
 
32
-	$options = [
33
-		'doublons' => $doublons,
34
-		'echap' => $echap,
35
-		'connect' => $connect,
36
-		'collecteurLiens' => $collecteurLiens,
37
-		'env' => $env
38
-	];
39
-	return $collecteurModeles->traiter($texte ?? '', $options);
32
+    $options = [
33
+        'doublons' => $doublons,
34
+        'echap' => $echap,
35
+        'connect' => $connect,
36
+        'collecteurLiens' => $collecteurLiens,
37
+        'env' => $env
38
+    ];
39
+    return $collecteurModeles->traiter($texte ?? '', $options);
40 40
 }
Please login to merge, or discard this patch.
ecrire/inc/recherche_to_array.php 2 patches
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -10,291 +10,291 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 
17 17
 // methodes sql
18 18
 function inc_recherche_to_array_dist($recherche, $options = []) {
19 19
 
20
-	// options par defaut
21
-	$options = array_merge(
22
-		[
23
-			'score' => true,
24
-			'champs' => false,
25
-			'toutvoir' => false,
26
-			'matches' => false,
27
-			'jointures' => false
28
-		],
29
-		$options
30
-	);
20
+    // options par defaut
21
+    $options = array_merge(
22
+        [
23
+            'score' => true,
24
+            'champs' => false,
25
+            'toutvoir' => false,
26
+            'matches' => false,
27
+            'jointures' => false
28
+        ],
29
+        $options
30
+    );
31 31
 
32
-	include_spip('inc/rechercher');
33
-	include_spip('inc/autoriser');
32
+    include_spip('inc/rechercher');
33
+    include_spip('inc/autoriser');
34 34
 
35
-	$requete = [
36
-		'SELECT' => [],
37
-		'FROM' => [],
38
-		'WHERE' => [],
39
-		'GROUPBY' => [],
40
-		'ORDERBY' => [],
41
-		'LIMIT' => '',
42
-		'HAVING' => []
43
-	];
35
+    $requete = [
36
+        'SELECT' => [],
37
+        'FROM' => [],
38
+        'WHERE' => [],
39
+        'GROUPBY' => [],
40
+        'ORDERBY' => [],
41
+        'LIMIT' => '',
42
+        'HAVING' => []
43
+    ];
44 44
 
45
-	$table = sinon($options['table'], 'article');
46
-	if ($options['champs']) {
47
-		$champs = $options['champs'];
48
-	} else {
49
-		$l = liste_des_champs();
50
-		$champs = $l['article'];
51
-	}
52
-	$serveur = $options['serveur'];
45
+    $table = sinon($options['table'], 'article');
46
+    if ($options['champs']) {
47
+        $champs = $options['champs'];
48
+    } else {
49
+        $l = liste_des_champs();
50
+        $champs = $l['article'];
51
+    }
52
+    $serveur = $options['serveur'];
53 53
 
54
-	[$methode, $q, $preg] = expression_recherche($recherche, $options);
54
+    [$methode, $q, $preg] = expression_recherche($recherche, $options);
55 55
 
56
-	$jointures = $options['jointures']
57
-		? liste_des_jointures()
58
-		: [];
56
+    $jointures = $options['jointures']
57
+        ? liste_des_jointures()
58
+        : [];
59 59
 
60
-	$_id_table = id_table_objet($table);
60
+    $_id_table = id_table_objet($table);
61 61
 
62
-	// c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
63
-	// (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
64
-	if (str_contains($_id_table, ',')) {
65
-		$_id_table = explode(',', $_id_table);
66
-		$_id_table = reset($_id_table);
67
-	}
62
+    // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
63
+    // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
64
+    if (str_contains($_id_table, ',')) {
65
+        $_id_table = explode(',', $_id_table);
66
+        $_id_table = reset($_id_table);
67
+    }
68 68
 
69
-	$requete['SELECT'][] = 't.' . $_id_table;
70
-	$a = [];
71
-	// Recherche fulltext
72
-	foreach ($champs as $champ => $poids) {
73
-		if (is_array($champ)) {
74
-			spip_log('requetes imbriquees interdites');
75
-		} else {
76
-			if (!str_contains($champ, '.')) {
77
-				$champ = "t.$champ";
78
-			}
79
-			$requete['SELECT'][] = $champ;
80
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
81
-		}
82
-	}
83
-	if ($a) {
84
-		$requete['WHERE'][] = implode(' OR ', $a);
85
-	}
86
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
69
+    $requete['SELECT'][] = 't.' . $_id_table;
70
+    $a = [];
71
+    // Recherche fulltext
72
+    foreach ($champs as $champ => $poids) {
73
+        if (is_array($champ)) {
74
+            spip_log('requetes imbriquees interdites');
75
+        } else {
76
+            if (!str_contains($champ, '.')) {
77
+                $champ = "t.$champ";
78
+            }
79
+            $requete['SELECT'][] = $champ;
80
+            $a[] = $champ . ' ' . $methode . ' ' . $q;
81
+        }
82
+    }
83
+    if ($a) {
84
+        $requete['WHERE'][] = implode(' OR ', $a);
85
+    }
86
+    $requete['FROM'][] = table_objet_sql($table) . ' AS t';
87 87
 
88
-	$results = [];
88
+    $results = [];
89 89
 
90
-	$s = sql_select(
91
-		$requete['SELECT'],
92
-		$requete['FROM'],
93
-		$requete['WHERE'],
94
-		implode(' ', $requete['GROUPBY']),
95
-		$requete['ORDERBY'],
96
-		$requete['LIMIT'],
97
-		$requete['HAVING'],
98
-		$serveur
99
-	);
90
+    $s = sql_select(
91
+        $requete['SELECT'],
92
+        $requete['FROM'],
93
+        $requete['WHERE'],
94
+        implode(' ', $requete['GROUPBY']),
95
+        $requete['ORDERBY'],
96
+        $requete['LIMIT'],
97
+        $requete['HAVING'],
98
+        $serveur
99
+    );
100 100
 
101
-	while (
102
-		($t = sql_fetch($s, $serveur))
103
-		&& (!isset($t['score']) || $t['score'] > 0)
104
-	) {
105
-		$id = (int) $t[$_id_table];
101
+    while (
102
+        ($t = sql_fetch($s, $serveur))
103
+        && (!isset($t['score']) || $t['score'] > 0)
104
+    ) {
105
+        $id = (int) $t[$_id_table];
106 106
 
107
-		if ($options['toutvoir'] || autoriser('voir', $table, $id)) {
108
-			// indiquer les champs concernes
109
-			$champs_vus = [];
110
-			$score = 0;
111
-			$matches = [];
107
+        if ($options['toutvoir'] || autoriser('voir', $table, $id)) {
108
+            // indiquer les champs concernes
109
+            $champs_vus = [];
110
+            $score = 0;
111
+            $matches = [];
112 112
 
113
-			$vu = false;
114
-			foreach ($champs as $champ => $poids) {
115
-				$champ = explode('.', $champ);
116
-				$champ = end($champ);
117
-				// translitteration_rapide uniquement si on est deja en utf-8
118
-				$value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
119
-				if (
120
-					$n =
121
-					($options['score'] || $options['matches'])
122
-						? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
123
-						: preg_match($preg, $value)
124
-				) {
125
-					$vu = true;
113
+            $vu = false;
114
+            foreach ($champs as $champ => $poids) {
115
+                $champ = explode('.', $champ);
116
+                $champ = end($champ);
117
+                // translitteration_rapide uniquement si on est deja en utf-8
118
+                $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
119
+                if (
120
+                    $n =
121
+                    ($options['score'] || $options['matches'])
122
+                        ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
123
+                        : preg_match($preg, $value)
124
+                ) {
125
+                    $vu = true;
126 126
 
127
-					if ($options['champs']) {
128
-						$champs_vus[$champ] = $t[$champ];
129
-					}
130
-					if ($options['score']) {
131
-						// compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
132
-						$score += $poids * strlen(implode('', array_column($regs, 0)));
133
-					}
127
+                    if ($options['champs']) {
128
+                        $champs_vus[$champ] = $t[$champ];
129
+                    }
130
+                    if ($options['score']) {
131
+                        // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
132
+                        $score += $poids * strlen(implode('', array_column($regs, 0)));
133
+                    }
134 134
 
135
-					if ($options['matches']) {
136
-						$matches[$champ] = $regs;
137
-					}
135
+                    if ($options['matches']) {
136
+                        $matches[$champ] = $regs;
137
+                    }
138 138
 
139
-					if (!$options['champs'] && !$options['score'] && !$options['matches']) {
140
-						break;
141
-					}
142
-				}
143
-			}
139
+                    if (!$options['champs'] && !$options['score'] && !$options['matches']) {
140
+                        break;
141
+                    }
142
+                }
143
+            }
144 144
 
145
-			if ($vu) {
146
-				if (!isset($results)) {
147
-					$results = [];
148
-				}
149
-				$results[$id] = [];
150
-				if ($champs_vus) {
151
-					$results[$id]['champs'] = $champs_vus;
152
-				}
153
-				if ($score) {
154
-					$results[$id]['score'] = $score;
155
-				}
156
-				if ($matches) {
157
-					$results[$id]['matches'] = $matches;
158
-				}
159
-			}
160
-		}
161
-	}
145
+            if ($vu) {
146
+                if (!isset($results)) {
147
+                    $results = [];
148
+                }
149
+                $results[$id] = [];
150
+                if ($champs_vus) {
151
+                    $results[$id]['champs'] = $champs_vus;
152
+                }
153
+                if ($score) {
154
+                    $results[$id]['score'] = $score;
155
+                }
156
+                if ($matches) {
157
+                    $results[$id]['matches'] = $matches;
158
+                }
159
+            }
160
+        }
161
+    }
162 162
 
163 163
 
164
-	// Gerer les donnees associees
165
-	// ici on est un peu naze : pas capables de reconstruire une jointure complexe
166
-	// on ne sait passer que par table de laison en 1 coup
167
-	if (
168
-		isset($jointures[$table])
169
-		&& ($joints = recherche_en_base(
170
-			$recherche,
171
-			$jointures[$table],
172
-			array_merge($options, ['jointures' => false])
173
-		))
174
-	) {
175
-		include_spip('action/editer_liens');
176
-		$trouver_table = charger_fonction('trouver_table', 'base');
177
-		$cle_depart = id_table_objet($table);
178
-		$table_depart = table_objet($table, $serveur);
179
-		$desc_depart = $trouver_table($table_depart, $serveur);
180
-		$depart_associable = objet_associable($table);
181
-		foreach ($joints as $table_liee => $ids_trouves) {
182
-			// on peut definir une fonction de recherche jointe pour regler les cas particuliers
183
-			if (
184
-				!(
185
-				($rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true))
186
-				|| ($rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true))
187
-				|| ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true))
188
-				)
189
-			) {
190
-				$cle_arrivee = id_table_objet($table_liee);
191
-				$table_arrivee = table_objet($table_liee, $serveur);
192
-				$desc_arrivee = $trouver_table($table_arrivee, $serveur);
193
-				// cas simple : $cle_depart dans la table_liee
194
-				if (isset($desc_arrivee['field'][$cle_depart])) {
195
-					$s = sql_select(
196
-						"$cle_depart, $cle_arrivee",
197
-						$desc_arrivee['table_sql'],
198
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
199
-						'',
200
-						'',
201
-						'',
202
-						'',
203
-						$serveur
204
-					);
205
-				} // cas simple : $cle_arrivee dans la table
206
-				elseif (isset($desc_depart['field'][$cle_arrivee])) {
207
-					$s = sql_select(
208
-						"$cle_depart, $cle_arrivee",
209
-						$desc_depart['table_sql'],
210
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
211
-						'',
212
-						'',
213
-						'',
214
-						'',
215
-						$serveur
216
-					);
217
-				}
218
-				// sinon cherchons une table de liaison
219
-				// cas recherche principale article, objet lie document : passer par spip_documents_liens
220
-				elseif ($l = objet_associable($table_liee)) {
221
-					[$primary, $table_liens] = $l;
222
-					$s = sql_select(
223
-						"id_objet as $cle_depart, $primary as $cle_arrivee",
224
-						$table_liens,
225
-						["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
226
-						'',
227
-						'',
228
-						'',
229
-						'',
230
-						$serveur
231
-					);
232
-				} // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
233
-				elseif ($l = $depart_associable) {
234
-					[$primary, $table_liens] = $l;
235
-					$s = sql_select(
236
-						"$primary as $cle_depart, id_objet as $cle_arrivee",
237
-						$table_liens,
238
-						["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
239
-						'',
240
-						'',
241
-						'',
242
-						'',
243
-						$serveur
244
-					);
245
-				} // cas table de liaison generique spip_xxx_yyy
246
-				elseif (
247
-					($t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur))
248
-					|| ($t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur))
249
-				) {
250
-					$s = sql_select(
251
-						"$cle_depart,$cle_arrivee",
252
-						$t['table_sql'],
253
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
254
-						'',
255
-						'',
256
-						'',
257
-						'',
258
-						$serveur
259
-					);
260
-				}
261
-			} else {
262
-				[$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
263
-					$table,
264
-					$table_liee,
265
-					array_keys($ids_trouves),
266
-					$serveur
267
-				);
268
-			}
164
+    // Gerer les donnees associees
165
+    // ici on est un peu naze : pas capables de reconstruire une jointure complexe
166
+    // on ne sait passer que par table de laison en 1 coup
167
+    if (
168
+        isset($jointures[$table])
169
+        && ($joints = recherche_en_base(
170
+            $recherche,
171
+            $jointures[$table],
172
+            array_merge($options, ['jointures' => false])
173
+        ))
174
+    ) {
175
+        include_spip('action/editer_liens');
176
+        $trouver_table = charger_fonction('trouver_table', 'base');
177
+        $cle_depart = id_table_objet($table);
178
+        $table_depart = table_objet($table, $serveur);
179
+        $desc_depart = $trouver_table($table_depart, $serveur);
180
+        $depart_associable = objet_associable($table);
181
+        foreach ($joints as $table_liee => $ids_trouves) {
182
+            // on peut definir une fonction de recherche jointe pour regler les cas particuliers
183
+            if (
184
+                !(
185
+                ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true))
186
+                || ($rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true))
187
+                || ($rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true))
188
+                )
189
+            ) {
190
+                $cle_arrivee = id_table_objet($table_liee);
191
+                $table_arrivee = table_objet($table_liee, $serveur);
192
+                $desc_arrivee = $trouver_table($table_arrivee, $serveur);
193
+                // cas simple : $cle_depart dans la table_liee
194
+                if (isset($desc_arrivee['field'][$cle_depart])) {
195
+                    $s = sql_select(
196
+                        "$cle_depart, $cle_arrivee",
197
+                        $desc_arrivee['table_sql'],
198
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
199
+                        '',
200
+                        '',
201
+                        '',
202
+                        '',
203
+                        $serveur
204
+                    );
205
+                } // cas simple : $cle_arrivee dans la table
206
+                elseif (isset($desc_depart['field'][$cle_arrivee])) {
207
+                    $s = sql_select(
208
+                        "$cle_depart, $cle_arrivee",
209
+                        $desc_depart['table_sql'],
210
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
211
+                        '',
212
+                        '',
213
+                        '',
214
+                        '',
215
+                        $serveur
216
+                    );
217
+                }
218
+                // sinon cherchons une table de liaison
219
+                // cas recherche principale article, objet lie document : passer par spip_documents_liens
220
+                elseif ($l = objet_associable($table_liee)) {
221
+                    [$primary, $table_liens] = $l;
222
+                    $s = sql_select(
223
+                        "id_objet as $cle_depart, $primary as $cle_arrivee",
224
+                        $table_liens,
225
+                        ["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
226
+                        '',
227
+                        '',
228
+                        '',
229
+                        '',
230
+                        $serveur
231
+                    );
232
+                } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
233
+                elseif ($l = $depart_associable) {
234
+                    [$primary, $table_liens] = $l;
235
+                    $s = sql_select(
236
+                        "$primary as $cle_depart, id_objet as $cle_arrivee",
237
+                        $table_liens,
238
+                        ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
239
+                        '',
240
+                        '',
241
+                        '',
242
+                        '',
243
+                        $serveur
244
+                    );
245
+                } // cas table de liaison generique spip_xxx_yyy
246
+                elseif (
247
+                    ($t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur))
248
+                    || ($t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur))
249
+                ) {
250
+                    $s = sql_select(
251
+                        "$cle_depart,$cle_arrivee",
252
+                        $t['table_sql'],
253
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
254
+                        '',
255
+                        '',
256
+                        '',
257
+                        '',
258
+                        $serveur
259
+                    );
260
+                }
261
+            } else {
262
+                [$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
263
+                    $table,
264
+                    $table_liee,
265
+                    array_keys($ids_trouves),
266
+                    $serveur
267
+                );
268
+            }
269 269
 
270
-			while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
271
-				$id = $t[$cle_depart];
272
-				$joint = $ids_trouves[$t[$cle_arrivee]];
273
-				if (!isset($results)) {
274
-					$results = [];
275
-				}
276
-				if (!isset($results[$id])) {
277
-					$results[$id] = [];
278
-				}
279
-				if (isset($joint['score']) && $joint['score']) {
280
-					if (!isset($results[$id]['score'])) {
281
-						$results[$id]['score'] = 0;
282
-					}
283
-					$results[$id]['score'] += $joint['score'];
284
-				}
285
-				if (isset($joint['champs']) && $joint['champs']) {
286
-					foreach ($joint['champs'] as $c => $val) {
287
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
288
-					}
289
-				}
290
-				if (isset($joint['matches']) && $joint['matches']) {
291
-					foreach ($joint['matches'] as $c => $val) {
292
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
293
-					}
294
-				}
295
-			}
296
-		}
297
-	}
270
+            while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
271
+                $id = $t[$cle_depart];
272
+                $joint = $ids_trouves[$t[$cle_arrivee]];
273
+                if (!isset($results)) {
274
+                    $results = [];
275
+                }
276
+                if (!isset($results[$id])) {
277
+                    $results[$id] = [];
278
+                }
279
+                if (isset($joint['score']) && $joint['score']) {
280
+                    if (!isset($results[$id]['score'])) {
281
+                        $results[$id]['score'] = 0;
282
+                    }
283
+                    $results[$id]['score'] += $joint['score'];
284
+                }
285
+                if (isset($joint['champs']) && $joint['champs']) {
286
+                    foreach ($joint['champs'] as $c => $val) {
287
+                        $results[$id]['champs'][$table_liee . '.' . $c] = $val;
288
+                    }
289
+                }
290
+                if (isset($joint['matches']) && $joint['matches']) {
291
+                    foreach ($joint['matches'] as $c => $val) {
292
+                        $results[$id]['matches'][$table_liee . '.' . $c] = $val;
293
+                    }
294
+                }
295
+            }
296
+        }
297
+    }
298 298
 
299
-	return $results;
299
+    return $results;
300 300
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		$_id_table = reset($_id_table);
67 67
 	}
68 68
 
69
-	$requete['SELECT'][] = 't.' . $_id_table;
69
+	$requete['SELECT'][] = 't.'.$_id_table;
70 70
 	$a = [];
71 71
 	// Recherche fulltext
72 72
 	foreach ($champs as $champ => $poids) {
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
 				$champ = "t.$champ";
78 78
 			}
79 79
 			$requete['SELECT'][] = $champ;
80
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
80
+			$a[] = $champ.' '.$methode.' '.$q;
81 81
 		}
82 82
 	}
83 83
 	if ($a) {
84 84
 		$requete['WHERE'][] = implode(' OR ', $a);
85 85
 	}
86
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
86
+	$requete['FROM'][] = table_objet_sql($table).' AS t';
87 87
 
88 88
 	$results = [];
89 89
 
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 					);
245 245
 				} // cas table de liaison generique spip_xxx_yyy
246 246
 				elseif (
247
-					($t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur))
248
-					|| ($t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur))
247
+					($t = $trouver_table($table_arrivee.'_'.$table_depart, $serveur))
248
+					|| ($t = $trouver_table($table_depart.'_'.$table_arrivee, $serveur))
249 249
 				) {
250 250
 					$s = sql_select(
251 251
 						"$cle_depart,$cle_arrivee",
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 				}
285 285
 				if (isset($joint['champs']) && $joint['champs']) {
286 286
 					foreach ($joint['champs'] as $c => $val) {
287
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
287
+						$results[$id]['champs'][$table_liee.'.'.$c] = $val;
288 288
 					}
289 289
 				}
290 290
 				if (isset($joint['matches']) && $joint['matches']) {
291 291
 					foreach ($joint['matches'] as $c => $val) {
292
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
292
+						$results[$id]['matches'][$table_liee.'.'.$c] = $val;
293 293
 					}
294 294
 				}
295 295
 			}
Please login to merge, or discard this patch.
ecrire/inc/presenter_enfants.php 2 patches
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 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/autoriser');
@@ -29,74 +29,74 @@  discard block
 block discarded – undo
29 29
  *  Un tableau des sous rubriques
30 30
  */
31 31
 function enfant_rub($collection, $debut = 0, $limite = 500) {
32
-	$voir_logo = (isset($GLOBALS['meta']['image_process']) && $GLOBALS['meta']['image_process'] != 'non');
33
-	$logo = '';
34
-
35
-	if ($voir_logo) {
36
-		$chercher_logo = charger_fonction('chercher_logo', 'inc');
37
-		include_spip('inc/filtres_images_mini');
38
-	}
39
-
40
-	$res = [];
41
-
42
-	$result = sql_select(
43
-		'id_rubrique, id_parent, titre, descriptif, lang',
44
-		'spip_rubriques',
45
-		'id_parent=' . (int) $collection,
46
-		'',
47
-		'0+titre,titre',
48
-		$debut == -1 ? '' : "$debut,$limite"
49
-	);
50
-	while ($row = sql_fetch($result)) {
51
-		$id_rubrique = $row['id_rubrique'];
52
-		$id_parent = $row['id_parent'];
53
-		// pour etre sur de passer par tous les traitements
54
-		$titre = generer_objet_info($id_rubrique, 'rubrique', 'titre');
55
-		if ('' !== ($rang = recuperer_numero($row['titre']))) {
56
-			$rang = "<span class='rang'>$rang.</span> ";
57
-		}
58
-
59
-		if (autoriser('voir', 'rubrique', $id_rubrique)) {
60
-			$les_sous_enfants = sous_enfant_rub($id_rubrique);
61
-
62
-			changer_typo($row['lang']);
63
-			$lang_dir = lang_dir($row['lang']);
64
-			$descriptif = propre($row['descriptif']);
65
-
66
-			if ($voir_logo && ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on'))) {
67
-				[$fid, $dir, $nom, $format] = $logo;
68
-				$logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
69
-				if ($logo) {
70
-					$logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">');
71
-				}
72
-			}
73
-
74
-			$lib_bouton = (acces_restreint_rubrique($id_rubrique)
75
-				? http_img_pack('auteur-0minirezo-16.png', '', " width='16' height='16'", _T('image_administrer_rubrique'))
76
-				: '') .
77
-				" <a class='titremlien' dir='$lang_dir'" .
78
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
79
-				" href='" .
80
-				generer_objet_url($id_rubrique, 'rubrique') .
81
-				"'><span class='titre'>" .
82
-				$rang . $titre
83
-				. '</span>'
84
-				. (is_string($logo) ? $logo : '')
85
-				. '</a>';
86
-
87
-			$titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
88
-				. ($descriptif ? "\n<div class='descriptif'>$descriptif</div>" : '')
89
-				;
90
-
91
-			$res[] =
92
-				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
93
-				$les_sous_enfants .
94
-				fin_cadre_sous_rub();
95
-		}
96
-	}
97
-
98
-	changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
99
-	return $res;
32
+    $voir_logo = (isset($GLOBALS['meta']['image_process']) && $GLOBALS['meta']['image_process'] != 'non');
33
+    $logo = '';
34
+
35
+    if ($voir_logo) {
36
+        $chercher_logo = charger_fonction('chercher_logo', 'inc');
37
+        include_spip('inc/filtres_images_mini');
38
+    }
39
+
40
+    $res = [];
41
+
42
+    $result = sql_select(
43
+        'id_rubrique, id_parent, titre, descriptif, lang',
44
+        'spip_rubriques',
45
+        'id_parent=' . (int) $collection,
46
+        '',
47
+        '0+titre,titre',
48
+        $debut == -1 ? '' : "$debut,$limite"
49
+    );
50
+    while ($row = sql_fetch($result)) {
51
+        $id_rubrique = $row['id_rubrique'];
52
+        $id_parent = $row['id_parent'];
53
+        // pour etre sur de passer par tous les traitements
54
+        $titre = generer_objet_info($id_rubrique, 'rubrique', 'titre');
55
+        if ('' !== ($rang = recuperer_numero($row['titre']))) {
56
+            $rang = "<span class='rang'>$rang.</span> ";
57
+        }
58
+
59
+        if (autoriser('voir', 'rubrique', $id_rubrique)) {
60
+            $les_sous_enfants = sous_enfant_rub($id_rubrique);
61
+
62
+            changer_typo($row['lang']);
63
+            $lang_dir = lang_dir($row['lang']);
64
+            $descriptif = propre($row['descriptif']);
65
+
66
+            if ($voir_logo && ($logo = $chercher_logo($id_rubrique, 'id_rubrique', 'on'))) {
67
+                [$fid, $dir, $nom, $format] = $logo;
68
+                $logo = image_recadre_avec_fallback("<img src='$fid' alt='' />", 70, 70);
69
+                if ($logo) {
70
+                    $logo = wrap(inserer_attribut($logo, 'class', 'logo'), '<span class="logo-carre">');
71
+                }
72
+            }
73
+
74
+            $lib_bouton = (acces_restreint_rubrique($id_rubrique)
75
+                ? http_img_pack('auteur-0minirezo-16.png', '', " width='16' height='16'", _T('image_administrer_rubrique'))
76
+                : '') .
77
+                " <a class='titremlien' dir='$lang_dir'" .
78
+                ($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
79
+                " href='" .
80
+                generer_objet_url($id_rubrique, 'rubrique') .
81
+                "'><span class='titre'>" .
82
+                $rang . $titre
83
+                . '</span>'
84
+                . (is_string($logo) ? $logo : '')
85
+                . '</a>';
86
+
87
+            $titre = bouton_block_depliable($lib_bouton, $les_sous_enfants ? false : -1, "enfants$id_rubrique")
88
+                . ($descriptif ? "\n<div class='descriptif'>$descriptif</div>" : '')
89
+                ;
90
+
91
+            $res[] =
92
+                debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
93
+                $les_sous_enfants .
94
+                fin_cadre_sous_rub();
95
+        }
96
+    }
97
+
98
+    changer_typo($GLOBALS['spip_lang']); # remettre la typo de l'interface pour la suite
99
+    return $res;
100 100
 }
101 101
 
102 102
 /**
@@ -109,71 +109,71 @@  discard block
 block discarded – undo
109 109
  *  Le contenu du bloc dépliable
110 110
  */
111 111
 function sous_enfant_rub($collection2) {
112
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $collection2);
113
-
114
-	$retour = '';
115
-	$pagination = '';
116
-	$debut = 0;
117
-	$limite = 500;
118
-
119
-	/**
120
-	 * On ne va afficher que 500 résultats max
121
-	 * Si > 500 on affiche une pagination
122
-	 */
123
-	if ($nb > $limite) {
124
-		$debut = _request('debut_rubrique' . $collection2) ?: $debut;
125
-		$pagination = chercher_filtre('pagination');
126
-		$pagination = '<nav class="pagination">' . $pagination(
127
-			$nb,
128
-			'_rubrique' . $collection2,
129
-			$debut,
130
-			$limite,
131
-			true,
132
-			'prive'
133
-		) . '</nav>';
134
-		$limite = $debut + $limite;
135
-	}
136
-
137
-	$result = sql_select(
138
-		'id_rubrique, id_parent, titre, lang',
139
-		'spip_rubriques',
140
-		'id_parent=' . (int) $collection2,
141
-		'',
142
-		'0+titre,titre',
143
-		$debut == -1 ? '' : "$debut,$limite"
144
-	);
145
-
146
-	while ($row = sql_fetch($result)) {
147
-		$id_rubrique2 = $row['id_rubrique'];
148
-		$titre2 = generer_objet_info(
149
-			$id_rubrique2,
150
-			'rubrique',
151
-			'titre'
152
-		); // pour etre sur de passer par tous les traitements
153
-		if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
154
-			$rang2 = "<span class='rang'>$rang2.</span> ";
155
-		}
156
-
157
-		changer_typo($row['lang']);
158
-		$lang_dir = lang_dir($row['lang']);
159
-		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
160
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url(
161
-				$id_rubrique2,
162
-				'rubrique'
163
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
164
-		}
165
-	}
166
-
167
-	$retour = $pagination . $retour . $pagination;
168
-
169
-	if (!$retour) {
170
-		return '';
171
-	}
172
-
173
-	return debut_block_depliable($debut > 0, "enfants$collection2")
174
-	. "\n<ul class='liste-items sous-sous-rub'>\n"
175
-	. $retour
176
-	. "</ul>\n" . fin_block() . "\n\n";
112
+    $nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $collection2);
113
+
114
+    $retour = '';
115
+    $pagination = '';
116
+    $debut = 0;
117
+    $limite = 500;
118
+
119
+    /**
120
+     * On ne va afficher que 500 résultats max
121
+     * Si > 500 on affiche une pagination
122
+     */
123
+    if ($nb > $limite) {
124
+        $debut = _request('debut_rubrique' . $collection2) ?: $debut;
125
+        $pagination = chercher_filtre('pagination');
126
+        $pagination = '<nav class="pagination">' . $pagination(
127
+            $nb,
128
+            '_rubrique' . $collection2,
129
+            $debut,
130
+            $limite,
131
+            true,
132
+            'prive'
133
+        ) . '</nav>';
134
+        $limite = $debut + $limite;
135
+    }
136
+
137
+    $result = sql_select(
138
+        'id_rubrique, id_parent, titre, lang',
139
+        'spip_rubriques',
140
+        'id_parent=' . (int) $collection2,
141
+        '',
142
+        '0+titre,titre',
143
+        $debut == -1 ? '' : "$debut,$limite"
144
+    );
145
+
146
+    while ($row = sql_fetch($result)) {
147
+        $id_rubrique2 = $row['id_rubrique'];
148
+        $titre2 = generer_objet_info(
149
+            $id_rubrique2,
150
+            'rubrique',
151
+            'titre'
152
+        ); // pour etre sur de passer par tous les traitements
153
+        if ('' !== ($rang2 = recuperer_numero($row['titre']))) {
154
+            $rang2 = "<span class='rang'>$rang2.</span> ";
155
+        }
156
+
157
+        changer_typo($row['lang']);
158
+        $lang_dir = lang_dir($row['lang']);
159
+        if (autoriser('voir', 'rubrique', $id_rubrique2)) {
160
+            $retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url(
161
+                $id_rubrique2,
162
+                'rubrique'
163
+            ) . "'>" . $rang2 . $titre2 . "</a></li>\n";
164
+        }
165
+    }
166
+
167
+    $retour = $pagination . $retour . $pagination;
168
+
169
+    if (!$retour) {
170
+        return '';
171
+    }
172
+
173
+    return debut_block_depliable($debut > 0, "enfants$collection2")
174
+    . "\n<ul class='liste-items sous-sous-rub'>\n"
175
+    . $retour
176
+    . "</ul>\n" . fin_block() . "\n\n";
177 177
 }
178 178
 
179 179
 /**
@@ -188,41 +188,41 @@  discard block
 block discarded – undo
188 188
  *  Le contenu textuel affiché, la liste des sous rubriques
189 189
  */
190 190
 function afficher_enfant_rub($id_rubrique = 0) {
191
-	$pagination = '';
192
-	$debut = 0;
193
-	$limite = 500;
194
-
195
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $id_rubrique);
196
-
197
-	if ($nb > $limite) {
198
-		$debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
199
-		$pagination = chercher_filtre('pagination');
200
-		$pagination = '<br class="nettoyeur"><nav class="pagination">' .
201
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
202
-		'</nav>';
203
-	}
204
-
205
-	$les_enfants = enfant_rub($id_rubrique, $debut, $limite);
206
-
207
-	if (!$n = count($les_enfants)) {
208
-		return '';
209
-	}
210
-
211
-	if ($n == 1) {
212
-		$les_enfants = reset($les_enfants);
213
-		$les_enfants2 = '';
214
-	} else {
215
-		$n = ceil($n / 2);
216
-		$les_enfants2 = implode('', array_slice($les_enfants, $n));
217
-		$les_enfants = implode('', array_slice($les_enfants, 0, $n));
218
-	}
219
-
220
-	return $pagination
221
-		. "<div class='gauche'>"
222
-		. $les_enfants
223
-		. '</div>'
224
-		. "<div class='droite'>"
225
-		. $les_enfants2
226
-		. '</div>'
227
-		. $pagination;
191
+    $pagination = '';
192
+    $debut = 0;
193
+    $limite = 500;
194
+
195
+    $nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $id_rubrique);
196
+
197
+    if ($nb > $limite) {
198
+        $debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
199
+        $pagination = chercher_filtre('pagination');
200
+        $pagination = '<br class="nettoyeur"><nav class="pagination">' .
201
+            $pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
202
+        '</nav>';
203
+    }
204
+
205
+    $les_enfants = enfant_rub($id_rubrique, $debut, $limite);
206
+
207
+    if (!$n = count($les_enfants)) {
208
+        return '';
209
+    }
210
+
211
+    if ($n == 1) {
212
+        $les_enfants = reset($les_enfants);
213
+        $les_enfants2 = '';
214
+    } else {
215
+        $n = ceil($n / 2);
216
+        $les_enfants2 = implode('', array_slice($les_enfants, $n));
217
+        $les_enfants = implode('', array_slice($les_enfants, 0, $n));
218
+    }
219
+
220
+    return $pagination
221
+        . "<div class='gauche'>"
222
+        . $les_enfants
223
+        . '</div>'
224
+        . "<div class='droite'>"
225
+        . $les_enfants2
226
+        . '</div>'
227
+        . $pagination;
228 228
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	$result = sql_select(
43 43
 		'id_rubrique, id_parent, titre, descriptif, lang',
44 44
 		'spip_rubriques',
45
-		'id_parent=' . (int) $collection,
45
+		'id_parent='.(int) $collection,
46 46
 		'',
47 47
 		'0+titre,titre',
48 48
 		$debut == -1 ? '' : "$debut,$limite"
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 
74 74
 			$lib_bouton = (acces_restreint_rubrique($id_rubrique)
75 75
 				? http_img_pack('auteur-0minirezo-16.png', '', " width='16' height='16'", _T('image_administrer_rubrique'))
76
-				: '') .
77
-				" <a class='titremlien' dir='$lang_dir'" .
78
-				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='" . $row['lang'] . "'" : '') .
79
-				" href='" .
80
-				generer_objet_url($id_rubrique, 'rubrique') .
81
-				"'><span class='titre'>" .
82
-				$rang . $titre
76
+				: '').
77
+				" <a class='titremlien' dir='$lang_dir'".
78
+				($row['lang'] !== $GLOBALS['spip_lang'] ? " hreflang='".$row['lang']."'" : '').
79
+				" href='".
80
+				generer_objet_url($id_rubrique, 'rubrique').
81
+				"'><span class='titre'>".
82
+				$rang.$titre
83 83
 				. '</span>'
84 84
 				. (is_string($logo) ? $logo : '')
85 85
 				. '</a>';
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 				;
90 90
 
91 91
 			$res[] =
92
-				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre) .
93
-				$les_sous_enfants .
92
+				debut_cadre_sous_rub(($id_parent ? 'rubrique-24.png' : 'secteur-24.png'), true, '', $titre).
93
+				$les_sous_enfants.
94 94
 				fin_cadre_sous_rub();
95 95
 		}
96 96
 	}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
  *  Le contenu du bloc dépliable
110 110
  */
111 111
 function sous_enfant_rub($collection2) {
112
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $collection2);
112
+	$nb = sql_countsel('spip_rubriques', 'id_parent='.(int) $collection2);
113 113
 
114 114
 	$retour = '';
115 115
 	$pagination = '';
@@ -121,23 +121,23 @@  discard block
 block discarded – undo
121 121
 	 * Si > 500 on affiche une pagination
122 122
 	 */
123 123
 	if ($nb > $limite) {
124
-		$debut = _request('debut_rubrique' . $collection2) ?: $debut;
124
+		$debut = _request('debut_rubrique'.$collection2) ?: $debut;
125 125
 		$pagination = chercher_filtre('pagination');
126
-		$pagination = '<nav class="pagination">' . $pagination(
126
+		$pagination = '<nav class="pagination">'.$pagination(
127 127
 			$nb,
128
-			'_rubrique' . $collection2,
128
+			'_rubrique'.$collection2,
129 129
 			$debut,
130 130
 			$limite,
131 131
 			true,
132 132
 			'prive'
133
-		) . '</nav>';
133
+		).'</nav>';
134 134
 		$limite = $debut + $limite;
135 135
 	}
136 136
 
137 137
 	$result = sql_select(
138 138
 		'id_rubrique, id_parent, titre, lang',
139 139
 		'spip_rubriques',
140
-		'id_parent=' . (int) $collection2,
140
+		'id_parent='.(int) $collection2,
141 141
 		'',
142 142
 		'0+titre,titre',
143 143
 		$debut == -1 ? '' : "$debut,$limite"
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 		changer_typo($row['lang']);
158 158
 		$lang_dir = lang_dir($row['lang']);
159 159
 		if (autoriser('voir', 'rubrique', $id_rubrique2)) {
160
-			$retour .= "\n<li class='item' dir='$lang_dir'><a href='" . generer_objet_url(
160
+			$retour .= "\n<li class='item' dir='$lang_dir'><a href='".generer_objet_url(
161 161
 				$id_rubrique2,
162 162
 				'rubrique'
163
-			) . "'>" . $rang2 . $titre2 . "</a></li>\n";
163
+			)."'>".$rang2.$titre2."</a></li>\n";
164 164
 		}
165 165
 	}
166 166
 
167
-	$retour = $pagination . $retour . $pagination;
167
+	$retour = $pagination.$retour.$pagination;
168 168
 
169 169
 	if (!$retour) {
170 170
 		return '';
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	return debut_block_depliable($debut > 0, "enfants$collection2")
174 174
 	. "\n<ul class='liste-items sous-sous-rub'>\n"
175 175
 	. $retour
176
-	. "</ul>\n" . fin_block() . "\n\n";
176
+	. "</ul>\n".fin_block()."\n\n";
177 177
 }
178 178
 
179 179
 /**
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 	$debut = 0;
193 193
 	$limite = 500;
194 194
 
195
-	$nb = sql_countsel('spip_rubriques', 'id_parent=' . (int) $id_rubrique);
195
+	$nb = sql_countsel('spip_rubriques', 'id_parent='.(int) $id_rubrique);
196 196
 
197 197
 	if ($nb > $limite) {
198
-		$debut = _request('debut_rubrique' . $id_rubrique) ?: $debut;
198
+		$debut = _request('debut_rubrique'.$id_rubrique) ?: $debut;
199 199
 		$pagination = chercher_filtre('pagination');
200
-		$pagination = '<br class="nettoyeur"><nav class="pagination">' .
201
-			$pagination($nb, '_rubrique' . $id_rubrique, $debut, $limite, true, 'prive') .
200
+		$pagination = '<br class="nettoyeur"><nav class="pagination">'.
201
+			$pagination($nb, '_rubrique'.$id_rubrique, $debut, $limite, true, 'prive').
202 202
 		'</nav>';
203 203
 	}
204 204
 
Please login to merge, or discard this patch.