Completed
Push — master ( 9b54d2...c65e43 )
by cam
01:57
created
ecrire/inc/definir_menus_favoris.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,19 +19,19 @@
 block discarded – undo
19 19
  * Retourne la liste des menus favoris par défaut ainsi que leur rang
20 20
  */
21 21
 function inc_definir_menus_favoris_dist() {
22
-	return [
22
+    return [
23 23
 
24
-		// Menu Édition,
25
-		'auteurs' => 1,
26
-		'rubriques' => 2,
27
-		'articles' => 3,
24
+        // Menu Édition,
25
+        'auteurs' => 1,
26
+        'rubriques' => 2,
27
+        'articles' => 3,
28 28
 
29
-		// Menu Maintenance
30
-		'admin_vider' => 1,
29
+        // Menu Maintenance
30
+        'admin_vider' => 1,
31 31
 
32
-		// Menu Configurations
33
-		'configurer_identite' => 1,
34
-		'admin_plugin' => 2,
32
+        // Menu Configurations
33
+        'configurer_identite' => 1,
34
+        'admin_plugin' => 2,
35 35
 
36
-	];
36
+    ];
37 37
 }
Please login to merge, or discard this patch.
ecrire/inc/admin.php 2 patches
Indentation   +134 added lines, -134 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
 /**
@@ -44,29 +44,29 @@  discard block
 block discarded – undo
44 44
  *     sinon code HTML de la page après le traitement effectué.
45 45
  **/
46 46
 function inc_admin_dist($script, $titre, $comment = '', $anonymous = false) {
47
-	$reprise = true;
48
-	if (
49
-		!isset($GLOBALS['meta'][$script])
50
-		|| !isset($GLOBALS['meta']['admin'])
51
-	) {
52
-		$reprise = false;
53
-		$res = debut_admin($script, $titre, $comment);
54
-		if ($res) {
55
-			return $res;
56
-		}
57
-		spip_log("meta: $script " . print_r($_POST, true));
58
-		ecrire_meta($script, serialize($_POST));
59
-	}
47
+    $reprise = true;
48
+    if (
49
+        !isset($GLOBALS['meta'][$script])
50
+        || !isset($GLOBALS['meta']['admin'])
51
+    ) {
52
+        $reprise = false;
53
+        $res = debut_admin($script, $titre, $comment);
54
+        if ($res) {
55
+            return $res;
56
+        }
57
+        spip_log("meta: $script " . print_r($_POST, true));
58
+        ecrire_meta($script, serialize($_POST));
59
+    }
60 60
 
61
-	$res = admin_verifie_session($script, $anonymous);
62
-	if ($res) {
63
-		return $res;
64
-	}
65
-	$base = charger_fonction($script, 'base');
66
-	$base($titre, $reprise);
67
-	fin_admin($script);
61
+    $res = admin_verifie_session($script, $anonymous);
62
+    if ($res) {
63
+        return $res;
64
+    }
65
+    $base = charger_fonction($script, 'base');
66
+    $base($titre, $reprise);
67
+    fin_admin($script);
68 68
 
69
-	return '';
69
+    return '';
70 70
 }
71 71
 
72 72
 /**
@@ -97,36 +97,36 @@  discard block
 block discarded – undo
97 97
  *     Code HTML si message d'erreur, '' sinon;
98 98
  */
99 99
 function admin_verifie_session($script, $anonymous = false) {
100
-	include_spip('base/abstract_sql');
101
-	$pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']);
102
-	$signal = fichier_admin($script, "$script$pref");
103
-	$valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
104
-	if ($valeur === null) {
105
-		ecrire_meta('admin', $signal, 'non');
106
-	} else {
107
-		if (
108
-			!$anonymous
109
-			&& $valeur != $signal
110
-			&& (
111
-				!preg_match('/^(.*)_(\d+)_/', (string) $GLOBALS['meta']['admin'], $l)
112
-				|| (int) $l[2] != $GLOBALS['visiteur_session']['id_auteur']
113
-			)
114
-		) {
115
-			include_spip('inc/minipres');
116
-			spip_log("refus de lancer $script, priorite a $valeur");
117
-			return minipres(_T('info_travaux_texte'), '', ['status' => 503]);
118
-		}
119
-	}
120
-	$journal = 'spip';
121
-	if (autoriser('configurer')) {
122
-		// c'est une action webmestre, soit par ftp soit par statut webmestre
123
-		$journal = 'webmestre';
124
-	}
125
-	// on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
100
+    include_spip('base/abstract_sql');
101
+    $pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']);
102
+    $signal = fichier_admin($script, "$script$pref");
103
+    $valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
104
+    if ($valeur === null) {
105
+        ecrire_meta('admin', $signal, 'non');
106
+    } else {
107
+        if (
108
+            !$anonymous
109
+            && $valeur != $signal
110
+            && (
111
+                !preg_match('/^(.*)_(\d+)_/', (string) $GLOBALS['meta']['admin'], $l)
112
+                || (int) $l[2] != $GLOBALS['visiteur_session']['id_auteur']
113
+            )
114
+        ) {
115
+            include_spip('inc/minipres');
116
+            spip_log("refus de lancer $script, priorite a $valeur");
117
+            return minipres(_T('info_travaux_texte'), '', ['status' => 503]);
118
+        }
119
+    }
120
+    $journal = 'spip';
121
+    if (autoriser('configurer')) {
122
+        // c'est une action webmestre, soit par ftp soit par statut webmestre
123
+        $journal = 'webmestre';
124
+    }
125
+    // on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
126 126
 
127
-	spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal);
127
+    spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal);
128 128
 
129
-	return '';
129
+    return '';
130 130
 }
131 131
 
132 132
 /**
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
  *     Chemin du répertoire.
140 140
  **/
141 141
 function dir_admin() {
142
-	if (autoriser('configurer')) {
143
-		return _DIR_TMP;
144
-	} else {
145
-		return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
146
-	}
142
+    if (autoriser('configurer')) {
143
+        return _DIR_TMP;
144
+    } else {
145
+        return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
146
+    }
147 147
 }
148 148
 
149 149
 /**
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
  *     Nom du fichier
161 161
  **/
162 162
 function fichier_admin($action, $pref = 'admin_') {
163
-	return $pref .
164
-	substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10);
163
+    return $pref .
164
+    substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10);
165 165
 }
166 166
 
167 167
 /**
@@ -187,76 +187,76 @@  discard block
 block discarded – undo
187 187
  *     sinon chaîne vide si déjà fait.
188 188
  **/
189 189
 function debut_admin($script, $action = '', $corps = '') {
190
-	if (
191
-		!$action
192
-		|| !autoriser('webmestre') && !autoriser('chargerftp')
193
-	) {
194
-		include_spip('inc/minipres');
190
+    if (
191
+        !$action
192
+        || !autoriser('webmestre') && !autoriser('chargerftp')
193
+    ) {
194
+        include_spip('inc/minipres');
195 195
 
196
-		return minipres();
197
-	} else {
198
-		$dir = dir_admin();
199
-		$signal = fichier_admin($script);
200
-		if (@file_exists($dir . $signal)) {
201
-			spip_log("Action admin: $action");
196
+        return minipres();
197
+    } else {
198
+        $dir = dir_admin();
199
+        $signal = fichier_admin($script);
200
+        if (@file_exists($dir . $signal)) {
201
+            spip_log("Action admin: $action");
202 202
 
203
-			return '';
204
-		}
205
-		include_spip('inc/minipres');
203
+            return '';
204
+        }
205
+        include_spip('inc/minipres');
206 206
 
207
-		// Si on est un super-admin, un bouton de validation suffit
208
-		// sauf dans les cas destroy
209
-		if (
210
-			(autoriser('webmestre') || $script === 'repair')
211
-			&& $script != 'delete_all'
212
-		) {
213
-			if (_request('validation_admin') == $signal) {
214
-				spip_log("Action super-admin: $action");
207
+        // Si on est un super-admin, un bouton de validation suffit
208
+        // sauf dans les cas destroy
209
+        if (
210
+            (autoriser('webmestre') || $script === 'repair')
211
+            && $script != 'delete_all'
212
+        ) {
213
+            if (_request('validation_admin') == $signal) {
214
+                spip_log("Action super-admin: $action");
215 215
 
216
-				return '';
217
-			}
218
-			$corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />';
219
-			$suivant = _T('bouton_valider');
220
-			$js = '';
221
-		} else {
222
-			// cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
223
-			// l'insertion du script a cet endroit n'est pas xhtml licite
224
-			// mais evite de l'embarquer dans toutes les pages minipres
225
-			$corps .= http_script('', 'spip_barre.js');
216
+                return '';
217
+            }
218
+            $corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />';
219
+            $suivant = _T('bouton_valider');
220
+            $js = '';
221
+        } else {
222
+            // cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
223
+            // l'insertion du script a cet endroit n'est pas xhtml licite
224
+            // mais evite de l'embarquer dans toutes les pages minipres
225
+            $corps .= http_script('', 'spip_barre.js');
226 226
 
227
-			$corps .= '<fieldset><legend>'
228
-				. _T('info_authentification_ftp')
229
-				. aider('ftp_auth')
230
-				. "</legend>\n<label for='fichier'>"
231
-				. _T('info_creer_repertoire')
232
-				. "</label>\n"
233
-				. "<span id='signal' class='formo'>" . $signal . '</span>'
234
-				. "<input type='hidden' id='fichier' name='fichier' value='"
235
-				. $signal
236
-				. "' />"
237
-				. _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)])
238
-				. '</fieldset>';
227
+            $corps .= '<fieldset><legend>'
228
+                . _T('info_authentification_ftp')
229
+                . aider('ftp_auth')
230
+                . "</legend>\n<label for='fichier'>"
231
+                . _T('info_creer_repertoire')
232
+                . "</label>\n"
233
+                . "<span id='signal' class='formo'>" . $signal . '</span>'
234
+                . "<input type='hidden' id='fichier' name='fichier' value='"
235
+                . $signal
236
+                . "' />"
237
+                . _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)])
238
+                . '</fieldset>';
239 239
 
240
-			$suivant = _T('bouton_recharger_page');
240
+            $suivant = _T('bouton_recharger_page');
241 241
 
242
-			// code volontairement tordu:
243
-			// provoquer la copie dans le presse papier du nom du repertoire
244
-			// en remettant a vide le champ pour que ca marche aussi en cas
245
-			// de JavaScript inactif.
246
-			$js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
247
-		}
242
+            // code volontairement tordu:
243
+            // provoquer la copie dans le presse papier du nom du repertoire
244
+            // en remettant a vide le champ pour que ca marche aussi en cas
245
+            // de JavaScript inactif.
246
+            $js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
247
+        }
248 248
 
249
-		// admin/xxx correspond
250
-		// a exec/base_xxx de preference
251
-		// et exec/xxx sinon (compat)
252
-		if (tester_url_ecrire("base_$script")) {
253
-			$script = "base_$script";
254
-		}
255
-		$form = copy_request($script, $corps, $suivant);
256
-		$info_action = _T('info_action', ['action' => "$action"]);
249
+        // admin/xxx correspond
250
+        // a exec/base_xxx de preference
251
+        // et exec/xxx sinon (compat)
252
+        if (tester_url_ecrire("base_$script")) {
253
+            $script = "base_$script";
254
+        }
255
+        $form = copy_request($script, $corps, $suivant);
256
+        $info_action = _T('info_action', ['action' => "$action"]);
257 257
 
258
-		return minipres($info_action, $form, ['onload' => $js]);
259
-	}
258
+        return minipres($info_action, $form, ['onload' => $js]);
259
+    }
260 260
 }
261 261
 
262 262
 /**
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
  *     Nom de l'action (en base) qui a été exécutée
268 268
  **/
269 269
 function fin_admin($action) {
270
-	$signal = dir_admin() . fichier_admin($action);
271
-	spip_unlink($signal);
272
-	if ($action != 'delete_all') {
273
-		effacer_meta($action);
274
-		effacer_meta('admin');
275
-		spip_log("efface les meta admin et $action ");
276
-	}
270
+    $signal = dir_admin() . fichier_admin($action);
271
+    spip_unlink($signal);
272
+    if ($action != 'delete_all') {
273
+        effacer_meta($action);
274
+        effacer_meta('admin');
275
+        spip_log("efface les meta admin et $action ");
276
+    }
277 277
 }
278 278
 
279 279
 /**
@@ -292,14 +292,14 @@  discard block
 block discarded – undo
292 292
  *     Code HTML du formulaire
293 293
  **/
294 294
 function copy_request($script, $suite, $submit = '') {
295
-	include_spip('inc/filtres');
296
-	foreach ([...$_POST, ...$_GET] as $n => $c) {
297
-		if (!in_array($n, ['fichier', 'exec', 'validation_admin']) && !is_array($c)) {
298
-			$suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" .
299
-				entites_html($c) .
300
-				"'  />";
301
-		}
302
-	}
295
+    include_spip('inc/filtres');
296
+    foreach ([...$_POST, ...$_GET] as $n => $c) {
297
+        if (!in_array($n, ['fichier', 'exec', 'validation_admin']) && !is_array($c)) {
298
+            $suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" .
299
+                entites_html($c) .
300
+                "'  />";
301
+        }
302
+    }
303 303
 
304
-	return generer_form_ecrire($script, $suite, '', $submit);
304
+    return generer_form_ecrire($script, $suite, '', $submit);
305 305
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		if ($res) {
55 55
 			return $res;
56 56
 		}
57
-		spip_log("meta: $script " . print_r($_POST, true));
57
+		spip_log("meta: $script ".print_r($_POST, true));
58 58
 		ecrire_meta($script, serialize($_POST));
59 59
 	}
60 60
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	}
125 125
 	// on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
126 126
 
127
-	spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal);
127
+	spip_log("admin $pref".($valeur ? ' (reprise)' : ' (init)'), $journal);
128 128
 
129 129
 	return '';
130 130
 }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	if (autoriser('configurer')) {
143 143
 		return _DIR_TMP;
144 144
 	} else {
145
-		return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
145
+		return _DIR_TRANSFERT.$GLOBALS['visiteur_session']['login'].'/';
146 146
 	}
147 147
 }
148 148
 
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
  *     Nom du fichier
161 161
  **/
162 162
 function fichier_admin($action, $pref = 'admin_') {
163
-	return $pref .
164
-	substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10);
163
+	return $pref.
164
+	substr(md5($action.(time() & ~2047).$GLOBALS['visiteur_session']['login']), 0, 10);
165 165
 }
166 166
 
167 167
 /**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	} else {
198 198
 		$dir = dir_admin();
199 199
 		$signal = fichier_admin($script);
200
-		if (@file_exists($dir . $signal)) {
200
+		if (@file_exists($dir.$signal)) {
201 201
 			spip_log("Action admin: $action");
202 202
 
203 203
 			return '';
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
 				return '';
217 217
 			}
218
-			$corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />';
218
+			$corps .= '<input type="hidden" name="validation_admin" value="'.$signal.'" />';
219 219
 			$suivant = _T('bouton_valider');
220 220
 			$js = '';
221 221
 		} else {
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 				. "</legend>\n<label for='fichier'>"
231 231
 				. _T('info_creer_repertoire')
232 232
 				. "</label>\n"
233
-				. "<span id='signal' class='formo'>" . $signal . '</span>'
233
+				. "<span id='signal' class='formo'>".$signal.'</span>'
234 234
 				. "<input type='hidden' id='fichier' name='fichier' value='"
235 235
 				. $signal
236 236
 				. "' />"
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
  *     Nom de l'action (en base) qui a été exécutée
268 268
  **/
269 269
 function fin_admin($action) {
270
-	$signal = dir_admin() . fichier_admin($action);
270
+	$signal = dir_admin().fichier_admin($action);
271 271
 	spip_unlink($signal);
272 272
 	if ($action != 'delete_all') {
273 273
 		effacer_meta($action);
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 	include_spip('inc/filtres');
296 296
 	foreach ([...$_POST, ...$_GET] as $n => $c) {
297 297
 		if (!in_array($n, ['fichier', 'exec', 'validation_admin']) && !is_array($c)) {
298
-			$suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" .
299
-				entites_html($c) .
298
+			$suite .= "\n<input type='hidden' name='".spip_htmlspecialchars($n)."' value='".
299
+				entites_html($c).
300 300
 				"'  />";
301 301
 		}
302 302
 	}
Please login to merge, or discard this patch.
ecrire/inc/editer.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -336,8 +336,7 @@
 block discarded – undo
336 336
 		if (!autoriser('modifier', $type, (int) $id)) {
337 337
 			$contexte['editable'] = '';
338 338
 		}
339
-	}
340
-	else {
339
+	} else {
341 340
 		if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) {
342 341
 			$contexte['editable'] = '';
343 342
 		}
Please login to merge, or discard this patch.
Indentation   +414 added lines, -414 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('base/abstract_sql');
22 22
 
@@ -58,56 +58,56 @@  discard block
 block discarded – undo
58 58
  *     Retour des traitements.
59 59
  **/
60 60
 function formulaires_editer_objet_traiter(
61
-	$type,
62
-	$id = 'new',
63
-	$id_parent = 0,
64
-	$lier_trad = 0,
65
-	$retour = '',
66
-	$config_fonc = 'articles_edit_config',
67
-	$row = [],
68
-	$hidden = ''
61
+    $type,
62
+    $id = 'new',
63
+    $id_parent = 0,
64
+    $lier_trad = 0,
65
+    $retour = '',
66
+    $config_fonc = 'articles_edit_config',
67
+    $row = [],
68
+    $hidden = ''
69 69
 ) {
70 70
 
71
-	$res = [];
72
-	// eviter la redirection forcee par l'action...
73
-	set_request('redirect');
74
-	if ($action_editer = charger_fonction("editer_$type", 'action', true)) {
75
-		[$id, $err] = $action_editer($id);
76
-	} else {
77
-		$action_editer = charger_fonction('editer_objet', 'action');
78
-		[$id, $err] = $action_editer($id, $type);
79
-	}
80
-	$id_table_objet = id_table_objet($type);
81
-	$res[$id_table_objet] = $id;
82
-	if ($err || !$id) {
83
-		$res['message_erreur'] = ($err ?: _T('erreur'));
84
-	} else {
85
-		// Un lien de trad a prendre en compte
86
-		if ($lier_trad) {
87
-			// referencer la traduction
88
-			$referencer_traduction = charger_fonction('referencer_traduction', 'action');
89
-			$referencer_traduction($type, $id, $lier_trad);
90
-			// actions de recopie de champs / liens sur le nouvel objet créé
91
-			$completer_traduction = charger_fonction('completer_traduction', 'inc');
92
-			$err = $completer_traduction($type, $id, $lier_trad);
93
-			if ($err) {
94
-				$res['message_erreur'] = $err;
95
-				return $res;
96
-			}
97
-		}
98
-
99
-		$res['message_ok'] = _T('info_modification_enregistree');
100
-		if ($retour) {
101
-			if (str_starts_with($retour, 'javascript:')) {
102
-				$res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>';
103
-				$res['editable'] = true;
104
-			} else {
105
-				$res['redirect'] = parametre_url($retour, $id_table_objet, $id);
106
-			}
107
-		}
108
-	}
109
-
110
-	return $res;
71
+    $res = [];
72
+    // eviter la redirection forcee par l'action...
73
+    set_request('redirect');
74
+    if ($action_editer = charger_fonction("editer_$type", 'action', true)) {
75
+        [$id, $err] = $action_editer($id);
76
+    } else {
77
+        $action_editer = charger_fonction('editer_objet', 'action');
78
+        [$id, $err] = $action_editer($id, $type);
79
+    }
80
+    $id_table_objet = id_table_objet($type);
81
+    $res[$id_table_objet] = $id;
82
+    if ($err || !$id) {
83
+        $res['message_erreur'] = ($err ?: _T('erreur'));
84
+    } else {
85
+        // Un lien de trad a prendre en compte
86
+        if ($lier_trad) {
87
+            // referencer la traduction
88
+            $referencer_traduction = charger_fonction('referencer_traduction', 'action');
89
+            $referencer_traduction($type, $id, $lier_trad);
90
+            // actions de recopie de champs / liens sur le nouvel objet créé
91
+            $completer_traduction = charger_fonction('completer_traduction', 'inc');
92
+            $err = $completer_traduction($type, $id, $lier_trad);
93
+            if ($err) {
94
+                $res['message_erreur'] = $err;
95
+                return $res;
96
+            }
97
+        }
98
+
99
+        $res['message_ok'] = _T('info_modification_enregistree');
100
+        if ($retour) {
101
+            if (str_starts_with($retour, 'javascript:')) {
102
+                $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>';
103
+                $res['editable'] = true;
104
+            } else {
105
+                $res['redirect'] = parametre_url($retour, $id_table_objet, $id);
106
+            }
107
+        }
108
+    }
109
+
110
+    return $res;
111 111
 }
112 112
 
113 113
 /**
@@ -131,29 +131,29 @@  discard block
 block discarded – undo
131 131
  *     Tableau des erreurs
132 132
  **/
133 133
 function formulaires_editer_objet_verifier($type, $id = 'new', $oblis = []) {
134
-	$erreurs = [];
135
-	if ((int) $id) {
136
-		$conflits = controler_contenu($type, $id);
137
-		if ($conflits && (is_countable($conflits) ? count($conflits) : 0)) {
138
-			foreach ($conflits as $champ => $conflit) {
139
-				if (!isset($erreurs[$champ])) {
140
-					$erreurs[$champ] = '';
141
-				}
142
-				$erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>';
143
-			}
144
-		}
145
-	}
146
-	foreach ($oblis as $obli) {
147
-		$value = _request($obli);
148
-		if (is_null($value) || !(is_array($value) ? count($value) : strlen((string) $value))) {
149
-			if (!isset($erreurs[$obli])) {
150
-				$erreurs[$obli] = '';
151
-			}
152
-			$erreurs[$obli] .= _T('info_obligatoire');
153
-		}
154
-	}
155
-
156
-	return $erreurs;
134
+    $erreurs = [];
135
+    if ((int) $id) {
136
+        $conflits = controler_contenu($type, $id);
137
+        if ($conflits && (is_countable($conflits) ? count($conflits) : 0)) {
138
+            foreach ($conflits as $champ => $conflit) {
139
+                if (!isset($erreurs[$champ])) {
140
+                    $erreurs[$champ] = '';
141
+                }
142
+                $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>';
143
+            }
144
+        }
145
+    }
146
+    foreach ($oblis as $obli) {
147
+        $value = _request($obli);
148
+        if (is_null($value) || !(is_array($value) ? count($value) : strlen((string) $value))) {
149
+            if (!isset($erreurs[$obli])) {
150
+                $erreurs[$obli] = '';
151
+            }
152
+            $erreurs[$obli] .= _T('info_obligatoire');
153
+        }
154
+    }
155
+
156
+    return $erreurs;
157 157
 }
158 158
 
159 159
 /**
@@ -198,151 +198,151 @@  discard block
 block discarded – undo
198 198
  *     Environnement du formulaire.
199 199
  **/
200 200
 function formulaires_editer_objet_charger(
201
-	$type,
202
-	$id = 'new',
203
-	$id_parent = 0,
204
-	$lier_trad = 0,
205
-	$retour = '',
206
-	$config_fonc = 'articles_edit_config',
207
-	$row = [],
208
-	$hidden = ''
201
+    $type,
202
+    $id = 'new',
203
+    $id_parent = 0,
204
+    $lier_trad = 0,
205
+    $retour = '',
206
+    $config_fonc = 'articles_edit_config',
207
+    $row = [],
208
+    $hidden = ''
209 209
 ) {
210 210
 
211
-	$table_objet = table_objet($type);
212
-	$table_objet_sql = table_objet_sql($type);
213
-	$id_table_objet = id_table_objet($type);
214
-	if (!is_array($row)) {
215
-		$row = [];
216
-	}
217
-
218
-	// on accepte pas une fonction de config inconnue si elle vient d'un modele
219
-	if (
220
-		$config_fonc
221
-		&& !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config'])
222
-		&& $config_fonc !== $table_objet . '_edit_config'
223
-		&& ($args = test_formulaire_inclus_par_modele())
224
-		&& in_array($config_fonc, $args)
225
-	) {
226
-		$config_fonc = '';
227
-	}
228
-
229
-	$new = !is_numeric($id);
230
-	$lang_default = '';
231
-	// Appel direct dans un squelette
232
-	if (!$row) {
233
-		if (!$new || $lier_trad) {
234
-			if ($select = charger_fonction('precharger_' . $type, 'inc', true)) {
235
-				$row = $select($id, $id_parent, $lier_trad);
236
-				// si on a une fonction precharger, elle pu faire un reglage de langue
237
-				$lang_default = (empty($row['lang']) ? null : $row['lang']);
238
-			} else {
239
-				$row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . (int) $id);
240
-			}
241
-			if (!$new) {
242
-				$md5 = controles_md5($row ?: []);
243
-			}
244
-		}
245
-		if (!$row) {
246
-			$row = [];
247
-			$trouver_table = charger_fonction('trouver_table', 'base');
248
-			if ($desc = $trouver_table($table_objet)) {
249
-				foreach ($desc['field'] as $k => $v) {
250
-					$row[$k] = '';
251
-				}
252
-			}
253
-		}
254
-	}
255
-
256
-	// Gaffe: sans ceci, on ecrase systematiquement l'article d'origine
257
-	// (et donc: pas de lien de traduction)
258
-	$id = ($new || $lier_trad)
259
-		? 'oui'
260
-		: $row[$id_table_objet];
261
-	$row[$id_table_objet] = $id;
262
-
263
-	$contexte = $row;
264
-	if (is_numeric($id_parent) && strlen($id_parent) && (!isset($contexte['id_parent']) || $new)) {
265
-		if (!isset($contexte['id_parent'])) {
266
-			unset($contexte['id_rubrique']);
267
-		}
268
-		$contexte['id_parent'] = $id_parent;
269
-	} elseif (!isset($contexte['id_parent'])) {
270
-		// id_rubrique dans id_parent si possible
271
-		if (isset($contexte['id_rubrique'])) {
272
-			$contexte['id_parent'] = $contexte['id_rubrique'];
273
-			unset($contexte['id_rubrique']);
274
-		} else {
275
-			$contexte['id_parent'] = '';
276
-		}
277
-		if (
278
-			!$contexte['id_parent']
279
-			&& ($preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true))
280
-		) {
281
-			$contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row);
282
-		}
283
-	}
284
-
285
-	$config = [];
286
-	if ($config_fonc) {
287
-		$contexte['config'] = $config = $config_fonc($contexte);
288
-		if (!$lang_default) {
289
-			include_spip('inc/session');
290
-			$lang_default = $config['langue'] ?? session_get('lang') ;
291
-		}
292
-	}
293
-	$config += [
294
-		'lignes' => 0,
295
-		'langue' => '',
296
-	];
297
-
298
-	$att_text = " class='textarea' "
299
-		. " rows='"
300
-		. ($config['lignes'] + 15)
301
-		. "' cols='40'";
302
-
303
-
304
-	// on veut conserver la langue de l'interface ;
305
-	// on passe cette donnee sous un autre nom, au cas ou le squelette
306
-	// voudrait l'exploiter
307
-	if (isset($contexte['lang'])) {
308
-		$contexte['langue'] = $contexte['lang'];
309
-		unset($contexte['lang']);
310
-	}
311
-
312
-	$contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" .
313
-		($lier_trad
314
-			 ? "\n<input type='hidden' name='lier_trad' value='" .
315
-				$lier_trad .
316
-				"' />" .
317
-				"\n<input type='hidden' name='changer_lang' value='" .
318
-				$lang_default .
319
-				"' />"
320
-			: '')
321
-		. $hidden
322
-		. ($md5 ?? '');
323
-
324
-	// preciser que le formulaire doit passer dans un pipeline
325
-	$contexte['_pipeline'] = ['editer_contenu_objet', ['type' => $type, 'id' => $id]];
326
-
327
-	// preciser que le formulaire doit etre securise auteur/action
328
-	// n'est plus utile lorsque l'action accepte l'id en argument direct
329
-	// on le garde pour compat
330
-	$contexte['_action'] = ["editer_$type", $id];
331
-
332
-	// et in fine placer l'autorisation
333
-	include_spip('inc/autoriser');
334
-	if ((int) $id) {
335
-		if (!autoriser('modifier', $type, (int) $id)) {
336
-			$contexte['editable'] = '';
337
-		}
338
-	}
339
-	else {
340
-		if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) {
341
-			$contexte['editable'] = '';
342
-		}
343
-	}
344
-
345
-	return $contexte;
211
+    $table_objet = table_objet($type);
212
+    $table_objet_sql = table_objet_sql($type);
213
+    $id_table_objet = id_table_objet($type);
214
+    if (!is_array($row)) {
215
+        $row = [];
216
+    }
217
+
218
+    // on accepte pas une fonction de config inconnue si elle vient d'un modele
219
+    if (
220
+        $config_fonc
221
+        && !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config'])
222
+        && $config_fonc !== $table_objet . '_edit_config'
223
+        && ($args = test_formulaire_inclus_par_modele())
224
+        && in_array($config_fonc, $args)
225
+    ) {
226
+        $config_fonc = '';
227
+    }
228
+
229
+    $new = !is_numeric($id);
230
+    $lang_default = '';
231
+    // Appel direct dans un squelette
232
+    if (!$row) {
233
+        if (!$new || $lier_trad) {
234
+            if ($select = charger_fonction('precharger_' . $type, 'inc', true)) {
235
+                $row = $select($id, $id_parent, $lier_trad);
236
+                // si on a une fonction precharger, elle pu faire un reglage de langue
237
+                $lang_default = (empty($row['lang']) ? null : $row['lang']);
238
+            } else {
239
+                $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . (int) $id);
240
+            }
241
+            if (!$new) {
242
+                $md5 = controles_md5($row ?: []);
243
+            }
244
+        }
245
+        if (!$row) {
246
+            $row = [];
247
+            $trouver_table = charger_fonction('trouver_table', 'base');
248
+            if ($desc = $trouver_table($table_objet)) {
249
+                foreach ($desc['field'] as $k => $v) {
250
+                    $row[$k] = '';
251
+                }
252
+            }
253
+        }
254
+    }
255
+
256
+    // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine
257
+    // (et donc: pas de lien de traduction)
258
+    $id = ($new || $lier_trad)
259
+        ? 'oui'
260
+        : $row[$id_table_objet];
261
+    $row[$id_table_objet] = $id;
262
+
263
+    $contexte = $row;
264
+    if (is_numeric($id_parent) && strlen($id_parent) && (!isset($contexte['id_parent']) || $new)) {
265
+        if (!isset($contexte['id_parent'])) {
266
+            unset($contexte['id_rubrique']);
267
+        }
268
+        $contexte['id_parent'] = $id_parent;
269
+    } elseif (!isset($contexte['id_parent'])) {
270
+        // id_rubrique dans id_parent si possible
271
+        if (isset($contexte['id_rubrique'])) {
272
+            $contexte['id_parent'] = $contexte['id_rubrique'];
273
+            unset($contexte['id_rubrique']);
274
+        } else {
275
+            $contexte['id_parent'] = '';
276
+        }
277
+        if (
278
+            !$contexte['id_parent']
279
+            && ($preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true))
280
+        ) {
281
+            $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row);
282
+        }
283
+    }
284
+
285
+    $config = [];
286
+    if ($config_fonc) {
287
+        $contexte['config'] = $config = $config_fonc($contexte);
288
+        if (!$lang_default) {
289
+            include_spip('inc/session');
290
+            $lang_default = $config['langue'] ?? session_get('lang') ;
291
+        }
292
+    }
293
+    $config += [
294
+        'lignes' => 0,
295
+        'langue' => '',
296
+    ];
297
+
298
+    $att_text = " class='textarea' "
299
+        . " rows='"
300
+        . ($config['lignes'] + 15)
301
+        . "' cols='40'";
302
+
303
+
304
+    // on veut conserver la langue de l'interface ;
305
+    // on passe cette donnee sous un autre nom, au cas ou le squelette
306
+    // voudrait l'exploiter
307
+    if (isset($contexte['lang'])) {
308
+        $contexte['langue'] = $contexte['lang'];
309
+        unset($contexte['lang']);
310
+    }
311
+
312
+    $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" .
313
+        ($lier_trad
314
+             ? "\n<input type='hidden' name='lier_trad' value='" .
315
+                $lier_trad .
316
+                "' />" .
317
+                "\n<input type='hidden' name='changer_lang' value='" .
318
+                $lang_default .
319
+                "' />"
320
+            : '')
321
+        . $hidden
322
+        . ($md5 ?? '');
323
+
324
+    // preciser que le formulaire doit passer dans un pipeline
325
+    $contexte['_pipeline'] = ['editer_contenu_objet', ['type' => $type, 'id' => $id]];
326
+
327
+    // preciser que le formulaire doit etre securise auteur/action
328
+    // n'est plus utile lorsque l'action accepte l'id en argument direct
329
+    // on le garde pour compat
330
+    $contexte['_action'] = ["editer_$type", $id];
331
+
332
+    // et in fine placer l'autorisation
333
+    include_spip('inc/autoriser');
334
+    if ((int) $id) {
335
+        if (!autoriser('modifier', $type, (int) $id)) {
336
+            $contexte['editable'] = '';
337
+        }
338
+    }
339
+    else {
340
+        if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) {
341
+            $contexte['editable'] = '';
342
+        }
343
+    }
344
+
345
+    return $contexte;
346 346
 }
347 347
 
348 348
 /**
@@ -353,29 +353,29 @@  discard block
 block discarded – undo
353 353
  * @return array
354 354
  */
355 355
 function coupe_trop_long($texte) {
356
-	$aider = charger_fonction('aider', 'inc');
357
-	if (strlen($texte) > 28 * 1024) {
358
-		$texte = str_replace("\r\n", "\n", $texte);
359
-		$pos = strpos($texte, "\n\n", 28 * 1024);  // coupe para > 28 ko
360
-		if ($pos > 0 && $pos < 32 * 1024) {
361
-			$debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n";
362
-			$suite = substr($texte, $pos + 2);
363
-		} else {
364
-			$pos = strpos($texte, ' ', 28 * 1024);  // sinon coupe espace
365
-			if (!($pos > 0 && $pos < 32 * 1024)) {
366
-				$pos = 28 * 1024;  // au pire (pas d'espace trouv'e)
367
-				$decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere
368
-			} else {
369
-				$decalage = 1;
370
-			}
371
-			$debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un
372
-			$suite = substr($texte, $pos + $decalage);
373
-		}
374
-
375
-		return ([$debut, $suite]);
376
-	} else {
377
-		return ([$texte, '']);
378
-	}
356
+    $aider = charger_fonction('aider', 'inc');
357
+    if (strlen($texte) > 28 * 1024) {
358
+        $texte = str_replace("\r\n", "\n", $texte);
359
+        $pos = strpos($texte, "\n\n", 28 * 1024);  // coupe para > 28 ko
360
+        if ($pos > 0 && $pos < 32 * 1024) {
361
+            $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n";
362
+            $suite = substr($texte, $pos + 2);
363
+        } else {
364
+            $pos = strpos($texte, ' ', 28 * 1024);  // sinon coupe espace
365
+            if (!($pos > 0 && $pos < 32 * 1024)) {
366
+                $pos = 28 * 1024;  // au pire (pas d'espace trouv'e)
367
+                $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere
368
+            } else {
369
+                $decalage = 1;
370
+            }
371
+            $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un
372
+            $suite = substr($texte, $pos + $decalage);
373
+        }
374
+
375
+        return ([$debut, $suite]);
376
+    } else {
377
+        return ([$texte, '']);
378
+    }
379 379
 }
380 380
 
381 381
 /**
@@ -386,13 +386,13 @@  discard block
 block discarded – undo
386 386
  * @param int $longueur
387 387
  */
388 388
 function titre_automatique($champ_titre, $champs_contenu, $longueur = null) {
389
-	if (!_request($champ_titre)) {
390
-		$titrer_contenu = charger_fonction('titrer_contenu', 'inc');
391
-		$t = is_null($longueur) ? $titrer_contenu($champs_contenu) : $titrer_contenu($champs_contenu, null, $longueur);
392
-		if ($t) {
393
-			set_request($champ_titre, $t);
394
-		}
395
-	}
389
+    if (!_request($champ_titre)) {
390
+        $titrer_contenu = charger_fonction('titrer_contenu', 'inc');
391
+        $t = is_null($longueur) ? $titrer_contenu($champs_contenu) : $titrer_contenu($champs_contenu, null, $longueur);
392
+        if ($t) {
393
+            set_request($champ_titre, $t);
394
+        }
395
+    }
396 396
 }
397 397
 
398 398
 /**
@@ -412,20 +412,20 @@  discard block
 block discarded – undo
412 412
  * @return string
413 413
  */
414 414
 function inc_titrer_contenu_dist($champs_contenu, $c = null, $longueur = 50) {
415
-	// trouver un champ texte non vide
416
-	$t = '';
417
-	foreach ($champs_contenu as $champ) {
418
-		if ($t = _request($champ, $c)) {
419
-			break;
420
-		}
421
-	}
422
-
423
-	if ($t) {
424
-		include_spip('inc/texte_mini');
425
-		$t = couper($t, $longueur, '...');
426
-	}
427
-
428
-	return $t;
415
+    // trouver un champ texte non vide
416
+    $t = '';
417
+    foreach ($champs_contenu as $champ) {
418
+        if ($t = _request($champ, $c)) {
419
+            break;
420
+        }
421
+    }
422
+
423
+    if ($t) {
424
+        include_spip('inc/texte_mini');
425
+        $t = couper($t, $longueur, '...');
426
+    }
427
+
428
+    return $t;
429 429
 }
430 430
 
431 431
 /**
@@ -447,22 +447,22 @@  discard block
 block discarded – undo
447 447
  *      - array sinon couples ('$prefixe$colonne => md5)
448 448
  **/
449 449
 function controles_md5(array $data, string $prefixe = 'ctr_', string $format = 'html') {
450
-	$ctr = [];
451
-	foreach ($data as $key => $val) {
452
-		$m = md5($val ?? '');
453
-		$k = $prefixe . $key;
454
-
455
-		$ctr[$k] = match ($format) {
456
-			'html' => "<input type='hidden' value='$m' name='$k' />",
457
-			default => $m,
458
-		};
459
-	}
460
-
461
-	if ($format === 'html') {
462
-		return "\n\n<!-- controles md5 -->\n" . implode("\n", $ctr) . "\n\n";
463
-	} else {
464
-		return $ctr;
465
-	}
450
+    $ctr = [];
451
+    foreach ($data as $key => $val) {
452
+        $m = md5($val ?? '');
453
+        $k = $prefixe . $key;
454
+
455
+        $ctr[$k] = match ($format) {
456
+            'html' => "<input type='hidden' value='$m' name='$k' />",
457
+            default => $m,
458
+        };
459
+    }
460
+
461
+    if ($format === 'html') {
462
+        return "\n\n<!-- controles md5 -->\n" . implode("\n", $ctr) . "\n\n";
463
+    } else {
464
+        return $ctr;
465
+    }
466 466
 }
467 467
 
468 468
 /**
@@ -501,80 +501,80 @@  discard block
 block discarded – undo
501 501
  *     - post : le contenu posté
502 502
  **/
503 503
 function controler_contenu($type, $id, $options = [], $c = false, $serveur = '') {
504
-	include_spip('inc/filtres');
505
-
506
-	$table_objet = table_objet($type);
507
-	$spip_table_objet = table_objet_sql($type);
508
-	$trouver_table = charger_fonction('trouver_table', 'base');
509
-	$desc = $trouver_table($table_objet, $serveur);
510
-
511
-	// Appels incomplets (sans $c)
512
-	if (!is_array($c)) {
513
-		$c = [];
514
-		foreach ($desc['field'] as $champ => $ignore) {
515
-			if (_request($champ)) {
516
-				$c[$champ] = _request($champ);
517
-			}
518
-		}
519
-	}
520
-
521
-	// Securite : certaines variables ne sont jamais acceptees ici
522
-	// car elles ne relevent pas de autoriser(article, modifier) ;
523
-	// il faut passer par instituer_XX()
524
-	// TODO: faut-il passer ces variables interdites
525
-	// dans un fichier de description separe ?
526
-	unset($c['statut']);
527
-	unset($c['id_parent']);
528
-	unset($c['id_rubrique']);
529
-	unset($c['id_secteur']);
530
-
531
-	// Gerer les champs non vides
532
-	if (isset($options['nonvide']) && is_array($options['nonvide'])) {
533
-		foreach ($options['nonvide'] as $champ => $sinon) {
534
-			if ($c[$champ] === '') {
535
-				$c[$champ] = $sinon;
536
-			}
537
-		}
538
-	}
539
-
540
-	// N'accepter que les champs qui existent
541
-	// [TODO] ici aussi on peut valider les contenus en fonction du type
542
-	$champs = [];
543
-	foreach ($desc['field'] as $champ => $ignore) {
544
-		if (isset($c[$champ])) {
545
-			$champs[$champ] = $c[$champ];
546
-		}
547
-	}
548
-
549
-	// Nettoyer les valeurs
550
-	$champs = array_map('corriger_caracteres', $champs);
551
-
552
-	// Envoyer aux plugins
553
-	$champs = pipeline(
554
-		'pre_edition',
555
-		[
556
-			'args' => [
557
-				'table' => $spip_table_objet, // compatibilite
558
-				'table_objet' => $table_objet,
559
-				'spip_table_objet' => $spip_table_objet,
560
-				'type' => $type,
561
-				'id_objet' => $id,
562
-				'champs' => $options['champs'] ?? [], // [doc] c'est quoi ?
563
-				'action' => 'controler',
564
-				'serveur' => $serveur,
565
-			],
566
-			'data' => $champs
567
-		]
568
-	);
569
-
570
-	if (!$champs) {
571
-		return false;
572
-	}
573
-
574
-	// Verifier si les mises a jour sont pertinentes, datees, en conflit etc
575
-	$conflits = controler_md5($champs, $_POST, $type, $id, $serveur, $options['prefix'] ?? 'ctr_');
576
-
577
-	return $conflits;
504
+    include_spip('inc/filtres');
505
+
506
+    $table_objet = table_objet($type);
507
+    $spip_table_objet = table_objet_sql($type);
508
+    $trouver_table = charger_fonction('trouver_table', 'base');
509
+    $desc = $trouver_table($table_objet, $serveur);
510
+
511
+    // Appels incomplets (sans $c)
512
+    if (!is_array($c)) {
513
+        $c = [];
514
+        foreach ($desc['field'] as $champ => $ignore) {
515
+            if (_request($champ)) {
516
+                $c[$champ] = _request($champ);
517
+            }
518
+        }
519
+    }
520
+
521
+    // Securite : certaines variables ne sont jamais acceptees ici
522
+    // car elles ne relevent pas de autoriser(article, modifier) ;
523
+    // il faut passer par instituer_XX()
524
+    // TODO: faut-il passer ces variables interdites
525
+    // dans un fichier de description separe ?
526
+    unset($c['statut']);
527
+    unset($c['id_parent']);
528
+    unset($c['id_rubrique']);
529
+    unset($c['id_secteur']);
530
+
531
+    // Gerer les champs non vides
532
+    if (isset($options['nonvide']) && is_array($options['nonvide'])) {
533
+        foreach ($options['nonvide'] as $champ => $sinon) {
534
+            if ($c[$champ] === '') {
535
+                $c[$champ] = $sinon;
536
+            }
537
+        }
538
+    }
539
+
540
+    // N'accepter que les champs qui existent
541
+    // [TODO] ici aussi on peut valider les contenus en fonction du type
542
+    $champs = [];
543
+    foreach ($desc['field'] as $champ => $ignore) {
544
+        if (isset($c[$champ])) {
545
+            $champs[$champ] = $c[$champ];
546
+        }
547
+    }
548
+
549
+    // Nettoyer les valeurs
550
+    $champs = array_map('corriger_caracteres', $champs);
551
+
552
+    // Envoyer aux plugins
553
+    $champs = pipeline(
554
+        'pre_edition',
555
+        [
556
+            'args' => [
557
+                'table' => $spip_table_objet, // compatibilite
558
+                'table_objet' => $table_objet,
559
+                'spip_table_objet' => $spip_table_objet,
560
+                'type' => $type,
561
+                'id_objet' => $id,
562
+                'champs' => $options['champs'] ?? [], // [doc] c'est quoi ?
563
+                'action' => 'controler',
564
+                'serveur' => $serveur,
565
+            ],
566
+            'data' => $champs
567
+        ]
568
+    );
569
+
570
+    if (!$champs) {
571
+        return false;
572
+    }
573
+
574
+    // Verifier si les mises a jour sont pertinentes, datees, en conflit etc
575
+    $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, $options['prefix'] ?? 'ctr_');
576
+
577
+    return $conflits;
578 578
 }
579 579
 
580 580
 
@@ -604,66 +604,66 @@  discard block
 block discarded – undo
604 604
  *     - post : le contenu posté
605 605
  **/
606 606
 function controler_md5(&$champs, $ctr, $type, $id, $serveur, $prefix = 'ctr_') {
607
-	$spip_table_objet = table_objet_sql($type);
608
-	$id_table_objet = id_table_objet($type);
609
-
610
-	// Controle des MD5 envoyes
611
-	// On elimine les donnees non modifiees par le formulaire (mais
612
-	// potentiellement modifiees entre temps par un autre utilisateur)
613
-	foreach ($champs as $key => $val) {
614
-		if (
615
-			isset($ctr[$prefix . $key])
616
-			&& ($m = $ctr[$prefix . $key])
617
-			&& (is_scalar($val) && $m == md5($val))
618
-		) {
619
-			unset($champs[$key]);
620
-		}
621
-	}
622
-	if (!$champs) {
623
-		return;
624
-	}
625
-
626
-	// On veut savoir si notre modif va avoir un impact
627
-	// par rapport aux donnees contenues dans la base
628
-	// (qui peuvent etre differentes de celles ayant servi a calculer le ctr)
629
-	$s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur);
630
-	$intact = true;
631
-	foreach ($champs as $ch => $val) {
632
-		$intact &= ($s[$ch] == $val);
633
-	}
634
-	if ($intact) {
635
-		return;
636
-	}
637
-
638
-	// Detection de conflits :
639
-	// On verifie si notre modif ne provient pas d'un formulaire
640
-	// genere a partir de donnees modifiees dans l'intervalle ; ici
641
-	// on compare a ce qui est dans la base, et on bloque en cas
642
-	// de conflit.
643
-	$ctrh = $ctrq = $conflits = [];
644
-	foreach (array_keys($champs) as $key) {
645
-		if (isset($ctr[$prefix . $key]) && ($m = $ctr[$prefix . $key])) {
646
-			$ctrh[$key] = $m;
647
-			$ctrq[] = $key;
648
-		}
649
-	}
650
-	if ($ctrq) {
651
-		$ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur);
652
-		foreach ($ctrh as $key => $m) {
653
-			if (
654
-				$m != md5((string) $ctrq[$key])
655
-				&& $champs[$key] !== $ctrq[$key]
656
-			) {
657
-				$conflits[$key] = [
658
-					'base' => $ctrq[$key],
659
-					'post' => $champs[$key]
660
-				];
661
-				unset($champs[$key]); # stocker quand meme les modifs ?
662
-			}
663
-		}
664
-	}
665
-
666
-	return $conflits;
607
+    $spip_table_objet = table_objet_sql($type);
608
+    $id_table_objet = id_table_objet($type);
609
+
610
+    // Controle des MD5 envoyes
611
+    // On elimine les donnees non modifiees par le formulaire (mais
612
+    // potentiellement modifiees entre temps par un autre utilisateur)
613
+    foreach ($champs as $key => $val) {
614
+        if (
615
+            isset($ctr[$prefix . $key])
616
+            && ($m = $ctr[$prefix . $key])
617
+            && (is_scalar($val) && $m == md5($val))
618
+        ) {
619
+            unset($champs[$key]);
620
+        }
621
+    }
622
+    if (!$champs) {
623
+        return;
624
+    }
625
+
626
+    // On veut savoir si notre modif va avoir un impact
627
+    // par rapport aux donnees contenues dans la base
628
+    // (qui peuvent etre differentes de celles ayant servi a calculer le ctr)
629
+    $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur);
630
+    $intact = true;
631
+    foreach ($champs as $ch => $val) {
632
+        $intact &= ($s[$ch] == $val);
633
+    }
634
+    if ($intact) {
635
+        return;
636
+    }
637
+
638
+    // Detection de conflits :
639
+    // On verifie si notre modif ne provient pas d'un formulaire
640
+    // genere a partir de donnees modifiees dans l'intervalle ; ici
641
+    // on compare a ce qui est dans la base, et on bloque en cas
642
+    // de conflit.
643
+    $ctrh = $ctrq = $conflits = [];
644
+    foreach (array_keys($champs) as $key) {
645
+        if (isset($ctr[$prefix . $key]) && ($m = $ctr[$prefix . $key])) {
646
+            $ctrh[$key] = $m;
647
+            $ctrq[] = $key;
648
+        }
649
+    }
650
+    if ($ctrq) {
651
+        $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur);
652
+        foreach ($ctrh as $key => $m) {
653
+            if (
654
+                $m != md5((string) $ctrq[$key])
655
+                && $champs[$key] !== $ctrq[$key]
656
+            ) {
657
+                $conflits[$key] = [
658
+                    'base' => $ctrq[$key],
659
+                    'post' => $champs[$key]
660
+                ];
661
+                unset($champs[$key]); # stocker quand meme les modifs ?
662
+            }
663
+        }
664
+    }
665
+
666
+    return $conflits;
667 667
 }
668 668
 
669 669
 /**
@@ -675,9 +675,9 @@  discard block
 block discarded – undo
675 675
  * @return string
676 676
  */
677 677
 function display_conflit_champ($x) {
678
-	if (strstr($x, "\n") || strlen($x) > 80) {
679
-		return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n";
680
-	} else {
681
-		return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n";
682
-	}
678
+    if (strstr($x, "\n") || strlen($x) > 80) {
679
+        return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n";
680
+    } else {
681
+        return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n";
682
+    }
683 683
 }
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		$res['message_ok'] = _T('info_modification_enregistree');
100 100
 		if ($retour) {
101 101
 			if (str_starts_with($retour, 'javascript:')) {
102
-				$res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>';
102
+				$res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/'.substr($retour, 11).'/*]]>*/</script>';
103 103
 				$res['editable'] = true;
104 104
 			} else {
105 105
 				$res['redirect'] = parametre_url($retour, $id_table_objet, $id);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 				if (!isset($erreurs[$champ])) {
140 140
 					$erreurs[$champ] = '';
141 141
 				}
142
-				$erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>';
142
+				$erreurs[$champ] .= _T('alerte_modif_info_concourante')."<br /><textarea readonly='readonly' class='forml'>".entites_html($conflit['base']).'</textarea>';
143 143
 			}
144 144
 		}
145 145
 	}
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	if (
220 220
 		$config_fonc
221 221
 		&& !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config'])
222
-		&& $config_fonc !== $table_objet . '_edit_config'
222
+		&& $config_fonc !== $table_objet.'_edit_config'
223 223
 		&& ($args = test_formulaire_inclus_par_modele())
224 224
 		&& in_array($config_fonc, $args)
225 225
 	) {
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 	// Appel direct dans un squelette
232 232
 	if (!$row) {
233 233
 		if (!$new || $lier_trad) {
234
-			if ($select = charger_fonction('precharger_' . $type, 'inc', true)) {
234
+			if ($select = charger_fonction('precharger_'.$type, 'inc', true)) {
235 235
 				$row = $select($id, $id_parent, $lier_trad);
236 236
 				// si on a une fonction precharger, elle pu faire un reglage de langue
237 237
 				$lang_default = (empty($row['lang']) ? null : $row['lang']);
238 238
 			} else {
239
-				$row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . (int) $id);
239
+				$row = sql_fetsel('*', $table_objet_sql, $id_table_objet.'='.(int) $id);
240 240
 			}
241 241
 			if (!$new) {
242 242
 				$md5 = controles_md5($row ?: []);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		$contexte['config'] = $config = $config_fonc($contexte);
288 288
 		if (!$lang_default) {
289 289
 			include_spip('inc/session');
290
-			$lang_default = $config['langue'] ?? session_get('lang') ;
290
+			$lang_default = $config['langue'] ?? session_get('lang');
291 291
 		}
292 292
 	}
293 293
 	$config += [
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 		unset($contexte['lang']);
310 310
 	}
311 311
 
312
-	$contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" .
312
+	$contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n".
313 313
 		($lier_trad
314
-			 ? "\n<input type='hidden' name='lier_trad' value='" .
315
-				$lier_trad .
316
-				"' />" .
317
-				"\n<input type='hidden' name='changer_lang' value='" .
318
-				$lang_default .
314
+			 ? "\n<input type='hidden' name='lier_trad' value='".
315
+				$lier_trad.
316
+				"' />".
317
+				"\n<input type='hidden' name='changer_lang' value='".
318
+				$lang_default.
319 319
 				"' />"
320 320
 			: '')
321 321
 		. $hidden
@@ -356,14 +356,14 @@  discard block
 block discarded – undo
356 356
 	$aider = charger_fonction('aider', 'inc');
357 357
 	if (strlen($texte) > 28 * 1024) {
358 358
 		$texte = str_replace("\r\n", "\n", $texte);
359
-		$pos = strpos($texte, "\n\n", 28 * 1024);  // coupe para > 28 ko
359
+		$pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko
360 360
 		if ($pos > 0 && $pos < 32 * 1024) {
361
-			$debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n";
361
+			$debut = substr($texte, 0, $pos)."\n\n<!--SPIP-->\n";
362 362
 			$suite = substr($texte, $pos + 2);
363 363
 		} else {
364
-			$pos = strpos($texte, ' ', 28 * 1024);  // sinon coupe espace
364
+			$pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace
365 365
 			if (!($pos > 0 && $pos < 32 * 1024)) {
366
-				$pos = 28 * 1024;  // au pire (pas d'espace trouv'e)
366
+				$pos = 28 * 1024; // au pire (pas d'espace trouv'e)
367 367
 				$decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere
368 368
 			} else {
369 369
 				$decalage = 1;
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	$ctr = [];
451 451
 	foreach ($data as $key => $val) {
452 452
 		$m = md5($val ?? '');
453
-		$k = $prefixe . $key;
453
+		$k = $prefixe.$key;
454 454
 
455 455
 		$ctr[$k] = match ($format) {
456 456
 			'html' => "<input type='hidden' value='$m' name='$k' />",
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	}
460 460
 
461 461
 	if ($format === 'html') {
462
-		return "\n\n<!-- controles md5 -->\n" . implode("\n", $ctr) . "\n\n";
462
+		return "\n\n<!-- controles md5 -->\n".implode("\n", $ctr)."\n\n";
463 463
 	} else {
464 464
 		return $ctr;
465 465
 	}
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 	// potentiellement modifiees entre temps par un autre utilisateur)
613 613
 	foreach ($champs as $key => $val) {
614 614
 		if (
615
-			isset($ctr[$prefix . $key])
616
-			&& ($m = $ctr[$prefix . $key])
615
+			isset($ctr[$prefix.$key])
616
+			&& ($m = $ctr[$prefix.$key])
617 617
 			&& (is_scalar($val) && $m == md5($val))
618 618
 		) {
619 619
 			unset($champs[$key]);
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	// de conflit.
643 643
 	$ctrh = $ctrq = $conflits = [];
644 644
 	foreach (array_keys($champs) as $key) {
645
-		if (isset($ctr[$prefix . $key]) && ($m = $ctr[$prefix . $key])) {
645
+		if (isset($ctr[$prefix.$key]) && ($m = $ctr[$prefix.$key])) {
646 646
 			$ctrh[$key] = $m;
647 647
 			$ctrq[] = $key;
648 648
 		}
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
  */
677 677
 function display_conflit_champ($x) {
678 678
 	if (strstr($x, "\n") || strlen($x) > 80) {
679
-		return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n";
679
+		return "<textarea style='width:99%; height:10em;'>".entites_html($x)."</textarea>\n";
680 680
 	} else {
681
-		return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n";
681
+		return "<input type='text' size='40' style='width:99%' value=\"".entites_html($x)."\" />\n";
682 682
 	}
683 683
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_mini.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 
46 46
 	if ($query) {
47
-		$url .= '?' . $query;
47
+		$url .= '?'.$query;
48 48
 	}
49 49
 
50
-	return '/' . preg_replace(',^/,S', '', (string) $url);
50
+	return '/'.preg_replace(',^/,S', '', (string) $url);
51 51
 }
52 52
 
53 53
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	if (preg_match(';^((?:[a-z]{3,33}:)?//.*?)(/.*)?$;iS', $lien, $r)) {
78 78
 		$r = array_pad($r, 3, '');
79 79
 
80
-		return $r[1] . resolve_path($r[2]);
80
+		return $r[1].resolve_path($r[2]);
81 81
 	}
82 82
 
83 83
 	# L'url site spip est un lien absolu aussi
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
 		$hash = $regs[5] ?? '';
98 98
 	}
99 99
 	return match (substr($lien, 0, 1)) {
100
-		'/' => $debut . resolve_path($lien),
101
-		'#' => $debut . resolve_path($dir . $mot . $get . $lien),
102
-		'' => $debut . resolve_path($dir . $mot . $get . $hash),
103
-		default => $debut . resolve_path($dir . $lien),
100
+		'/' => $debut.resolve_path($lien),
101
+		'#' => $debut.resolve_path($dir.$mot.$get.$lien),
102
+		'' => $debut.resolve_path($dir.$mot.$get.$hash),
103
+		default => $debut.resolve_path($dir.$lien),
104 104
 	};
105 105
 }
106 106
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		return '';
130 130
 	}
131 131
 	if (!$base) {
132
-		$base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
132
+		$base = url_de_base().(_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
133 133
 	}
134 134
 
135 135
 	return suivre_lien($base, $url);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
  * @param array $protocoles_autorises
153 153
  * @return bool
154 154
  */
155
-function protocole_verifier($url_absolue, $protocoles_autorises = ['http','https']) {
155
+function protocole_verifier($url_absolue, $protocoles_autorises = ['http', 'https']) {
156 156
 
157 157
 	if (preg_match(';^([a-z]{3,7})://;i', $url_absolue, $m)) {
158 158
 		$protocole = $m[1];
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 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
 
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
  * @return string URL nettoyée
35 35
  **/
36 36
 function resolve_path($url) {
37
-	[$url, $query] = array_pad(explode('?', $url, 2), 2, null);
38
-	while (
39
-		preg_match(',/\.?/,', (string) $url, $regs) # supprime // et /./
40
-		|| preg_match(',/[^/]*/\.\./,S', (string) $url, $regs)  # supprime /toto/../
41
-		|| preg_match(',^/\.\./,S', (string) $url, $regs) # supprime les /../ du haut
42
-	) {
43
-		$url = str_replace($regs[0], '/', (string) $url);
44
-	}
37
+    [$url, $query] = array_pad(explode('?', $url, 2), 2, null);
38
+    while (
39
+        preg_match(',/\.?/,', (string) $url, $regs) # supprime // et /./
40
+        || preg_match(',/[^/]*/\.\./,S', (string) $url, $regs)  # supprime /toto/../
41
+        || preg_match(',^/\.\./,S', (string) $url, $regs) # supprime les /../ du haut
42
+    ) {
43
+        $url = str_replace($regs[0], '/', (string) $url);
44
+    }
45 45
 
46
-	if ($query) {
47
-		$url .= '?' . $query;
48
-	}
46
+    if ($query) {
47
+        $url .= '?' . $query;
48
+    }
49 49
 
50
-	return '/' . preg_replace(',^/,S', '', (string) $url);
50
+    return '/' . preg_replace(',^/,S', '', (string) $url);
51 51
 }
52 52
 
53 53
 
@@ -68,40 +68,40 @@  discard block
 block discarded – undo
68 68
  **/
69 69
 function suivre_lien($url, $lien) {
70 70
 
71
-	$mot = null;
72
-	$get = null;
73
-	$hash = null;
74
-	if (preg_match(',^(mailto|javascript|data|tel|callto|file|ftp):,iS', $lien)) {
75
-		return $lien;
76
-	}
77
-	if (preg_match(';^((?:[a-z]{3,33}:)?//.*?)(/.*)?$;iS', $lien, $r)) {
78
-		$r = array_pad($r, 3, '');
71
+    $mot = null;
72
+    $get = null;
73
+    $hash = null;
74
+    if (preg_match(',^(mailto|javascript|data|tel|callto|file|ftp):,iS', $lien)) {
75
+        return $lien;
76
+    }
77
+    if (preg_match(';^((?:[a-z]{3,33}:)?//.*?)(/.*)?$;iS', $lien, $r)) {
78
+        $r = array_pad($r, 3, '');
79 79
 
80
-		return $r[1] . resolve_path($r[2]);
81
-	}
80
+        return $r[1] . resolve_path($r[2]);
81
+    }
82 82
 
83
-	# L'url site spip est un lien absolu aussi
84
-	if (isset($GLOBALS['meta']['adresse_site']) && $lien == $GLOBALS['meta']['adresse_site']) {
85
-		return $lien;
86
-	}
83
+    # L'url site spip est un lien absolu aussi
84
+    if (isset($GLOBALS['meta']['adresse_site']) && $lien == $GLOBALS['meta']['adresse_site']) {
85
+        return $lien;
86
+    }
87 87
 
88
-	# lien relatif, il faut verifier l'url de base
89
-	# commencer par virer la chaine de get de l'url de base
90
-	$dir = '/';
91
-	$debut = '';
92
-	if (preg_match(';^((?:[a-z]{3,7}:)?//[^/]+)(/.*?/?)?([^/#?]*)([?][^#]*)?(#.*)?$;S', $url, $regs)) {
93
-		$debut = $regs[1];
94
-		$dir = strlen($regs[2]) ? $regs[2] : '/';
95
-		$mot = $regs[3];
96
-		$get = $regs[4] ?? '';
97
-		$hash = $regs[5] ?? '';
98
-	}
99
-	return match (substr($lien, 0, 1)) {
100
-		'/' => $debut . resolve_path($lien),
101
-		'#' => $debut . resolve_path($dir . $mot . $get . $lien),
102
-		'' => $debut . resolve_path($dir . $mot . $get . $hash),
103
-		default => $debut . resolve_path($dir . $lien),
104
-	};
88
+    # lien relatif, il faut verifier l'url de base
89
+    # commencer par virer la chaine de get de l'url de base
90
+    $dir = '/';
91
+    $debut = '';
92
+    if (preg_match(';^((?:[a-z]{3,7}:)?//[^/]+)(/.*?/?)?([^/#?]*)([?][^#]*)?(#.*)?$;S', $url, $regs)) {
93
+        $debut = $regs[1];
94
+        $dir = strlen($regs[2]) ? $regs[2] : '/';
95
+        $mot = $regs[3];
96
+        $get = $regs[4] ?? '';
97
+        $hash = $regs[5] ?? '';
98
+    }
99
+    return match (substr($lien, 0, 1)) {
100
+        '/' => $debut . resolve_path($lien),
101
+        '#' => $debut . resolve_path($dir . $mot . $get . $lien),
102
+        '' => $debut . resolve_path($dir . $mot . $get . $hash),
103
+        default => $debut . resolve_path($dir . $lien),
104
+    };
105 105
 }
106 106
 
107 107
 
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
  * @return string texte ou URL (en absolus)
125 125
  **/
126 126
 function url_absolue($url, $base = '') {
127
-	$url = trim((string) $url);
128
-	if (strlen($url = trim($url)) == 0) {
129
-		return '';
130
-	}
131
-	if (!$base) {
132
-		$base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
133
-	}
127
+    $url = trim((string) $url);
128
+    if (strlen($url = trim($url)) == 0) {
129
+        return '';
130
+    }
131
+    if (!$base) {
132
+        $base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
133
+    }
134 134
 
135
-	return suivre_lien($base, $url);
135
+    return suivre_lien($base, $url);
136 136
 }
137 137
 
138 138
 /**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
  * @return string
144 144
  */
145 145
 function protocole_implicite($url_absolue) {
146
-	return preg_replace(';^[a-z]{3,7}://;i', '//', $url_absolue);
146
+    return preg_replace(';^[a-z]{3,7}://;i', '//', $url_absolue);
147 147
 }
148 148
 
149 149
 /**
@@ -154,16 +154,16 @@  discard block
 block discarded – undo
154 154
  */
155 155
 function protocole_verifier($url_absolue, $protocoles_autorises = ['http','https']) {
156 156
 
157
-	if (preg_match(';^([a-z]{3,7})://;i', $url_absolue, $m)) {
158
-		$protocole = $m[1];
159
-		if (
160
-			in_array($protocole, $protocoles_autorises)
161
-			|| in_array(strtolower($protocole), array_map('strtolower', $protocoles_autorises))
162
-		) {
163
-			return true;
164
-		}
165
-	}
166
-	return false;
157
+    if (preg_match(';^([a-z]{3,7})://;i', $url_absolue, $m)) {
158
+        $protocole = $m[1];
159
+        if (
160
+            in_array($protocole, $protocoles_autorises)
161
+            || in_array(strtolower($protocole), array_map('strtolower', $protocoles_autorises))
162
+        ) {
163
+            return true;
164
+        }
165
+    }
166
+    return false;
167 167
 }
168 168
 
169 169
 /**
@@ -180,31 +180,31 @@  discard block
 block discarded – undo
180 180
  * @return string texte avec des URLs absolues
181 181
  **/
182 182
 function liens_absolus($texte, $base = '') {
183
-	if ($texte === null || $texte === '') {
184
-		return '';
185
-	}
186
-	if (preg_match_all(',(<(a|link|image|img|script)\s[^<>]*(href|src)=[^<>]*>),imsS', $texte, $liens, PREG_SET_ORDER)) {
187
-		if (!function_exists('extraire_attribut')) {
188
-			include_spip('inc/filtres');
189
-		}
190
-		foreach ($liens as $lien) {
191
-			foreach (['href', 'src'] as $attr) {
192
-				$href = extraire_attribut($lien[0], $attr) ?? '';
193
-				if (
194
-					strlen((string) $href) > 0
195
-					&& !preg_match(';^((?:[a-z]{3,7}:)?//);iS', (string) $href)
196
-				) {
197
-					$abs = url_absolue($href, $base);
198
-					if (rtrim((string) $href, '/') !== rtrim($abs, '/') && !preg_match('/^#/', (string) $href)) {
199
-						$texte_lien = inserer_attribut($lien[0], $attr, $abs);
200
-						$texte = str_replace($lien[0], $texte_lien, $texte);
201
-					}
202
-				}
203
-			}
204
-		}
205
-	}
183
+    if ($texte === null || $texte === '') {
184
+        return '';
185
+    }
186
+    if (preg_match_all(',(<(a|link|image|img|script)\s[^<>]*(href|src)=[^<>]*>),imsS', $texte, $liens, PREG_SET_ORDER)) {
187
+        if (!function_exists('extraire_attribut')) {
188
+            include_spip('inc/filtres');
189
+        }
190
+        foreach ($liens as $lien) {
191
+            foreach (['href', 'src'] as $attr) {
192
+                $href = extraire_attribut($lien[0], $attr) ?? '';
193
+                if (
194
+                    strlen((string) $href) > 0
195
+                    && !preg_match(';^((?:[a-z]{3,7}:)?//);iS', (string) $href)
196
+                ) {
197
+                    $abs = url_absolue($href, $base);
198
+                    if (rtrim((string) $href, '/') !== rtrim($abs, '/') && !preg_match('/^#/', (string) $href)) {
199
+                        $texte_lien = inserer_attribut($lien[0], $attr, $abs);
200
+                        $texte = str_replace($lien[0], $texte_lien, $texte);
201
+                    }
202
+                }
203
+            }
204
+        }
205
+    }
206 206
 
207
-	return $texte;
207
+    return $texte;
208 208
 }
209 209
 
210 210
 
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
  * @return string texte ou URL (en absolus)
223 223
  **/
224 224
 function abs_url($texte, $base = '') {
225
-	trigger_deprecation('spip', '5.0', sprintf('Using "%s" is deprecated. Use "%s" or "%s"', __FUNCTION__, 'url_absolue', 'liens_absolus'));
226
-	if ($GLOBALS['mode_abs_url'] == 'url') {
227
-		return url_absolue($texte, $base);
228
-	} else {
229
-		return liens_absolus($texte, $base);
230
-	}
225
+    trigger_deprecation('spip', '5.0', sprintf('Using "%s" is deprecated. Use "%s" or "%s"', __FUNCTION__, 'url_absolue', 'liens_absolus'));
226
+    if ($GLOBALS['mode_abs_url'] == 'url') {
227
+        return url_absolue($texte, $base);
228
+    } else {
229
+        return liens_absolus($texte, $base);
230
+    }
231 231
 }
232 232
 
233 233
 /**
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
  * @return string
241 241
  */
242 242
 function spip_htmlspecialchars($string, $flags = null, $encoding = 'UTF-8', $double_encode = true) {
243
-	if (is_null($flags)) {
244
-		$flags = ENT_COMPAT | ENT_HTML401;
245
-	}
243
+    if (is_null($flags)) {
244
+        $flags = ENT_COMPAT | ENT_HTML401;
245
+    }
246 246
 
247
-	return htmlspecialchars($string, $flags, $encoding, $double_encode);
247
+    return htmlspecialchars($string, $flags, $encoding, $double_encode);
248 248
 }
249 249
 
250 250
 /**
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
  * @return string
258 258
  */
259 259
 function spip_htmlentities($string, $flags = null, $encoding = 'UTF-8', $double_encode = true) {
260
-	if (is_null($flags)) {
261
-		$flags = ENT_COMPAT | ENT_HTML401;
262
-	}
260
+    if (is_null($flags)) {
261
+        $flags = ENT_COMPAT | ENT_HTML401;
262
+    }
263 263
 
264
-	return htmlentities($string, $flags, $encoding, $double_encode);
264
+    return htmlentities($string, $flags, $encoding, $double_encode);
265 265
 }
Please login to merge, or discard this patch.
ecrire/inc/xml.php 2 patches
Indentation   +157 added lines, -157 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
 
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
  *     - false si l'arbre xml ne peut être créé ou est vide
47 47
  **/
48 48
 function spip_xml_load($fichier, $strict = true, $clean = true, $taille_max = 1_048_576, $datas = '', $profondeur = -1) {
49
-	$contenu = '';
50
-	if (tester_url_absolue($fichier)) {
51
-		include_spip('inc/distant');
52
-		$contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]);
53
-		$contenu = $contenu['page'] ?? '';
54
-	} else {
55
-		lire_fichier($fichier, $contenu);
56
-	}
57
-	$arbre = [];
58
-	if ($contenu) {
59
-		$arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur);
60
-	}
49
+    $contenu = '';
50
+    if (tester_url_absolue($fichier)) {
51
+        include_spip('inc/distant');
52
+        $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]);
53
+        $contenu = $contenu['page'] ?? '';
54
+    } else {
55
+        lire_fichier($fichier, $contenu);
56
+    }
57
+    $arbre = [];
58
+    if ($contenu) {
59
+        $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur);
60
+    }
61 61
 
62
-	return count($arbre) ? $arbre : false;
62
+    return count($arbre) ? $arbre : false;
63 63
 }
64 64
 
65 65
 if (!defined('_SPIP_XML_TAG_SPLIT')) {
66
-	define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS');
66
+    define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS');
67 67
 }
68 68
 
69 69
 /**
@@ -82,150 +82,150 @@  discard block
 block discarded – undo
82 82
  *     - false si l'arbre xml ne peut être créé ou est vide
83 83
  **/
84 84
 function spip_xml_parse(&$texte, $strict = true, $clean = true, $profondeur = -1) {
85
-	$out = [];
86
-	// enlever les commentaires
87
-	$charset = 'AUTO';
88
-	if ($clean) {
89
-		if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) {
90
-			$charset = $regs[2];
91
-		}
92
-		$texte = preg_replace(',<!--(.*?)-->,is', '', $texte);
93
-		$texte = preg_replace(',<\?(.*?)\?>,is', '', $texte);
94
-		include_spip('inc/charsets');
95
-		$clean = $charset;
96
-		//$texte = importer_charset($texte,$charset);
97
-	}
98
-	if (is_string($clean)) {
99
-		$charset = $clean;
100
-	}
101
-	$txt = $texte;
85
+    $out = [];
86
+    // enlever les commentaires
87
+    $charset = 'AUTO';
88
+    if ($clean) {
89
+        if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) {
90
+            $charset = $regs[2];
91
+        }
92
+        $texte = preg_replace(',<!--(.*?)-->,is', '', $texte);
93
+        $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte);
94
+        include_spip('inc/charsets');
95
+        $clean = $charset;
96
+        //$texte = importer_charset($texte,$charset);
97
+    }
98
+    if (is_string($clean)) {
99
+        $charset = $clean;
100
+    }
101
+    $txt = $texte;
102 102
 
103
-	// tant qu'il y a des tags
104
-	$chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
105
-	while ((is_countable($chars) ? count($chars) : 0) >= 2) {
106
-		// tag ouvrant
107
-		//$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE);
103
+    // tant qu'il y a des tags
104
+    $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
105
+    while ((is_countable($chars) ? count($chars) : 0) >= 2) {
106
+        // tag ouvrant
107
+        //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE);
108 108
 
109
-		// $before doit etre vide ou des espaces uniquements!
110
-		$before = trim($chars[0]);
109
+        // $before doit etre vide ou des espaces uniquements!
110
+        $before = trim($chars[0]);
111 111
 
112
-		if (strlen($before) > 0) {
113
-			return importer_charset($texte, $charset);
114
-		}//$texte; // before non vide, donc on est dans du texte
112
+        if (strlen($before) > 0) {
113
+            return importer_charset($texte, $charset);
114
+        }//$texte; // before non vide, donc on est dans du texte
115 115
 
116
-		$tag = rtrim($chars[1]);
117
-		$txt = $chars[2];
116
+        $tag = rtrim($chars[1]);
117
+        $txt = $chars[2];
118 118
 
119
-		if (str_starts_with($tag, '![CDATA[')) {
120
-			return importer_charset($texte, $charset);
121
-		}//$texte;
122
-		if (str_ends_with($tag, '/')) { // self closing tag
123
-			$tag = rtrim(substr($tag, 0, strlen($tag) - 1));
124
-			$out[$tag][] = '';
125
-		} else {
126
-			$closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag));
127
-			$closing_tag = reset($closing_tag);
128
-			// tag fermant
129
-			$ncclos = strlen("</$closing_tag>");
130
-			$p = strpos($txt, (string) "</$closing_tag>");
131
-			if ($p !== false && strpos($txt, '<') < $p) {
132
-				$nclose = 0;
133
-				$nopen = 0;
134
-				$d = 0;
135
-				while (
136
-					$p !== false
137
-					&& ($morceau = substr($txt, $d, $p - $d))
138
-					&& ($nopen += preg_match_all(
139
-						'{<' . preg_quote((string) $closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is',
140
-						$morceau,
141
-						$matches,
142
-						PREG_SET_ORDER
143
-					)) > $nclose
144
-				) {
145
-					$nclose++;
146
-					$d = $p + $ncclos;
147
-					$p = strpos($txt, (string) "</$closing_tag>", $d);
148
-				}
149
-			}
150
-			if ($p === false) {
151
-				if ($strict) {
152
-					$out[$tag][] = "erreur : tag fermant $tag manquant::$txt";
119
+        if (str_starts_with($tag, '![CDATA[')) {
120
+            return importer_charset($texte, $charset);
121
+        }//$texte;
122
+        if (str_ends_with($tag, '/')) { // self closing tag
123
+            $tag = rtrim(substr($tag, 0, strlen($tag) - 1));
124
+            $out[$tag][] = '';
125
+        } else {
126
+            $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag));
127
+            $closing_tag = reset($closing_tag);
128
+            // tag fermant
129
+            $ncclos = strlen("</$closing_tag>");
130
+            $p = strpos($txt, (string) "</$closing_tag>");
131
+            if ($p !== false && strpos($txt, '<') < $p) {
132
+                $nclose = 0;
133
+                $nopen = 0;
134
+                $d = 0;
135
+                while (
136
+                    $p !== false
137
+                    && ($morceau = substr($txt, $d, $p - $d))
138
+                    && ($nopen += preg_match_all(
139
+                        '{<' . preg_quote((string) $closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is',
140
+                        $morceau,
141
+                        $matches,
142
+                        PREG_SET_ORDER
143
+                    )) > $nclose
144
+                ) {
145
+                    $nclose++;
146
+                    $d = $p + $ncclos;
147
+                    $p = strpos($txt, (string) "</$closing_tag>", $d);
148
+                }
149
+            }
150
+            if ($p === false) {
151
+                if ($strict) {
152
+                    $out[$tag][] = "erreur : tag fermant $tag manquant::$txt";
153 153
 
154
-					return $out;
155
-				} else {
156
-					return importer_charset($texte, $charset);
157
-				}//$texte // un tag qui constitue du texte a reporter dans $before
158
-			}
159
-			$content = substr($txt, 0, $p);
160
-			$txt = substr($txt, $p + $ncclos);
161
-			if ($profondeur == 0 || !str_contains($content, '<')) { // eviter une recursion si pas utile
162
-			$out[$tag][] = importer_charset($content, $charset);
163
-			}//$content;
164
-			else {
165
-				$out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1);
166
-			}
167
-		}
168
-		$chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
169
-	}
170
-	if (count($out) && (strlen(trim($txt)) == 0)) {
171
-		return $out;
172
-	} else {
173
-		return importer_charset($texte, $charset);
174
-	}//$texte;
154
+                    return $out;
155
+                } else {
156
+                    return importer_charset($texte, $charset);
157
+                }//$texte // un tag qui constitue du texte a reporter dans $before
158
+            }
159
+            $content = substr($txt, 0, $p);
160
+            $txt = substr($txt, $p + $ncclos);
161
+            if ($profondeur == 0 || !str_contains($content, '<')) { // eviter une recursion si pas utile
162
+            $out[$tag][] = importer_charset($content, $charset);
163
+            }//$content;
164
+            else {
165
+                $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1);
166
+            }
167
+        }
168
+        $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE);
169
+    }
170
+    if (count($out) && (strlen(trim($txt)) == 0)) {
171
+        return $out;
172
+    } else {
173
+        return importer_charset($texte, $charset);
174
+    }//$texte;
175 175
 }
176 176
 
177 177
 function spip_xml_aplatit($arbre, $separateur = ' ') {
178
-	$s = '';
179
-	if (is_array($arbre)) {
180
-		foreach ($arbre as $tag => $feuille) {
181
-			if (is_array($feuille)) {
182
-				if ($tag !== (int) $tag) {
183
-					$f = spip_xml_aplatit($feuille, $separateur);
184
-					if (strlen((string) $f)) {
185
-						$tagf = explode(' ', $tag);
186
-						$tagf = $tagf[0];
187
-						$s .= "<$tag>$f</$tagf>";
188
-					} else {
189
-						$s .= "<$tag />";
190
-					}
191
-				} else {
192
-					$s .= spip_xml_aplatit($feuille);
193
-				}
194
-				$s .= $separateur;
195
-			} else {
196
-				$s .= "$feuille$separateur";
197
-			}
198
-		}
199
-	}
178
+    $s = '';
179
+    if (is_array($arbre)) {
180
+        foreach ($arbre as $tag => $feuille) {
181
+            if (is_array($feuille)) {
182
+                if ($tag !== (int) $tag) {
183
+                    $f = spip_xml_aplatit($feuille, $separateur);
184
+                    if (strlen((string) $f)) {
185
+                        $tagf = explode(' ', $tag);
186
+                        $tagf = $tagf[0];
187
+                        $s .= "<$tag>$f</$tagf>";
188
+                    } else {
189
+                        $s .= "<$tag />";
190
+                    }
191
+                } else {
192
+                    $s .= spip_xml_aplatit($feuille);
193
+                }
194
+                $s .= $separateur;
195
+            } else {
196
+                $s .= "$feuille$separateur";
197
+            }
198
+        }
199
+    }
200 200
 
201
-	return strlen((string) $separateur) ? substr($s, 0, -strlen((string) $separateur)) : $s;
201
+    return strlen((string) $separateur) ? substr($s, 0, -strlen((string) $separateur)) : $s;
202 202
 }
203 203
 
204 204
 function spip_xml_tagname($tag) {
205
-	if (preg_match(',^([a-z][\w:]*),i', (string) $tag, $reg)) {
206
-		return $reg[1];
207
-	}
205
+    if (preg_match(',^([a-z][\w:]*),i', (string) $tag, $reg)) {
206
+        return $reg[1];
207
+    }
208 208
 
209
-	return '';
209
+    return '';
210 210
 }
211 211
 
212 212
 function spip_xml_decompose_tag($tag) {
213
-	$tagname = spip_xml_tagname($tag);
214
-	$liste = [];
215
-	$tag = ltrim(strpbrk((string) $tag, " \n\t"));
216
-	$p = strpos($tag, '=');
217
-	while ($p !== false) {
218
-		$attr = trim(substr($tag, 0, $p));
219
-		$tag = ltrim(substr($tag, $p + 1));
220
-		$quote = $tag[0];
221
-		$p = strpos($tag, $quote, 1);
222
-		$cont = substr($tag, 1, $p - 1);
223
-		$liste[$attr] = $cont;
224
-		$tag = substr($tag, $p + 1);
225
-		$p = strpos($tag, '=');
226
-	}
213
+    $tagname = spip_xml_tagname($tag);
214
+    $liste = [];
215
+    $tag = ltrim(strpbrk((string) $tag, " \n\t"));
216
+    $p = strpos($tag, '=');
217
+    while ($p !== false) {
218
+        $attr = trim(substr($tag, 0, $p));
219
+        $tag = ltrim(substr($tag, $p + 1));
220
+        $quote = $tag[0];
221
+        $p = strpos($tag, $quote, 1);
222
+        $cont = substr($tag, 1, $p - 1);
223
+        $liste[$attr] = $cont;
224
+        $tag = substr($tag, $p + 1);
225
+        $p = strpos($tag, '=');
226
+    }
227 227
 
228
-	return [$tagname, $liste];
228
+    return [$tagname, $liste];
229 229
 }
230 230
 
231 231
 /**
@@ -248,21 +248,21 @@  discard block
 block discarded – undo
248 248
  *     false si aucun élément ne valide l'expression régulière, true sinon.
249 249
  **/
250 250
 function spip_xml_match_nodes($regexp, &$arbre, &$matches, $init = true) {
251
-	if ($init) {
252
-		$matches = [];
253
-	}
254
-	if (is_array($arbre) && count($arbre)) {
255
-		foreach (array_keys($arbre) as $tag) {
256
-			if (preg_match($regexp, $tag)) {
257
-				$matches[$tag] = &$arbre[$tag];
258
-			}
259
-			if (is_array($arbre[$tag])) {
260
-				foreach (array_keys($arbre[$tag]) as $occurences) {
261
-					spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false);
262
-				}
263
-			}
264
-		}
265
-	}
251
+    if ($init) {
252
+        $matches = [];
253
+    }
254
+    if (is_array($arbre) && count($arbre)) {
255
+        foreach (array_keys($arbre) as $tag) {
256
+            if (preg_match($regexp, $tag)) {
257
+                $matches[$tag] = &$arbre[$tag];
258
+            }
259
+            if (is_array($arbre[$tag])) {
260
+                foreach (array_keys($arbre[$tag]) as $occurences) {
261
+                    spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false);
262
+                }
263
+            }
264
+        }
265
+    }
266 266
 
267
-	return (is_countable($matches) ? count($matches) : 0);
267
+    return (is_countable($matches) ? count($matches) : 0);
268 268
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
 					$p !== false
137 137
 					&& ($morceau = substr($txt, $d, $p - $d))
138 138
 					&& ($nopen += preg_match_all(
139
-						'{<' . preg_quote((string) $closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is',
139
+						'{<'.preg_quote((string) $closing_tag).'(\s*>|\s[^>]*[^/>]>)}is',
140 140
 						$morceau,
141 141
 						$matches,
142 142
 						PREG_SET_ORDER
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
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 use Spip\Texte\Collecteur\Modeles;
14 14
 
15 15
 if (!defined('_ECRIRE_INC_VERSION')) {
16
-	return;
16
+    return;
17 17
 }
18 18
 
19 19
 /**
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function traiter_modeles($texte, $doublons = false, $echap = '', string $connect = '', ?Liens $collecteurLiens = null, $env = []) {
28 28
 
29
-	include_spip('src/Texte/Collecteur/AbstractCollecteur');
30
-	include_spip('src/Texte/Collecteur/Modeles');
31
-	$collecteurModeles = new Modeles();
29
+    include_spip('src/Texte/Collecteur/AbstractCollecteur');
30
+    include_spip('src/Texte/Collecteur/Modeles');
31
+    $collecteurModeles = new Modeles();
32 32
 
33
-	$options = [
34
-		'doublons' => $doublons,
35
-		'echap' => $echap,
36
-		'connect' => $connect,
37
-		'collecteurLiens' => $collecteurLiens,
38
-		'env' => $env
39
-	];
40
-	return $collecteurModeles->traiter($texte ?? '', $options);
33
+    $options = [
34
+        'doublons' => $doublons,
35
+        'echap' => $echap,
36
+        'connect' => $connect,
37
+        'collecteurLiens' => $collecteurLiens,
38
+        'env' => $env
39
+    ];
40
+    return $collecteurModeles->traiter($texte ?? '', $options);
41 41
 }
Please login to merge, or discard this patch.
ecrire/inc/informer.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -10,76 +10,76 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 # Les information d'une rubrique selectionnee dans le mini navigateur
17 17
 
18 18
 function inc_informer_dist($id, $col, $exclus, $rac, $type, $do = 'aff') {
19
-	include_spip('inc/texte');
20
-	$titre = $descriptif = '';
21
-	if ($type === 'rubrique') {
22
-		$row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . (int) $id);
23
-		if ($row) {
24
-			$titre = typo($row['titre']);
25
-			$descriptif = propre($row['descriptif']);
26
-		} else {
27
-			$titre = _T('info_racine_site');
28
-		}
29
-	}
19
+    include_spip('inc/texte');
20
+    $titre = $descriptif = '';
21
+    if ($type === 'rubrique') {
22
+        $row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . (int) $id);
23
+        if ($row) {
24
+            $titre = typo($row['titre']);
25
+            $descriptif = propre($row['descriptif']);
26
+        } else {
27
+            $titre = _T('info_racine_site');
28
+        }
29
+    }
30 30
 
31
-	$res = '';
32
-	if (
33
-		$type === 'rubrique'
34
-		&& (int) ($GLOBALS['visiteur_session']['prefs']['display'] ?? 0) !== 1
35
-		&& isset($GLOBALS['meta']['image_process'])
36
-		&& $GLOBALS['meta']['image_process'] !== 'non'
37
-	) {
38
-		$chercher_logo = charger_fonction('chercher_logo', 'inc');
39
-		if ($res = $chercher_logo($id, 'id_rubrique', 'on')) {
40
-			[$fid, $dir, $nom, $format] = $res;
41
-			include_spip('inc/filtres_images_mini');
42
-			$res = image_reduire("<img src='$fid' alt='' />", 100, 48);
43
-			if ($res) {
44
-				$res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>";
45
-			}
46
-		}
47
-	}
31
+    $res = '';
32
+    if (
33
+        $type === 'rubrique'
34
+        && (int) ($GLOBALS['visiteur_session']['prefs']['display'] ?? 0) !== 1
35
+        && isset($GLOBALS['meta']['image_process'])
36
+        && $GLOBALS['meta']['image_process'] !== 'non'
37
+    ) {
38
+        $chercher_logo = charger_fonction('chercher_logo', 'inc');
39
+        if ($res = $chercher_logo($id, 'id_rubrique', 'on')) {
40
+            [$fid, $dir, $nom, $format] = $res;
41
+            include_spip('inc/filtres_images_mini');
42
+            $res = image_reduire("<img src='$fid' alt='' />", 100, 48);
43
+            if ($res) {
44
+                $res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>";
45
+            }
46
+        }
47
+    }
48 48
 
49
-	$rac = spip_htmlentities($rac, ENT_QUOTES);
50
-	$do = spip_htmlentities($do, ENT_QUOTES);
51
-	$id = (int) $id;
49
+    $rac = spip_htmlentities($rac, ENT_QUOTES);
50
+    $do = spip_htmlentities($do, ENT_QUOTES);
51
+    $id = (int) $id;
52 52
 
53 53
 # ce lien provoque la selection (directe) de la rubrique cliquee
54 54
 # et l'affichage de son titre dans le bandeau
55
-	$titre = strtr(
56
-		str_replace(
57
-			"'",
58
-			'&#8217;',
59
-			str_replace('"', '&#34;', (string) textebrut($titre))
60
-		),
61
-		"\n\r",
62
-		'  '
63
-	);
55
+    $titre = strtr(
56
+        str_replace(
57
+            "'",
58
+            '&#8217;',
59
+            str_replace('"', '&#34;', (string) textebrut($titre))
60
+        ),
61
+        "\n\r",
62
+        '  '
63
+    );
64 64
 
65
-	$js_func = $do . '_selection_titre';
65
+    $js_func = $do . '_selection_titre';
66 66
 
67
-	return "<div style='display: none;'>"
68
-	. "<input type='text' id='" . $rac . "_sel' value='$id' />"
69
-	. "<input type='text' id='" . $rac . "_sel2' value=\""
70
-	. entites_html($titre)
71
-	. '" />'
72
-	. '</div>'
73
-	. "<div class='informer' style='padding: 5px; border-top: 0px;'>"
74
-	. '<div class="informer__item">'
75
-	. ($res ?: '')
76
-	. "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>'
77
-	. ($descriptif ? "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>' : '')
78
-	. '</div>'
79
-	. "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
80
-	. "<input type='submit' class='fondo btn submit' value='"
81
-	. _T('bouton_choisir')
82
-	. "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />"
83
-	. '</div>'
84
-	. '</div>';
67
+    return "<div style='display: none;'>"
68
+    . "<input type='text' id='" . $rac . "_sel' value='$id' />"
69
+    . "<input type='text' id='" . $rac . "_sel2' value=\""
70
+    . entites_html($titre)
71
+    . '" />'
72
+    . '</div>'
73
+    . "<div class='informer' style='padding: 5px; border-top: 0px;'>"
74
+    . '<div class="informer__item">'
75
+    . ($res ?: '')
76
+    . "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>'
77
+    . ($descriptif ? "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>' : '')
78
+    . '</div>'
79
+    . "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
80
+    . "<input type='submit' class='fondo btn submit' value='"
81
+    . _T('bouton_choisir')
82
+    . "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />"
83
+    . '</div>'
84
+    . '</div>';
85 85
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	include_spip('inc/texte');
20 20
 	$titre = $descriptif = '';
21 21
 	if ($type === 'rubrique') {
22
-		$row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = ' . (int) $id);
22
+		$row = sql_fetsel('titre, descriptif', 'spip_rubriques', 'id_rubrique = '.(int) $id);
23 23
 		if ($row) {
24 24
 			$titre = typo($row['titre']);
25 25
 			$descriptif = propre($row['descriptif']);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			include_spip('inc/filtres_images_mini');
42 42
 			$res = image_reduire("<img src='$fid' alt='' />", 100, 48);
43 43
 			if ($res) {
44
-				$res = "<div class='informer__media' style='float: " . $GLOBALS['spip_lang_right'] . '; margin-' . $GLOBALS['spip_lang_right'] . ": -5px; margin-top: -5px;'>$res</div>";
44
+				$res = "<div class='informer__media' style='float: ".$GLOBALS['spip_lang_right'].'; margin-'.$GLOBALS['spip_lang_right'].": -5px; margin-top: -5px;'>$res</div>";
45 45
 			}
46 46
 		}
47 47
 	}
@@ -62,21 +62,21 @@  discard block
 block discarded – undo
62 62
 		'  '
63 63
 	);
64 64
 
65
-	$js_func = $do . '_selection_titre';
65
+	$js_func = $do.'_selection_titre';
66 66
 
67 67
 	return "<div style='display: none;'>"
68
-	. "<input type='text' id='" . $rac . "_sel' value='$id' />"
69
-	. "<input type='text' id='" . $rac . "_sel2' value=\""
68
+	. "<input type='text' id='".$rac."_sel' value='$id' />"
69
+	. "<input type='text' id='".$rac."_sel2' value=\""
70 70
 	. entites_html($titre)
71 71
 	. '" />'
72 72
 	. '</div>'
73 73
 	. "<div class='informer' style='padding: 5px; border-top: 0px;'>"
74 74
 	. '<div class="informer__item">'
75 75
 	. ($res ?: '')
76
-	. "<p class='informer__titre'><b>" . safehtml($titre) . '</b></p>'
77
-	. ($descriptif ? "<div class='informer__descriptif'>" . safehtml($descriptif) . '</div>' : '')
76
+	. "<p class='informer__titre'><b>".safehtml($titre).'</b></p>'
77
+	. ($descriptif ? "<div class='informer__descriptif'>".safehtml($descriptif).'</div>' : '')
78 78
 	. '</div>'
79
-	. "<div class='informer__action' style='clear:both; text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
79
+	. "<div class='informer__action' style='clear:both; text-align: ".$GLOBALS['spip_lang_right'].";'>"
80 80
 	. "<input type='submit' class='fondo btn submit' value='"
81 81
 	. _T('bouton_choisir')
82 82
 	. "'\nonclick=\"$js_func('$titre',$id,'selection_rubrique','id_parent'); return false;\" />"
Please login to merge, or discard this patch.
ecrire/inc/chercher_rubrique.php 2 patches
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 if (!defined('_SPIP_SELECT_RUBRIQUES')) {
24
-	/**
25
-	 * @var int Nombre de rubriques maximum du sélecteur de rubriques.
26
-	 * Au delà, on bascule sur un sélecteur ajax.
27
-	 * mettre 100000 pour desactiver ajax
28
-	 */
29
-	define('_SPIP_SELECT_RUBRIQUES', 20);
24
+    /**
25
+     * @var int Nombre de rubriques maximum du sélecteur de rubriques.
26
+     * Au delà, on bascule sur un sélecteur ajax.
27
+     * mettre 100000 pour desactiver ajax
28
+     */
29
+    define('_SPIP_SELECT_RUBRIQUES', 20);
30 30
 }
31 31
 
32 32
 /**
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
  *     Code HTML du sélecteur
55 55
  **/
56 56
 function inc_chercher_rubrique_dist($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
57
-	if (sql_countsel('spip_rubriques') < 1) {
58
-		return '';
59
-	}
60
-
61
-	// Mode sans Ajax :
62
-	// - soit parce que le cookie ajax n'est pas la
63
-	// - soit parce qu'il y a peu de rubriques
64
-	if (
65
-		_SPIP_AJAX < 1
66
-		|| $type == 'breve'
67
-		|| sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
68
-	) {
69
-		return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
70
-	} else {
71
-		return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
72
-	}
57
+    if (sql_countsel('spip_rubriques') < 1) {
58
+        return '';
59
+    }
60
+
61
+    // Mode sans Ajax :
62
+    // - soit parce que le cookie ajax n'est pas la
63
+    // - soit parce qu'il y a peu de rubriques
64
+    if (
65
+        _SPIP_AJAX < 1
66
+        || $type == 'breve'
67
+        || sql_countsel('spip_rubriques') < _SPIP_SELECT_RUBRIQUES
68
+    ) {
69
+        return selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem);
70
+    } else {
71
+        return selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem, $do);
72
+    }
73 73
 }
74 74
 
75 75
 // compatibilite pour extensions qui utilisaient l'ancien nom
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
  **/
87 87
 function style_menu_rubriques($i) {
88 88
 
89
-	$espace = '';
90
-	$style = '';
91
-	for ($count = 1; $count <= $i; $count++) {
92
-		$espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
93
-	}
94
-	if ($i == 1) {
95
-		$espace = '';
96
-	}
97
-	$class = "niveau_$i";
98
-
99
-	return [$class, $style, $espace];
89
+    $espace = '';
90
+    $style = '';
91
+    for ($count = 1; $count <= $i; $count++) {
92
+        $espace .= '&nbsp;&nbsp;&nbsp;&nbsp;';
93
+    }
94
+    if ($i == 1) {
95
+        $espace = '';
96
+    }
97
+    $class = "niveau_$i";
98
+
99
+    return [$class, $style, $espace];
100 100
 }
101 101
 
102 102
 /**
@@ -120,57 +120,57 @@  discard block
 block discarded – undo
120 120
  *     Code HTML du sélecteur
121 121
  **/
122 122
 function sous_menu_rubriques($id_rubrique, $root, $niv, &$data, &$enfants, $exclus, $restreint, $type) {
123
-	static $decalage_secteur;
124
-
125
-	// Si on a demande l'exclusion ne pas descendre dans la rubrique courante
126
-	if ($exclus > 0 && $root == $exclus) {
127
-		return '';
128
-	}
129
-
130
-	// en fonction du niveau faire un affichage plus ou moins kikoo
131
-
132
-	// selected ?
133
-	$selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
134
-
135
-	// le style en fonction de la profondeur
136
-	[$class, $style, $espace] = style_menu_rubriques($niv);
137
-
138
-	$class .= ' selec_rub';
139
-
140
-	// creer l'<option> pour la rubrique $root
141
-
142
-	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
143
-	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
144
-			. $data[$root]
145
-			. '</option>' . "\n";
146
-	} else {
147
-		$r = '';
148
-	}
149
-
150
-	// et le sous-menu pour ses enfants
151
-	$sous = '';
152
-	if (isset($enfants[$root])) {
153
-		foreach ($enfants[$root] as $sousrub) {
154
-			$sous .= sous_menu_rubriques(
155
-				$id_rubrique,
156
-				$sousrub,
157
-				$niv + 1,
158
-				$data,
159
-				$enfants,
160
-				$exclus,
161
-				$restreint,
162
-				$type
163
-			);
164
-		}
165
-	}
166
-
167
-	// si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
168
-	if ($restreint && $root != $id_rubrique && !autoriser('publierdans', 'rubrique', $root)) {
169
-		return $sous;
170
-	}
171
-
172
-	// et voila le travail
173
-	return $r . $sous;
123
+    static $decalage_secteur;
124
+
125
+    // Si on a demande l'exclusion ne pas descendre dans la rubrique courante
126
+    if ($exclus > 0 && $root == $exclus) {
127
+        return '';
128
+    }
129
+
130
+    // en fonction du niveau faire un affichage plus ou moins kikoo
131
+
132
+    // selected ?
133
+    $selected = ($root == $id_rubrique) ? ' selected="selected"' : '';
134
+
135
+    // le style en fonction de la profondeur
136
+    [$class, $style, $espace] = style_menu_rubriques($niv);
137
+
138
+    $class .= ' selec_rub';
139
+
140
+    // creer l'<option> pour la rubrique $root
141
+
142
+    if (isset($data[$root])) { # pas de racine sauf pour les rubriques
143
+    $r = "<option$selected value='$root' class='$class' style='$style'>$espace"
144
+            . $data[$root]
145
+            . '</option>' . "\n";
146
+    } else {
147
+        $r = '';
148
+    }
149
+
150
+    // et le sous-menu pour ses enfants
151
+    $sous = '';
152
+    if (isset($enfants[$root])) {
153
+        foreach ($enfants[$root] as $sousrub) {
154
+            $sous .= sous_menu_rubriques(
155
+                $id_rubrique,
156
+                $sousrub,
157
+                $niv + 1,
158
+                $data,
159
+                $enfants,
160
+                $exclus,
161
+                $restreint,
162
+                $type
163
+            );
164
+        }
165
+    }
166
+
167
+    // si l'objet a deplacer est publie, verifier qu'on a acces aux rubriques
168
+    if ($restreint && $root != $id_rubrique && !autoriser('publierdans', 'rubrique', $root)) {
169
+        return $sous;
170
+    }
171
+
172
+    // et voila le travail
173
+    return $r . $sous;
174 174
 }
175 175
 
176 176
 /**
@@ -191,75 +191,75 @@  discard block
 block discarded – undo
191 191
  *     Code HTML du sélecteur
192 192
  **/
193 193
 function selecteur_rubrique_html($id_rubrique, $type, $restreint, $idem = 0) {
194
-	$enfants = [];
195
-	$data = [];
196
-	if ($type == 'rubrique' && autoriser('publierdans', 'rubrique', 0)) {
197
-		$data[0] = _T('info_racine_site');
198
-	}
199
-	# premier choix = neant
200
-	# si auteur (rubriques restreintes)
201
-	# ou si creation avec id_rubrique=0
202
-	elseif ($type == 'auteur' || !$id_rubrique) {
203
-		$data[0] = '&nbsp;';
204
-	}
205
-
206
-	//
207
-	// creer une structure contenant toute l'arborescence
208
-	//
209
-
210
-	include_spip('base/abstract_sql');
211
-	$q = sql_select(
212
-		'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
213
-		'spip_rubriques',
214
-		($type == 'breve' ? ' id_parent=0 ' : ''),
215
-		'',
216
-		'0+titre,titre'
217
-	);
218
-	while ($r = sql_fetch($q)) {
219
-		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
220
-			// titre largeur maxi a 50
221
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
222
-			if (
223
-				$GLOBALS['meta']['multi_rubriques'] == 'oui'
224
-				&& ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0)
225
-			) {
226
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
227
-			}
228
-			$data[$r['id_rubrique']] = $titre;
229
-			$enfants[$r['id_parent']][] = $r['id_rubrique'];
230
-			if ($id_rubrique == $r['id_rubrique']) {
231
-				$id_parent = $r['id_parent'];
232
-			}
233
-		}
234
-	}
235
-
236
-	// si une seule rubrique comme choix possible,
237
-	// inutile de mettre le selecteur sur un choix vide par defaut
238
-	// sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
239
-	if (
240
-		count($data) == 2
241
-		&& isset($data[0])
242
-		&& !in_array($type, ['auteur', 'rubrique'])
243
-		&& !$id_rubrique
244
-	) {
245
-		unset($data[0]);
246
-	}
247
-
248
-
249
-	$opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
250
-	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
251
-
252
-	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
253
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
254
-	} else {
255
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
256
-	}
257
-
258
-	# message pour neuneus (a supprimer ?)
194
+    $enfants = [];
195
+    $data = [];
196
+    if ($type == 'rubrique' && autoriser('publierdans', 'rubrique', 0)) {
197
+        $data[0] = _T('info_racine_site');
198
+    }
199
+    # premier choix = neant
200
+    # si auteur (rubriques restreintes)
201
+    # ou si creation avec id_rubrique=0
202
+    elseif ($type == 'auteur' || !$id_rubrique) {
203
+        $data[0] = '&nbsp;';
204
+    }
205
+
206
+    //
207
+    // creer une structure contenant toute l'arborescence
208
+    //
209
+
210
+    include_spip('base/abstract_sql');
211
+    $q = sql_select(
212
+        'id_rubrique, id_parent, titre, statut, lang, langue_choisie',
213
+        'spip_rubriques',
214
+        ($type == 'breve' ? ' id_parent=0 ' : ''),
215
+        '',
216
+        '0+titre,titre'
217
+    );
218
+    while ($r = sql_fetch($q)) {
219
+        if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
220
+            // titre largeur maxi a 50
221
+            $titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
222
+            if (
223
+                $GLOBALS['meta']['multi_rubriques'] == 'oui'
224
+                && ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0)
225
+            ) {
226
+                $titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
227
+            }
228
+            $data[$r['id_rubrique']] = $titre;
229
+            $enfants[$r['id_parent']][] = $r['id_rubrique'];
230
+            if ($id_rubrique == $r['id_rubrique']) {
231
+                $id_parent = $r['id_parent'];
232
+            }
233
+        }
234
+    }
235
+
236
+    // si une seule rubrique comme choix possible,
237
+    // inutile de mettre le selecteur sur un choix vide par defaut
238
+    // sauf si le selecteur s'adresse a une rubrique puisque on peut la mettre a la racine dans ce cas
239
+    if (
240
+        count($data) == 2
241
+        && isset($data[0])
242
+        && !in_array($type, ['auteur', 'rubrique'])
243
+        && !$id_rubrique
244
+    ) {
245
+        unset($data[0]);
246
+    }
247
+
248
+
249
+    $opt = sous_menu_rubriques($id_rubrique, 0, 0, $data, $enfants, $idem, $restreint, $type);
250
+    $att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
251
+
252
+    if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
253
+        $r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
254
+    } else {
255
+        $r = '<select' . $att . " size='1'>\n$opt</select>\n";
256
+    }
257
+
258
+    # message pour neuneus (a supprimer ?)
259 259
 #	if ($type != 'auteur' AND $type != 'breve')
260 260
 #		$r .= "\n<br />"._T('texte_rappel_selection_champs');
261 261
 
262
-	return $r;
262
+    return $r;
263 263
 }
264 264
 
265 265
 /**
@@ -293,22 +293,22 @@  discard block
 block discarded – undo
293 293
  */
294 294
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
295 295
 
296
-	if ($id_rubrique) {
297
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
298
-	} else {
299
-		$titre = $type == 'auteur' ? '&nbsp;' : _T('info_racine_site');
300
-	}
296
+    if ($id_rubrique) {
297
+        $titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
298
+    } else {
299
+        $titre = $type == 'auteur' ? '&nbsp;' : _T('info_racine_site');
300
+    }
301 301
 
302
-	$titre = str_replace('&amp;', '&', (string) entites_html(textebrut(typo($titre))));
303
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
302
+    $titre = str_replace('&amp;', '&', (string) entites_html(textebrut(typo($titre))));
303
+    $init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
304 304
 
305
-	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
306
-		. ($idem ? "&exclus=$idem" : '')
307
-		. ($restreint ? '' : '&racine=oui')
308
-		. (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
305
+    $url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
306
+        . ($idem ? "&exclus=$idem" : '')
307
+        . ($restreint ? '' : '&racine=oui')
308
+        . (isset($GLOBALS['var_profile']) ? '&var_profile=1' : ''));
309 309
 
310 310
 
311
-	return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
311
+    return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique);
312 312
 }
313 313
 
314 314
 /**
@@ -338,30 +338,30 @@  discard block
 block discarded – undo
338 338
  *     Code HTML du sélecteur de rubrique AJAX
339 339
  **/
340 340
 function construire_selecteur($url, $js, $idom, $name, $init = '', $id = 0) {
341
-	$icone = (str_contains($idom, 'auteur')) ? 'auteur-24.png' : 'rechercher-20.png';
342
-	// si icone de recherche on embed le svg
343
-	$balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
344
-	$img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur'));
345
-
346
-	return
347
-		"<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
348
-		. $js
349
-		. " jQuery(this).toggleClass('toggled'); "
350
-		. "return charger_node_url_si_vide('"
351
-		. $url
352
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
353
-		. $img_icone
354
-		. "</a><img src='"
355
-		. chemin_image('loader.svg')
356
-		. "' class='loader' id='img_"
357
-		. $idom
358
-		. "'\nstyle='visibility: hidden;' alt='*' />"
359
-		. "<input id='titreparent' name='titreparent' class='text'"
360
-		. $init
361
-		. ' />'
362
-		. "<input type='hidden' id='$name' name='$name' value='"
363
-		. $id
364
-		. "' /><div class='nettoyeur'></div></div><div id='"
365
-		. $idom
366
-		. "'\nstyle='display: none;'></div>";
341
+    $icone = (str_contains($idom, 'auteur')) ? 'auteur-24.png' : 'rechercher-20.png';
342
+    // si icone de recherche on embed le svg
343
+    $balise = ($icone === 'rechercher-20.png' ? chercher_filtre('balise_svg') : chercher_filtre('balise_img'));
344
+    $img_icone = $balise(chemin_image($icone), _T('titre_image_selecteur'));
345
+
346
+    return
347
+        "<div class='rubrique_actuelle'><a href='#' class='rubrique-search' role='button' style='display:inline-flex;vertical-align:middle;' onclick=\""
348
+        . $js
349
+        . " jQuery(this).toggleClass('toggled'); "
350
+        . "return charger_node_url_si_vide('"
351
+        . $url
352
+        . "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
353
+        . $img_icone
354
+        . "</a><img src='"
355
+        . chemin_image('loader.svg')
356
+        . "' class='loader' id='img_"
357
+        . $idom
358
+        . "'\nstyle='visibility: hidden;' alt='*' />"
359
+        . "<input id='titreparent' name='titreparent' class='text'"
360
+        . $init
361
+        . ' />'
362
+        . "<input type='hidden' id='$name' name='$name' value='"
363
+        . $id
364
+        . "' /><div class='nettoyeur'></div></div><div id='"
365
+        . $idom
366
+        . "'\nstyle='display: none;'></div>";
367 367
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	if (isset($data[$root])) { # pas de racine sauf pour les rubriques
143 143
 	$r = "<option$selected value='$root' class='$class' style='$style'>$espace"
144 144
 			. $data[$root]
145
-			. '</option>' . "\n";
145
+			. '</option>'."\n";
146 146
 	} else {
147 147
 		$r = '';
148 148
 	}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	// et voila le travail
173
-	return $r . $sous;
173
+	return $r.$sous;
174 174
 }
175 175
 
176 176
 /**
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 	while ($r = sql_fetch($q)) {
219 219
 		if (autoriser('voir', 'rubrique', $r['id_rubrique'])) {
220 220
 			// titre largeur maxi a 50
221
-			$titre = couper(supprimer_tags(typo($r['titre'])) . ' ', 50);
221
+			$titre = couper(supprimer_tags(typo($r['titre'])).' ', 50);
222 222
 			if (
223 223
 				$GLOBALS['meta']['multi_rubriques'] == 'oui'
224 224
 				&& ($r['langue_choisie'] == 'oui' || $r['id_parent'] == 0)
225 225
 			) {
226
-				$titre .= ' [' . traduire_nom_langue($r['lang']) . ']';
226
+				$titre .= ' ['.traduire_nom_langue($r['lang']).']';
227 227
 			}
228 228
 			$data[$r['id_rubrique']] = $titre;
229 229
 			$enfants[$r['id_parent']][] = $r['id_rubrique'];
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	$att = " id='id_parent' name='id_parent'\nclass='selecteur_parent verdana1'";
251 251
 
252 252
 	if (preg_match(',^<option[^<>]*value=.(\d*).[^<>]*>([^<]*)</option>$,', $opt, $r)) {
253
-		$r = "<input$att type='hidden' value='" . $r[1] . "' />" . $r[2];
253
+		$r = "<input$att type='hidden' value='".$r[1]."' />".$r[2];
254 254
 	} else {
255
-		$r = '<select' . $att . " size='1'>\n$opt</select>\n";
255
+		$r = '<select'.$att." size='1'>\n$opt</select>\n";
256 256
 	}
257 257
 
258 258
 	# message pour neuneus (a supprimer ?)
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem = 0, $do = 'aff') {
295 295
 
296 296
 	if ($id_rubrique) {
297
-		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
297
+		$titre = sql_getfetsel('titre', 'spip_rubriques', 'id_rubrique='.(int) $id_rubrique);
298 298
 	} else {
299 299
 		$titre = $type == 'auteur' ? '&nbsp;' : _T('info_racine_site');
300 300
 	}
301 301
 
302 302
 	$titre = str_replace('&amp;', '&', (string) entites_html(textebrut(typo($titre))));
303
-	$init = " disabled='disabled' type='text' value=\"" . $titre . "\"\nstyle='width:300px;'";
303
+	$init = " disabled='disabled' type='text' value=\"".$titre."\"\nstyle='width:300px;'";
304 304
 
305 305
 	$url = generer_url_ecrire('selectionner', "id=$id_rubrique&type=$type&do=$do"
306 306
 		. ($idem ? "&exclus=$idem" : '')
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 		. " jQuery(this).toggleClass('toggled'); "
350 350
 		. "return charger_node_url_si_vide('"
351 351
 		. $url
352
-		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='" . attribut_html(_T('titre_image_selecteur')) . "'>"
352
+		. "', this.parentNode.nextSibling, this.nextSibling,'',event)\" title='".attribut_html(_T('titre_image_selecteur'))."'>"
353 353
 		. $img_icone
354 354
 		. "</a><img src='"
355 355
 		. chemin_image('loader.svg')
Please login to merge, or discard this patch.
ecrire/inc/cvt_multietapes.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -313,9 +313,9 @@
 block discarded – undo
313 313
 		&& ($e = $flux['args']['contexte']['_etape']) > 1
314 314
 		&& ($ext = $flux['args']['ext'])
315 315
 		&& ($f = $flux['data'])
316
-		&& file_exists($f . "_$e.$ext")
316
+		&& file_exists($f."_$e.$ext")
317 317
 	) {
318
-		$flux['data'] = $f . "_$e";
318
+		$flux['data'] = $f."_$e";
319 319
 	}
320 320
 
321 321
 	return $flux;
Please login to merge, or discard this patch.
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
  */
66 66
 
67 67
 if (!defined('_ECRIRE_INC_VERSION')) {
68
-	return;
68
+    return;
69 69
 }
70 70
 
71 71
 /**
@@ -76,46 +76,46 @@  discard block
 block discarded – undo
76 76
  * @return array|false
77 77
  */
78 78
 function cvtmulti_recuperer_post_precedents($form) {
79
-	include_spip('inc/filtres');
80
-	if (
81
-		$form
82
-		&& ($c = _request('cvtm_prev_post'))
83
-		&& ($c = decoder_contexte_ajax($c, $form))
84
-	) {
85
-		#var_dump($c);
79
+    include_spip('inc/filtres');
80
+    if (
81
+        $form
82
+        && ($c = _request('cvtm_prev_post'))
83
+        && ($c = decoder_contexte_ajax($c, $form))
84
+    ) {
85
+        #var_dump($c);
86 86
 
87
-		# reinjecter dans la bonne variable pour permettre de retrouver
88
-		# toutes les saisies dans un seul tableau
89
-		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
90
-			$store = &$_POST;
91
-		} else {
92
-			$store = &$_GET;
93
-		}
87
+        # reinjecter dans la bonne variable pour permettre de retrouver
88
+        # toutes les saisies dans un seul tableau
89
+        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
90
+            $store = &$_POST;
91
+        } else {
92
+            $store = &$_GET;
93
+        }
94 94
 
95
-		foreach ($c as $k => $v) { // on ecrase pas si saisi a nouveau !
96
-		if (!isset($store[$k])) {
97
-				$_REQUEST[$k] = $store[$k] = $v;
98
-		} // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie
99
-			elseif (
100
-				is_array($store[$k])
101
-				&& is_array($v)
102
-				&& ($z = array_keys($v))
103
-				&& !is_numeric(reset($z))
104
-				&& ($z = array_keys($store[$k]))
105
-				&& !is_numeric(reset($z))
106
-			) {
107
-				$_REQUEST[$k] = $store[$k] = array_merge($v, $store[$k]);
108
-			}
109
-		}
95
+        foreach ($c as $k => $v) { // on ecrase pas si saisi a nouveau !
96
+        if (!isset($store[$k])) {
97
+                $_REQUEST[$k] = $store[$k] = $v;
98
+        } // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie
99
+            elseif (
100
+                is_array($store[$k])
101
+                && is_array($v)
102
+                && ($z = array_keys($v))
103
+                && !is_numeric(reset($z))
104
+                && ($z = array_keys($store[$k]))
105
+                && !is_numeric(reset($z))
106
+            ) {
107
+                $_REQUEST[$k] = $store[$k] = array_merge($v, $store[$k]);
108
+            }
109
+        }
110 110
 
111
-		// vider pour eviter un second appel a verifier_n
112
-		// en cas de double implementation (unipotence)
113
-		set_request('cvtm_prev_post');
111
+        // vider pour eviter un second appel a verifier_n
112
+        // en cas de double implementation (unipotence)
113
+        set_request('cvtm_prev_post');
114 114
 
115
-		return [$c['_etape'], $c['_etapes']];
116
-	}
115
+        return [$c['_etape'], $c['_etapes']];
116
+    }
117 117
 
118
-	return false;
118
+    return false;
119 119
 }
120 120
 
121 121
 /**
@@ -128,28 +128,28 @@  discard block
 block discarded – undo
128 128
  * @return array
129 129
  */
130 130
 function cvtmulti_sauver_post($form, $je_suis_poste, &$valeurs) {
131
-	if (!isset($valeurs['_cvtm_prev_post'])) {
132
-		$post = ['_etape' => $valeurs['_etape'], '_etapes' => $valeurs['_etapes']];
133
-		foreach (array_keys($valeurs) as $champ) {
134
-			if (
135
-				!str_starts_with($champ, '_')
136
-				&& ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request']))
137
-				&& ($v = _request($champ)) !== null
138
-			) {
139
-				$post[$champ] = $v;
140
-			}
141
-		}
142
-		include_spip('inc/filtres');
143
-		$c = encoder_contexte_ajax($post, $form);
144
-		if (!isset($valeurs['_hidden'])) {
145
-			$valeurs['_hidden'] = '';
146
-		}
147
-		$valeurs['_hidden'] .= "<input type='hidden' name='cvtm_prev_post' value='$c' />";
148
-		// marquer comme fait, pour eviter double encodage (unipotence)
149
-		$valeurs['_cvtm_prev_post'] = true;
150
-	}
131
+    if (!isset($valeurs['_cvtm_prev_post'])) {
132
+        $post = ['_etape' => $valeurs['_etape'], '_etapes' => $valeurs['_etapes']];
133
+        foreach (array_keys($valeurs) as $champ) {
134
+            if (
135
+                !str_starts_with($champ, '_')
136
+                && ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request']))
137
+                && ($v = _request($champ)) !== null
138
+            ) {
139
+                $post[$champ] = $v;
140
+            }
141
+        }
142
+        include_spip('inc/filtres');
143
+        $c = encoder_contexte_ajax($post, $form);
144
+        if (!isset($valeurs['_hidden'])) {
145
+            $valeurs['_hidden'] = '';
146
+        }
147
+        $valeurs['_hidden'] .= "<input type='hidden' name='cvtm_prev_post' value='$c' />";
148
+        // marquer comme fait, pour eviter double encodage (unipotence)
149
+        $valeurs['_cvtm_prev_post'] = true;
150
+    }
151 151
 
152
-	return $valeurs;
152
+    return $valeurs;
153 153
 }
154 154
 
155 155
 /**
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
  * @return array
160 160
  */
161 161
 function cvtmulti_formulaire_charger_etapes($args, $valeurs) {
162
-	if (!isset($valeurs['_etape'])) {
163
-		$form = $args['form'];
164
-		$je_suis_poste = $args['je_suis_poste'];
165
-		$nb_etapes = $valeurs['_etapes'];
166
-		$etape = _request('_etape');
167
-		$etape = min(max($etape, 1), $nb_etapes);
168
-		set_request('_etape', $etape);
169
-		$valeurs['_etape'] = $etape;
162
+    if (!isset($valeurs['_etape'])) {
163
+        $form = $args['form'];
164
+        $je_suis_poste = $args['je_suis_poste'];
165
+        $nb_etapes = $valeurs['_etapes'];
166
+        $etape = _request('_etape');
167
+        $etape = min(max($etape, 1), $nb_etapes);
168
+        set_request('_etape', $etape);
169
+        $valeurs['_etape'] = $etape;
170 170
 
171
-		// sauver les posts de cette etape pour les avoir a la prochaine etape
172
-		$valeurs = cvtmulti_sauver_post($form, $je_suis_poste, $valeurs);
173
-	}
174
-	return $valeurs;
171
+        // sauver les posts de cette etape pour les avoir a la prochaine etape
172
+        $valeurs = cvtmulti_sauver_post($form, $je_suis_poste, $valeurs);
173
+    }
174
+    return $valeurs;
175 175
 }
176 176
 
177 177
 /**
@@ -182,87 +182,87 @@  discard block
 block discarded – undo
182 182
  * @return array
183 183
  */
184 184
 function cvtmulti_formulaire_verifier_etapes($args, $erreurs) {
185
-	#var_dump('Pipe verifier');
185
+    #var_dump('Pipe verifier');
186 186
 
187
-	if (
188
-		($form = $args['form'])
189
-		&& ($e = cvtmulti_recuperer_post_precedents($form)) !== false
190
-	) {
191
-		// recuperer l'etape saisie et le nombre d'etapes total
192
-		[$etape, $etapes] = $e;
193
-		$etape_demandee = (int) _request('aller_a_etape'); // possibilite de poster un entier dans aller_a_etape
187
+    if (
188
+        ($form = $args['form'])
189
+        && ($e = cvtmulti_recuperer_post_precedents($form)) !== false
190
+    ) {
191
+        // recuperer l'etape saisie et le nombre d'etapes total
192
+        [$etape, $etapes] = $e;
193
+        $etape_demandee = (int) _request('aller_a_etape'); // possibilite de poster un entier dans aller_a_etape
194 194
 
195
-		$args['etape_saisie'] = $etape;
196
-		$args['etapes'] = $etapes;
197
-		// lancer les verifs pour chaque etape deja saisie de 1 a $etape
198
-		$erreurs_etapes = [];
199
-		$derniere_etape_ok = 0;
200
-		$e = 0;
201
-		while ($e < max($etape, $etape_demandee - 1) && $e < $etapes) {
202
-			$e++;
203
-			$erreurs_etapes[$e] = [];
204
-			if ($verifier = charger_fonction("verifier_$e", "formulaires/$form/", true)) {
205
-				$erreurs_etapes[$e] = $verifier(...$args['args']);
206
-			} elseif ($verifier = charger_fonction('verifier_etape', "formulaires/$form/", true)) {
207
-				$a = $args['args'];
208
-				array_unshift($a, $e);
209
-				$erreurs_etapes[$e] = $verifier(...$a);
210
-			}
211
-			// et on appelle un pipeline dedie aux etapes, plus easy
212
-			$args['etape'] = $e;
213
-			$args['etape_demandee'] = $etape_demandee;
214
-			$erreurs_etapes[$e] = pipeline(
215
-				'formulaire_verifier_etape',
216
-				[
217
-					'args' => $args,
218
-					'data' => $erreurs_etapes[$e]
219
-				]
220
-			);
195
+        $args['etape_saisie'] = $etape;
196
+        $args['etapes'] = $etapes;
197
+        // lancer les verifs pour chaque etape deja saisie de 1 a $etape
198
+        $erreurs_etapes = [];
199
+        $derniere_etape_ok = 0;
200
+        $e = 0;
201
+        while ($e < max($etape, $etape_demandee - 1) && $e < $etapes) {
202
+            $e++;
203
+            $erreurs_etapes[$e] = [];
204
+            if ($verifier = charger_fonction("verifier_$e", "formulaires/$form/", true)) {
205
+                $erreurs_etapes[$e] = $verifier(...$args['args']);
206
+            } elseif ($verifier = charger_fonction('verifier_etape', "formulaires/$form/", true)) {
207
+                $a = $args['args'];
208
+                array_unshift($a, $e);
209
+                $erreurs_etapes[$e] = $verifier(...$a);
210
+            }
211
+            // et on appelle un pipeline dedie aux etapes, plus easy
212
+            $args['etape'] = $e;
213
+            $args['etape_demandee'] = $etape_demandee;
214
+            $erreurs_etapes[$e] = pipeline(
215
+                'formulaire_verifier_etape',
216
+                [
217
+                    'args' => $args,
218
+                    'data' => $erreurs_etapes[$e]
219
+                ]
220
+            );
221 221
 
222
-			if ($derniere_etape_ok === $e - 1 && !(is_countable($erreurs_etapes[$e]) ? count($erreurs_etapes[$e]) : 0)) {
223
-				$derniere_etape_ok = $e;
224
-			}
225
-			// possibilite de poster dans _retour_etape_x ou aller_a_etape
226
-			if (!is_null(_request("_retour_etape_$e"))) {
227
-				$etape_demandee = $e;
228
-			}
229
-			// Il se peut que les verifications ait décidé de faire sauter des étapes
230
-			if ($aller_a_etape = (int) _request('aller_a_etape')) {
231
-				$etape_demandee = $aller_a_etape; // possibilite de poster un entier dans aller_a_etape
232
-			}
233
-		}
222
+            if ($derniere_etape_ok === $e - 1 && !(is_countable($erreurs_etapes[$e]) ? count($erreurs_etapes[$e]) : 0)) {
223
+                $derniere_etape_ok = $e;
224
+            }
225
+            // possibilite de poster dans _retour_etape_x ou aller_a_etape
226
+            if (!is_null(_request("_retour_etape_$e"))) {
227
+                $etape_demandee = $e;
228
+            }
229
+            // Il se peut que les verifications ait décidé de faire sauter des étapes
230
+            if ($aller_a_etape = (int) _request('aller_a_etape')) {
231
+                $etape_demandee = $aller_a_etape; // possibilite de poster un entier dans aller_a_etape
232
+            }
233
+        }
234 234
 
235 235
 
236
-		// si la derniere etape OK etait la derniere
237
-		// on renvoie le flux inchange et ca declenche traiter
238
-		if (
239
-			$derniere_etape_ok == $etapes
240
-			&& (!$etape_demandee || $etape_demandee >= $etapes)
241
-		) {
242
-			return $erreurs;
243
-		} else {
244
-			$etape = $derniere_etape_ok + 1;
245
-			if ($etape_demandee > 0 && $etape_demandee < $etape) {
246
-				$etape = $etape_demandee;
247
-			}
248
-			$etape = min($etape, $etapes);
249
-			#var_dump("prochaine etape $etape");
250
-			// retourner les erreurs de l'etape ciblee
251
-			$erreurs = $erreurs_etapes[$etape] ?? [];
252
-			// Ne pas se tromper dans le texte du message d'erreur : la clé '_etapes' n'est pas une erreur !
253
-			if ($erreurs) {
254
-				if (!isset($erreurs['message_erreur'])) {
255
-					$erreurs['message_erreur'] = singulier_ou_pluriel(is_countable($erreurs) ? count($erreurs) : 0, 'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie');
256
-				}
257
-			} else {
258
-				$erreurs['message_erreur'] = '';
259
-			}
260
-			$erreurs['_etapes'] = "etape suivante $etape";
261
-			set_request('_etape', $etape);
262
-		}
263
-	}
236
+        // si la derniere etape OK etait la derniere
237
+        // on renvoie le flux inchange et ca declenche traiter
238
+        if (
239
+            $derniere_etape_ok == $etapes
240
+            && (!$etape_demandee || $etape_demandee >= $etapes)
241
+        ) {
242
+            return $erreurs;
243
+        } else {
244
+            $etape = $derniere_etape_ok + 1;
245
+            if ($etape_demandee > 0 && $etape_demandee < $etape) {
246
+                $etape = $etape_demandee;
247
+            }
248
+            $etape = min($etape, $etapes);
249
+            #var_dump("prochaine etape $etape");
250
+            // retourner les erreurs de l'etape ciblee
251
+            $erreurs = $erreurs_etapes[$etape] ?? [];
252
+            // Ne pas se tromper dans le texte du message d'erreur : la clé '_etapes' n'est pas une erreur !
253
+            if ($erreurs) {
254
+                if (!isset($erreurs['message_erreur'])) {
255
+                    $erreurs['message_erreur'] = singulier_ou_pluriel(is_countable($erreurs) ? count($erreurs) : 0, 'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie');
256
+                }
257
+            } else {
258
+                $erreurs['message_erreur'] = '';
259
+            }
260
+            $erreurs['_etapes'] = "etape suivante $etape";
261
+            set_request('_etape', $etape);
262
+        }
263
+    }
264 264
 
265
-	return $erreurs;
265
+    return $erreurs;
266 266
 }
267 267
 
268 268
 /**
@@ -274,17 +274,17 @@  discard block
 block discarded – undo
274 274
  * @return array
275 275
  */
276 276
 function cvtmulti_styliser($flux) {
277
-	if (
278
-		str_starts_with((string) $flux['args']['fond'], 'formulaires/')
279
-		&& isset($flux['args']['contexte']['_etapes'])
280
-		&& isset($flux['args']['contexte']['_etape'])
281
-		&& ($e = $flux['args']['contexte']['_etape']) > 1
282
-		&& ($ext = $flux['args']['ext'])
283
-		&& ($f = $flux['data'])
284
-		&& file_exists($f . "_$e.$ext")
285
-	) {
286
-		$flux['data'] = $f . "_$e";
287
-	}
277
+    if (
278
+        str_starts_with((string) $flux['args']['fond'], 'formulaires/')
279
+        && isset($flux['args']['contexte']['_etapes'])
280
+        && isset($flux['args']['contexte']['_etape'])
281
+        && ($e = $flux['args']['contexte']['_etape']) > 1
282
+        && ($ext = $flux['args']['ext'])
283
+        && ($f = $flux['data'])
284
+        && file_exists($f . "_$e.$ext")
285
+    ) {
286
+        $flux['data'] = $f . "_$e";
287
+    }
288 288
 
289
-	return $flux;
289
+    return $flux;
290 290
 }
Please login to merge, or discard this patch.