Completed
Push — master ( d9afd7...afcd40 )
by cam
01:15
created
ecrire/plugins/afficher_plugin.php 2 patches
Indentation   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -17,221 +17,221 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 include_spip('inc/charsets');
23 23
 include_spip('inc/texte');
24 24
 include_spip('inc/plugin'); // pour plugin_est_installe
25 25
 
26 26
 function plugins_afficher_plugin_dist(
27
-	$url_page,
28
-	$plug_file,
29
-	$checked,
30
-	$actif,
31
-	$expose = false,
32
-	$class_li = 'item',
33
-	$dir_plugins = _DIR_PLUGINS
27
+    $url_page,
28
+    $plug_file,
29
+    $checked,
30
+    $actif,
31
+    $expose = false,
32
+    $class_li = 'item',
33
+    $dir_plugins = _DIR_PLUGINS
34 34
 ) {
35 35
 
36
-	static $id_input = 0;
37
-	static $versions = [];
38
-
39
-	$force_reload = (_request('var_mode') == 'recalcul');
40
-	$get_infos = charger_fonction('get_infos', 'plugins');
41
-	$info = $get_infos($plug_file, $force_reload, $dir_plugins);
42
-	$prefix = $info['prefix'];
43
-	$cfg = '';
44
-	$checkable = ($dir_plugins !== _DIR_PLUGINS_DIST);
45
-	$nom = plugin_nom($info, $dir_plugins, $plug_file);
46
-	$erreur = '';
47
-
48
-	if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
49
-		$info['slogan'] = _T('plugin_info_non_compatible_spip');
50
-		$erreur = http_img_pack(
51
-			'plugin-dis-32.png',
52
-			_T('plugin_info_non_compatible_spip'),
53
-			" class='picto_err'",
54
-			_T('plugin_info_non_compatible_spip')
55
-		);
56
-		$class_li .= ' disabled';
57
-		$checkable = false;
58
-	} elseif (isset($info['erreur'])) {
59
-		$class_li .= ' error';
60
-		$erreur = http_img_pack(
61
-			'plugin-err-32.png',
62
-			_T('plugin_info_erreur_xml'),
63
-			" class='picto_err'",
64
-			_T('plugin_info_erreur_xml')
65
-		)
66
-			. "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>';
67
-		$checkable = false;
68
-	} elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) {
69
-		$class_li .= ' error';
70
-		$erreur = http_img_pack(
71
-			'plugin-err-32.png',
72
-			_T('plugin_impossible_activer', ['plugin' => $nom]),
73
-			" class='picto_err'",
74
-			_T('plugin_impossible_activer', ['plugin' => $nom])
75
-		)
76
-			. "<div class='erreur'>" . implode(
77
-				'<br />',
78
-				$GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]
79
-			) . '</div>';
80
-	} else {
81
-		$cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : '';
82
-		if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) {
83
-			//$info['slogan'] = _T('plugin_info_non_compatible_spip');
84
-			$erreur = http_img_pack(
85
-				'plugin-dis-32.png',
86
-				_T('plugin_info_non_compatible_spip'),
87
-				" class='picto_err picto_compat_forcee'",
88
-				_L('Version incompatible : compatibilité forcée')
89
-			);
90
-		}
91
-	}
92
-
93
-	// numerotons les occurrences d'un meme prefix
94
-	$versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : '';
95
-
96
-	$class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : '');
97
-
98
-	return "<li id='$prefix$id' class='$class_li'>"
99
-	. ((!$checkable and !$checked)
100
-		? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked))
101
-	. plugin_resume($info, $dir_plugins, $plug_file, $url_page)
102
-	. $cfg
103
-	. $erreur
104
-	. (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file))
105
-		? plugin_desintalle($plug_file, $nom, $dir_plugins) : '')
106
-	. "<div class='details'>" // pour l'ajax de exec/info_plugin
107
-	. (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins))
108
-	. '</div>'
109
-	. '</li>';
36
+    static $id_input = 0;
37
+    static $versions = [];
38
+
39
+    $force_reload = (_request('var_mode') == 'recalcul');
40
+    $get_infos = charger_fonction('get_infos', 'plugins');
41
+    $info = $get_infos($plug_file, $force_reload, $dir_plugins);
42
+    $prefix = $info['prefix'];
43
+    $cfg = '';
44
+    $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST);
45
+    $nom = plugin_nom($info, $dir_plugins, $plug_file);
46
+    $erreur = '';
47
+
48
+    if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
49
+        $info['slogan'] = _T('plugin_info_non_compatible_spip');
50
+        $erreur = http_img_pack(
51
+            'plugin-dis-32.png',
52
+            _T('plugin_info_non_compatible_spip'),
53
+            " class='picto_err'",
54
+            _T('plugin_info_non_compatible_spip')
55
+        );
56
+        $class_li .= ' disabled';
57
+        $checkable = false;
58
+    } elseif (isset($info['erreur'])) {
59
+        $class_li .= ' error';
60
+        $erreur = http_img_pack(
61
+            'plugin-err-32.png',
62
+            _T('plugin_info_erreur_xml'),
63
+            " class='picto_err'",
64
+            _T('plugin_info_erreur_xml')
65
+        )
66
+            . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>';
67
+        $checkable = false;
68
+    } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) {
69
+        $class_li .= ' error';
70
+        $erreur = http_img_pack(
71
+            'plugin-err-32.png',
72
+            _T('plugin_impossible_activer', ['plugin' => $nom]),
73
+            " class='picto_err'",
74
+            _T('plugin_impossible_activer', ['plugin' => $nom])
75
+        )
76
+            . "<div class='erreur'>" . implode(
77
+                '<br />',
78
+                $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]
79
+            ) . '</div>';
80
+    } else {
81
+        $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : '';
82
+        if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) {
83
+            //$info['slogan'] = _T('plugin_info_non_compatible_spip');
84
+            $erreur = http_img_pack(
85
+                'plugin-dis-32.png',
86
+                _T('plugin_info_non_compatible_spip'),
87
+                " class='picto_err picto_compat_forcee'",
88
+                _L('Version incompatible : compatibilité forcée')
89
+            );
90
+        }
91
+    }
92
+
93
+    // numerotons les occurrences d'un meme prefix
94
+    $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : '';
95
+
96
+    $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : '');
97
+
98
+    return "<li id='$prefix$id' class='$class_li'>"
99
+    . ((!$checkable and !$checked)
100
+        ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked))
101
+    . plugin_resume($info, $dir_plugins, $plug_file, $url_page)
102
+    . $cfg
103
+    . $erreur
104
+    . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file))
105
+        ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '')
106
+    . "<div class='details'>" // pour l'ajax de exec/info_plugin
107
+    . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins))
108
+    . '</div>'
109
+    . '</li>';
110 110
 }
111 111
 
112 112
 function plugin_bouton_config($nom, $infos, $dir) {
113
-	// la verification se base sur le filesystem
114
-	// il faut donc n'utiliser que des minuscules, par convention
115
-	$prefix = strtolower($infos['prefix']);
116
-	// si paquet.xml fournit un squelette, le prendre
117
-	if (isset($infos['config']) and $infos['config']) {
118
-		return recuperer_fond(
119
-			"$dir$nom/" . $infos['config'],
120
-			[
121
-				'script' => 'configurer_' . $prefix,
122
-				'nom' => $nom
123
-			]
124
-		);
125
-	}
126
-
127
-	// si le plugin CFG est la, l'essayer
128
-	if (defined('_DIR_PLUGIN_CFG')) {
129
-		if (include_spip('inc/cfg')) { // test CFG version >= 1.0.5
130
-		if ($cfg = icone_lien_cfg("$dir$nom", 'cfg')) {
131
-				return "<div class='cfg_link'>$cfg</div>";
132
-		}
133
-		}
134
-	}
135
-
136
-	// sinon prendre le squelette std sur le nom std
137
-	return recuperer_fond(
138
-		'prive/squelettes/inclure/cfg',
139
-		[
140
-			'script' => 'configurer_' . $prefix,
141
-			'nom' => $nom
142
-		]
143
-	);
113
+    // la verification se base sur le filesystem
114
+    // il faut donc n'utiliser que des minuscules, par convention
115
+    $prefix = strtolower($infos['prefix']);
116
+    // si paquet.xml fournit un squelette, le prendre
117
+    if (isset($infos['config']) and $infos['config']) {
118
+        return recuperer_fond(
119
+            "$dir$nom/" . $infos['config'],
120
+            [
121
+                'script' => 'configurer_' . $prefix,
122
+                'nom' => $nom
123
+            ]
124
+        );
125
+    }
126
+
127
+    // si le plugin CFG est la, l'essayer
128
+    if (defined('_DIR_PLUGIN_CFG')) {
129
+        if (include_spip('inc/cfg')) { // test CFG version >= 1.0.5
130
+        if ($cfg = icone_lien_cfg("$dir$nom", 'cfg')) {
131
+                return "<div class='cfg_link'>$cfg</div>";
132
+        }
133
+        }
134
+    }
135
+
136
+    // sinon prendre le squelette std sur le nom std
137
+    return recuperer_fond(
138
+        'prive/squelettes/inclure/cfg',
139
+        [
140
+            'script' => 'configurer_' . $prefix,
141
+            'nom' => $nom
142
+        ]
143
+    );
144 144
 }
145 145
 
146 146
 // checkbox pour activer ou desactiver
147 147
 // si ce n'est pas une extension
148 148
 
149 149
 function plugin_checkbox($id_input, $file, $actif) {
150
-	$name = substr(md5($file), 0, 16);
151
-
152
-	return "<div class='check'>\n"
153
-	. "<input type='checkbox' name='s$name' id='label_$id_input'"
154
-	. ($actif ? " checked='checked'" : '')
155
-	. " class='checkbox'  value='O' />"
156
-	. "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>'
157
-	. '</div>';
150
+    $name = substr(md5($file), 0, 16);
151
+
152
+    return "<div class='check'>\n"
153
+    . "<input type='checkbox' name='s$name' id='label_$id_input'"
154
+    . ($actif ? " checked='checked'" : '')
155
+    . " class='checkbox'  value='O' />"
156
+    . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>'
157
+    . '</div>';
158 158
 }
159 159
 
160 160
 function plugin_nom($info, $dir_plugins, $plug_file) {
161
-	$prefix = $info['prefix'];
162
-	$dir = "$dir_plugins$plug_file";
163
-	// Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom"
164
-	if ($info['dtd'] == 'paquet') {
165
-		$nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix");
166
-		if (!$nom) {
167
-			$nom = typo($info['nom']);
168
-		}
169
-	} else {
170
-		$nom = typo(attribut_html($info['nom']));
171
-	}
172
-
173
-	return trim($nom);
161
+    $prefix = $info['prefix'];
162
+    $dir = "$dir_plugins$plug_file";
163
+    // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom"
164
+    if ($info['dtd'] == 'paquet') {
165
+        $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix");
166
+        if (!$nom) {
167
+            $nom = typo($info['nom']);
168
+        }
169
+    } else {
170
+        $nom = typo(attribut_html($info['nom']));
171
+    }
172
+
173
+    return trim($nom);
174 174
 }
175 175
 
176 176
 // Cartouche Resume
177 177
 function plugin_resume($info, $dir_plugins, $plug_file, $url_page) {
178
-	$prefix = $info['prefix'];
179
-	$dir = "$dir_plugins$plug_file";
180
-	$slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix"));
181
-	// une seule ligne dans le slogan : couper si besoin
182
-	if (($p = strpos($slogan, '<br />')) !== false) {
183
-		$slogan = substr($slogan, 0, $p);
184
-	}
185
-	// couper par securite
186
-	$slogan = couper($slogan, 80);
187
-
188
-	$nom = plugin_nom($info, $dir_plugins, $plug_file);
189
-
190
-	$url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE)));
191
-
192
-	$icon_class = 'icon';
193
-	$img = '';
194
-	if (isset($info['logo']) and $i = trim($info['logo'])) {
195
-		$img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]);
196
-		if (!extraire_attribut($img, 'src')) {
197
-			$img = '';
198
-		}
199
-	}
200
-	if (!$img) {
201
-		$img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'");
202
-		$icon_class .= ' no-logo';
203
-	}
204
-
205
-	$i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>";
206
-
207
-	return "<div class='resume'>"
208
-	. "<h3><a href='$url' rel='info'>"
209
-	. $nom
210
-	. '</a></h3>'
211
-	. " <span class='version'>" . $info['version'] . '</span>'
212
-	. " <span class='etat'> - "
213
-	. plugin_etat_en_clair($info['etat'])
214
-	. '</span>'
215
-	. "<div class='short'>" . $slogan . '</div>'
216
-	. $i
217
-	. '</div>';
178
+    $prefix = $info['prefix'];
179
+    $dir = "$dir_plugins$plug_file";
180
+    $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix"));
181
+    // une seule ligne dans le slogan : couper si besoin
182
+    if (($p = strpos($slogan, '<br />')) !== false) {
183
+        $slogan = substr($slogan, 0, $p);
184
+    }
185
+    // couper par securite
186
+    $slogan = couper($slogan, 80);
187
+
188
+    $nom = plugin_nom($info, $dir_plugins, $plug_file);
189
+
190
+    $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE)));
191
+
192
+    $icon_class = 'icon';
193
+    $img = '';
194
+    if (isset($info['logo']) and $i = trim($info['logo'])) {
195
+        $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]);
196
+        if (!extraire_attribut($img, 'src')) {
197
+            $img = '';
198
+        }
199
+    }
200
+    if (!$img) {
201
+        $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'");
202
+        $icon_class .= ' no-logo';
203
+    }
204
+
205
+    $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>";
206
+
207
+    return "<div class='resume'>"
208
+    . "<h3><a href='$url' rel='info'>"
209
+    . $nom
210
+    . '</a></h3>'
211
+    . " <span class='version'>" . $info['version'] . '</span>'
212
+    . " <span class='etat'> - "
213
+    . plugin_etat_en_clair($info['etat'])
214
+    . '</span>'
215
+    . "<div class='short'>" . $slogan . '</div>'
216
+    . $i
217
+    . '</div>';
218 218
 }
219 219
 
220 220
 function plugin_desintalle($plug_file, $nom, $dir_plugins = null) {
221
-	if (!$dir_plugins) {
222
-		$dir_plugins = _DIR_PLUGINS;
223
-	}
221
+    if (!$dir_plugins) {
222
+        $dir_plugins = _DIR_PLUGINS;
223
+    }
224 224
 
225
-	$action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin');
226
-	$text = _T('bouton_desinstaller');
227
-	$text2 = _T('info_desinstaller_plugin');
228
-	$file = basename($plug_file);
225
+    $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin');
226
+    $text = _T('bouton_desinstaller');
227
+    $text2 = _T('info_desinstaller_plugin');
228
+    $file = basename($plug_file);
229 229
 
230
-	return "<div class='actions'>[" .
231
-	"<a href='$action'
230
+    return "<div class='actions'>[" .
231
+    "<a href='$action'
232 232
 		onclick='return confirm(\"$text $nom ?\\n$text2\")'>"
233
-	. $text
234
-	. '</a>]</div>';
233
+    . $text
234
+    . '</a>]</div>';
235 235
 }
236 236
 
237 237
 /**
@@ -245,145 +245,145 @@  discard block
 block discarded – undo
245 245
  *     Traduction de l'état dans la langue en cours
246 246
  **/
247 247
 function plugin_etat_en_clair($etat) {
248
-	if (!in_array($etat, ['stable', 'test', 'experimental'])) {
249
-		$etat = 'developpement';
250
-	}
248
+    if (!in_array($etat, ['stable', 'test', 'experimental'])) {
249
+        $etat = 'developpement';
250
+    }
251 251
 
252
-	return _T('plugin_etat_' . $etat);
252
+    return _T('plugin_etat_' . $etat);
253 253
 }
254 254
 
255 255
 function plugin_propre($texte, $module = '', $propre = 'propre') {
256
-	// retirer le retour a la racine du module, car le find_in_path se fait depuis la racine
257
-	if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) {
258
-		$module = substr($module, strlen(_DIR_RACINE));
259
-	}
260
-	if (preg_match('|^\w+_[\w_]+$|', $texte)) {
261
-		$texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]);
262
-	}
263
-
264
-	return $propre($texte);
256
+    // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine
257
+    if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) {
258
+        $module = substr($module, strlen(_DIR_RACINE));
259
+    }
260
+    if (preg_match('|^\w+_[\w_]+$|', $texte)) {
261
+        $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]);
262
+    }
263
+
264
+    return $propre($texte);
265 265
 }
266 266
 
267 267
 function plugin_typo($texte, $module = '') {
268
-	return plugin_propre($texte, $module, 'typo');
268
+    return plugin_propre($texte, $module, 'typo');
269 269
 }
270 270
 
271 271
 
272 272
 function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) {
273
-	$log = null;
274
-	if (!$dir_plugins) {
275
-		$dir_plugins = _DIR_PLUGINS;
276
-	}
277
-
278
-	$prefix = $info['prefix'];
279
-	$dir = "$dir_plugins$plug_file/lang/paquet-$prefix";
280
-
281
-	$s = '';
282
-	// TODO: le traiter_multi ici n'est pas beau
283
-	// cf. description du plugin/_stable_/ortho/plugin.xml
284
-	// concerne les anciens plugin.xml donc on devrait plus en avoir besoin
285
-	$description = '';
286
-	if (isset($info['description'])) {
287
-		$description = plugin_propre($info['description'], $dir);
288
-	}
289
-
290
-	if (
291
-		isset($info['documentation'])
292
-		and $lien = $info['documentation']
293
-	) {
294
-		$description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>';
295
-	}
296
-	$s .= "<dd class='desc'>" . $description . "</dd>\n";
297
-
298
-	if (isset($info['auteur'])) {
299
-		if (is_array($info['auteur'])) {
300
-			$a = formater_credits($info['auteur'], ', ');
301
-		} // pour compat mais ne doit plus arriver
302
-		else {
303
-			$a = trim($info['auteur']);
304
-		}
305
-		if ($a) {
306
-			$s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre(
307
-				$a,
308
-				$dir
309
-			)) . "</dd>\n";
310
-		}
311
-	}
312
-
313
-	if (isset($info['credit'])) {
314
-		if ($a = formater_credits($info['credit'], ', ')) {
315
-			$s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre(
316
-				$a,
317
-				$dir
318
-			)) . "</dd>\n";
319
-		}
320
-	}
321
-
322
-	if (isset($info['licence'])) {
323
-		if (is_array($info['licence'])) {
324
-			$a = formater_credits($info['licence'], ', ');
325
-		} // pour compat mais ne doit plus arriver
326
-		else {
327
-			$a = trim($info['licence']);
328
-		}
329
-		if ($a) {
330
-			$s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre(
331
-				$a,
332
-				$dir
333
-			)) . "</dd>\n";
334
-		}
335
-	}
336
-
337
-	$s = "<dl class='description'>$s</dl>";
338
-
339
-	//
340
-	// Ajouter les infos techniques
341
-	//
342
-	$infotech = [];
343
-
344
-	$version = '<dt>' . _T('version') . '</dt><dd>' . $info['version'];
345
-	// Version VCS
346
-	if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) {
347
-		$version .= ' ' . $vcs;
348
-	}
349
-	$version .= '</dd>';
350
-	$infotech[] = $version;
351
-	$infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>';
352
-	// source zip le cas echeant
353
-	$infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log)
354
-		and preg_match(',^source:(.*)$,m', $log, $r))
355
-		? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>'
356
-		: '';
357
-
358
-	$infotech[] = !$info['necessite'] ? '' :
359
-		('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(
360
-			' ',
361
-			array_map('array_shift', $info['necessite'])
362
-		) . '</dd>');
363
-
364
-	$s .= "<dl class='tech'>"
365
-		. join('', $infotech)
366
-		. '</dl>';
367
-
368
-
369
-	return $s;
273
+    $log = null;
274
+    if (!$dir_plugins) {
275
+        $dir_plugins = _DIR_PLUGINS;
276
+    }
277
+
278
+    $prefix = $info['prefix'];
279
+    $dir = "$dir_plugins$plug_file/lang/paquet-$prefix";
280
+
281
+    $s = '';
282
+    // TODO: le traiter_multi ici n'est pas beau
283
+    // cf. description du plugin/_stable_/ortho/plugin.xml
284
+    // concerne les anciens plugin.xml donc on devrait plus en avoir besoin
285
+    $description = '';
286
+    if (isset($info['description'])) {
287
+        $description = plugin_propre($info['description'], $dir);
288
+    }
289
+
290
+    if (
291
+        isset($info['documentation'])
292
+        and $lien = $info['documentation']
293
+    ) {
294
+        $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>';
295
+    }
296
+    $s .= "<dd class='desc'>" . $description . "</dd>\n";
297
+
298
+    if (isset($info['auteur'])) {
299
+        if (is_array($info['auteur'])) {
300
+            $a = formater_credits($info['auteur'], ', ');
301
+        } // pour compat mais ne doit plus arriver
302
+        else {
303
+            $a = trim($info['auteur']);
304
+        }
305
+        if ($a) {
306
+            $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre(
307
+                $a,
308
+                $dir
309
+            )) . "</dd>\n";
310
+        }
311
+    }
312
+
313
+    if (isset($info['credit'])) {
314
+        if ($a = formater_credits($info['credit'], ', ')) {
315
+            $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre(
316
+                $a,
317
+                $dir
318
+            )) . "</dd>\n";
319
+        }
320
+    }
321
+
322
+    if (isset($info['licence'])) {
323
+        if (is_array($info['licence'])) {
324
+            $a = formater_credits($info['licence'], ', ');
325
+        } // pour compat mais ne doit plus arriver
326
+        else {
327
+            $a = trim($info['licence']);
328
+        }
329
+        if ($a) {
330
+            $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre(
331
+                $a,
332
+                $dir
333
+            )) . "</dd>\n";
334
+        }
335
+    }
336
+
337
+    $s = "<dl class='description'>$s</dl>";
338
+
339
+    //
340
+    // Ajouter les infos techniques
341
+    //
342
+    $infotech = [];
343
+
344
+    $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version'];
345
+    // Version VCS
346
+    if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) {
347
+        $version .= ' ' . $vcs;
348
+    }
349
+    $version .= '</dd>';
350
+    $infotech[] = $version;
351
+    $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>';
352
+    // source zip le cas echeant
353
+    $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log)
354
+        and preg_match(',^source:(.*)$,m', $log, $r))
355
+        ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>'
356
+        : '';
357
+
358
+    $infotech[] = !$info['necessite'] ? '' :
359
+        ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(
360
+            ' ',
361
+            array_map('array_shift', $info['necessite'])
362
+        ) . '</dd>');
363
+
364
+    $s .= "<dl class='tech'>"
365
+        . join('', $infotech)
366
+        . '</dl>';
367
+
368
+
369
+    return $s;
370 370
 }
371 371
 
372 372
 function formater_credits($infos, $sep = ', ') {
373
-	$texte = '';
374
-
375
-	foreach ($infos as $_credit) {
376
-		if ($texte) {
377
-			$texte .= $sep;
378
-		}
379
-		// Si le credit en cours n'est pas un array c'est donc un copyright
380
-		$texte .=
381
-			(!is_array($_credit))
382
-				? PtoBR(propre($_credit))
383
-				: ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') .
384
-				$_credit['nom'] .
385
-				($_credit['url'] ? '</a>' : '');
386
-	}
387
-
388
-	return $texte;
373
+    $texte = '';
374
+
375
+    foreach ($infos as $_credit) {
376
+        if ($texte) {
377
+            $texte .= $sep;
378
+        }
379
+        // Si le credit en cours n'est pas un array c'est donc un copyright
380
+        $texte .=
381
+            (!is_array($_credit))
382
+                ? PtoBR(propre($_credit))
383
+                : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') .
384
+                $_credit['nom'] .
385
+                ($_credit['url'] ? '</a>' : '');
386
+    }
387
+
388
+    return $texte;
389 389
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -35 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 			" class='picto_err'",
64 64
 			_T('plugin_info_erreur_xml')
65 65
 		)
66
-			. "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>';
66
+			. "<div class='erreur'>".join('<br >', $info['erreur']).'</div>';
67 67
 		$checkable = false;
68
-	} elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) {
68
+	} elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file])) {
69 69
 		$class_li .= ' error';
70 70
 		$erreur = http_img_pack(
71 71
 			'plugin-err-32.png',
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 			" class='picto_err'",
74 74
 			_T('plugin_impossible_activer', ['plugin' => $nom])
75 75
 		)
76
-			. "<div class='erreur'>" . implode(
76
+			. "<div class='erreur'>".implode(
77 77
 				'<br />',
78
-				$GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]
79
-			) . '</div>';
78
+				$GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file]
79
+			).'</div>';
80 80
 	} else {
81 81
 		$cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : '';
82 82
 		if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) {
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
 	// numerotons les occurrences d'un meme prefix
94 94
 	$versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : '';
95 95
 
96
-	$class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : '');
96
+	$class_li .= ($actif ? ' actif' : '').($expose ? ' on' : '');
97 97
 
98 98
 	return "<li id='$prefix$id' class='$class_li'>"
99 99
 	. ((!$checkable and !$checked)
100
-		? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked))
100
+		? '' : plugin_checkbox(++$id_input, $dir_plugins.$plug_file, $checked))
101 101
 	. plugin_resume($info, $dir_plugins, $plug_file, $url_page)
102 102
 	. $cfg
103 103
 	. $erreur
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	// si paquet.xml fournit un squelette, le prendre
117 117
 	if (isset($infos['config']) and $infos['config']) {
118 118
 		return recuperer_fond(
119
-			"$dir$nom/" . $infos['config'],
119
+			"$dir$nom/".$infos['config'],
120 120
 			[
121
-				'script' => 'configurer_' . $prefix,
121
+				'script' => 'configurer_'.$prefix,
122 122
 				'nom' => $nom
123 123
 			]
124 124
 		);
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	return recuperer_fond(
138 138
 		'prive/squelettes/inclure/cfg',
139 139
 		[
140
-			'script' => 'configurer_' . $prefix,
140
+			'script' => 'configurer_'.$prefix,
141 141
 			'nom' => $nom
142 142
 		]
143 143
 	);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	. "<input type='checkbox' name='s$name' id='label_$id_input'"
154 154
 	. ($actif ? " checked='checked'" : '')
155 155
 	. " class='checkbox'  value='O' />"
156
-	. "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>'
156
+	. "\n<label for='label_$id_input'>"._T('activer_plugin').'</label>'
157 157
 	. '</div>';
158 158
 }
159 159
 
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 	. "<h3><a href='$url' rel='info'>"
209 209
 	. $nom
210 210
 	. '</a></h3>'
211
-	. " <span class='version'>" . $info['version'] . '</span>'
211
+	. " <span class='version'>".$info['version'].'</span>'
212 212
 	. " <span class='etat'> - "
213 213
 	. plugin_etat_en_clair($info['etat'])
214 214
 	. '</span>'
215
-	. "<div class='short'>" . $slogan . '</div>'
215
+	. "<div class='short'>".$slogan.'</div>'
216 216
 	. $i
217 217
 	. '</div>';
218 218
 }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	$text2 = _T('info_desinstaller_plugin');
228 228
 	$file = basename($plug_file);
229 229
 
230
-	return "<div class='actions'>[" .
230
+	return "<div class='actions'>[".
231 231
 	"<a href='$action'
232 232
 		onclick='return confirm(\"$text $nom ?\\n$text2\")'>"
233 233
 	. $text
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 		$etat = 'developpement';
250 250
 	}
251 251
 
252
-	return _T('plugin_etat_' . $etat);
252
+	return _T('plugin_etat_'.$etat);
253 253
 }
254 254
 
255 255
 function plugin_propre($texte, $module = '', $propre = 'propre') {
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 		$module = substr($module, strlen(_DIR_RACINE));
259 259
 	}
260 260
 	if (preg_match('|^\w+_[\w_]+$|', $texte)) {
261
-		$texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]);
261
+		$texte = _T(($module ? "$module:" : '').$texte, [], ['force' => false]);
262 262
 	}
263 263
 
264 264
 	return $propre($texte);
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 		isset($info['documentation'])
292 292
 		and $lien = $info['documentation']
293 293
 	) {
294
-		$description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>';
294
+		$description .= "<p><em class='site'><a href='$lien' class='spip_out'>"._T('en_savoir_plus').'</a></em></p>';
295 295
 	}
296
-	$s .= "<dd class='desc'>" . $description . "</dd>\n";
296
+	$s .= "<dd class='desc'>".$description."</dd>\n";
297 297
 
298 298
 	if (isset($info['auteur'])) {
299 299
 		if (is_array($info['auteur'])) {
@@ -303,19 +303,19 @@  discard block
 block discarded – undo
303 303
 			$a = trim($info['auteur']);
304 304
 		}
305 305
 		if ($a) {
306
-			$s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre(
306
+			$s .= "<dt class='auteurs'>"._T('public:par_auteur')."</dt><dd class='auteurs'>".PtoBR(propre(
307 307
 				$a,
308 308
 				$dir
309
-			)) . "</dd>\n";
309
+			))."</dd>\n";
310 310
 		}
311 311
 	}
312 312
 
313 313
 	if (isset($info['credit'])) {
314 314
 		if ($a = formater_credits($info['credit'], ', ')) {
315
-			$s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre(
315
+			$s .= "<dt class='credits'>"._T('plugin_info_credit')."</dt><dd class='credits'>".PtoBR(propre(
316 316
 				$a,
317 317
 				$dir
318
-			)) . "</dd>\n";
318
+			))."</dd>\n";
319 319
 		}
320 320
 	}
321 321
 
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 			$a = trim($info['licence']);
328 328
 		}
329 329
 		if ($a) {
330
-			$s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre(
330
+			$s .= "<dt class='licence'>"._T('intitule_licence')."</dt><dd class='licence'>".PtoBR(propre(
331 331
 				$a,
332 332
 				$dir
333
-			)) . "</dd>\n";
333
+			))."</dd>\n";
334 334
 		}
335 335
 	}
336 336
 
@@ -341,25 +341,24 @@  discard block
 block discarded – undo
341 341
 	//
342 342
 	$infotech = [];
343 343
 
344
-	$version = '<dt>' . _T('version') . '</dt><dd>' . $info['version'];
344
+	$version = '<dt>'._T('version').'</dt><dd>'.$info['version'];
345 345
 	// Version VCS
346
-	if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) {
347
-		$version .= ' ' . $vcs;
346
+	if ($vcs = version_vcs_courante($dir_plugins.$plug_file)) {
347
+		$version .= ' '.$vcs;
348 348
 	}
349 349
 	$version .= '</dd>';
350 350
 	$infotech[] = $version;
351
-	$infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>';
351
+	$infotech[] = '<dt>'._T('repertoire_plugins').'</dt><dd>'.joli_repertoire("$dir_plugins$plug_file").'</dd>';
352 352
 	// source zip le cas echeant
353
-	$infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log)
353
+	$infotech[] = (lire_fichier($dir_plugins.$plug_file.'/install.log', $log)
354 354
 		and preg_match(',^source:(.*)$,m', $log, $r))
355
-		? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>'
355
+		? '<dt>'._T('plugin_source').'</dt><dd>'.trim($r[1]).'</dd>'
356 356
 		: '';
357 357
 
358
-	$infotech[] = !$info['necessite'] ? '' :
359
-		('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(
358
+	$infotech[] = !$info['necessite'] ? '' : ('<dt>'._T('plugin_info_necessite').'</dt><dd>'.join(
360 359
 			' ',
361 360
 			array_map('array_shift', $info['necessite'])
362
-		) . '</dd>');
361
+		).'</dd>');
363 362
 
364 363
 	$s .= "<dl class='tech'>"
365 364
 		. join('', $infotech)
@@ -380,8 +379,8 @@  discard block
 block discarded – undo
380 379
 		$texte .=
381 380
 			(!is_array($_credit))
382 381
 				? PtoBR(propre($_credit))
383
-				: ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') .
384
-				$_credit['nom'] .
382
+				: ($_credit['url'] ? '<a href="'.$_credit['url'].'">' : '').
383
+				$_credit['nom'].
385 384
 				($_credit['url'] ? '</a>' : '');
386 385
 	}
387 386
 
Please login to merge, or discard this patch.
ecrire/inc/presentation.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Presentation
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/presentation_mini');
@@ -31,141 +31,141 @@  discard block
 block discarded – undo
31 31
 include_spip('inc/filtres_alertes');
32 32
 
33 33
 function debut_cadre($style, $icone = '', $fonction = '', $titre = '', $id = '', $class = '', $padding = true) {
34
-	$fond = null;
35
-	$style_mapping = [
36
-		'r' => 'simple',
37
-		'e' => 'raccourcis',
38
-		'couleur' => 'basic highlight',
39
-		'couleur-foncee' => 'basic highlight',
40
-		'trait-couleur' => 'important',
41
-		'alerte' => 'notice',
42
-		'info' => 'info',
43
-		'sous_rub' => 'simple sous-rub'
44
-	];
45
-	$style_titre_mapping = ['couleur' => 'topper', 'trait-couleur' => 'section'];
46
-	$c = $style_mapping[$style] ?? 'simple';
47
-	$class = $c . ($class ? " $class" : '');
48
-	if (!$padding) {
49
-		$class .= ($class ? ' ' : '') . 'no-padding';
50
-	}
51
-
52
-	//($id?"id='$id' ":"")
53
-	if (strlen($icone) > 1) {
54
-		if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
55
-			[$fond, $fonction] = $icone_renommer($icone, $fonction);
56
-		}
57
-		$size = 24;
58
-		if (preg_match('/-([0-9]{1,3})[.](gif|png)$/i', $fond, $match)) {
59
-			$size = $match[1];
60
-		}
61
-		if ($fonction) {
62
-			// 2 images pour composer l'icone : le fond (article) en background,
63
-			// la fonction (new) en image
64
-			$icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n" .
65
-				http_style_background($fond, 'no-repeat center center', $size));
66
-		} else {
67
-			$icone = http_img_pack($fond, '', "class='cadre-icone' width='$size' height='$size'");
68
-		}
69
-		$titre = $icone . $titre;
70
-	}
71
-
72
-	return boite_ouvrir($titre, $class, $style_titre_mapping[$style] ?? '', $id);
34
+    $fond = null;
35
+    $style_mapping = [
36
+        'r' => 'simple',
37
+        'e' => 'raccourcis',
38
+        'couleur' => 'basic highlight',
39
+        'couleur-foncee' => 'basic highlight',
40
+        'trait-couleur' => 'important',
41
+        'alerte' => 'notice',
42
+        'info' => 'info',
43
+        'sous_rub' => 'simple sous-rub'
44
+    ];
45
+    $style_titre_mapping = ['couleur' => 'topper', 'trait-couleur' => 'section'];
46
+    $c = $style_mapping[$style] ?? 'simple';
47
+    $class = $c . ($class ? " $class" : '');
48
+    if (!$padding) {
49
+        $class .= ($class ? ' ' : '') . 'no-padding';
50
+    }
51
+
52
+    //($id?"id='$id' ":"")
53
+    if (strlen($icone) > 1) {
54
+        if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
55
+            [$fond, $fonction] = $icone_renommer($icone, $fonction);
56
+        }
57
+        $size = 24;
58
+        if (preg_match('/-([0-9]{1,3})[.](gif|png)$/i', $fond, $match)) {
59
+            $size = $match[1];
60
+        }
61
+        if ($fonction) {
62
+            // 2 images pour composer l'icone : le fond (article) en background,
63
+            // la fonction (new) en image
64
+            $icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n" .
65
+                http_style_background($fond, 'no-repeat center center', $size));
66
+        } else {
67
+            $icone = http_img_pack($fond, '', "class='cadre-icone' width='$size' height='$size'");
68
+        }
69
+        $titre = $icone . $titre;
70
+    }
71
+
72
+    return boite_ouvrir($titre, $class, $style_titre_mapping[$style] ?? '', $id);
73 73
 }
74 74
 
75 75
 function fin_cadre() {
76
- return boite_fermer();
76
+    return boite_fermer();
77 77
 }
78 78
 
79 79
 
80 80
 function debut_cadre_relief(
81
-	$icone = '',
82
-	$dummy = '',
83
-	$fonction = '',
84
-	$titre = '',
85
-	$id = '',
86
-	$class = ''
81
+    $icone = '',
82
+    $dummy = '',
83
+    $fonction = '',
84
+    $titre = '',
85
+    $id = '',
86
+    $class = ''
87 87
 ) {
88
-	return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
88
+    return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
89 89
 }
90 90
 
91 91
 function fin_cadre_relief() {
92
- return fin_cadre();
92
+    return fin_cadre();
93 93
 }
94 94
 
95 95
 function debut_cadre_enfonce(
96
-	$icone = '',
97
-	$dummy = '',
98
-	$fonction = '',
99
-	$titre = '',
100
-	$id = '',
101
-	$class = ''
96
+    $icone = '',
97
+    $dummy = '',
98
+    $fonction = '',
99
+    $titre = '',
100
+    $id = '',
101
+    $class = ''
102 102
 ) {
103
-	return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
103
+    return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
104 104
 }
105 105
 
106 106
 function fin_cadre_enfonce() {
107
- return fin_cadre();
107
+    return fin_cadre();
108 108
 }
109 109
 
110 110
 function debut_cadre_sous_rub(
111
-	$icone = '',
112
-	$dummy = '',
113
-	$fonction = '',
114
-	$titre = '',
115
-	$id = '',
116
-	$class = ''
111
+    $icone = '',
112
+    $dummy = '',
113
+    $fonction = '',
114
+    $titre = '',
115
+    $id = '',
116
+    $class = ''
117 117
 ) {
118
-	return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
118
+    return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
119 119
 }
120 120
 
121 121
 function fin_cadre_sous_rub() {
122
- return fin_cadre();
122
+    return fin_cadre();
123 123
 }
124 124
 
125 125
 function debut_cadre_couleur(
126
-	$icone = '',
127
-	$dummy = '',
128
-	$fonction = '',
129
-	$titre = '',
130
-	$id = '',
131
-	$class = ''
126
+    $icone = '',
127
+    $dummy = '',
128
+    $fonction = '',
129
+    $titre = '',
130
+    $id = '',
131
+    $class = ''
132 132
 ) {
133
-	return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
133
+    return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
134 134
 }
135 135
 
136 136
 function fin_cadre_couleur() {
137
- return fin_cadre();
137
+    return fin_cadre();
138 138
 }
139 139
 
140 140
 function debut_cadre_trait_couleur(
141
-	$icone = '',
142
-	$dummy = '',
143
-	$fonction = '',
144
-	$titre = '',
145
-	$id = '',
146
-	$class = ''
141
+    $icone = '',
142
+    $dummy = '',
143
+    $fonction = '',
144
+    $titre = '',
145
+    $id = '',
146
+    $class = ''
147 147
 ) {
148
-	return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
148
+    return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
149 149
 }
150 150
 
151 151
 function fin_cadre_trait_couleur() {
152
- return fin_cadre();
152
+    return fin_cadre();
153 153
 }
154 154
 
155 155
 function debut_boite_alerte() {
156
- return debut_cadre('alerte', '', '', '', '', '');
156
+    return debut_cadre('alerte', '', '', '', '', '');
157 157
 }
158 158
 
159 159
 function fin_boite_alerte() {
160
- return fin_cadre();
160
+    return fin_cadre();
161 161
 }
162 162
 
163 163
 function debut_boite_info() {
164
- return debut_cadre('info', '', '', '', '', '');
164
+    return debut_cadre('info', '', '', '', '', '');
165 165
 }
166 166
 
167 167
 function fin_boite_info() {
168
- return fin_cadre();
168
+    return fin_cadre();
169 169
 }
170 170
 
171 171
 /**
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
  * @return string Code PHP.
177 177
  **/
178 178
 function gros_titre(
179
-	$titre,
180
-	$ze_logo = ''
179
+    $titre,
180
+    $ze_logo = ''
181 181
 ) {
182
-	return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
182
+    return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
183 183
 }
184 184
 
185 185
 // La boite des raccourcis
186 186
 // Se place a droite si l'ecran est en mode panoramique.
187 187
 function bloc_des_raccourcis($bloc) {
188
-	return creer_colonne_droite()
189
-	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
188
+    return creer_colonne_droite()
189
+    . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
190 190
 }
191 191
 
192 192
 //
@@ -196,18 +196,18 @@  discard block
 block discarded – undo
196 196
 // Fonctions onglets
197 197
 // @param string $sous_classe	prend la valeur second pour definir les onglet de deuxieme niveau
198 198
 function debut_onglet($classe = 'barre_onglet') {
199
- return "<div class = '$classe clearfix'><ul>\n";
199
+    return "<div class = '$classe clearfix'><ul>\n";
200 200
 }
201 201
 
202 202
 function fin_onglet() {
203
- return "</ul></div>\n";
203
+    return "</ul></div>\n";
204 204
 }
205 205
 
206 206
 function onglet($texte, $lien, $onglet_ref, $onglet, $icone = '') {
207
-	return '<li>'
208
-	. ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
209
-	. lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
210
-	. '</li>';
207
+    return '<li>'
208
+    . ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
209
+    . lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
210
+    . '</li>';
211 211
 }
212 212
 
213 213
 /**
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
  *     Code HTML du lien
240 240
  **/
241 241
 function icone_verticale($texte, $lien, $fond, $fonction = '', $align = '', $javascript = '') {
242
-	// cas d'ajax_action_auteur: faut defaire le boulot
243
-	// (il faudrait fusionner avec le cas $javascript)
244
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
245
-		[$x, $lien, $atts, $texte] = $r;
246
-		$javascript .= $atts;
247
-	}
248
-
249
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
242
+    // cas d'ajax_action_auteur: faut defaire le boulot
243
+    // (il faudrait fusionner avec le cas $javascript)
244
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
245
+        [$x, $lien, $atts, $texte] = $r;
246
+        $javascript .= $atts;
247
+    }
248
+
249
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
250 250
 }
251 251
 
252 252
 /**
@@ -271,15 +271,15 @@  discard block
 block discarded – undo
271 271
  *     Code HTML du lien
272 272
  **/
273 273
 function icone_horizontale($texte, $lien, $fond, $fonction = '', $dummy = '', $javascript = '') {
274
-	$retour = '';
275
-	// cas d'ajax_action_auteur: faut defaire le boulot
276
-	// (il faudrait fusionner avec le cas $javascript)
277
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
278
-		[$x, $lien, $atts, $texte] = $r;
279
-		$javascript .= $atts;
280
-	}
274
+    $retour = '';
275
+    // cas d'ajax_action_auteur: faut defaire le boulot
276
+    // (il faudrait fusionner avec le cas $javascript)
277
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
278
+        [$x, $lien, $atts, $texte] = $r;
279
+        $javascript .= $atts;
280
+    }
281 281
 
282
-	$retour = icone_base($lien, $texte, $fond, $fonction, 'horizontale', $javascript);
282
+    $retour = icone_base($lien, $texte, $fond, $fonction, 'horizontale', $javascript);
283 283
 
284
-	return $retour;
284
+    return $retour;
285 285
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 	];
45 45
 	$style_titre_mapping = ['couleur' => 'topper', 'trait-couleur' => 'section'];
46 46
 	$c = $style_mapping[$style] ?? 'simple';
47
-	$class = $c . ($class ? " $class" : '');
47
+	$class = $c.($class ? " $class" : '');
48 48
 	if (!$padding) {
49
-		$class .= ($class ? ' ' : '') . 'no-padding';
49
+		$class .= ($class ? ' ' : '').'no-padding';
50 50
 	}
51 51
 
52 52
 	//($id?"id='$id' ":"")
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 		if ($fonction) {
62 62
 			// 2 images pour composer l'icone : le fond (article) en background,
63 63
 			// la fonction (new) en image
64
-			$icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n" .
64
+			$icone = http_img_pack($fonction, '', "class='cadre-icone' width='$size' height='$size'\n".
65 65
 				http_style_background($fond, 'no-repeat center center', $size));
66 66
 		} else {
67 67
 			$icone = http_img_pack($fond, '', "class='cadre-icone' width='$size' height='$size'");
68 68
 		}
69
-		$titre = $icone . $titre;
69
+		$titre = $icone.$titre;
70 70
 	}
71 71
 
72 72
 	return boite_ouvrir($titre, $class, $style_titre_mapping[$style] ?? '', $id);
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
 	$titre,
180 180
 	$ze_logo = ''
181 181
 ) {
182
-	return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
182
+	return "<h1 class = 'grostitre'>".$ze_logo.' '.typo($titre)."</h1>\n";
183 183
 }
184 184
 
185 185
 // La boite des raccourcis
186 186
 // Se place a droite si l'ecran est en mode panoramique.
187 187
 function bloc_des_raccourcis($bloc) {
188 188
 	return creer_colonne_droite()
189
-	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
189
+	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis').$bloc.boite_fermer();
190 190
 }
191 191
 
192 192
 //
Please login to merge, or discard this patch.
ecrire/inc/layer.php 2 patches
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -26,70 +26,70 @@  discard block
 block discarded – undo
26 26
  * @return string Code HTML du cadre dépliable
27 27
  **/
28 28
 function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') {
29
-	$bouton = bouton_block_depliable($titre, $deplie, $ids);
30
-
31
-	return
32
-		debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
33
-		. debut_block_depliable($deplie, $ids)
34
-		. "<div class='cadre_padding'>\n"
35
-		. $contenu
36
-		. "</div>\n"
37
-		. fin_block()
38
-		. fin_cadre();
29
+    $bouton = bouton_block_depliable($titre, $deplie, $ids);
30
+
31
+    return
32
+        debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
33
+        . debut_block_depliable($deplie, $ids)
34
+        . "<div class='cadre_padding'>\n"
35
+        . $contenu
36
+        . "</div>\n"
37
+        . fin_block()
38
+        . fin_cadre();
39 39
 }
40 40
 
41 41
 function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) {
42
-	return "\n"
43
-	. bouton_block_depliable($invite, $visible, $nom)
44
-	. debut_block_depliable($visible, $nom)
45
-	. $masque
46
-	. fin_block();
42
+    return "\n"
43
+    . bouton_block_depliable($invite, $visible, $nom)
44
+    . debut_block_depliable($visible, $nom)
45
+    . $masque
46
+    . fin_block();
47 47
 }
48 48
 
49 49
 function debut_block_depliable($deplie, $id = '') {
50
-	$class = ' blocdeplie';
51
-	// si on n'accepte pas js, ne pas fermer
52
-	if (!$deplie) {
53
-		$class = ' blocreplie';
54
-	}
50
+    $class = ' blocdeplie';
51
+    // si on n'accepte pas js, ne pas fermer
52
+    if (!$deplie) {
53
+        $class = ' blocreplie';
54
+    }
55 55
 
56
-	return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>";
56
+    return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>";
57 57
 }
58 58
 
59 59
 function fin_block() {
60
-	return "<div class='nettoyeur'></div>\n</div>";
60
+    return "<div class='nettoyeur'></div>\n</div>";
61 61
 }
62 62
 
63 63
 // $texte : texte du bouton
64 64
 // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page
65 65
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
66 66
 function bouton_block_depliable($texte, $deplie, $ids = '') {
67
-	$bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
68
-
69
-	$class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie');
70
-	if (strlen($ids)) {
71
-		$cible = explode(',', $ids);
72
-		$cible = '#' . implode(',#', $cible);
73
-	} else {
74
-		$cible = "#$bouton_id + div.bloc_depliable";
75
-	}
76
-
77
-	$b = (strpos($texte, '<h') === false ? 'h3' : 'div');
78
-
79
-	return "<$b "
80
-	. ($bouton_id ? "id='$bouton_id' " : '')
81
-	. "class='titrem$class'"
82
-	. (($deplie === -1)
83
-		? ''
84
-		: " onmouseover=\"jQuery(this).depliant('$cible');\""
85
-	)
86
-	. '>'
87
-	// une ancre pour rendre accessible au clavier le depliage du sous bloc
88
-	. "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
89
-	. "$texte</$b>"
90
-	. http_script(($deplie === 'incertain')
91
-		? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
92
-		: '');
67
+    $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
68
+
69
+    $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie');
70
+    if (strlen($ids)) {
71
+        $cible = explode(',', $ids);
72
+        $cible = '#' . implode(',#', $cible);
73
+    } else {
74
+        $cible = "#$bouton_id + div.bloc_depliable";
75
+    }
76
+
77
+    $b = (strpos($texte, '<h') === false ? 'h3' : 'div');
78
+
79
+    return "<$b "
80
+    . ($bouton_id ? "id='$bouton_id' " : '')
81
+    . "class='titrem$class'"
82
+    . (($deplie === -1)
83
+        ? ''
84
+        : " onmouseover=\"jQuery(this).depliant('$cible');\""
85
+    )
86
+    . '>'
87
+    // une ancre pour rendre accessible au clavier le depliage du sous bloc
88
+    . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
89
+    . "$texte</$b>"
90
+    . http_script(($deplie === 'incertain')
91
+        ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
92
+        : '');
93 93
 }
94 94
 
95 95
 //
@@ -97,66 +97,66 @@  discard block
 block discarded – undo
97 97
 //
98 98
 function verif_butineur() {
99 99
 
100
-	preg_match(',^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,', $_SERVER['HTTP_USER_AGENT'], $match);
101
-	$GLOBALS['browser_name'] = $match[1];
102
-	$GLOBALS['browser_version'] = $match[2];
103
-	$GLOBALS['browser_description'] = $match[3];
104
-	$GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
105
-	$GLOBALS['browser_barre'] = '';
106
-
107
-	if (!preg_match(',opera,i', $GLOBALS['browser_description']) && preg_match(',opera,i', $GLOBALS['browser_name'])) {
108
-		$GLOBALS['browser_name'] = 'Opera';
109
-		$GLOBALS['browser_version'] = $match[2];
110
-		$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
111
-	} else {
112
-		if (preg_match(',opera,i', $GLOBALS['browser_description'])) {
113
-			preg_match(',Opera ([^\ ]*),i', $GLOBALS['browser_description'], $match);
114
-			$GLOBALS['browser_name'] = 'Opera';
115
-			$GLOBALS['browser_version'] = $match[1];
116
-			$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
117
-		} else {
118
-			if (preg_match(',msie,i', $GLOBALS['browser_description'])) {
119
-				preg_match(',MSIE ([^;]*),i', $GLOBALS['browser_description'], $match);
120
-				$GLOBALS['browser_name'] = 'MSIE';
121
-				$GLOBALS['browser_version'] = $match[1];
122
-				$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5);
123
-			} else {
124
-				if (
125
-					preg_match(',KHTML,i', $GLOBALS['browser_description']) &&
126
-					preg_match(',Safari/([^;]*),', $GLOBALS['browser_description'], $match)
127
-				) {
128
-					$GLOBALS['browser_name'] = 'Safari';
129
-					$GLOBALS['browser_version'] = $match[1];
130
-					$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0);
131
-				} else {
132
-					if (preg_match(',mozilla,i', $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) {
133
-						// Numero de version pour Mozilla "authentique"
134
-						if (preg_match(',rv:([0-9]+\.[0-9]+),', $GLOBALS['browser_description'], $match)) {
135
-							$GLOBALS['browser_rev'] = doubleval($match[1]);
136
-						} // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
137
-						else {
138
-							if (
139
-								strpos($GLOBALS['browser_description'], 'Gecko') and !strpos(
140
-									$GLOBALS['browser_description'],
141
-									'KHTML'
142
-								)
143
-							) {
144
-								$GLOBALS['browser_rev'] = 1.4;
145
-							} // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
146
-							else {
147
-								$GLOBALS['browser_rev'] = 1.0;
148
-							}
149
-						}
150
-						$GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3;
151
-					}
152
-				}
153
-			}
154
-		}
155
-	}
156
-
157
-	if (!$GLOBALS['browser_name']) {
158
-		$GLOBALS['browser_name'] = 'Mozilla';
159
-	}
100
+    preg_match(',^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,', $_SERVER['HTTP_USER_AGENT'], $match);
101
+    $GLOBALS['browser_name'] = $match[1];
102
+    $GLOBALS['browser_version'] = $match[2];
103
+    $GLOBALS['browser_description'] = $match[3];
104
+    $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
105
+    $GLOBALS['browser_barre'] = '';
106
+
107
+    if (!preg_match(',opera,i', $GLOBALS['browser_description']) && preg_match(',opera,i', $GLOBALS['browser_name'])) {
108
+        $GLOBALS['browser_name'] = 'Opera';
109
+        $GLOBALS['browser_version'] = $match[2];
110
+        $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
111
+    } else {
112
+        if (preg_match(',opera,i', $GLOBALS['browser_description'])) {
113
+            preg_match(',Opera ([^\ ]*),i', $GLOBALS['browser_description'], $match);
114
+            $GLOBALS['browser_name'] = 'Opera';
115
+            $GLOBALS['browser_version'] = $match[1];
116
+            $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
117
+        } else {
118
+            if (preg_match(',msie,i', $GLOBALS['browser_description'])) {
119
+                preg_match(',MSIE ([^;]*),i', $GLOBALS['browser_description'], $match);
120
+                $GLOBALS['browser_name'] = 'MSIE';
121
+                $GLOBALS['browser_version'] = $match[1];
122
+                $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5);
123
+            } else {
124
+                if (
125
+                    preg_match(',KHTML,i', $GLOBALS['browser_description']) &&
126
+                    preg_match(',Safari/([^;]*),', $GLOBALS['browser_description'], $match)
127
+                ) {
128
+                    $GLOBALS['browser_name'] = 'Safari';
129
+                    $GLOBALS['browser_version'] = $match[1];
130
+                    $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0);
131
+                } else {
132
+                    if (preg_match(',mozilla,i', $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) {
133
+                        // Numero de version pour Mozilla "authentique"
134
+                        if (preg_match(',rv:([0-9]+\.[0-9]+),', $GLOBALS['browser_description'], $match)) {
135
+                            $GLOBALS['browser_rev'] = doubleval($match[1]);
136
+                        } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
137
+                        else {
138
+                            if (
139
+                                strpos($GLOBALS['browser_description'], 'Gecko') and !strpos(
140
+                                    $GLOBALS['browser_description'],
141
+                                    'KHTML'
142
+                                )
143
+                            ) {
144
+                                $GLOBALS['browser_rev'] = 1.4;
145
+                            } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
146
+                            else {
147
+                                $GLOBALS['browser_rev'] = 1.0;
148
+                            }
149
+                        }
150
+                        $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3;
151
+                    }
152
+                }
153
+            }
154
+        }
155
+    }
156
+
157
+    if (!$GLOBALS['browser_name']) {
158
+        $GLOBALS['browser_name'] = 'Mozilla';
159
+    }
160 160
 }
161 161
 
162 162
 verif_butineur();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$class = ' blocreplie';
54 54
 	}
55 55
 
56
-	return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>";
56
+	return '<div '.($id ? "id='$id' " : '')."class='bloc_depliable$class'>";
57 57
 }
58 58
 
59 59
 function fin_block() {
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page
65 65
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
66 66
 function bouton_block_depliable($texte, $deplie, $ids = '') {
67
-	$bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
67
+	$bouton_id = 'b'.substr(md5($texte.microtime()), 0, 8);
68 68
 
69 69
 	$class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie');
70 70
 	if (strlen($ids)) {
71 71
 		$cible = explode(',', $ids);
72
-		$cible = '#' . implode(',#', $cible);
72
+		$cible = '#'.implode(',#', $cible);
73 73
 	} else {
74 74
 		$cible = "#$bouton_id + div.bloc_depliable";
75 75
 	}
Please login to merge, or discard this patch.
ecrire/inc/genie.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -75,28 +75,28 @@  discard block
 block discarded – undo
75 75
  * @return
76 76
  **/
77 77
 function inc_genie_dist($taches = []) {
78
-	include_spip('inc/queue');
79
-
80
-	if (_request('exec') == 'job_queue') {
81
-		return false;
82
-	}
83
-
84
-	$force_jobs = [];
85
-	// l'ancienne facon de lancer une tache cron immediatement
86
-	// etait de la passer en parametre a ing_genie_dist
87
-	// on reroute en ajoutant simplement le job a la queue, ASAP
88
-	foreach ($taches as $function => $period) {
89
-		$force_jobs[] = queue_add_job(
90
-			$function,
91
-			_T('tache_cron_asap', ['function' => $function]),
92
-			[time() - abs($period)],
93
-			'genie/'
94
-		);
95
-	}
96
-
97
-	// et on passe la main a la gestion de la queue !
98
-	// en forcant eventuellement les jobs ajoute a l'instant
99
-	return queue_schedule(count($force_jobs) ? $force_jobs : null);
78
+    include_spip('inc/queue');
79
+
80
+    if (_request('exec') == 'job_queue') {
81
+        return false;
82
+    }
83
+
84
+    $force_jobs = [];
85
+    // l'ancienne facon de lancer une tache cron immediatement
86
+    // etait de la passer en parametre a ing_genie_dist
87
+    // on reroute en ajoutant simplement le job a la queue, ASAP
88
+    foreach ($taches as $function => $period) {
89
+        $force_jobs[] = queue_add_job(
90
+            $function,
91
+            _T('tache_cron_asap', ['function' => $function]),
92
+            [time() - abs($period)],
93
+            'genie/'
94
+        );
95
+    }
96
+
97
+    // et on passe la main a la gestion de la queue !
98
+    // en forcant eventuellement les jobs ajoute a l'instant
99
+    return queue_schedule(count($force_jobs) ? $force_jobs : null);
100 100
 }
101 101
 
102 102
 //
@@ -109,33 +109,33 @@  discard block
 block discarded – undo
109 109
 //
110 110
 function taches_generales($taches_generales = []) {
111 111
 
112
-	// verifier que toutes les taches cron sont planifiees
113
-	// c'est une tache cron !
114
-	$taches_generales['queue_watch'] = 3600 * 24;
112
+    // verifier que toutes les taches cron sont planifiees
113
+    // c'est une tache cron !
114
+    $taches_generales['queue_watch'] = 3600 * 24;
115 115
 
116
-	// MAJ des rubriques publiques (cas de la publication post-datee)
117
-	// est fait au coup par coup a present
118
-	//	$taches_generales['rubriques'] = 3600;
116
+    // MAJ des rubriques publiques (cas de la publication post-datee)
117
+    // est fait au coup par coup a present
118
+    //	$taches_generales['rubriques'] = 3600;
119 119
 
120
-	// Optimisation de la base
121
-	$taches_generales['optimiser'] = 3600 * 48;
120
+    // Optimisation de la base
121
+    $taches_generales['optimiser'] = 3600 * 48;
122 122
 
123
-	// nouveautes
124
-	if (
125
-		isset($GLOBALS['meta']['adresse_neuf']) and $GLOBALS['meta']['adresse_neuf']
126
-		and $GLOBALS['meta']['jours_neuf']
127
-		and ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')
128
-	) {
129
-		$taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf'];
130
-	}
123
+    // nouveautes
124
+    if (
125
+        isset($GLOBALS['meta']['adresse_neuf']) and $GLOBALS['meta']['adresse_neuf']
126
+        and $GLOBALS['meta']['jours_neuf']
127
+        and ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')
128
+    ) {
129
+        $taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf'];
130
+    }
131 131
 
132
-	// maintenance (ajax, verifications diverses)
133
-	$taches_generales['maintenance'] = 3600 * 2;
132
+    // maintenance (ajax, verifications diverses)
133
+    $taches_generales['maintenance'] = 3600 * 2;
134 134
 
135
-	// verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement)
136
-	$taches_generales['mise_a_jour'] = 3 * 24 * 3600;
135
+    // verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement)
136
+    $taches_generales['mise_a_jour'] = 3 * 24 * 3600;
137 137
 
138
-	return pipeline('taches_generales_cron', $taches_generales);
138
+    return pipeline('taches_generales_cron', $taches_generales);
139 139
 }
140 140
 
141 141
 /**
@@ -151,22 +151,22 @@  discard block
 block discarded – undo
151 151
  * @return int
152 152
  */
153 153
 function genie_queue_watch_dist() {
154
-	static $deja_la = false;
155
-	if ($deja_la) {
156
-		return;
157
-	} // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple)
158
-	$deja_la = true;
159
-	$taches = taches_generales();
160
-	$programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches)));
161
-	$programmees = array_column($programmees, 'fonction');
162
-	foreach ($taches as $tache => $periode) {
163
-		if (!in_array($tache, $programmees)) {
164
-			queue_genie_replan_job($tache, $periode, time() - round(random_int(1, $periode)), 0);
165
-		}
166
-	}
167
-	$deja_la = false;
168
-
169
-	return 1;
154
+    static $deja_la = false;
155
+    if ($deja_la) {
156
+        return;
157
+    } // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple)
158
+    $deja_la = true;
159
+    $taches = taches_generales();
160
+    $programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches)));
161
+    $programmees = array_column($programmees, 'fonction');
162
+    foreach ($taches as $tache => $periode) {
163
+        if (!in_array($tache, $programmees)) {
164
+            queue_genie_replan_job($tache, $periode, time() - round(random_int(1, $periode)), 0);
165
+        }
166
+    }
167
+    $deja_la = false;
168
+
169
+    return 1;
170 170
 }
171 171
 
172 172
 /**
@@ -187,32 +187,32 @@  discard block
 block discarded – undo
187 187
  * @return void
188 188
  */
189 189
 function queue_genie_replan_job($function, $period, $last = 0, $time = null, $priority = 0) {
190
-	static $done = [];
191
-	if (isset($done[$function])) {
192
-		return;
193
-	}
194
-	$done[$function] = true;
195
-	if (is_null($time)) {
196
-		$time = time();
197
-		if ($last) {
198
-			$time = max($last + $period, $time);
199
-		}
200
-	}
201
-	if (!$last) {
202
-		$last = $time - $period;
203
-	}
204
-	spip_log("replan_job $function $period $last $time $priority", 'queue');
205
-	include_spip('inc/queue');
206
-	// on replanifie un job cron
207
-	// uniquement si il n'y en a pas deja un avec le meme nom
208
-	// independament de l'argument
209
-	queue_add_job(
210
-		$function,
211
-		_T('tache_cron_secondes', ['function' => $function, 'nb' => $period]),
212
-		[$last],
213
-		'genie/',
214
-		'function_only',
215
-		$time,
216
-		$priority
217
-	);
190
+    static $done = [];
191
+    if (isset($done[$function])) {
192
+        return;
193
+    }
194
+    $done[$function] = true;
195
+    if (is_null($time)) {
196
+        $time = time();
197
+        if ($last) {
198
+            $time = max($last + $period, $time);
199
+        }
200
+    }
201
+    if (!$last) {
202
+        $last = $time - $period;
203
+    }
204
+    spip_log("replan_job $function $period $last $time $priority", 'queue');
205
+    include_spip('inc/queue');
206
+    // on replanifie un job cron
207
+    // uniquement si il n'y en a pas deja un avec le meme nom
208
+    // independament de l'argument
209
+    queue_add_job(
210
+        $function,
211
+        _T('tache_cron_secondes', ['function' => $function, 'nb' => $period]),
212
+        [$last],
213
+        'genie/',
214
+        'function_only',
215
+        $time,
216
+        $priority
217
+    );
218 218
 }
Please login to merge, or discard this patch.
ecrire/inc/install.php 2 patches
Indentation   +360 added lines, -360 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = '<' . "?php\n"
47
-		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
-		. $texte
49
-		. '?' . '>';
46
+    $texte = '<' . "?php\n"
47
+        . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
+        . $texte
49
+        . '?' . '>';
50 50
 
51
-	ecrire_fichier($nom, $texte);
51
+    ecrire_fichier($nom, $texte);
52 52
 }
53 53
 
54 54
 
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
  *
78 78
  **/
79 79
 function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') {
80
-	$adr = addcslashes($adr, "'\\");
81
-	$port = addcslashes($port, "'\\");
82
-	$login = addcslashes($login, "'\\");
83
-	$pass = addcslashes($pass, "'\\");
84
-	$base = addcslashes($base, "'\\");
85
-	$type = addcslashes($type, "'\\");
86
-	$pref = addcslashes($pref, "'\\");
87
-	$ldap = addcslashes($ldap, "'\\");
88
-	$charset = addcslashes($charset, "'\\");
89
-
90
-	return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
-	. 'spip_connect_db('
92
-	. "'$adr','$port','$login','$pass','$base'"
93
-	. ",'$type', '$pref','$ldap','$charset');\n";
80
+    $adr = addcslashes($adr, "'\\");
81
+    $port = addcslashes($port, "'\\");
82
+    $login = addcslashes($login, "'\\");
83
+    $pass = addcslashes($pass, "'\\");
84
+    $base = addcslashes($base, "'\\");
85
+    $type = addcslashes($type, "'\\");
86
+    $pref = addcslashes($pref, "'\\");
87
+    $ldap = addcslashes($ldap, "'\\");
88
+    $charset = addcslashes($charset, "'\\");
89
+
90
+    return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
+    . 'spip_connect_db('
92
+    . "'$adr','$port','$login','$pass','$base'"
93
+    . ",'$type', '$pref','$ldap','$charset');\n";
94 94
 }
95 95
 
96 96
 
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
  *     Tableau des informations sur la connexion
107 107
  **/
108 108
 function analyse_fichier_connection($file) {
109
-	$s = @join('', file($file));
110
-	if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
-		array_shift($regs);
112
-
113
-		return $regs;
114
-	} else {
115
-		$ar = '\s*\'([^\']*)\'';
116
-		$r = '\s*,' . $ar;
117
-		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
-		if (preg_match($r, $s, $regs)) {
119
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
120
-			array_shift($regs);
121
-			array_shift($regs);
122
-
123
-			return $regs;
124
-		}
125
-	}
126
-	spip_log("$file n'est pas un fichier de connexion");
127
-
128
-	return [];
109
+    $s = @join('', file($file));
110
+    if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
+        array_shift($regs);
112
+
113
+        return $regs;
114
+    } else {
115
+        $ar = '\s*\'([^\']*)\'';
116
+        $r = '\s*,' . $ar;
117
+        $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
+        if (preg_match($r, $s, $regs)) {
119
+            $regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
120
+            array_shift($regs);
121
+            array_shift($regs);
122
+
123
+            return $regs;
124
+        }
125
+    }
126
+    spip_log("$file n'est pas un fichier de connexion");
127
+
128
+    return [];
129 129
 }
130 130
 
131 131
 /**
@@ -142,73 +142,73 @@  discard block
 block discarded – undo
142 142
  *     Liste des noms de connecteurs
143 143
  **/
144 144
 function bases_referencees($exclu = '') {
145
-	$tables = [];
146
-	foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
-		if ($f != $exclu and analyse_fichier_connection($f)) {
148
-			$tables[] = basename($f, '.php');
149
-		}
150
-	}
151
-
152
-	return $tables;
145
+    $tables = [];
146
+    foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
+        if ($f != $exclu and analyse_fichier_connection($f)) {
148
+            $tables[] = basename($f, '.php');
149
+        }
150
+    }
151
+
152
+    return $tables;
153 153
 }
154 154
 
155 155
 
156 156
 function install_mode_appel($server_db, $tout = true) {
157
-	return ($server_db != 'mysql') ? ''
158
-		: (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
-			. test_sql_mode_mysql($server_db));
157
+    return ($server_db != 'mysql') ? ''
158
+        : (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
+            . test_sql_mode_mysql($server_db));
160 160
 }
161 161
 
162 162
 //
163 163
 // Verifier que l'hebergement est compatible SPIP ... ou l'inverse :-)
164 164
 // (sert a l'etape 1 de l'installation)
165 165
 function tester_compatibilite_hebergement() {
166
-	$err = [];
167
-
168
-	$p = phpversion();
169
-	if (version_compare($p, _PHP_MIN, '<')) {
170
-		$err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
171
-	}
172
-
173
-	// Si on n'a pas la bonne version de PHP, c'est la fin
174
-	if ($err) {
175
-		die("<div class='error'>"
176
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
177
-			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
178
-	}
179
-
180
-	// Il faut une base de donnees tout de meme ...
181
-	$serveurs = install_select_serveur();
182
-	if (!$serveurs) {
183
-		$err[] = _T('install_extension_php_obligatoire')
184
-			. " <a href='http://www.php.net/mysql'>MYSQL</a>"
185
-			. "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
186
-			. "| <a href='http://www.php.net/sqlite'>SQLite</a>";
187
-	}
188
-
189
-	// et il faut preg
190
-	if (!function_exists('preg_match_all')) {
191
-		$err[] = _T('install_extension_php_obligatoire')
192
-			. " <a href='http://se.php.net/pcre'>PCRE</a>";
193
-	}
194
-
195
-	// et surtout pas ce mbstring.overload
196
-	if ($a = @ini_get('mbstring.func_overload')) {
197
-		$err[] = _T('install_extension_mbstring')
198
-			. "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
199
-	}
200
-
201
-	if ($err) {
202
-		echo "<div class='error'>"
203
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
204
-		foreach ($err as $e) {
205
-			echo "<li><strong>$e</strong></li>\n";
206
-		}
207
-
208
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
209
-		# de forcer malgre tout (pour tester, ou si bug de detection)
210
-		echo "</ul></div>\n";
211
-	}
166
+    $err = [];
167
+
168
+    $p = phpversion();
169
+    if (version_compare($p, _PHP_MIN, '<')) {
170
+        $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
171
+    }
172
+
173
+    // Si on n'a pas la bonne version de PHP, c'est la fin
174
+    if ($err) {
175
+        die("<div class='error'>"
176
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
177
+            . "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
178
+    }
179
+
180
+    // Il faut une base de donnees tout de meme ...
181
+    $serveurs = install_select_serveur();
182
+    if (!$serveurs) {
183
+        $err[] = _T('install_extension_php_obligatoire')
184
+            . " <a href='http://www.php.net/mysql'>MYSQL</a>"
185
+            . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
186
+            . "| <a href='http://www.php.net/sqlite'>SQLite</a>";
187
+    }
188
+
189
+    // et il faut preg
190
+    if (!function_exists('preg_match_all')) {
191
+        $err[] = _T('install_extension_php_obligatoire')
192
+            . " <a href='http://se.php.net/pcre'>PCRE</a>";
193
+    }
194
+
195
+    // et surtout pas ce mbstring.overload
196
+    if ($a = @ini_get('mbstring.func_overload')) {
197
+        $err[] = _T('install_extension_mbstring')
198
+            . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
199
+    }
200
+
201
+    if ($err) {
202
+        echo "<div class='error'>"
203
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
204
+        foreach ($err as $e) {
205
+            echo "<li><strong>$e</strong></li>\n";
206
+        }
207
+
208
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
209
+        # de forcer malgre tout (pour tester, ou si bug de detection)
210
+        echo "</ul></div>\n";
211
+    }
212 212
 }
213 213
 
214 214
 
@@ -218,23 +218,23 @@  discard block
 block discarded – undo
218 218
  * @note superflu ??
219 219
  */
220 220
 function login_hebergeur() {
221
-	$base_hebergeur = 'localhost'; # par defaut
221
+    $base_hebergeur = 'localhost'; # par defaut
222 222
 
223
-	// Free
224
-	if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
225
-		$base_hebergeur = 'sql.free.fr';
226
-		$login_hebergeur = $regs[1];
227
-	} else {
228
-		$login_hebergeur = '';
229
-	}
223
+    // Free
224
+    if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
225
+        $base_hebergeur = 'sql.free.fr';
226
+        $login_hebergeur = $regs[1];
227
+    } else {
228
+        $login_hebergeur = '';
229
+    }
230 230
 
231
-	return [$base_hebergeur, $login_hebergeur];
231
+    return [$base_hebergeur, $login_hebergeur];
232 232
 }
233 233
 
234 234
 
235 235
 function info_etape($titre, $complement = '') {
236
-	return '<h2>' . $titre . "</h2>\n" .
237
-	($complement ? '' . $complement . "\n" : '');
236
+    return '<h2>' . $titre . "</h2>\n" .
237
+    ($complement ? '' . $complement . "\n" : '');
238 238
 }
239 239
 
240 240
 /**
@@ -244,154 +244,154 @@  discard block
 block discarded – undo
244 244
  * @return string Code HTML du bouton
245 245
  **/
246 246
 function bouton_suivant($code = '') {
247
-	if ($code == '') {
248
-		$code = _T('bouton_suivant');
249
-	}
250
-	static $suivant = 0;
251
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
252
-	$suivant += 1;
253
-
254
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
255
-	$code .
256
-	" >>\" /></p>\n";
247
+    if ($code == '') {
248
+        $code = _T('bouton_suivant');
249
+    }
250
+    static $suivant = 0;
251
+    $id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
252
+    $suivant += 1;
253
+
254
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
255
+    $code .
256
+    " >>\" /></p>\n";
257 257
 }
258 258
 
259 259
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
260
-	$intitule_etat = [];
261
-	//$en_cours = _request('etape')?_request('etape'):"";
262
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
263
-	$debut = 1;
264
-	$etat = 'ok';
265
-	$last = count($liste);
260
+    $intitule_etat = [];
261
+    //$en_cours = _request('etape')?_request('etape'):"";
262
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
263
+    $debut = 1;
264
+    $etat = 'ok';
265
+    $last = count($liste);
266 266
 //	$texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo'));
267 267
 
268
-	$intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
269
-	$intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
270
-	$intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
271
-	$intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
268
+    $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
269
+    $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
270
+    $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
271
+    $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
272 272
 
273
-	$intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
274
-	$intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
275
-	$intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
276
-	$intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
277
-	$intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
273
+    $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
274
+    $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
275
+    $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
276
+    $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
277
+    $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
278 278
 
279 279
 //	$aff_etapes = "<span id='etapes'>";
280 280
 
281
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
282
-
283
-	foreach ($liste as $etape => $fichier) {
284
-		if ($debut < $last) {
285
-			if ($debut == $en_cours && $erreur) {
286
-				$class = 'on erreur';
287
-			} else {
288
-				if ($debut == $en_cours) {
289
-					$class = 'on';
290
-				} else {
291
-					if ($debut > $en_cours) {
292
-						$class = 'prochains';
293
-					} else {
294
-						$class = 'valides';
295
-					}
296
-				}
297
-			}
298
-
299
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
300
-			$aff_etapes .= ($debut == $en_cours) ? '<strong>' : '';
301
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
302
-			$aff_etapes .= $intitule_etat["$phase"][$debut];
303
-			$aff_etapes .= ($debut == $en_cours) ? '</strong>' : '';
304
-			$aff_etapes .= '</div></li>';
305
-		}
306
-		$debut++;
307
-	}
308
-	$aff_etapes .= '</ul>';
309
-	$aff_etapes .= "<br class='nettoyeur' />\n";
310
-
311
-	return $aff_etapes;
281
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
282
+
283
+    foreach ($liste as $etape => $fichier) {
284
+        if ($debut < $last) {
285
+            if ($debut == $en_cours && $erreur) {
286
+                $class = 'on erreur';
287
+            } else {
288
+                if ($debut == $en_cours) {
289
+                    $class = 'on';
290
+                } else {
291
+                    if ($debut > $en_cours) {
292
+                        $class = 'prochains';
293
+                    } else {
294
+                        $class = 'valides';
295
+                    }
296
+                }
297
+            }
298
+
299
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
300
+            $aff_etapes .= ($debut == $en_cours) ? '<strong>' : '';
301
+            $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
302
+            $aff_etapes .= $intitule_etat["$phase"][$debut];
303
+            $aff_etapes .= ($debut == $en_cours) ? '</strong>' : '';
304
+            $aff_etapes .= '</div></li>';
305
+        }
306
+        $debut++;
307
+    }
308
+    $aff_etapes .= '</ul>';
309
+    $aff_etapes .= "<br class='nettoyeur' />\n";
310
+
311
+    return $aff_etapes;
312 312
 }
313 313
 
314 314
 
315 315
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
316
-	return "<fieldset>\n" .
317
-	$avant .
318
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
319
-	fieldset_champs($champs) .
320
-	$apres .
321
-	"</fieldset>\n";
316
+    return "<fieldset>\n" .
317
+    $avant .
318
+    ($legend ? '<legend>' . $legend . "</legend>\n" : '') .
319
+    fieldset_champs($champs) .
320
+    $apres .
321
+    "</fieldset>\n";
322 322
 }
323 323
 
324 324
 function fieldset_champs($champs = []) {
325
-	$fieldset = '';
326
-	foreach ($champs as $nom => $contenu) {
327
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
328
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
329
-		if (isset($contenu['alternatives'])) {
330
-			$fieldset .= $contenu['label'] . "\n";
331
-			foreach ($contenu['alternatives'] as $valeur => $label) {
332
-				$fieldset .= "<input type='radio' name='" . $nom .
333
-					"' id='$nom-$valeur' value='$valeur'"
334
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
335
-					. "/>\n";
336
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
337
-			}
338
-			$fieldset .= "<br />\n";
339
-		} else {
340
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
341
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
342
-				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
343
-				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
344
-				. " />\n";
345
-		}
346
-	}
347
-
348
-	return $fieldset;
325
+    $fieldset = '';
326
+    foreach ($champs as $nom => $contenu) {
327
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
328
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
329
+        if (isset($contenu['alternatives'])) {
330
+            $fieldset .= $contenu['label'] . "\n";
331
+            foreach ($contenu['alternatives'] as $valeur => $label) {
332
+                $fieldset .= "<input type='radio' name='" . $nom .
333
+                    "' id='$nom-$valeur' value='$valeur'"
334
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
335
+                    . "/>\n";
336
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
337
+            }
338
+            $fieldset .= "<br />\n";
339
+        } else {
340
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
341
+            $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
342
+                . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
343
+                . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
344
+                . " />\n";
345
+        }
346
+    }
347
+
348
+    return $fieldset;
349 349
 }
350 350
 
351 351
 function install_select_serveur() {
352
-	$options = [];
353
-	$dir = _DIR_RESTREINT . 'req/';
354
-	$d = opendir($dir);
355
-	if (!$d) {
356
-		return [];
357
-	}
358
-	while (($f = readdir($d)) !== false) {
359
-		if (
360
-			(preg_match('/^(.*)[.]php$/', $f, $s))
361
-			and is_readable($f = $dir . $f)
362
-		) {
363
-			require_once($f);
364
-			$s = $s[1];
365
-			$v = 'spip_versions_' . $s;
366
-			if (function_exists($v) and $v()) {
367
-				$titre = _T("install_select_type_$s");
368
-				// proposer mysql par defaut si dispo
369
-				$checked = ($s == 'mysql' ? " checked='checked'" : '');
370
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
371
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
372
-			} else {
373
-				spip_log("$s: portage indisponible");
374
-			}
375
-		}
376
-	}
377
-	sort($options);
378
-
379
-	return $options;
352
+    $options = [];
353
+    $dir = _DIR_RESTREINT . 'req/';
354
+    $d = opendir($dir);
355
+    if (!$d) {
356
+        return [];
357
+    }
358
+    while (($f = readdir($d)) !== false) {
359
+        if (
360
+            (preg_match('/^(.*)[.]php$/', $f, $s))
361
+            and is_readable($f = $dir . $f)
362
+        ) {
363
+            require_once($f);
364
+            $s = $s[1];
365
+            $v = 'spip_versions_' . $s;
366
+            if (function_exists($v) and $v()) {
367
+                $titre = _T("install_select_type_$s");
368
+                // proposer mysql par defaut si dispo
369
+                $checked = ($s == 'mysql' ? " checked='checked'" : '');
370
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
371
+                    . "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
372
+            } else {
373
+                spip_log("$s: portage indisponible");
374
+            }
375
+        }
376
+    }
377
+    sort($options);
378
+
379
+    return $options;
380 380
 }
381 381
 
382 382
 function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) {
383
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
384
-
385
-	return generer_form_ecrire('install', (
386
-		"\n<input type='hidden' name='etape' value='$etape' />"
387
-		. $hidden
388
-		. (_request('echec') ?
389
-			('<p><b>' . _T('avis_connexion_echec_1') .
390
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
391
-			: '')
392
-
393
-		. ($jquery ? http_script('', 'jquery.js') : '')
394
-		. http_script('
383
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
384
+
385
+    return generer_form_ecrire('install', (
386
+        "\n<input type='hidden' name='etape' value='$etape' />"
387
+        . $hidden
388
+        . (_request('echec') ?
389
+            ('<p><b>' . _T('avis_connexion_echec_1') .
390
+                '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
391
+            : '')
392
+
393
+        . ($jquery ? http_script('', 'jquery.js') : '')
394
+        . http_script('
395 395
 		jQuery(function($) {
396 396
 			$details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur");
397 397
 			$("input[type=hidden][name=server_db]").each(function(){
@@ -424,145 +424,145 @@  discard block
 block discarded – undo
424 424
 			});
425 425
 		});')
426 426
 
427
-		. ($server_db
428
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
429
-			. (($predef[0])
430
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
431
-				: '')
432
-			: ('<fieldset><legend>'
433
-				. _T('install_select_type_db')
434
-				. '</legend>'
435
-				. '<p class="explication">'
436
-				. _T('install_types_db_connus')
437
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
438
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
439
-				. '</p>'
440
-				. "\n<div class='p'>\n<ul>\n"
441
-				. join("\n", install_select_serveur())
442
-				. "\n</ul>\n</div></fieldset>")
443
-		)
444
-		. '<div id="install_adresse_base_hebergeur">'
445
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
446
-		. ($predef[1]
447
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
448
-			: fieldset(
449
-				_T('entree_base_donnee_1'),
450
-				[
451
-					'adresse_db' => [
452
-						'label' => $db[1],
453
-						'valeur' => $db[0]
454
-					],
455
-				]
456
-			)
457
-		)
458
-		. '</div>'
459
-
460
-		. '<div id="install_login_base_hebergeur">'
461
-		. ($predef[2]
462
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
463
-			: fieldset(
464
-				_T('entree_login_connexion_1'),
465
-				[
466
-					'login_db' => [
467
-						'label' => $login[1],
468
-						'valeur' => $login[0]
469
-					],
470
-				]
471
-			)
472
-		)
473
-		. '</div>'
474
-
475
-		. '<div id="install_pass_base_hebergeur">'
476
-		. ($predef[3]
477
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
478
-			: fieldset(
479
-				_T('entree_mot_passe_1'),
480
-				[
481
-					'pass_db' => [
482
-						'label' => $pass[1],
483
-						'valeur' => $pass[0]
484
-					],
485
-				]
486
-			)
487
-		)
488
-		. '</div>'
489
-
490
-		. bouton_suivant()));
427
+        . ($server_db
428
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
429
+            . (($predef[0])
430
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
431
+                : '')
432
+            : ('<fieldset><legend>'
433
+                . _T('install_select_type_db')
434
+                . '</legend>'
435
+                . '<p class="explication">'
436
+                . _T('install_types_db_connus')
437
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
438
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
439
+                . '</p>'
440
+                . "\n<div class='p'>\n<ul>\n"
441
+                . join("\n", install_select_serveur())
442
+                . "\n</ul>\n</div></fieldset>")
443
+        )
444
+        . '<div id="install_adresse_base_hebergeur">'
445
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
446
+        . ($predef[1]
447
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
448
+            : fieldset(
449
+                _T('entree_base_donnee_1'),
450
+                [
451
+                    'adresse_db' => [
452
+                        'label' => $db[1],
453
+                        'valeur' => $db[0]
454
+                    ],
455
+                ]
456
+            )
457
+        )
458
+        . '</div>'
459
+
460
+        . '<div id="install_login_base_hebergeur">'
461
+        . ($predef[2]
462
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
463
+            : fieldset(
464
+                _T('entree_login_connexion_1'),
465
+                [
466
+                    'login_db' => [
467
+                        'label' => $login[1],
468
+                        'valeur' => $login[0]
469
+                    ],
470
+                ]
471
+            )
472
+        )
473
+        . '</div>'
474
+
475
+        . '<div id="install_pass_base_hebergeur">'
476
+        . ($predef[3]
477
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
478
+            : fieldset(
479
+                _T('entree_mot_passe_1'),
480
+                [
481
+                    'pass_db' => [
482
+                        'label' => $pass[1],
483
+                        'valeur' => $pass[0]
484
+                    ],
485
+                ]
486
+            )
487
+        )
488
+        . '</div>'
489
+
490
+        . bouton_suivant()));
491 491
 }
492 492
 
493 493
 // 4 valeurs qu'on reconduit d'un script a l'autre
494 494
 // sauf s'ils sont predefinis.
495 495
 
496 496
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
497
-	return ((defined('_INSTALL_HOST_DB'))
498
-		? ''
499
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
500
-	)
501
-	. ((defined('_INSTALL_USER_DB'))
502
-		? ''
503
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
504
-	)
505
-	. ((defined('_INSTALL_PASS_DB'))
506
-		? ''
507
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
508
-	)
509
-
510
-	. ((defined('_INSTALL_SERVER_DB'))
511
-		? ''
512
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
513
-	);
497
+    return ((defined('_INSTALL_HOST_DB'))
498
+        ? ''
499
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
500
+    )
501
+    . ((defined('_INSTALL_USER_DB'))
502
+        ? ''
503
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
504
+    )
505
+    . ((defined('_INSTALL_PASS_DB'))
506
+        ? ''
507
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
508
+    )
509
+
510
+    . ((defined('_INSTALL_SERVER_DB'))
511
+        ? ''
512
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
513
+    );
514 514
 }
515 515
 
516 516
 // presentation des bases existantes
517 517
 
518 518
 function install_etape_liste_bases($server_db, $login_db, $disabled = []) {
519
-	$bases = $checked = [];
520
-	$noms = sql_listdbs($server_db);
521
-	if (!$noms) {
522
-		return '';
523
-	}
524
-
525
-	foreach ($noms as $nom) {
526
-		$id = spip_htmlspecialchars($nom);
527
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
528
-		$base = ' name="choix_db" value="'
529
-			. $nom
530
-			. '"'
531
-			. $dis
532
-			. " type='radio' id='$id'";
533
-		$label = "<label for='$id'>"
534
-			. ($dis ? "<i>$nom</i>" : $nom)
535
-			. '</label>';
536
-
537
-		if (
538
-			!$checked and !$dis and
539
-			(($nom == $login_db) or
540
-				($GLOBALS['table_prefix'] == $nom))
541
-		) {
542
-			$checked = "<input$base checked='checked' />\n$label";
543
-		} else {
544
-			$bases[] = "<input$base />\n$label";
545
-		}
546
-	}
547
-
548
-	if (!$bases && !$checked) {
549
-		return false;
550
-	}
551
-
552
-	if ($checked) {
553
-		array_unshift($bases, $checked);
554
-		$checked = true;
555
-	}
556
-
557
-	return [$checked, $bases];
519
+    $bases = $checked = [];
520
+    $noms = sql_listdbs($server_db);
521
+    if (!$noms) {
522
+        return '';
523
+    }
524
+
525
+    foreach ($noms as $nom) {
526
+        $id = spip_htmlspecialchars($nom);
527
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
528
+        $base = ' name="choix_db" value="'
529
+            . $nom
530
+            . '"'
531
+            . $dis
532
+            . " type='radio' id='$id'";
533
+        $label = "<label for='$id'>"
534
+            . ($dis ? "<i>$nom</i>" : $nom)
535
+            . '</label>';
536
+
537
+        if (
538
+            !$checked and !$dis and
539
+            (($nom == $login_db) or
540
+                ($GLOBALS['table_prefix'] == $nom))
541
+        ) {
542
+            $checked = "<input$base checked='checked' />\n$label";
543
+        } else {
544
+            $bases[] = "<input$base />\n$label";
545
+        }
546
+    }
547
+
548
+    if (!$bases && !$checked) {
549
+        return false;
550
+    }
551
+
552
+    if ($checked) {
553
+        array_unshift($bases, $checked);
554
+        $checked = true;
555
+    }
556
+
557
+    return [$checked, $bases];
558 558
 }
559 559
 
560 560
 function install_propager($hidden) {
561
-	$res = '';
562
-	foreach ($hidden as $k) {
563
-		$v = spip_htmlentities(_request($k));
564
-		$res .= "<input type='hidden' name='$k' value='$v' />";
565
-	}
561
+    $res = '';
562
+    foreach ($hidden as $k) {
563
+        $v = spip_htmlentities(_request($k));
564
+        $res .= "<input type='hidden' name='$k' value='$v' />";
565
+    }
566 566
 
567
-	return $res;
567
+    return $res;
568 568
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = '<' . "?php\n"
46
+	$texte = '<'."?php\n"
47 47
 		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48 48
 		. $texte
49
-		. '?' . '>';
49
+		. '?'.'>';
50 50
 
51 51
 	ecrire_fichier($nom, $texte);
52 52
 }
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
 		return $regs;
114 114
 	} else {
115 115
 		$ar = '\s*\'([^\']*)\'';
116
-		$r = '\s*,' . $ar;
116
+		$r = '\s*,'.$ar;
117 117
 		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118 118
 		if (preg_match($r, $s, $regs)) {
119
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ':' . $regs[2] . ';');
119
+			$regs[2] = $regs[1].(!$regs[2] ? '' : ':'.$regs[2].';');
120 120
 			array_shift($regs);
121 121
 			array_shift($regs);
122 122
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	// Si on n'a pas la bonne version de PHP, c'est la fin
174 174
 	if ($err) {
175 175
 		die("<div class='error'>"
176
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
176
+			. '<h3>'._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>"
177 177
 			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
178 178
 	}
179 179
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 
201 201
 	if ($err) {
202 202
 		echo "<div class='error'>"
203
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
203
+			. '<h3>'._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>";
204 204
 		foreach ($err as $e) {
205 205
 			echo "<li><strong>$e</strong></li>\n";
206 206
 		}
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 
234 234
 
235 235
 function info_etape($titre, $complement = '') {
236
-	return '<h2>' . $titre . "</h2>\n" .
237
-	($complement ? '' . $complement . "\n" : '');
236
+	return '<h2>'.$titre."</h2>\n".
237
+	($complement ? ''.$complement."\n" : '');
238 238
 }
239 239
 
240 240
 /**
@@ -248,18 +248,18 @@  discard block
 block discarded – undo
248 248
 		$code = _T('bouton_suivant');
249 249
 	}
250 250
 	static $suivant = 0;
251
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
251
+	$id = 'suivant'.(($suivant > 0) ? strval($suivant) : '');
252 252
 	$suivant += 1;
253 253
 
254
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
255
-	$code .
254
+	return "\n<p class='boutons suivant'><input id='".$id."' type='submit'\nvalue=\"".
255
+	$code.
256 256
 	" >>\" /></p>\n";
257 257
 }
258 258
 
259 259
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
260 260
 	$intitule_etat = [];
261 261
 	//$en_cours = _request('etape')?_request('etape'):"";
262
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
262
+	$liste = find_all_in_path($dir, $phase.'(([0-9])+|fin)[.]php$');
263 263
 	$debut = 1;
264 264
 	$etat = 'ok';
265 265
 	$last = count($liste);
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 
299 299
 			$aff_etapes .= "<li class='$class'><div class='fond'>";
300 300
 			$aff_etapes .= ($debut == $en_cours) ? '<strong>' : '';
301
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
301
+			$aff_etapes .= '<em>'._T('etape')." </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
302 302
 			$aff_etapes .= $intitule_etat["$phase"][$debut];
303 303
 			$aff_etapes .= ($debut == $en_cours) ? '</strong>' : '';
304 304
 			$aff_etapes .= '</div></li>';
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 
314 314
 
315 315
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
316
-	return "<fieldset>\n" .
317
-	$avant .
318
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
319
-	fieldset_champs($champs) .
320
-	$apres .
316
+	return "<fieldset>\n".
317
+	$avant.
318
+	($legend ? '<legend>'.$legend."</legend>\n" : '').
319
+	fieldset_champs($champs).
320
+	$apres.
321 321
 	"</fieldset>\n";
322 322
 }
323 323
 
@@ -327,18 +327,18 @@  discard block
 block discarded – undo
327 327
 		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
328 328
 		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
329 329
 		if (isset($contenu['alternatives'])) {
330
-			$fieldset .= $contenu['label'] . "\n";
330
+			$fieldset .= $contenu['label']."\n";
331 331
 			foreach ($contenu['alternatives'] as $valeur => $label) {
332
-				$fieldset .= "<input type='radio' name='" . $nom .
332
+				$fieldset .= "<input type='radio' name='".$nom.
333 333
 					"' id='$nom-$valeur' value='$valeur'"
334 334
 					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
335 335
 					. "/>\n";
336
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
336
+				$fieldset .= "<label for='$nom-$valeur'>".$label."</label>\n";
337 337
 			}
338 338
 			$fieldset .= "<br />\n";
339 339
 		} else {
340
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
341
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
340
+			$fieldset .= "<label for='".$nom."'>".$contenu['label']."</label>\n";
341
+			$fieldset .= '<input '.$class."type='".$type."' id='".$nom."' name='".$nom."'\nvalue='".$contenu['valeur']."'"
342 342
 				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
343 343
 				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : '')
344 344
 				. " />\n";
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
 function install_select_serveur() {
352 352
 	$options = [];
353
-	$dir = _DIR_RESTREINT . 'req/';
353
+	$dir = _DIR_RESTREINT.'req/';
354 354
 	$d = opendir($dir);
355 355
 	if (!$d) {
356 356
 		return [];
@@ -358,17 +358,17 @@  discard block
 block discarded – undo
358 358
 	while (($f = readdir($d)) !== false) {
359 359
 		if (
360 360
 			(preg_match('/^(.*)[.]php$/', $f, $s))
361
-			and is_readable($f = $dir . $f)
361
+			and is_readable($f = $dir.$f)
362 362
 		) {
363 363
 			require_once($f);
364 364
 			$s = $s[1];
365
-			$v = 'spip_versions_' . $s;
365
+			$v = 'spip_versions_'.$s;
366 366
 			if (function_exists($v) and $v()) {
367 367
 				$titre = _T("install_select_type_$s");
368 368
 				// proposer mysql par defaut si dispo
369 369
 				$checked = ($s == 'mysql' ? " checked='checked'" : '');
370 370
 				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
371
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
371
+					. "<label for='$s'>".($titre ?: $s).'</label></li>';
372 372
 			} else {
373 373
 				spip_log("$s: portage indisponible");
374 374
 			}
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 		"\n<input type='hidden' name='etape' value='$etape' />"
387 387
 		. $hidden
388 388
 		. (_request('echec') ?
389
-			('<p><b>' . _T('avis_connexion_echec_1') .
390
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
389
+			('<p><b>'._T('avis_connexion_echec_1').
390
+				'</b></p><p>'._T('avis_connexion_echec_2')."</p><p style='font-size: small;'>"._T('avis_connexion_echec_3').'</p>')
391 391
 			: '')
392 392
 
393 393
 		. ($jquery ? http_script('', 'jquery.js') : '')
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
 		});')
426 426
 
427 427
 		. ($server_db
428
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
428
+			? '<input type="hidden" name="server_db" value="'.$server_db.'" />'
429 429
 			. (($predef[0])
430
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
430
+				? ('<h3>'._T('install_serveur_hebergeur').'</h3>')
431 431
 				: '')
432 432
 			: ('<fieldset><legend>'
433 433
 				. _T('install_select_type_db')
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 				. "\n</ul>\n</div></fieldset>")
443 443
 		)
444 444
 		. '<div id="install_adresse_base_hebergeur">'
445
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
445
+		. '<p>'._T('texte_connexion_mysql').'</p>'
446 446
 		. ($predef[1]
447
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
447
+			? '<h3>'._T('install_adresse_base_hebergeur').'</h3>'
448 448
 			: fieldset(
449 449
 				_T('entree_base_donnee_1'),
450 450
 				[
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
 		. '<div id="install_login_base_hebergeur">'
461 461
 		. ($predef[2]
462
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
462
+			? '<h3>'._T('install_login_base_hebergeur').'</h3>'
463 463
 			: fieldset(
464 464
 				_T('entree_login_connexion_1'),
465 465
 				[
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 
475 475
 		. '<div id="install_pass_base_hebergeur">'
476 476
 		. ($predef[3]
477
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
477
+			? '<h3>'._T('install_pass_base_hebergeur').'</h3>'
478 478
 			: fieldset(
479 479
 				_T('entree_mot_passe_1'),
480 480
 				[
@@ -496,20 +496,20 @@  discard block
 block discarded – undo
496 496
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
497 497
 	return ((defined('_INSTALL_HOST_DB'))
498 498
 		? ''
499
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
499
+		: "\n<input type='hidden' name='adresse_db'  value=\"".spip_htmlspecialchars($adresse_db).'" />'
500 500
 	)
501 501
 	. ((defined('_INSTALL_USER_DB'))
502 502
 		? ''
503
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
503
+		: "\n<input type='hidden' name='login_db' value=\"".spip_htmlspecialchars($login_db).'" />'
504 504
 	)
505 505
 	. ((defined('_INSTALL_PASS_DB'))
506 506
 		? ''
507
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
507
+		: "\n<input type='hidden' name='pass_db' value=\"".spip_htmlspecialchars($pass_db).'" />'
508 508
 	)
509 509
 
510 510
 	. ((defined('_INSTALL_SERVER_DB'))
511 511
 		? ''
512
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
512
+		: "\n<input type='hidden' name='server_db' value=\"".spip_htmlspecialchars($server_db).'" />'
513 513
 	);
514 514
 }
515 515
 
Please login to merge, or discard this patch.
ecrire/inc/lien.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
99 99
 }
100 100
 
101
-define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS');
101
+define('_EXTRAIRE_LIEN', ',^\s*(?:'._PROTOCOLES_STD.'):?/?/?\s*$,iS');
102 102
 
103 103
 function traiter_lien_explicite($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) {
104 104
 	if (preg_match(_EXTRAIRE_LIEN, $ref)) {
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
 		$lien_court = charger_fonction('lien_court', 'inc');
115 115
 		$texte = $lien_court($texte);
116 116
 		if ($echappe_typo) {
117
-			$texte = '<html>' . quote_amp($texte) . '</html>';
117
+			$texte = '<html>'.quote_amp($texte).'</html>';
118 118
 		}
119 119
 	}
120 120
 
121 121
 	// petites corrections d'URL
122 122
 	if (preg_match('/^www\.[^@]+$/S', $lien)) {
123
-		$lien = 'http://' . $lien;
123
+		$lien = 'http://'.$lien;
124 124
 	} else {
125 125
 		if (strpos($lien, '@') && email_valide($lien)) {
126 126
 			if (!$texte) {
127 127
 				$texte = $lien;
128 128
 			}
129
-			$lien = 'mailto:' . $lien;
129
+			$lien = 'mailto:'.$lien;
130 130
 		}
131 131
 	}
132 132
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 }
143 143
 
144 144
 function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, string $connect = '') {
145
-	if (function_exists($f = 'glossaire_' . $ancre)) {
145
+	if (function_exists($f = 'glossaire_'.$ancre)) {
146 146
 		$url = $f($texte, $id);
147 147
 	} else {
148 148
 		$url = glossaire_std($texte);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	if (!($match = typer_raccourci($ref))) {
157 157
 		return false;
158 158
 	}
159
-	[$type, , $id, , $args, , $ancre] = array_pad($match, 7, null);
159
+	[$type,, $id,, $args,, $ancre] = array_pad($match, 7, null);
160 160
 	// attention dans le cas des sites le lien doit pointer non pas sur
161 161
 	// la page locale du site, mais directement sur le site lui-meme
162 162
 	if ($f = charger_fonction("implicite_$type", 'liens', true)) {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		$r['titre'] = $texte;
184 184
 	}
185 185
 	if (!@$r['titre']) {
186
-		$r['titre'] = _T($type) . " $id";
186
+		$r['titre'] = _T($type)." $id";
187 187
 	}
188 188
 	if ($pour == 'titre') {
189 189
 		return $r['titre'];
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		and $mime = sql_getfetsel(
197 197
 			'mime_type',
198 198
 			'spip_types_documents',
199
-			'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')',
199
+			'extension IN ('.sql_get_select('extension', 'spip_documents', 'id_document='.sql_quote($id)).')',
200 200
 			'',
201 201
 			'',
202 202
 			'',
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 	'(<([a-z_-]{3,})' # <modele
298 298
 	. '\s*([0-9]*)\s*' # id
299 299
 	. '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
300
-	. '\s*/?' . '>)' # fin du modele >
300
+	. '\s*/?'.'>)' # fin du modele >
301 301
 	. '\s*(<\/a>)?' # eventuel </a>
302 302
 );
303 303
 
304
-define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS');
304
+define('_RACCOURCI_MODELE_DEBUT', '@^'._RACCOURCI_MODELE.'@isS');
305 305
 
306 306
 function traiter_modeles($texte, $doublons = false, $echap = '', string $connect = '', $liens = null, $env = []) {
307 307
 	// preserver la compatibilite : true = recherche des documents
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 						if (test_espace_prive()) {
381 381
 							$modele = entites_html(substr($texte, $a, $cherche));
382 382
 							if (!is_null($liens)) {
383
-								$modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>';
383
+								$modele = '<pre>'.str_replace($liens[0], $liens[1], $modele).'</pre>';
384 384
 							}
385 385
 						}
386 386
 					}
Please login to merge, or discard this patch.
Indentation   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('base/abstract_sql');
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
 //
24 24
 
25 25
 function inc_lien_dist(
26
-	$lien,
27
-	$texte = '',
28
-	$class = '',
29
-	$title = '',
30
-	$hlang = '',
31
-	$rel = '',
32
-	string $connect = '',
33
-	$env = []
26
+    $lien,
27
+    $texte = '',
28
+    $class = '',
29
+    $title = '',
30
+    $hlang = '',
31
+    $rel = '',
32
+    string $connect = '',
33
+    $env = []
34 34
 ) {
35
-	return $lien;
35
+    return $lien;
36 36
 }
37 37
 
38 38
 // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip
@@ -43,28 +43,28 @@  discard block
 block discarded – undo
43 43
 
44 44
 function expanser_liens($t, string $connect = '', $env = []) {
45 45
 
46
-	$t = pipeline('pre_liens', $t);
46
+    $t = pipeline('pre_liens', $t);
47 47
 
48
-	// on passe a traiter_modeles la liste des liens reperes pour lui permettre
49
-	// de remettre le texte d'origine dans les parametres du modele
50
-	$t = traiter_modeles($t, false, false, $connect);
48
+    // on passe a traiter_modeles la liste des liens reperes pour lui permettre
49
+    // de remettre le texte d'origine dans les parametres du modele
50
+    $t = traiter_modeles($t, false, false, $connect);
51 51
 
52
-	return $t;
52
+    return $t;
53 53
 }
54 54
 
55 55
 // Meme analyse mais pour eliminer les liens
56 56
 // et ne laisser que leur titre, a expliciter si ce n'est fait
57 57
 function nettoyer_raccourcis_typo($texte, string $connect = '') {
58
-	return $texte;
58
+    return $texte;
59 59
 }
60 60
 
61 61
 // Repere dans la partie texte d'un raccourci [texte->...]
62 62
 // la langue et la bulle eventuelles
63 63
 function traiter_raccourci_lien_atts($texte) {
64
-	$bulle = '';
65
-	$hlang = '';
64
+    $bulle = '';
65
+    $hlang = '';
66 66
 
67
-	return [trim($texte), $bulle, $hlang];
67
+    return [trim($texte), $bulle, $hlang];
68 68
 }
69 69
 
70 70
 define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/');
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
  * @return string
81 81
  */
82 82
 function virtuel_redirige($virtuel, $url = false) {
83
-	return $virtuel;
83
+    return $virtuel;
84 84
 }
85 85
 
86 86
 // Cherche un lien du type [->raccourci 123]
@@ -93,121 +93,121 @@  discard block
 block discarded – undo
93 93
 // 'url':   seulement U  (i.e. generer_url_RACCOURCI)
94 94
 
95 95
 function calculer_url($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) {
96
-	$r = traiter_lien_implicite($ref, $texte, $pour, $connect);
96
+    $r = traiter_lien_implicite($ref, $texte, $pour, $connect);
97 97
 
98
-	return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
98
+    return $r ?: traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
99 99
 }
100 100
 
101 101
 define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS');
102 102
 
103 103
 function traiter_lien_explicite($ref, $texte = '', $pour = 'url', string $connect = '', $echappe_typo = true) {
104
-	if (preg_match(_EXTRAIRE_LIEN, $ref)) {
105
-		return ($pour != 'tout') ? '' : ['', '', '', ''];
106
-	}
107
-
108
-	$lien = entites_html(trim($ref));
109
-
110
-	// Liens explicites
111
-	if (!$texte) {
112
-		$texte = str_replace('"', '', $lien);
113
-		// evite l'affichage de trops longues urls.
114
-		$lien_court = charger_fonction('lien_court', 'inc');
115
-		$texte = $lien_court($texte);
116
-		if ($echappe_typo) {
117
-			$texte = '<html>' . quote_amp($texte) . '</html>';
118
-		}
119
-	}
120
-
121
-	// petites corrections d'URL
122
-	if (preg_match('/^www\.[^@]+$/S', $lien)) {
123
-		$lien = 'http://' . $lien;
124
-	} else {
125
-		if (strpos($lien, '@') && email_valide($lien)) {
126
-			if (!$texte) {
127
-				$texte = $lien;
128
-			}
129
-			$lien = 'mailto:' . $lien;
130
-		}
131
-	}
132
-
133
-	if ($pour == 'url') {
134
-		return $lien;
135
-	}
136
-
137
-	if ($pour == 'titre') {
138
-		return $texte;
139
-	}
140
-
141
-	return ['url' => $lien, 'titre' => $texte];
104
+    if (preg_match(_EXTRAIRE_LIEN, $ref)) {
105
+        return ($pour != 'tout') ? '' : ['', '', '', ''];
106
+    }
107
+
108
+    $lien = entites_html(trim($ref));
109
+
110
+    // Liens explicites
111
+    if (!$texte) {
112
+        $texte = str_replace('"', '', $lien);
113
+        // evite l'affichage de trops longues urls.
114
+        $lien_court = charger_fonction('lien_court', 'inc');
115
+        $texte = $lien_court($texte);
116
+        if ($echappe_typo) {
117
+            $texte = '<html>' . quote_amp($texte) . '</html>';
118
+        }
119
+    }
120
+
121
+    // petites corrections d'URL
122
+    if (preg_match('/^www\.[^@]+$/S', $lien)) {
123
+        $lien = 'http://' . $lien;
124
+    } else {
125
+        if (strpos($lien, '@') && email_valide($lien)) {
126
+            if (!$texte) {
127
+                $texte = $lien;
128
+            }
129
+            $lien = 'mailto:' . $lien;
130
+        }
131
+    }
132
+
133
+    if ($pour == 'url') {
134
+        return $lien;
135
+    }
136
+
137
+    if ($pour == 'titre') {
138
+        return $texte;
139
+    }
140
+
141
+    return ['url' => $lien, 'titre' => $texte];
142 142
 }
143 143
 
144 144
 function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, string $connect = '') {
145
-	if (function_exists($f = 'glossaire_' . $ancre)) {
146
-		$url = $f($texte, $id);
147
-	} else {
148
-		$url = glossaire_std($texte);
149
-	}
145
+    if (function_exists($f = 'glossaire_' . $ancre)) {
146
+        $url = $f($texte, $id);
147
+    } else {
148
+        $url = glossaire_std($texte);
149
+    }
150 150
 
151
-	return $url;
151
+    return $url;
152 152
 }
153 153
 
154 154
 function traiter_lien_implicite($ref, $texte = '', $pour = 'url', string $connect = '') {
155
-	$url = null;
156
-	if (!($match = typer_raccourci($ref))) {
157
-		return false;
158
-	}
159
-	[$type, , $id, , $args, , $ancre] = array_pad($match, 7, null);
160
-	// attention dans le cas des sites le lien doit pointer non pas sur
161
-	// la page locale du site, mais directement sur le site lui-meme
162
-	if ($f = charger_fonction("implicite_$type", 'liens', true)) {
163
-		$url = $f($texte, $id, $type, $args, $ancre, $connect);
164
-	}
165
-	if (!$url) {
166
-		$url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', null, '', $connect);
167
-	}
168
-	if (!$url) {
169
-		return false;
170
-	}
171
-	if (is_array($url)) {
172
-		[$type, $id] = array_pad($url, 2, null);
173
-		$url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', null, '', $connect);
174
-	}
175
-	if ($pour === 'url') {
176
-		return $url;
177
-	}
178
-	$r = traiter_raccourci_titre($id, $type, $connect);
179
-	if ($r) {
180
-		$r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in';
181
-	}
182
-	if ($texte = trim($texte)) {
183
-		$r['titre'] = $texte;
184
-	}
185
-	if (!@$r['titre']) {
186
-		$r['titre'] = _T($type) . " $id";
187
-	}
188
-	if ($pour == 'titre') {
189
-		return $r['titre'];
190
-	}
191
-	$r['url'] = $url;
192
-
193
-	// dans le cas d'un lien vers un doc, ajouter le type='mime/type'
194
-	if (
195
-		$type == 'document'
196
-		and $mime = sql_getfetsel(
197
-			'mime_type',
198
-			'spip_types_documents',
199
-			'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')',
200
-			'',
201
-			'',
202
-			'',
203
-			'',
204
-			$connect
205
-		)
206
-	) {
207
-		$r['mime'] = $mime;
208
-	}
209
-
210
-	return $r;
155
+    $url = null;
156
+    if (!($match = typer_raccourci($ref))) {
157
+        return false;
158
+    }
159
+    [$type, , $id, , $args, , $ancre] = array_pad($match, 7, null);
160
+    // attention dans le cas des sites le lien doit pointer non pas sur
161
+    // la page locale du site, mais directement sur le site lui-meme
162
+    if ($f = charger_fonction("implicite_$type", 'liens', true)) {
163
+        $url = $f($texte, $id, $type, $args, $ancre, $connect);
164
+    }
165
+    if (!$url) {
166
+        $url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', null, '', $connect);
167
+    }
168
+    if (!$url) {
169
+        return false;
170
+    }
171
+    if (is_array($url)) {
172
+        [$type, $id] = array_pad($url, 2, null);
173
+        $url = generer_objet_url($id, $type, $args ?? '', $ancre ?? '', null, '', $connect);
174
+    }
175
+    if ($pour === 'url') {
176
+        return $url;
177
+    }
178
+    $r = traiter_raccourci_titre($id, $type, $connect);
179
+    if ($r) {
180
+        $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in';
181
+    }
182
+    if ($texte = trim($texte)) {
183
+        $r['titre'] = $texte;
184
+    }
185
+    if (!@$r['titre']) {
186
+        $r['titre'] = _T($type) . " $id";
187
+    }
188
+    if ($pour == 'titre') {
189
+        return $r['titre'];
190
+    }
191
+    $r['url'] = $url;
192
+
193
+    // dans le cas d'un lien vers un doc, ajouter le type='mime/type'
194
+    if (
195
+        $type == 'document'
196
+        and $mime = sql_getfetsel(
197
+            'mime_type',
198
+            'spip_types_documents',
199
+            'extension IN (' . sql_get_select('extension', 'spip_documents', 'id_document=' . sql_quote($id)) . ')',
200
+            '',
201
+            '',
202
+            '',
203
+            '',
204
+            $connect
205
+        )
206
+    ) {
207
+        $r['mime'] = $mime;
208
+    }
209
+
210
+    return $r;
211 211
 }
212 212
 
213 213
 // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes
@@ -215,41 +215,41 @@  discard block
 block discarded – undo
215 215
 define('_RACCOURCI_URL', '/^\s*(\w*?)\s*(\d+)(\?(.*?))?(#([^\s]*))?\s*$/S');
216 216
 
217 217
 function typer_raccourci($lien) {
218
-	if (!preg_match(_RACCOURCI_URL, $lien, $match)) {
219
-		return [];
220
-	}
221
-	$f = $match[1];
222
-	// valeur par defaut et alias historiques
223
-	if (!$f) {
224
-		$f = 'article';
225
-	} else {
226
-		if ($f == 'art') {
227
-			$f = 'article';
228
-		} else {
229
-			if ($f == 'br') {
230
-				$f = 'breve';
231
-			} else {
232
-				if ($f == 'rub') {
233
-					$f = 'rubrique';
234
-				} else {
235
-					if ($f == 'aut') {
236
-						$f = 'auteur';
237
-					} else {
238
-						if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') {
239
-							$f = 'document';
240
-						} else {
241
-							if (preg_match('/^br..?ve$/S', $f)) {
242
-								$f = 'breve';
243
-							}
244
-						}
245
-					}
246
-				}
247
-			}
248
-		}
249
-	} # accents :(
250
-	$match[0] = $f;
251
-
252
-	return $match;
218
+    if (!preg_match(_RACCOURCI_URL, $lien, $match)) {
219
+        return [];
220
+    }
221
+    $f = $match[1];
222
+    // valeur par defaut et alias historiques
223
+    if (!$f) {
224
+        $f = 'article';
225
+    } else {
226
+        if ($f == 'art') {
227
+            $f = 'article';
228
+        } else {
229
+            if ($f == 'br') {
230
+                $f = 'breve';
231
+            } else {
232
+                if ($f == 'rub') {
233
+                    $f = 'rubrique';
234
+                } else {
235
+                    if ($f == 'aut') {
236
+                        $f = 'auteur';
237
+                    } else {
238
+                        if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') {
239
+                            $f = 'document';
240
+                        } else {
241
+                            if (preg_match('/^br..?ve$/S', $f)) {
242
+                                $f = 'breve';
243
+                            }
244
+                        }
245
+                    }
246
+                }
247
+            }
248
+        }
249
+    } # accents :(
250
+    $match[0] = $f;
251
+
252
+    return $match;
253 253
 }
254 254
 
255 255
 /**
@@ -264,25 +264,25 @@  discard block
 block discarded – undo
264 264
  * }
265 265
  **/
266 266
 function traiter_raccourci_titre($id, $type, $connect = null) {
267
-	$trouver_table = charger_fonction('trouver_table', 'base');
268
-	$desc = $trouver_table(table_objet($type));
269
-	if (!($desc and $s = $desc['titre'])) {
270
-		return [];
271
-	}
272
-	$_id = $desc['key']['PRIMARY KEY'];
273
-	$r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect);
274
-	if (!$r) {
275
-		return [];
276
-	}
277
-	$r['titre'] = supprimer_numero($r['titre']);
278
-	if (!$r['titre'] and !empty($r['surnom'])) {
279
-		$r['titre'] = $r['surnom'];
280
-	}
281
-	if (!isset($r['lang'])) {
282
-		$r['lang'] = '';
283
-	}
284
-
285
-	return $r;
267
+    $trouver_table = charger_fonction('trouver_table', 'base');
268
+    $desc = $trouver_table(table_objet($type));
269
+    if (!($desc and $s = $desc['titre'])) {
270
+        return [];
271
+    }
272
+    $_id = $desc['key']['PRIMARY KEY'];
273
+    $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect);
274
+    if (!$r) {
275
+        return [];
276
+    }
277
+    $r['titre'] = supprimer_numero($r['titre']);
278
+    if (!$r['titre'] and !empty($r['surnom'])) {
279
+        $r['titre'] = $r['surnom'];
280
+    }
281
+    if (!isset($r['lang'])) {
282
+        $r['lang'] = '';
283
+    }
284
+
285
+    return $r;
286 286
 }
287 287
 
288 288
 // traite les modeles (dans la fonction typo), en remplacant
@@ -293,136 +293,136 @@  discard block
 block discarded – undo
293 293
 // mais on renvoie les params (pour l'indexation par le moteur de recherche)
294 294
 
295 295
 define(
296
-	'_RACCOURCI_MODELE',
297
-	'(<([a-z_-]{3,})' # <modele
298
-	. '\s*([0-9]*)\s*' # id
299
-	. '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
300
-	. '\s*/?' . '>)' # fin du modele >
301
-	. '\s*(<\/a>)?' # eventuel </a>
296
+    '_RACCOURCI_MODELE',
297
+    '(<([a-z_-]{3,})' # <modele
298
+    . '\s*([0-9]*)\s*' # id
299
+    . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
300
+    . '\s*/?' . '>)' # fin du modele >
301
+    . '\s*(<\/a>)?' # eventuel </a>
302 302
 );
303 303
 
304 304
 define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS');
305 305
 
306 306
 function traiter_modeles($texte, $doublons = false, $echap = '', string $connect = '', $liens = null, $env = []) {
307
-	// preserver la compatibilite : true = recherche des documents
308
-	if ($doublons === true) {
309
-		$doublons = ['documents' => ['doc', 'emb', 'img']];
310
-	}
311
-	// detecter les modeles (rapide)
312
-	if (
313
-		strpos($texte, '<') !== false and
314
-		preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)
315
-	) {
316
-		include_spip('public/assembler');
317
-		$wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true);
318
-		foreach ($matches as $match) {
319
-			// Recuperer l'appel complet (y compris un eventuel lien)
320
-
321
-			$a = strpos($texte, (string) $match[0]);
322
-			preg_match(
323
-				_RACCOURCI_MODELE_DEBUT,
324
-				substr($texte, $a),
325
-				$regs
326
-			);
327
-			$regs[] = ''; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
328
-			[, $mod, $type, $id, $params, $fin] = $regs;
329
-			if (
330
-				$fin and
331
-				preg_match(
332
-					'/<a\s[^<>]*>\s*$/i',
333
-					substr($texte, 0, $a),
334
-					$r
335
-				)
336
-			) {
337
-				$lien = [
338
-					'href' => extraire_attribut($r[0], 'href'),
339
-					'class' => extraire_attribut($r[0], 'class'),
340
-					'mime' => extraire_attribut($r[0], 'type'),
341
-					'title' => extraire_attribut($r[0], 'title'),
342
-					'hreflang' => extraire_attribut($r[0], 'hreflang')
343
-				];
344
-				$n = strlen($r[0]);
345
-				$a -= $n;
346
-				$cherche = $n + strlen($regs[0]);
347
-			} else {
348
-				$lien = false;
349
-				$cherche = strlen($mod);
350
-			}
351
-
352
-			// calculer le modele
353
-			# hack indexation
354
-			if ($doublons) {
355
-				$texte .= preg_replace(',[|][^|=]*,s', ' ', $params);
356
-			} # version normale
357
-			else {
358
-				// si un tableau de liens a ete passe, reinjecter le contenu d'origine
359
-				// dans les parametres, plutot que les liens echappes
360
-				if (!is_null($liens)) {
361
-					$params = str_replace($liens[0], $liens[1], $params);
362
-				}
363
-				$modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
364
-				// en cas d'echec,
365
-				// si l'objet demande a une url,
366
-				// creer un petit encadre vers elle
367
-				if ($modele === false) {
368
-					if (!$lien) {
369
-						$lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
370
-					}
371
-					if ($lien) {
372
-						$modele = '<a href="'
373
-							. $lien['url']
374
-							. '" class="spip_modele'
375
-							. '">'
376
-							. sinon($lien['titre'], _T('ecrire:info_sans_titre'))
377
-							. '</a>';
378
-					} else {
379
-						$modele = '';
380
-						if (test_espace_prive()) {
381
-							$modele = entites_html(substr($texte, $a, $cherche));
382
-							if (!is_null($liens)) {
383
-								$modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>';
384
-							}
385
-						}
386
-					}
387
-				}
388
-				// le remplacer dans le texte
389
-				if ($modele !== false) {
390
-					$modele = protege_js_modeles($modele);
391
-					if ($wrap_embed_html) {
392
-						$modele = $wrap_embed_html($mod, $modele);
393
-					}
394
-					$rempl = code_echappement($modele, $echap);
395
-					$texte = substr($texte, 0, $a)
396
-						. $rempl
397
-						. substr($texte, $a + $cherche);
398
-				}
399
-			}
400
-
401
-			// hack pour tout l'espace prive
402
-			if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) {
403
-				foreach ($doublons ?: ['documents' => ['doc', 'emb', 'img']] as $quoi => $modeles) {
404
-					if (in_array($type, $modeles)) {
405
-						$GLOBALS["doublons_{$quoi}_inclus"][] = $id;
406
-					}
407
-				}
408
-			}
409
-		}
410
-	}
411
-
412
-	return $texte;
307
+    // preserver la compatibilite : true = recherche des documents
308
+    if ($doublons === true) {
309
+        $doublons = ['documents' => ['doc', 'emb', 'img']];
310
+    }
311
+    // detecter les modeles (rapide)
312
+    if (
313
+        strpos($texte, '<') !== false and
314
+        preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)
315
+    ) {
316
+        include_spip('public/assembler');
317
+        $wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true);
318
+        foreach ($matches as $match) {
319
+            // Recuperer l'appel complet (y compris un eventuel lien)
320
+
321
+            $a = strpos($texte, (string) $match[0]);
322
+            preg_match(
323
+                _RACCOURCI_MODELE_DEBUT,
324
+                substr($texte, $a),
325
+                $regs
326
+            );
327
+            $regs[] = ''; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
328
+            [, $mod, $type, $id, $params, $fin] = $regs;
329
+            if (
330
+                $fin and
331
+                preg_match(
332
+                    '/<a\s[^<>]*>\s*$/i',
333
+                    substr($texte, 0, $a),
334
+                    $r
335
+                )
336
+            ) {
337
+                $lien = [
338
+                    'href' => extraire_attribut($r[0], 'href'),
339
+                    'class' => extraire_attribut($r[0], 'class'),
340
+                    'mime' => extraire_attribut($r[0], 'type'),
341
+                    'title' => extraire_attribut($r[0], 'title'),
342
+                    'hreflang' => extraire_attribut($r[0], 'hreflang')
343
+                ];
344
+                $n = strlen($r[0]);
345
+                $a -= $n;
346
+                $cherche = $n + strlen($regs[0]);
347
+            } else {
348
+                $lien = false;
349
+                $cherche = strlen($mod);
350
+            }
351
+
352
+            // calculer le modele
353
+            # hack indexation
354
+            if ($doublons) {
355
+                $texte .= preg_replace(',[|][^|=]*,s', ' ', $params);
356
+            } # version normale
357
+            else {
358
+                // si un tableau de liens a ete passe, reinjecter le contenu d'origine
359
+                // dans les parametres, plutot que les liens echappes
360
+                if (!is_null($liens)) {
361
+                    $params = str_replace($liens[0], $liens[1], $params);
362
+                }
363
+                $modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
364
+                // en cas d'echec,
365
+                // si l'objet demande a une url,
366
+                // creer un petit encadre vers elle
367
+                if ($modele === false) {
368
+                    if (!$lien) {
369
+                        $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
370
+                    }
371
+                    if ($lien) {
372
+                        $modele = '<a href="'
373
+                            . $lien['url']
374
+                            . '" class="spip_modele'
375
+                            . '">'
376
+                            . sinon($lien['titre'], _T('ecrire:info_sans_titre'))
377
+                            . '</a>';
378
+                    } else {
379
+                        $modele = '';
380
+                        if (test_espace_prive()) {
381
+                            $modele = entites_html(substr($texte, $a, $cherche));
382
+                            if (!is_null($liens)) {
383
+                                $modele = '<pre>' . str_replace($liens[0], $liens[1], $modele) . '</pre>';
384
+                            }
385
+                        }
386
+                    }
387
+                }
388
+                // le remplacer dans le texte
389
+                if ($modele !== false) {
390
+                    $modele = protege_js_modeles($modele);
391
+                    if ($wrap_embed_html) {
392
+                        $modele = $wrap_embed_html($mod, $modele);
393
+                    }
394
+                    $rempl = code_echappement($modele, $echap);
395
+                    $texte = substr($texte, 0, $a)
396
+                        . $rempl
397
+                        . substr($texte, $a + $cherche);
398
+                }
399
+            }
400
+
401
+            // hack pour tout l'espace prive
402
+            if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) {
403
+                foreach ($doublons ?: ['documents' => ['doc', 'emb', 'img']] as $quoi => $modeles) {
404
+                    if (in_array($type, $modeles)) {
405
+                        $GLOBALS["doublons_{$quoi}_inclus"][] = $id;
406
+                    }
407
+                }
408
+            }
409
+        }
410
+    }
411
+
412
+    return $texte;
413 413
 }
414 414
 
415 415
 //
416 416
 // Raccourcis ancre [#ancre<-]
417 417
 //
418 418
 function traiter_raccourci_ancre($letexte) {
419
-	return $letexte;
419
+    return $letexte;
420 420
 }
421 421
 
422 422
 function traiter_raccourci_glossaire($texte) {
423
-	return $texte;
423
+    return $texte;
424 424
 }
425 425
 
426 426
 function glossaire_std($terme) {
427
-	return $terme;
427
+    return $terme;
428 428
 }
Please login to merge, or discard this patch.
ecrire/inc/texte_mini.php 2 patches
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 include_spip('inc/filtres');
23 23
 include_spip('inc/lang');
@@ -39,21 +39,21 @@  discard block
 block discarded – undo
39 39
  **/
40 40
 function definir_puce() {
41 41
 
42
-	// Attention au sens, qui n'est pas defini de la meme facon dans
43
-	// l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
-	// celle du texte) et public (spip_lang est la langue du texte)
45
-	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
42
+    // Attention au sens, qui n'est pas defini de la meme facon dans
43
+    // l'espace prive (spip_lang est la langue de l'interface, lang_dir
44
+    // celle du texte) et public (spip_lang est la langue du texte)
45
+    $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
-	if ($dir == 'rtl') {
49
-		$p .= '_rtl';
50
-	}
47
+    $p = 'puce' . (test_espace_prive() ? '_prive' : '');
48
+    if ($dir == 'rtl') {
49
+        $p .= '_rtl';
50
+    }
51 51
 
52
-	if (!isset($GLOBALS[$p])) {
53
-		$GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
54
-	}
52
+    if (!isset($GLOBALS[$p])) {
53
+        $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
54
+    }
55 55
 
56
-	return $GLOBALS[$p];
56
+    return $GLOBALS[$p];
57 57
 }
58 58
 
59 59
 
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 // dont on souhaite qu'ils provoquent un saut de paragraphe
62 62
 
63 63
 if (!defined('_BALISES_BLOCS')) {
64
-	define(
65
-		'_BALISES_BLOCS',
66
-		'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
67
-	);
64
+    define(
65
+        '_BALISES_BLOCS',
66
+        'address|applet|article|aside|blockquote|button|center|d[ltd]|div|fieldset|fig(ure|caption)|footer|form|h[1-6r]|hgroup|head|header|iframe|li|map|marquee|nav|noscript|object|ol|pre|section|t(able|[rdh]|body|foot|extarea)|ul|script|style'
67
+    );
68 68
 }
69 69
 
70 70
 if (!defined('_BALISES_BLOCS_REGEXP')) {
71
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
71
+    define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
72 72
 }
73 73
 
74 74
 //
@@ -79,106 +79,106 @@  discard block
 block discarded – undo
79 79
 // une $source differente ; le script detecte automagiquement si ce qu'on
80 80
 // echappe est un div ou un span
81 81
 function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) {
82
-	if (!strlen($rempl)) {
83
-		return '';
84
-	}
85
-
86
-	// Tester si on echappe en span ou en div
87
-	if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
-	}
90
-
91
-	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
-	$taille = 30000;
93
-	$return = '';
94
-	for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
-		// Convertir en base64 et cacher dans un attribut
96
-		// utiliser les " pour eviter le re-encodage de ' et &#8217
97
-		$base64 = base64_encode(substr($rempl, $i, $taille));
98
-		$return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
-	}
100
-
101
-	return $return;
82
+    if (!strlen($rempl)) {
83
+        return '';
84
+    }
85
+
86
+    // Tester si on echappe en span ou en div
87
+    if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
88
+        $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89
+    }
90
+
91
+    // Decouper en morceaux, base64 a des probleme selon la taille de la pile
92
+    $taille = 30000;
93
+    $return = '';
94
+    for ($i = 0; $i < strlen($rempl); $i += $taille) {
95
+        // Convertir en base64 et cacher dans un attribut
96
+        // utiliser les " pour eviter le re-encodage de ' et &#8217
97
+        $base64 = base64_encode(substr($rempl, $i, $taille));
98
+        $return .= "<$mode class=\"base64$source\" title=\"$base64\"></$mode>";
99
+    }
100
+
101
+    return $return;
102 102
 }
103 103
 
104 104
 
105 105
 // Echapper les <html>...</ html>
106 106
 function traiter_echap_html_dist($regs) {
107
-	return $regs[3];
107
+    return $regs[3];
108 108
 }
109 109
 
110 110
 // Echapper les <pre>...</ pre>
111 111
 function traiter_echap_pre_dist($regs) {
112
-	// echapper les <code> dans <pre>
113
-	$pre = $regs[3];
114
-
115
-	// echapper les < dans <code>
116
-	// on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
117
-	if (
118
-		strpos($pre, '<') !== false
119
-		and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)
120
-	) {
121
-		foreach ($matches as $m) {
122
-			if ($m[1] === 'code') {
123
-				$code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
124
-				$pre = str_replace($m[0], $code, $pre);
125
-			}
126
-		}
127
-	}
128
-	return "<pre>$pre</pre>";
112
+    // echapper les <code> dans <pre>
113
+    $pre = $regs[3];
114
+
115
+    // echapper les < dans <code>
116
+    // on utilise _PROTEGE_BLOCS pour simplifier le code et la maintenance, mais on est interesse que par <code>
117
+    if (
118
+        strpos($pre, '<') !== false
119
+        and preg_match_all(_PROTEGE_BLOCS, $pre, $matches, PREG_SET_ORDER)
120
+    ) {
121
+        foreach ($matches as $m) {
122
+            if ($m[1] === 'code') {
123
+                $code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
124
+                $pre = str_replace($m[0], $code, $pre);
125
+            }
126
+        }
127
+    }
128
+    return "<pre>$pre</pre>";
129 129
 }
130 130
 
131 131
 // Echapper les <code>...</ code>
132 132
 function traiter_echap_code_dist($regs) {
133
-	[, , $att, $corps] = $regs;
134
-	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
135
-
136
-	// ne pas mettre le <div...> s'il n'y a qu'une ligne
137
-	if (is_int(strpos($echap, "\n"))) {
138
-		// supprimer les sauts de ligne debut/fin
139
-		// (mais pas les espaces => ascii art).
140
-		$echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $echap);
141
-		$echap = nl2br($echap);
142
-		$echap = "<div style='text-align: left;' "
143
-			. "class='spip_code' dir='ltr'><code$att>"
144
-			. $echap . '</code></div>';
145
-	} else {
146
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>';
147
-	}
148
-
149
-	$echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
150
-	$echap = str_replace('  ', ' &nbsp;', $echap);
151
-
152
-	return $echap;
133
+    [, , $att, $corps] = $regs;
134
+    $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
135
+
136
+    // ne pas mettre le <div...> s'il n'y a qu'une ligne
137
+    if (is_int(strpos($echap, "\n"))) {
138
+        // supprimer les sauts de ligne debut/fin
139
+        // (mais pas les espaces => ascii art).
140
+        $echap = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $echap);
141
+        $echap = nl2br($echap);
142
+        $echap = "<div style='text-align: left;' "
143
+            . "class='spip_code' dir='ltr'><code$att>"
144
+            . $echap . '</code></div>';
145
+    } else {
146
+        $echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>';
147
+    }
148
+
149
+    $echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
150
+    $echap = str_replace('  ', ' &nbsp;', $echap);
151
+
152
+    return $echap;
153 153
 }
154 154
 
155 155
 // Echapper les <cadre>...</ cadre> aka <frame>...</ frame>
156 156
 function traiter_echap_cadre_dist($regs) {
157
-	$echap = trim(entites_html($regs[3]));
158
-	// compter les lignes un peu plus finement qu'avec les \n
159
-	$lignes = explode("\n", trim($echap));
160
-	$n = 0;
161
-	foreach ($lignes as $l) {
162
-		$n += floor(strlen($l) / 60) + 1;
163
-	}
164
-	$n = max($n, 2);
165
-	$echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
166
-
167
-	return $echap;
157
+    $echap = trim(entites_html($regs[3]));
158
+    // compter les lignes un peu plus finement qu'avec les \n
159
+    $lignes = explode("\n", trim($echap));
160
+    $n = 0;
161
+    foreach ($lignes as $l) {
162
+        $n += floor(strlen($l) / 60) + 1;
163
+    }
164
+    $n = max($n, 2);
165
+    $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre' dir='ltr'>$echap</textarea>";
166
+
167
+    return $echap;
168 168
 }
169 169
 
170 170
 function traiter_echap_frame_dist($regs) {
171
-	return traiter_echap_cadre_dist($regs);
171
+    return traiter_echap_cadre_dist($regs);
172 172
 }
173 173
 
174 174
 function traiter_echap_script_dist($regs) {
175
-	// rendre joli (et inactif) si c'est un script language=php
176
-	if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
177
-		return highlight_string($regs[0], true);
178
-	}
175
+    // rendre joli (et inactif) si c'est un script language=php
176
+    if (preg_match(',<script\b[^>]+php,ims', $regs[0])) {
177
+        return highlight_string($regs[0], true);
178
+    }
179 179
 
180
-	// Cas normal : le script passe tel quel
181
-	return $regs[0];
180
+    // Cas normal : le script passe tel quel
181
+    return $regs[0];
182 182
 }
183 183
 
184 184
 define('_PROTEGE_BLOCS', ',<(html|pre|code|cadre|frame|script|style)(\s[^>]*)?>(.*)</\1>,UimsS');
@@ -196,79 +196,79 @@  discard block
 block discarded – undo
196 196
  * @return string|string[]
197 197
  */
198 198
 function echappe_html(
199
-	$letexte,
200
-	$source = '',
201
-	$no_transform = false,
202
-	$preg = '',
203
-	$callback_prefix = ''
199
+    $letexte,
200
+    $source = '',
201
+    $no_transform = false,
202
+    $preg = '',
203
+    $callback_prefix = ''
204 204
 ) {
205
-	if (!is_string($letexte) or !strlen($letexte)) {
206
-		return $letexte;
207
-	}
208
-
209
-	// si le texte recu est long PCRE risque d'exploser, on
210
-	// fait donc un mic-mac pour augmenter pcre.backtrack_limit
211
-	if (($len = strlen($letexte)) > 100000) {
212
-		if (!$old = @ini_get('pcre.backtrack_limit')) {
213
-			$old = 100000;
214
-		}
215
-		if ($len > $old) {
216
-			$a = @ini_set('pcre.backtrack_limit', $len);
217
-			spip_log("ini_set pcre.backtrack_limit=$len ($old)");
218
-		}
219
-	}
220
-
221
-	if (
222
-		($preg or strpos($letexte, '<') !== false)
223
-		and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
224
-	) {
225
-		foreach ($matches as $regs) {
226
-			// echappements tels quels ?
227
-			if ($no_transform) {
228
-				$echap = $regs[0];
229
-			} // sinon les traiter selon le cas
230
-			else {
231
-				if (
232
-					function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
233
-					or function_exists($f = $f . '_dist')
234
-				) {
235
-					$echap = $f($regs);
236
-				}
237
-			}
238
-
239
-			$p = strpos($letexte, (string) $regs[0]);
240
-			$letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
241
-		}
242
-	}
243
-
244
-	if ($no_transform) {
245
-		return $letexte;
246
-	}
247
-
248
-	// Echapper le php pour faire joli (ici, c'est pas pour la securite)
249
-	// seulement si on a echappe les <script>
250
-	// (derogatoire car on ne peut pas faire passer < ? ... ? >
251
-	// dans une callback autonommee
252
-	if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
253
-		if (
254
-			strpos($letexte, '<' . '?') !== false and preg_match_all(
255
-				',<[?].*($|[?]>),UisS',
256
-				$letexte,
257
-				$matches,
258
-				PREG_SET_ORDER
259
-			)
260
-		) {
261
-			foreach ($matches as $regs) {
262
-				$letexte = str_replace(
263
-					$regs[0],
264
-					code_echappement(highlight_string($regs[0], true), $source),
265
-					$letexte
266
-				);
267
-			}
268
-		}
269
-	}
270
-
271
-	return $letexte;
205
+    if (!is_string($letexte) or !strlen($letexte)) {
206
+        return $letexte;
207
+    }
208
+
209
+    // si le texte recu est long PCRE risque d'exploser, on
210
+    // fait donc un mic-mac pour augmenter pcre.backtrack_limit
211
+    if (($len = strlen($letexte)) > 100000) {
212
+        if (!$old = @ini_get('pcre.backtrack_limit')) {
213
+            $old = 100000;
214
+        }
215
+        if ($len > $old) {
216
+            $a = @ini_set('pcre.backtrack_limit', $len);
217
+            spip_log("ini_set pcre.backtrack_limit=$len ($old)");
218
+        }
219
+    }
220
+
221
+    if (
222
+        ($preg or strpos($letexte, '<') !== false)
223
+        and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
224
+    ) {
225
+        foreach ($matches as $regs) {
226
+            // echappements tels quels ?
227
+            if ($no_transform) {
228
+                $echap = $regs[0];
229
+            } // sinon les traiter selon le cas
230
+            else {
231
+                if (
232
+                    function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
233
+                    or function_exists($f = $f . '_dist')
234
+                ) {
235
+                    $echap = $f($regs);
236
+                }
237
+            }
238
+
239
+            $p = strpos($letexte, (string) $regs[0]);
240
+            $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
241
+        }
242
+    }
243
+
244
+    if ($no_transform) {
245
+        return $letexte;
246
+    }
247
+
248
+    // Echapper le php pour faire joli (ici, c'est pas pour la securite)
249
+    // seulement si on a echappe les <script>
250
+    // (derogatoire car on ne peut pas faire passer < ? ... ? >
251
+    // dans une callback autonommee
252
+    if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
253
+        if (
254
+            strpos($letexte, '<' . '?') !== false and preg_match_all(
255
+                ',<[?].*($|[?]>),UisS',
256
+                $letexte,
257
+                $matches,
258
+                PREG_SET_ORDER
259
+            )
260
+        ) {
261
+            foreach ($matches as $regs) {
262
+                $letexte = str_replace(
263
+                    $regs[0],
264
+                    code_echappement(highlight_string($regs[0], true), $source),
265
+                    $letexte
266
+                );
267
+            }
268
+        }
269
+    }
270
+
271
+    return $letexte;
272 272
 }
273 273
 
274 274
 //
@@ -276,57 +276,57 @@  discard block
 block discarded – undo
276 276
 // Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes
277 277
 // par propre() : exemple dans multi et dans typo()
278 278
 function echappe_retour($letexte, $source = '', $filtre = '') {
279
-	if (strpos($letexte, (string) "base64$source")) {
280
-		# spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
281
-		$max_prof = 5;
282
-		while (
283
-			strpos($letexte, '<') !== false
284
-			and
285
-			preg_match_all(
286
-				',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
287
-				$letexte,
288
-				$regs,
289
-				PREG_SET_ORDER
290
-			)
291
-			and $max_prof--
292
-		) {
293
-			foreach ($regs as $reg) {
294
-				$rempl = base64_decode(extraire_attribut($reg[0], 'title'));
295
-				// recherche d'attributs supplementaires
296
-				$at = [];
297
-				foreach (['lang', 'dir'] as $attr) {
298
-					if ($a = extraire_attribut($reg[0], $attr)) {
299
-						$at[$attr] = $a;
300
-					}
301
-				}
302
-				if ($at) {
303
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
304
-					foreach ($at as $attr => $a) {
305
-						$rempl = inserer_attribut($rempl, $attr, $a);
306
-					}
307
-				}
308
-				if ($filtre) {
309
-					$rempl = $filtre($rempl);
310
-				}
311
-				$letexte = str_replace($reg[0], $rempl, $letexte);
312
-			}
313
-		}
314
-	}
315
-
316
-	return $letexte;
279
+    if (strpos($letexte, (string) "base64$source")) {
280
+        # spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
281
+        $max_prof = 5;
282
+        while (
283
+            strpos($letexte, '<') !== false
284
+            and
285
+            preg_match_all(
286
+                ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
287
+                $letexte,
288
+                $regs,
289
+                PREG_SET_ORDER
290
+            )
291
+            and $max_prof--
292
+        ) {
293
+            foreach ($regs as $reg) {
294
+                $rempl = base64_decode(extraire_attribut($reg[0], 'title'));
295
+                // recherche d'attributs supplementaires
296
+                $at = [];
297
+                foreach (['lang', 'dir'] as $attr) {
298
+                    if ($a = extraire_attribut($reg[0], $attr)) {
299
+                        $at[$attr] = $a;
300
+                    }
301
+                }
302
+                if ($at) {
303
+                    $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
304
+                    foreach ($at as $attr => $a) {
305
+                        $rempl = inserer_attribut($rempl, $attr, $a);
306
+                    }
307
+                }
308
+                if ($filtre) {
309
+                    $rempl = $filtre($rempl);
310
+                }
311
+                $letexte = str_replace($reg[0], $rempl, $letexte);
312
+            }
313
+        }
314
+    }
315
+
316
+    return $letexte;
317 317
 }
318 318
 
319 319
 // Reinserer le javascript de confiance (venant des modeles)
320 320
 
321 321
 function echappe_retour_modeles($letexte, $interdire_scripts = false) {
322
-	$letexte = echappe_retour($letexte);
322
+    $letexte = echappe_retour($letexte);
323 323
 
324
-	// Dans les appels directs hors squelette, securiser aussi ici
325
-	if ($interdire_scripts) {
326
-		$letexte = interdire_scripts($letexte);
327
-	}
324
+    // Dans les appels directs hors squelette, securiser aussi ici
325
+    if ($interdire_scripts) {
326
+        $letexte = interdire_scripts($letexte);
327
+    }
328 328
 
329
-	return trim($letexte);
329
+    return trim($letexte);
330 330
 }
331 331
 
332 332
 
@@ -354,131 +354,131 @@  discard block
 block discarded – undo
354 354
  *     Texte coupé
355 355
  **/
356 356
 function couper($texte, $taille = 50, $suite = null) {
357
-	if (!($length = strlen($texte)) or $taille <= 0) {
358
-		return '';
359
-	}
360
-	$offset = 400 + 2 * $taille;
361
-	while (
362
-		$offset < $length
363
-		and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
364
-	) {
365
-		$offset = 2 * $offset;
366
-	}
367
-	if (
368
-		$offset < $length
369
-		&& ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
370
-	) {
371
-		$p_tag_fermant = strpos($texte, '>', $offset);
372
-		if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
373
-			$offset = $p_tag_fermant + 1;
374
-		} // prolonger la coupe jusqu'au tag fermant suivant eventuel
375
-	}
376
-	$texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
377
-
378
-	if (!function_exists('nettoyer_raccourcis_typo')) {
379
-		include_spip('inc/lien');
380
-	}
381
-	$texte = nettoyer_raccourcis_typo($texte);
382
-
383
-	// balises de sauts de ligne et paragraphe
384
-	$texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
385
-	$texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
386
-
387
-	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
388
-	$texte = str_replace("\n\n", "\r", $texte);
389
-
390
-	// supprimer les tags
391
-	$texte = supprimer_tags($texte);
392
-	$texte = trim(str_replace("\n", ' ', $texte));
393
-	$texte .= "\n";  // marquer la fin
394
-
395
-	// corriger la longueur de coupe
396
-	// en fonction de la presence de caracteres utf
397
-	if ($GLOBALS['meta']['charset'] == 'utf-8') {
398
-		$long = charset2unicode($texte);
399
-		$long = spip_substr($long, 0, max($taille, 1));
400
-		$nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
401
-		$taille += $nbcharutf;
402
-	}
403
-
404
-
405
-	// couper au mot precedent
406
-	$long = spip_substr($texte, 0, max($taille - 4, 1));
407
-	$u = $GLOBALS['meta']['pcre_u'];
408
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
409
-	if (is_null($suite)) {
410
-		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
411
-	}
412
-	$points = $suite;
413
-
414
-	// trop court ? ne pas faire de (...)
415
-	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
416
-		$points = '';
417
-		$long = spip_substr($texte, 0, $taille);
418
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
419
-		// encore trop court ? couper au caractere
420
-		if (spip_strlen($texte) < 0.75 * $taille) {
421
-			$texte = $long;
422
-		}
423
-	} else {
424
-		$texte = $court;
425
-	}
426
-
427
-	if (strpos($texte, "\n")) {  // la fin est encore la : c'est qu'on n'a pas de texte de suite
428
-	$points = '';
429
-	}
430
-
431
-	// remettre les paragraphes
432
-	$texte = preg_replace("/\r+/", "\n\n", $texte);
433
-
434
-	// supprimer l'eventuelle entite finale mal coupee
435
-	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
436
-
437
-	return quote_amp(trim($texte)) . $points;
357
+    if (!($length = strlen($texte)) or $taille <= 0) {
358
+        return '';
359
+    }
360
+    $offset = 400 + 2 * $taille;
361
+    while (
362
+        $offset < $length
363
+        and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
364
+    ) {
365
+        $offset = 2 * $offset;
366
+    }
367
+    if (
368
+        $offset < $length
369
+        && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
370
+    ) {
371
+        $p_tag_fermant = strpos($texte, '>', $offset);
372
+        if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
373
+            $offset = $p_tag_fermant + 1;
374
+        } // prolonger la coupe jusqu'au tag fermant suivant eventuel
375
+    }
376
+    $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
377
+
378
+    if (!function_exists('nettoyer_raccourcis_typo')) {
379
+        include_spip('inc/lien');
380
+    }
381
+    $texte = nettoyer_raccourcis_typo($texte);
382
+
383
+    // balises de sauts de ligne et paragraphe
384
+    $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
385
+    $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
386
+
387
+    // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
388
+    $texte = str_replace("\n\n", "\r", $texte);
389
+
390
+    // supprimer les tags
391
+    $texte = supprimer_tags($texte);
392
+    $texte = trim(str_replace("\n", ' ', $texte));
393
+    $texte .= "\n";  // marquer la fin
394
+
395
+    // corriger la longueur de coupe
396
+    // en fonction de la presence de caracteres utf
397
+    if ($GLOBALS['meta']['charset'] == 'utf-8') {
398
+        $long = charset2unicode($texte);
399
+        $long = spip_substr($long, 0, max($taille, 1));
400
+        $nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
401
+        $taille += $nbcharutf;
402
+    }
403
+
404
+
405
+    // couper au mot precedent
406
+    $long = spip_substr($texte, 0, max($taille - 4, 1));
407
+    $u = $GLOBALS['meta']['pcre_u'];
408
+    $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
409
+    if (is_null($suite)) {
410
+        $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
411
+    }
412
+    $points = $suite;
413
+
414
+    // trop court ? ne pas faire de (...)
415
+    if (spip_strlen($court) < max(0.75 * $taille, 2)) {
416
+        $points = '';
417
+        $long = spip_substr($texte, 0, $taille);
418
+        $texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
419
+        // encore trop court ? couper au caractere
420
+        if (spip_strlen($texte) < 0.75 * $taille) {
421
+            $texte = $long;
422
+        }
423
+    } else {
424
+        $texte = $court;
425
+    }
426
+
427
+    if (strpos($texte, "\n")) {  // la fin est encore la : c'est qu'on n'a pas de texte de suite
428
+    $points = '';
429
+    }
430
+
431
+    // remettre les paragraphes
432
+    $texte = preg_replace("/\r+/", "\n\n", $texte);
433
+
434
+    // supprimer l'eventuelle entite finale mal coupee
435
+    $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
436
+
437
+    return quote_amp(trim($texte)) . $points;
438 438
 }
439 439
 
440 440
 
441 441
 function protege_js_modeles($t) {
442
-	if (isset($GLOBALS['visiteur_session'])) {
443
-		if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
444
-			if (!defined('_PROTEGE_JS_MODELES')) {
445
-				include_spip('inc/acces');
446
-				define('_PROTEGE_JS_MODELES', creer_uniqid());
447
-			}
448
-			foreach ($r as $regs) {
449
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
450
-			}
451
-		}
452
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
453
-			if (!defined('_PROTEGE_PHP_MODELES')) {
454
-				include_spip('inc/acces');
455
-				define('_PROTEGE_PHP_MODELES', creer_uniqid());
456
-			}
457
-			foreach ($r as $regs) {
458
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
459
-			}
460
-		}
461
-	}
462
-
463
-	return $t;
442
+    if (isset($GLOBALS['visiteur_session'])) {
443
+        if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
444
+            if (!defined('_PROTEGE_JS_MODELES')) {
445
+                include_spip('inc/acces');
446
+                define('_PROTEGE_JS_MODELES', creer_uniqid());
447
+            }
448
+            foreach ($r as $regs) {
449
+                $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
450
+            }
451
+        }
452
+        if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
453
+            if (!defined('_PROTEGE_PHP_MODELES')) {
454
+                include_spip('inc/acces');
455
+                define('_PROTEGE_PHP_MODELES', creer_uniqid());
456
+            }
457
+            foreach ($r as $regs) {
458
+                $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
459
+            }
460
+        }
461
+    }
462
+
463
+    return $t;
464 464
 }
465 465
 
466 466
 
467 467
 function echapper_faux_tags($letexte) {
468
-	if (strpos($letexte, '<') === false) {
469
-		return $letexte;
470
-	}
471
-	$textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
472
-
473
-	$letexte = '';
474
-	while (is_countable($textMatches) ? count($textMatches) : 0) {
475
-		// un texte a echapper
476
-		$letexte .= str_replace('<', '&lt;', array_shift($textMatches));
477
-		// un tag html qui a servit a faite le split
478
-		$letexte .= array_shift($textMatches);
479
-	}
480
-
481
-	return $letexte;
468
+    if (strpos($letexte, '<') === false) {
469
+        return $letexte;
470
+    }
471
+    $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
472
+
473
+    $letexte = '';
474
+    while (is_countable($textMatches) ? count($textMatches) : 0) {
475
+        // un texte a echapper
476
+        $letexte .= str_replace('<', '&lt;', array_shift($textMatches));
477
+        // un tag html qui a servit a faite le split
478
+        $letexte .= array_shift($textMatches);
479
+    }
480
+
481
+    return $letexte;
482 482
 }
483 483
 
484 484
 /**
@@ -491,47 +491,47 @@  discard block
 block discarded – undo
491 491
  * @return string
492 492
  */
493 493
 function echapper_html_suspect($texte, $strict = true) {
494
-	static $echapper_html_suspect;
495
-	if (!$texte or !is_string($texte)) {
496
-		return $texte;
497
-	}
498
-
499
-	if (!isset($echapper_html_suspect)) {
500
-		$echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
501
-	}
502
-	// si fonction personalisee, on delegue
503
-	if ($echapper_html_suspect) {
504
-		return $echapper_html_suspect($texte, $strict);
505
-	}
506
-
507
-	if (
508
-		strpos($texte, '<') === false
509
-		or strpos($texte, '=') === false
510
-	) {
511
-		return $texte;
512
-	}
513
-
514
-	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
515
-	// car sinon on declenche sur les modeles ou ressources
516
-	if (
517
-		!$strict and
518
-		(strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
519
-	) {
520
-		return $texte;
521
-	}
522
-
523
-	// on teste sur strlen car safehtml supprime le contenu dangereux
524
-	// mais il peut aussi changer des ' en " sur les attributs html,
525
-	// donc un test d'egalite est trop strict
526
-	if (strlen(safehtml($texte)) !== strlen($texte)) {
527
-		$texte = str_replace('<', '&lt;', $texte);
528
-		if (!function_exists('attribut_html')) {
529
-			include_spip('inc/filtres');
530
-		}
531
-		$texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
532
-	}
533
-
534
-	return $texte;
494
+    static $echapper_html_suspect;
495
+    if (!$texte or !is_string($texte)) {
496
+        return $texte;
497
+    }
498
+
499
+    if (!isset($echapper_html_suspect)) {
500
+        $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
501
+    }
502
+    // si fonction personalisee, on delegue
503
+    if ($echapper_html_suspect) {
504
+        return $echapper_html_suspect($texte, $strict);
505
+    }
506
+
507
+    if (
508
+        strpos($texte, '<') === false
509
+        or strpos($texte, '=') === false
510
+    ) {
511
+        return $texte;
512
+    }
513
+
514
+    // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
515
+    // car sinon on declenche sur les modeles ou ressources
516
+    if (
517
+        !$strict and
518
+        (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
519
+    ) {
520
+        return $texte;
521
+    }
522
+
523
+    // on teste sur strlen car safehtml supprime le contenu dangereux
524
+    // mais il peut aussi changer des ' en " sur les attributs html,
525
+    // donc un test d'egalite est trop strict
526
+    if (strlen(safehtml($texte)) !== strlen($texte)) {
527
+        $texte = str_replace('<', '&lt;', $texte);
528
+        if (!function_exists('attribut_html')) {
529
+            include_spip('inc/filtres');
530
+        }
531
+        $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
532
+    }
533
+
534
+    return $texte;
535 535
 }
536 536
 
537 537
 
@@ -552,30 +552,30 @@  discard block
 block discarded – undo
552 552
  *      Texte sécurisé
553 553
  **/
554 554
 function safehtml($t) {
555
-	static $safehtml;
556
-
557
-	if (!$t or !is_string($t)) {
558
-		return $t;
559
-	}
560
-	# attention safehtml nettoie deux ou trois caracteres de plus. A voir
561
-	if (strpos($t, '<') === false) {
562
-		return str_replace("\x00", '', $t);
563
-	}
564
-
565
-	if (!function_exists('interdire_scripts')) {
566
-		include_spip('inc/texte');
567
-	}
568
-	$t = interdire_scripts($t); // jolifier le php
569
-	$t = echappe_js($t);
570
-
571
-	if (!isset($safehtml)) {
572
-		$safehtml = charger_fonction('safehtml', 'inc', true);
573
-	}
574
-	if ($safehtml) {
575
-		$t = $safehtml($t);
576
-	}
577
-
578
-	return interdire_scripts($t); // interdire le php (2 precautions)
555
+    static $safehtml;
556
+
557
+    if (!$t or !is_string($t)) {
558
+        return $t;
559
+    }
560
+    # attention safehtml nettoie deux ou trois caracteres de plus. A voir
561
+    if (strpos($t, '<') === false) {
562
+        return str_replace("\x00", '', $t);
563
+    }
564
+
565
+    if (!function_exists('interdire_scripts')) {
566
+        include_spip('inc/texte');
567
+    }
568
+    $t = interdire_scripts($t); // jolifier le php
569
+    $t = echappe_js($t);
570
+
571
+    if (!isset($safehtml)) {
572
+        $safehtml = charger_fonction('safehtml', 'inc', true);
573
+    }
574
+    if ($safehtml) {
575
+        $t = $safehtml($t);
576
+    }
577
+
578
+    return interdire_scripts($t); // interdire le php (2 precautions)
579 579
 }
580 580
 
581 581
 
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
  *     Texte sans les modèles d'image
598 598
  **/
599 599
 function supprime_img($letexte, $message = null) {
600
-	if ($message === null) {
601
-		$message = '(' . _T('img_indisponible') . ')';
602
-	}
603
-
604
-	return preg_replace(
605
-		',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
606
-		$message,
607
-		$letexte
608
-	);
600
+    if ($message === null) {
601
+        $message = '(' . _T('img_indisponible') . ')';
602
+    }
603
+
604
+    return preg_replace(
605
+        ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
606
+        $message,
607
+        $letexte
608
+    );
609 609
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	// celle du texte) et public (spip_lang est la langue du texte)
45 45
 	$dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']);
46 46
 
47
-	$p = 'puce' . (test_espace_prive() ? '_prive' : '');
47
+	$p = 'puce'.(test_espace_prive() ? '_prive' : '');
48 48
 	if ($dir == 'rtl') {
49 49
 		$p .= '_rtl';
50 50
 	}
51 51
 
52 52
 	if (!isset($GLOBALS[$p])) {
53
-		$GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>';
53
+		$GLOBALS[$p] = '<span class="spip-puce '.$dir.'"><b>–</b></span>';
54 54
 	}
55 55
 
56 56
 	return $GLOBALS[$p];
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 }
69 69
 
70 70
 if (!defined('_BALISES_BLOCS_REGEXP')) {
71
-	define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS');
71
+	define('_BALISES_BLOCS_REGEXP', ',</?('._BALISES_BLOCS.')[>[:space:]],iS');
72 72
 }
73 73
 
74 74
 //
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 	// Tester si on echappe en span ou en div
87 87
 	if (is_null($mode) or !in_array($mode, ['div', 'span'])) {
88
-		$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $rempl) ? 'div' : 'span';
88
+		$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $rempl) ? 'div' : 'span';
89 89
 	}
90 90
 
91 91
 	// Decouper en morceaux, base64 a des probleme selon la taille de la pile
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	) {
121 121
 		foreach ($matches as $m) {
122 122
 			if ($m[1] === 'code') {
123
-				$code = '<code' . $m[2] . '>' . spip_htmlspecialchars($m[3]) . '</code>';
123
+				$code = '<code'.$m[2].'>'.spip_htmlspecialchars($m[3]).'</code>';
124 124
 				$pre = str_replace($m[0], $code, $pre);
125 125
 			}
126 126
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 // Echapper les <code>...</ code>
132 132
 function traiter_echap_code_dist($regs) {
133
-	[, , $att, $corps] = $regs;
133
+	[,, $att, $corps] = $regs;
134 134
 	$echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code !
135 135
 
136 136
 	// ne pas mettre le <div...> s'il n'y a qu'une ligne
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 		$echap = nl2br($echap);
142 142
 		$echap = "<div style='text-align: left;' "
143 143
 			. "class='spip_code' dir='ltr'><code$att>"
144
-			. $echap . '</code></div>';
144
+			. $echap.'</code></div>';
145 145
 	} else {
146
-		$echap = "<code$att class='spip_code' dir='ltr'>" . $echap . '</code>';
146
+		$echap = "<code$att class='spip_code' dir='ltr'>".$echap.'</code>';
147 147
 	}
148 148
 
149 149
 	$echap = str_replace("\t", '&nbsp; &nbsp; &nbsp; &nbsp; ', $echap);
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 			} // sinon les traiter selon le cas
230 230
 			else {
231 231
 				if (
232
-					function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
233
-					or function_exists($f = $f . '_dist')
232
+					function_exists($f = $callback_prefix.'traiter_echap_'.strtolower($regs[1]))
233
+					or function_exists($f = $f.'_dist')
234 234
 				) {
235 235
 					$echap = $f($regs);
236 236
 				}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	// dans une callback autonommee
252 252
 	if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
253 253
 		if (
254
-			strpos($letexte, '<' . '?') !== false and preg_match_all(
254
+			strpos($letexte, '<'.'?') !== false and preg_match_all(
255 255
 				',<[?].*($|[?]>),UisS',
256 256
 				$letexte,
257 257
 				$matches,
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 			strpos($letexte, '<') !== false
284 284
 			and
285 285
 			preg_match_all(
286
-				',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
286
+				',<(span|div)\sclass=[\'"]base64'.$source.'[\'"]\s(.*)>\s*</\1>,UmsS',
287 287
 				$letexte,
288 288
 				$regs,
289 289
 				PREG_SET_ORDER
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 					}
301 301
 				}
302 302
 				if ($at) {
303
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
303
+					$rempl = '<'.$reg[1].'>'.$rempl.'</'.$reg[1].'>';
304 304
 					foreach ($at as $attr => $a) {
305 305
 						$rempl = inserer_attribut($rempl, $attr, $a);
306 306
 					}
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 	$texte = nettoyer_raccourcis_typo($texte);
382 382
 
383 383
 	// balises de sauts de ligne et paragraphe
384
-	$texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
385
-	$texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
384
+	$texte = preg_replace('/<p( [^>]*)?'.'>/', "\r", $texte);
385
+	$texte = preg_replace('/<br( [^>]*)?'.'>/', "\n", $texte);
386 386
 
387 387
 	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
388 388
 	$texte = str_replace("\n\n", "\r", $texte);
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	// supprimer les tags
391 391
 	$texte = supprimer_tags($texte);
392 392
 	$texte = trim(str_replace("\n", ' ', $texte));
393
-	$texte .= "\n";  // marquer la fin
393
+	$texte .= "\n"; // marquer la fin
394 394
 
395 395
 	// corriger la longueur de coupe
396 396
 	// en fonction de la presence de caracteres utf
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	// couper au mot precedent
406 406
 	$long = spip_substr($texte, 0, max($taille - 4, 1));
407 407
 	$u = $GLOBALS['meta']['pcre_u'];
408
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
408
+	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
409 409
 	if (is_null($suite)) {
410 410
 		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
411 411
 	}
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
416 416
 		$points = '';
417 417
 		$long = spip_substr($texte, 0, $taille);
418
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
418
+		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/".$u, "\\1", $long);
419 419
 		// encore trop court ? couper au caractere
420 420
 		if (spip_strlen($texte) < 0.75 * $taille) {
421 421
 			$texte = $long;
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	// supprimer l'eventuelle entite finale mal coupee
435 435
 	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
436 436
 
437
-	return quote_amp(trim($texte)) . $points;
437
+	return quote_amp(trim($texte)).$points;
438 438
 }
439 439
 
440 440
 
@@ -446,16 +446,16 @@  discard block
 block discarded – undo
446 446
 				define('_PROTEGE_JS_MODELES', creer_uniqid());
447 447
 			}
448 448
 			foreach ($r as $regs) {
449
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
449
+				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript'._PROTEGE_JS_MODELES), $t);
450 450
 			}
451 451
 		}
452
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
452
+		if (preg_match_all(',<\?php.*?($|\?'.'>),isS', $t, $r, PREG_SET_ORDER)) {
453 453
 			if (!defined('_PROTEGE_PHP_MODELES')) {
454 454
 				include_spip('inc/acces');
455 455
 				define('_PROTEGE_PHP_MODELES', creer_uniqid());
456 456
 			}
457 457
 			foreach ($r as $regs) {
458
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
458
+				$t = str_replace($regs[0], code_echappement($regs[0], 'php'._PROTEGE_PHP_MODELES), $t);
459 459
 			}
460 460
 		}
461 461
 	}
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		if (!function_exists('attribut_html')) {
529 529
 			include_spip('inc/filtres');
530 530
 		}
531
-		$texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
531
+		$texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte;
532 532
 	}
533 533
 
534 534
 	return $texte;
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
  **/
599 599
 function supprime_img($letexte, $message = null) {
600 600
 	if ($message === null) {
601
-		$message = '(' . _T('img_indisponible') . ')';
601
+		$message = '('._T('img_indisponible').')';
602 602
 	}
603 603
 
604 604
 	return preg_replace(
605
-		',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
605
+		',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i',
606 606
 		$message,
607 607
 		$letexte
608 608
 	);
Please login to merge, or discard this patch.
ecrire/xml/valider.php 2 patches
Indentation   +318 added lines, -318 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -23,320 +23,320 @@  discard block
 block discarded – undo
23 23
  **/
24 24
 class ValidateurXML {
25 25
 
26
-	public function validerElement($phraseur, $name, $attrs) {
27
-		if (!($p = isset($this->dtc->elements[$name]))) {
28
-			if ($p = strpos($name, ':')) {
29
-				$name = substr($name, $p + 1);
30
-				$p = isset($this->dtc->elements[$name]);
31
-			}
32
-			if (!$p) {
33
-				coordonnees_erreur($this, " <b>$name</b>&nbsp;: "
34
-					. _T('zxml_inconnu_balise'));
35
-
36
-				return;
37
-			}
38
-		}
39
-		// controler les filles illegitimes, ca suffit
40
-		$depth = $this->depth;
41
-		$ouvrant = $this->ouvrant;
42
-		#spip_log("trouve $name apres " . $ouvrant[$depth]);
43
-		if (isset($ouvrant[$depth])) {
44
-			if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) {
45
-				$pere = $r[1];
46
-				#spip_log("pere $pere");
47
-				if (isset($this->dtc->elements[$pere])) {
48
-					$fils = $this->dtc->elements[$pere];
49
-					#spip_log("rejeton $name fils " . @join(',',$fils));
50
-					if (!($p = @in_array($name, $fils))) {
51
-						if ($p = strpos($name, ':')) {
52
-							$p = substr($name, $p + 1);
53
-							$p = @in_array($p, $fils);
54
-						}
55
-					}
56
-					if (!$p) {
57
-						$bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]);
58
-						coordonnees_erreur($this, " <b>$name</b> "
59
-							. _T('zxml_non_fils')
60
-							. ' <b>'
61
-							. $pere
62
-							. '</b>'
63
-							. (!$bons_peres ? ''
64
-								: ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
65
-					} elseif ($this->dtc->regles[$pere][0] == '/') {
66
-						$frat = substr($depth, 2);
67
-						if (!isset($this->fratrie[$frat])) {
68
-							$this->fratrie[$frat] = '';
69
-						}
70
-						$this->fratrie[$frat] .= "$name ";
71
-					}
72
-				}
73
-			}
74
-		}
75
-		// Init de la suite des balises a memoriser si regle difficile
76
-		if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') {
77
-			$this->fratrie[$depth] = '';
78
-		}
79
-		if (isset($this->dtc->attributs[$name])) {
80
-			foreach ($this->dtc->attributs[$name] as $n => $v) {
81
-				if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) {
82
-					coordonnees_erreur($this, " <b>$n</b>"
83
-						. '&nbsp;:&nbsp;'
84
-						. _T('zxml_obligatoire_attribut')
85
-						. " <b>$name</b>");
86
-				}
87
-			}
88
-		}
89
-	}
90
-
91
-	public function validerAttribut($phraseur, $name, $val, $bal) {
92
-		// Si la balise est inconnue, eviter d'insister
93
-		if (!isset($this->dtc->attributs[$bal])) {
94
-			return;
95
-		}
96
-
97
-		$a = $this->dtc->attributs[$bal];
98
-		if (!isset($a[$name])) {
99
-			$bons = join(', ', array_keys($a));
100
-			if ($bons) {
101
-				$bons = " title=' " .
102
-					_T('zxml_connus_attributs') .
103
-					'&nbsp;: ' .
104
-					$bons .
105
-					"'";
106
-			}
107
-			$bons .= " style='font-weight: bold'";
108
-			coordonnees_erreur($this, " <b>$name</b> "
109
-				. _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
110
-				. " <a$bons>$bal</a> ("
111
-				. _T('zxml_survoler')
112
-				. ')');
113
-		} else {
114
-			$type = $a[$name][0];
115
-			if (!preg_match('/^\w+$/', $type)) {
116
-				$this->valider_motif($phraseur, $name, $val, $bal, $type);
117
-			} else {
118
-				if (method_exists($this, $f = 'validerAttribut_' . $type)) {
119
-					$this->$f($phraseur, $name, $val, $bal);
120
-				}
121
-			}
122
-			#		else spip_log("$type type d'attribut inconnu");
123
-		}
124
-	}
125
-
126
-	public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) {
127
-		$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN);
128
-	}
129
-
130
-	public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) {
131
-		$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS);
132
-	}
133
-
134
-	public function validerAttribut_ID($phraseur, $name, $val, $bal) {
135
-		if (isset($this->ids[$val])) {
136
-			[$l, $c] = $this->ids[$val];
137
-			coordonnees_erreur($this, " <p><b>$val</b> "
138
-				. _T('zxml_valeur_attribut')
139
-				. " <b>$name</b> "
140
-				. _T('zxml_de')
141
-				. " <b>$bal</b> "
142
-				. _T('zxml_vu')
143
-				. " (L$l,C$c)");
144
-		} else {
145
-			$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID);
146
-			$this->ids[$val] = [xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
147
-		}
148
-	}
149
-
150
-	public function validerAttribut_IDREF($phraseur, $name, $val, $bal) {
151
-		$this->idrefs[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
152
-	}
153
-
154
-	public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) {
155
-		$this->idrefss[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
156
-	}
157
-
158
-	public function valider_motif($phraseur, $name, $val, $bal, $motif) {
159
-		if (!preg_match($motif, $val)) {
160
-			coordonnees_erreur($this, "<b>$val</b> "
161
-				. _T('zxml_valeur_attribut')
162
-				. " <b>$name</b> "
163
-				. _T('zxml_de')
164
-				. " <b>$bal</b> "
165
-				. _T('zxml_non_conforme')
166
-				. '</p><p>'
167
-				. '<b>' . $motif . '</b>');
168
-		}
169
-	}
170
-
171
-	public function valider_idref($nom, $ligne, $col) {
172
-		if (!isset($this->ids[$nom])) {
173
-			$this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
174
-		}
175
-	}
176
-
177
-	public function valider_passe2() {
178
-		if (!$this->err) {
179
-			foreach ($this->idrefs as $idref) {
180
-				[$nom, $ligne, $col] = $idref;
181
-				$this->valider_idref($nom, $ligne, $col);
182
-			}
183
-			foreach ($this->idrefss as $idref) {
184
-				[$noms, $ligne, $col] = $idref;
185
-				foreach (preg_split('/\s+/', $noms) as $nom) {
186
-					$this->valider_idref($nom, $ligne, $col);
187
-				}
188
-			}
189
-		}
190
-	}
191
-
192
-	public function debutElement($phraseur, $name, $attrs) {
193
-		if ($this->dtc->elements) {
194
-			$this->validerElement($phraseur, $name, $attrs);
195
-		}
196
-
197
-		if ($f = $this->process['debut']) {
198
-			$f($this, $name, $attrs);
199
-		}
200
-		$depth = $this->depth;
201
-		$this->debuts[$depth] = strlen($this->res);
202
-		foreach ($attrs as $k => $v) {
203
-			$this->validerAttribut($phraseur, $k, $v, $name);
204
-		}
205
-	}
206
-
207
-	public function finElement($phraseur, $name) {
208
-		$depth = $this->depth;
209
-		$contenu = $this->contenu;
210
-
211
-		$n = strlen($this->res);
212
-		$c = strlen(trim($contenu[$depth]));
213
-		$k = $this->debuts[$depth];
214
-
215
-		$regle = $this->dtc->regles[$name] ?? false;
216
-		$vide = ($regle == 'EMPTY');
217
-		// controler que les balises devant etre vides le sont
218
-		if ($vide) {
219
-			if ($n <> ($k + $c)) {
220
-				coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
221
-			}
222
-			// pour les regles PCDATA ou iteration de disjonction, tout est fait
223
-		} elseif ($regle and ($regle != '*')) {
224
-			if ($regle == '+') {
225
-				// iteration de disjonction non vide: 1 balise au -
226
-				if ($n == $k) {
227
-					coordonnees_erreur($this, "<p>\n<b>$name</b> "
228
-						. _T('zxml_vide_balise'));
229
-				}
230
-			} else {
231
-				$f = $this->fratrie[substr($depth, 2)] ?? null;
232
-				if (is_null($f) or !preg_match($regle, $f)) {
233
-					coordonnees_erreur(
234
-						$this,
235
-						" <p>\n<b>$name</b> "
236
-						. _T('zxml_succession_fils_incorrecte')
237
-						. '&nbsp;: <b>'
238
-						. $f
239
-						. '</b>'
240
-					);
241
-				}
242
-			}
243
-		}
244
-		if ($f = $this->process['fin']) {
245
-			$f($this, $name, $vide);
246
-		}
247
-	}
248
-
249
-	public function textElement($phraseur, $data) {
250
-		if (trim($data)) {
251
-			$d = $this->depth;
252
-			$d = $this->ouvrant[$d];
253
-			preg_match('/^\s*(\S+)/', $d, $m);
254
-			if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
255
-				coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
256
-					. _T('zxml_nonvide_balise')); // message a affiner
257
-			}
258
-		}
259
-		if ($f = $this->process['text']) {
260
-			$f($this, $data);
261
-		}
262
-	}
263
-
264
-	public function piElement($phraseur, $target, $data) {
265
-		if ($f = $this->process['pi']) {
266
-			$f($this, $target, $data);
267
-		}
268
-	}
269
-
270
-	// Denonciation des entitees XML inconnues
271
-	// Pour contourner le bug de conception de SAX qui ne signale pas si elles
272
-	// sont dans un attribut, les  entites les plus frequentes ont ete
273
-	// transcodees au prealable  (sauf & < > " que SAX traite correctement).
274
-	// On ne les verra donc pas passer a cette etape, contrairement a ce que
275
-	// le source de la page laisse legitimement supposer.
276
-
277
-	public function defaultElement($phraseur, $data) {
278
-		if (
279
-			!preg_match('/^<!--/', $data)
280
-			and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))
281
-		) {
282
-			foreach ($r as $m) {
283
-				[$t, $e] = $m;
284
-				if (!isset($this->dtc->entites[$e])) {
285
-					coordonnees_erreur($this, " <b>$e</b> "
286
-						. _T('zxml_inconnu_entite')
287
-						. ' ');
288
-				}
289
-			}
290
-		}
291
-		if (isset($this->process['default']) and ($f = $this->process['default'])) {
292
-			$f($this, $data);
293
-		}
294
-	}
295
-
296
-	public function phraserTout($phraseur, $data) {
297
-		xml_parsestring($this, $data);
298
-
299
-		if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
300
-			$this->err[] = ['DOCTYPE ?', 0, 0];
301
-		} else {
302
-			$this->valider_passe2();
303
-		}
304
-	}
305
-
306
-	/**
307
-	 * Constructeur
308
-	 *
309
-	 * @param array $process ?
310
-	 **/
311
-	public function __construct($process = []) {
312
-		if (is_array($process)) {
313
-			$this->process = $process;
314
-		}
315
-	}
316
-
317
-	public $ids = [];
318
-	public $idrefs = [];
319
-	public $idrefss = [];
320
-	public $debuts = [];
321
-	public $fratrie = [];
322
-
323
-	public $dtc = null;
324
-	public $sax = null;
325
-	public $depth = '';
326
-	public $entete = '';
327
-	public $page = '';
328
-	public $res = '';
329
-	public $err = [];
330
-	public $contenu = [];
331
-	public $ouvrant = [];
332
-	public $reperes = [];
333
-	public $process = [
334
-		'debut' => 'xml_debutElement',
335
-		'fin' => 'xml_finElement',
336
-		'text' => 'xml_textElement',
337
-		'pi' => 'xml_piElement',
338
-		'default' => 'xml_defaultElement'
339
-	];
26
+    public function validerElement($phraseur, $name, $attrs) {
27
+        if (!($p = isset($this->dtc->elements[$name]))) {
28
+            if ($p = strpos($name, ':')) {
29
+                $name = substr($name, $p + 1);
30
+                $p = isset($this->dtc->elements[$name]);
31
+            }
32
+            if (!$p) {
33
+                coordonnees_erreur($this, " <b>$name</b>&nbsp;: "
34
+                    . _T('zxml_inconnu_balise'));
35
+
36
+                return;
37
+            }
38
+        }
39
+        // controler les filles illegitimes, ca suffit
40
+        $depth = $this->depth;
41
+        $ouvrant = $this->ouvrant;
42
+        #spip_log("trouve $name apres " . $ouvrant[$depth]);
43
+        if (isset($ouvrant[$depth])) {
44
+            if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) {
45
+                $pere = $r[1];
46
+                #spip_log("pere $pere");
47
+                if (isset($this->dtc->elements[$pere])) {
48
+                    $fils = $this->dtc->elements[$pere];
49
+                    #spip_log("rejeton $name fils " . @join(',',$fils));
50
+                    if (!($p = @in_array($name, $fils))) {
51
+                        if ($p = strpos($name, ':')) {
52
+                            $p = substr($name, $p + 1);
53
+                            $p = @in_array($p, $fils);
54
+                        }
55
+                    }
56
+                    if (!$p) {
57
+                        $bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]);
58
+                        coordonnees_erreur($this, " <b>$name</b> "
59
+                            . _T('zxml_non_fils')
60
+                            . ' <b>'
61
+                            . $pere
62
+                            . '</b>'
63
+                            . (!$bons_peres ? ''
64
+                                : ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
65
+                    } elseif ($this->dtc->regles[$pere][0] == '/') {
66
+                        $frat = substr($depth, 2);
67
+                        if (!isset($this->fratrie[$frat])) {
68
+                            $this->fratrie[$frat] = '';
69
+                        }
70
+                        $this->fratrie[$frat] .= "$name ";
71
+                    }
72
+                }
73
+            }
74
+        }
75
+        // Init de la suite des balises a memoriser si regle difficile
76
+        if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') {
77
+            $this->fratrie[$depth] = '';
78
+        }
79
+        if (isset($this->dtc->attributs[$name])) {
80
+            foreach ($this->dtc->attributs[$name] as $n => $v) {
81
+                if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) {
82
+                    coordonnees_erreur($this, " <b>$n</b>"
83
+                        . '&nbsp;:&nbsp;'
84
+                        . _T('zxml_obligatoire_attribut')
85
+                        . " <b>$name</b>");
86
+                }
87
+            }
88
+        }
89
+    }
90
+
91
+    public function validerAttribut($phraseur, $name, $val, $bal) {
92
+        // Si la balise est inconnue, eviter d'insister
93
+        if (!isset($this->dtc->attributs[$bal])) {
94
+            return;
95
+        }
96
+
97
+        $a = $this->dtc->attributs[$bal];
98
+        if (!isset($a[$name])) {
99
+            $bons = join(', ', array_keys($a));
100
+            if ($bons) {
101
+                $bons = " title=' " .
102
+                    _T('zxml_connus_attributs') .
103
+                    '&nbsp;: ' .
104
+                    $bons .
105
+                    "'";
106
+            }
107
+            $bons .= " style='font-weight: bold'";
108
+            coordonnees_erreur($this, " <b>$name</b> "
109
+                . _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
110
+                . " <a$bons>$bal</a> ("
111
+                . _T('zxml_survoler')
112
+                . ')');
113
+        } else {
114
+            $type = $a[$name][0];
115
+            if (!preg_match('/^\w+$/', $type)) {
116
+                $this->valider_motif($phraseur, $name, $val, $bal, $type);
117
+            } else {
118
+                if (method_exists($this, $f = 'validerAttribut_' . $type)) {
119
+                    $this->$f($phraseur, $name, $val, $bal);
120
+                }
121
+            }
122
+            #		else spip_log("$type type d'attribut inconnu");
123
+        }
124
+    }
125
+
126
+    public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) {
127
+        $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN);
128
+    }
129
+
130
+    public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) {
131
+        $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS);
132
+    }
133
+
134
+    public function validerAttribut_ID($phraseur, $name, $val, $bal) {
135
+        if (isset($this->ids[$val])) {
136
+            [$l, $c] = $this->ids[$val];
137
+            coordonnees_erreur($this, " <p><b>$val</b> "
138
+                . _T('zxml_valeur_attribut')
139
+                . " <b>$name</b> "
140
+                . _T('zxml_de')
141
+                . " <b>$bal</b> "
142
+                . _T('zxml_vu')
143
+                . " (L$l,C$c)");
144
+        } else {
145
+            $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID);
146
+            $this->ids[$val] = [xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
147
+        }
148
+    }
149
+
150
+    public function validerAttribut_IDREF($phraseur, $name, $val, $bal) {
151
+        $this->idrefs[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
152
+    }
153
+
154
+    public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) {
155
+        $this->idrefss[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
156
+    }
157
+
158
+    public function valider_motif($phraseur, $name, $val, $bal, $motif) {
159
+        if (!preg_match($motif, $val)) {
160
+            coordonnees_erreur($this, "<b>$val</b> "
161
+                . _T('zxml_valeur_attribut')
162
+                . " <b>$name</b> "
163
+                . _T('zxml_de')
164
+                . " <b>$bal</b> "
165
+                . _T('zxml_non_conforme')
166
+                . '</p><p>'
167
+                . '<b>' . $motif . '</b>');
168
+        }
169
+    }
170
+
171
+    public function valider_idref($nom, $ligne, $col) {
172
+        if (!isset($this->ids[$nom])) {
173
+            $this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
174
+        }
175
+    }
176
+
177
+    public function valider_passe2() {
178
+        if (!$this->err) {
179
+            foreach ($this->idrefs as $idref) {
180
+                [$nom, $ligne, $col] = $idref;
181
+                $this->valider_idref($nom, $ligne, $col);
182
+            }
183
+            foreach ($this->idrefss as $idref) {
184
+                [$noms, $ligne, $col] = $idref;
185
+                foreach (preg_split('/\s+/', $noms) as $nom) {
186
+                    $this->valider_idref($nom, $ligne, $col);
187
+                }
188
+            }
189
+        }
190
+    }
191
+
192
+    public function debutElement($phraseur, $name, $attrs) {
193
+        if ($this->dtc->elements) {
194
+            $this->validerElement($phraseur, $name, $attrs);
195
+        }
196
+
197
+        if ($f = $this->process['debut']) {
198
+            $f($this, $name, $attrs);
199
+        }
200
+        $depth = $this->depth;
201
+        $this->debuts[$depth] = strlen($this->res);
202
+        foreach ($attrs as $k => $v) {
203
+            $this->validerAttribut($phraseur, $k, $v, $name);
204
+        }
205
+    }
206
+
207
+    public function finElement($phraseur, $name) {
208
+        $depth = $this->depth;
209
+        $contenu = $this->contenu;
210
+
211
+        $n = strlen($this->res);
212
+        $c = strlen(trim($contenu[$depth]));
213
+        $k = $this->debuts[$depth];
214
+
215
+        $regle = $this->dtc->regles[$name] ?? false;
216
+        $vide = ($regle == 'EMPTY');
217
+        // controler que les balises devant etre vides le sont
218
+        if ($vide) {
219
+            if ($n <> ($k + $c)) {
220
+                coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
221
+            }
222
+            // pour les regles PCDATA ou iteration de disjonction, tout est fait
223
+        } elseif ($regle and ($regle != '*')) {
224
+            if ($regle == '+') {
225
+                // iteration de disjonction non vide: 1 balise au -
226
+                if ($n == $k) {
227
+                    coordonnees_erreur($this, "<p>\n<b>$name</b> "
228
+                        . _T('zxml_vide_balise'));
229
+                }
230
+            } else {
231
+                $f = $this->fratrie[substr($depth, 2)] ?? null;
232
+                if (is_null($f) or !preg_match($regle, $f)) {
233
+                    coordonnees_erreur(
234
+                        $this,
235
+                        " <p>\n<b>$name</b> "
236
+                        . _T('zxml_succession_fils_incorrecte')
237
+                        . '&nbsp;: <b>'
238
+                        . $f
239
+                        . '</b>'
240
+                    );
241
+                }
242
+            }
243
+        }
244
+        if ($f = $this->process['fin']) {
245
+            $f($this, $name, $vide);
246
+        }
247
+    }
248
+
249
+    public function textElement($phraseur, $data) {
250
+        if (trim($data)) {
251
+            $d = $this->depth;
252
+            $d = $this->ouvrant[$d];
253
+            preg_match('/^\s*(\S+)/', $d, $m);
254
+            if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
255
+                coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
256
+                    . _T('zxml_nonvide_balise')); // message a affiner
257
+            }
258
+        }
259
+        if ($f = $this->process['text']) {
260
+            $f($this, $data);
261
+        }
262
+    }
263
+
264
+    public function piElement($phraseur, $target, $data) {
265
+        if ($f = $this->process['pi']) {
266
+            $f($this, $target, $data);
267
+        }
268
+    }
269
+
270
+    // Denonciation des entitees XML inconnues
271
+    // Pour contourner le bug de conception de SAX qui ne signale pas si elles
272
+    // sont dans un attribut, les  entites les plus frequentes ont ete
273
+    // transcodees au prealable  (sauf & < > " que SAX traite correctement).
274
+    // On ne les verra donc pas passer a cette etape, contrairement a ce que
275
+    // le source de la page laisse legitimement supposer.
276
+
277
+    public function defaultElement($phraseur, $data) {
278
+        if (
279
+            !preg_match('/^<!--/', $data)
280
+            and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))
281
+        ) {
282
+            foreach ($r as $m) {
283
+                [$t, $e] = $m;
284
+                if (!isset($this->dtc->entites[$e])) {
285
+                    coordonnees_erreur($this, " <b>$e</b> "
286
+                        . _T('zxml_inconnu_entite')
287
+                        . ' ');
288
+                }
289
+            }
290
+        }
291
+        if (isset($this->process['default']) and ($f = $this->process['default'])) {
292
+            $f($this, $data);
293
+        }
294
+    }
295
+
296
+    public function phraserTout($phraseur, $data) {
297
+        xml_parsestring($this, $data);
298
+
299
+        if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
300
+            $this->err[] = ['DOCTYPE ?', 0, 0];
301
+        } else {
302
+            $this->valider_passe2();
303
+        }
304
+    }
305
+
306
+    /**
307
+     * Constructeur
308
+     *
309
+     * @param array $process ?
310
+     **/
311
+    public function __construct($process = []) {
312
+        if (is_array($process)) {
313
+            $this->process = $process;
314
+        }
315
+    }
316
+
317
+    public $ids = [];
318
+    public $idrefs = [];
319
+    public $idrefss = [];
320
+    public $debuts = [];
321
+    public $fratrie = [];
322
+
323
+    public $dtc = null;
324
+    public $sax = null;
325
+    public $depth = '';
326
+    public $entete = '';
327
+    public $page = '';
328
+    public $res = '';
329
+    public $err = [];
330
+    public $contenu = [];
331
+    public $ouvrant = [];
332
+    public $reperes = [];
333
+    public $process = [
334
+        'debut' => 'xml_debutElement',
335
+        'fin' => 'xml_finElement',
336
+        'text' => 'xml_textElement',
337
+        'pi' => 'xml_piElement',
338
+        'default' => 'xml_defaultElement'
339
+    ];
340 340
 }
341 341
 
342 342
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
  *
347 347
  **/
348 348
 function xml_valider_dist($page, $apply = false, $process = false, $doctype = '', $charset = null) {
349
-	$f = new ValidateurXML($process);
350
-	$sax = charger_fonction('sax', 'xml');
349
+    $f = new ValidateurXML($process);
350
+    $sax = charger_fonction('sax', 'xml');
351 351
 
352
-	return $sax($page, $apply, $f, $doctype, $charset);
352
+    return $sax($page, $apply, $f, $doctype, $charset);
353 353
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 							. $pere
62 62
 							. '</b>'
63 63
 							. (!$bons_peres ? ''
64
-								: ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
64
+								: ('<p style="font-size: 80%"> '._T('zxml_mais_de').' <b>'.$bons_peres.'</b></p>')));
65 65
 					} elseif ($this->dtc->regles[$pere][0] == '/') {
66 66
 						$frat = substr($depth, 2);
67 67
 						if (!isset($this->fratrie[$frat])) {
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 		if (!isset($a[$name])) {
99 99
 			$bons = join(', ', array_keys($a));
100 100
 			if ($bons) {
101
-				$bons = " title=' " .
102
-					_T('zxml_connus_attributs') .
103
-					'&nbsp;: ' .
104
-					$bons .
101
+				$bons = " title=' ".
102
+					_T('zxml_connus_attributs').
103
+					'&nbsp;: '.
104
+					$bons.
105 105
 					"'";
106 106
 			}
107 107
 			$bons .= " style='font-weight: bold'";
108 108
 			coordonnees_erreur($this, " <b>$name</b> "
109
-				. _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
109
+				. _T('zxml_inconnu_attribut').' '._T('zxml_de')
110 110
 				. " <a$bons>$bal</a> ("
111 111
 				. _T('zxml_survoler')
112 112
 				. ')');
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 			if (!preg_match('/^\w+$/', $type)) {
116 116
 				$this->valider_motif($phraseur, $name, $val, $bal, $type);
117 117
 			} else {
118
-				if (method_exists($this, $f = 'validerAttribut_' . $type)) {
118
+				if (method_exists($this, $f = 'validerAttribut_'.$type)) {
119 119
 					$this->$f($phraseur, $name, $val, $bal);
120 120
 				}
121 121
 			}
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 				. " <b>$bal</b> "
165 165
 				. _T('zxml_non_conforme')
166 166
 				. '</p><p>'
167
-				. '<b>' . $motif . '</b>');
167
+				. '<b>'.$motif.'</b>');
168 168
 		}
169 169
 	}
170 170
 
171 171
 	public function valider_idref($nom, $ligne, $col) {
172 172
 		if (!isset($this->ids[$nom])) {
173
-			$this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
173
+			$this->err[] = [" <p><b>$nom</b> "._T('zxml_inconnu_id'), $ligne, $col];
174 174
 		}
175 175
 	}
176 176
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		// controler que les balises devant etre vides le sont
218 218
 		if ($vide) {
219 219
 			if ($n <> ($k + $c)) {
220
-				coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
220
+				coordonnees_erreur($this, " <p><b>$name</b> "._T('zxml_nonvide_balise'));
221 221
 			}
222 222
 			// pour les regles PCDATA ou iteration de disjonction, tout est fait
223 223
 		} elseif ($regle and ($regle != '*')) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$d = $this->ouvrant[$d];
253 253
 			preg_match('/^\s*(\S+)/', $d, $m);
254 254
 			if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
255
-				coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
255
+				coordonnees_erreur($this, ' <p><b>'.$m[1].'</b> '
256 256
 					. _T('zxml_nonvide_balise')); // message a affiner
257 257
 			}
258 258
 		}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	public function phraserTout($phraseur, $data) {
297 297
 		xml_parsestring($this, $data);
298 298
 
299
-		if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
299
+		if (!$this->dtc or preg_match(',^'._MESSAGE_DOCTYPE.',', $data)) {
300 300
 			$this->err[] = ['DOCTYPE ?', 0, 0];
301 301
 		} else {
302 302
 			$this->valider_passe2();
Please login to merge, or discard this patch.
ecrire/public/debusquer.php 2 patches
Indentation   +681 added lines, -681 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('public/decompiler');
@@ -66,136 +66,136 @@  discard block
 block discarded – undo
66 66
  *     - string si $message à false.
67 67
  **/
68 68
 function public_debusquer_dist($message = '', $lieu = '', $opt = []) {
69
-	static $tableau_des_erreurs = [];
70
-
71
-	// Pour des tests unitaires, pouvoir récupérer les erreurs générées
72
-	if (isset($opt['erreurs'])) {
73
-		if ($opt['erreurs'] == 'get') {
74
-			return $tableau_des_erreurs;
75
-		}
76
-		if ($opt['erreurs'] == 'reset') {
77
-			$tableau_des_erreurs = [];
78
-
79
-			return true;
80
-		}
81
-	}
82
-
83
-	// Erreur ou appel final ?
84
-	if ($message) {
85
-		$message = debusquer_compose_message($message);
86
-		$tableau_des_erreurs[] = [$message, $lieu];
87
-		set_request('var_mode', 'debug');
88
-		$GLOBALS['bouton_admin_debug'] = true;
89
-		// Permettre a la compil de continuer
90
-		if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) {
91
-			$lieu->code = "''";
92
-		}
93
-		// forcer l'appel au debusqueur en cas de boucles infernales
94
-		$urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS);
95
-		if (!$urgence) {
96
-			return;
97
-		}
98
-	}
99
-	if (empty($GLOBALS['debug_objets']['principal'])) {
100
-		// espace public ?
101
-		if (isset($GLOBALS['fond'])) {
102
-			$GLOBALS['debug_objets']['principal'] = $GLOBALS['fond'];
103
-		}
104
-	}
105
-
106
-	include_spip('inc/autoriser');
107
-	if (!autoriser('debug')) {
108
-		return;
109
-	}
110
-	include_spip('inc/headers');
111
-	include_spip('inc/filtres');
112
-
113
-	// en cas de squelette inclus,  virer le code de l'incluant:
114
-	// - il contient souvent une Div restreignant la largeur a 3 fois rien
115
-	// - ca fait 2 headers !
116
-	// sauf si l'on se trouve deja dans un flux compresse (plugin compresseur
117
-	// actif par exemple)
118
-	if (
119
-		ob_get_length()
120
-		and
121
-		!in_array('ob_gzhandler', ob_get_status())
122
-	) {
123
-		ob_end_clean();
124
-	}
125
-
126
-	lang_select($GLOBALS['visiteur_session']['lang']);
127
-	$fonc = _request('var_mode_objet');
128
-	$mode = _request('var_mode_affiche');
129
-	$self = str_replace("\\'", '&#39;', self());
130
-	$self = parametre_url($self, 'var_mode', 'debug');
131
-
132
-	$res = debusquer_bandeau($tableau_des_erreurs)
133
-		. '<br />'
134
-		. debusquer_squelette($fonc, $mode, $self);
135
-
136
-	if (!_DIR_RESTREINT or headers_sent()) {
137
-		return $res;
138
-	}
139
-	if ($tableau_des_erreurs) {
140
-		http_response_code(503);
141
-	}
142
-
143
-	http_no_cache();
144
-	if (isset($_GET['var_profile'])) {
145
-		$titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', '');
146
-		$titre = parametre_url($titre, 'var_mode', '');
147
-	} else {
148
-		if (!$fonc) {
149
-			$fonc = $GLOBALS['debug_objets']['principal'];
150
-		}
151
-		$titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : ''));
152
-	}
153
-	if ($message === false) {
154
-		lang_select();
155
-
156
-		return debusquer_entete($titre, $res);
157
-	} else {
158
-		echo debusquer_entete($titre, $res);
159
-	}
160
-	exit;
69
+    static $tableau_des_erreurs = [];
70
+
71
+    // Pour des tests unitaires, pouvoir récupérer les erreurs générées
72
+    if (isset($opt['erreurs'])) {
73
+        if ($opt['erreurs'] == 'get') {
74
+            return $tableau_des_erreurs;
75
+        }
76
+        if ($opt['erreurs'] == 'reset') {
77
+            $tableau_des_erreurs = [];
78
+
79
+            return true;
80
+        }
81
+    }
82
+
83
+    // Erreur ou appel final ?
84
+    if ($message) {
85
+        $message = debusquer_compose_message($message);
86
+        $tableau_des_erreurs[] = [$message, $lieu];
87
+        set_request('var_mode', 'debug');
88
+        $GLOBALS['bouton_admin_debug'] = true;
89
+        // Permettre a la compil de continuer
90
+        if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) {
91
+            $lieu->code = "''";
92
+        }
93
+        // forcer l'appel au debusqueur en cas de boucles infernales
94
+        $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS);
95
+        if (!$urgence) {
96
+            return;
97
+        }
98
+    }
99
+    if (empty($GLOBALS['debug_objets']['principal'])) {
100
+        // espace public ?
101
+        if (isset($GLOBALS['fond'])) {
102
+            $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond'];
103
+        }
104
+    }
105
+
106
+    include_spip('inc/autoriser');
107
+    if (!autoriser('debug')) {
108
+        return;
109
+    }
110
+    include_spip('inc/headers');
111
+    include_spip('inc/filtres');
112
+
113
+    // en cas de squelette inclus,  virer le code de l'incluant:
114
+    // - il contient souvent une Div restreignant la largeur a 3 fois rien
115
+    // - ca fait 2 headers !
116
+    // sauf si l'on se trouve deja dans un flux compresse (plugin compresseur
117
+    // actif par exemple)
118
+    if (
119
+        ob_get_length()
120
+        and
121
+        !in_array('ob_gzhandler', ob_get_status())
122
+    ) {
123
+        ob_end_clean();
124
+    }
125
+
126
+    lang_select($GLOBALS['visiteur_session']['lang']);
127
+    $fonc = _request('var_mode_objet');
128
+    $mode = _request('var_mode_affiche');
129
+    $self = str_replace("\\'", '&#39;', self());
130
+    $self = parametre_url($self, 'var_mode', 'debug');
131
+
132
+    $res = debusquer_bandeau($tableau_des_erreurs)
133
+        . '<br />'
134
+        . debusquer_squelette($fonc, $mode, $self);
135
+
136
+    if (!_DIR_RESTREINT or headers_sent()) {
137
+        return $res;
138
+    }
139
+    if ($tableau_des_erreurs) {
140
+        http_response_code(503);
141
+    }
142
+
143
+    http_no_cache();
144
+    if (isset($_GET['var_profile'])) {
145
+        $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', '');
146
+        $titre = parametre_url($titre, 'var_mode', '');
147
+    } else {
148
+        if (!$fonc) {
149
+            $fonc = $GLOBALS['debug_objets']['principal'];
150
+        }
151
+        $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : ''));
152
+    }
153
+    if ($message === false) {
154
+        lang_select();
155
+
156
+        return debusquer_entete($titre, $res);
157
+    } else {
158
+        echo debusquer_entete($titre, $res);
159
+    }
160
+    exit;
161 161
 }
162 162
 
163 163
 function debusquer_compose_message($msg) {
164
-	if (is_array($msg)) {
165
-		// si c'est un texte, c'est une traduction a faire, mais
166
-		// sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments)
167
-		if (!is_numeric($msg[0]) and count($msg) == 2) {
168
-			// message avec argument: instancier
169
-			$msg = _T($msg[0], $msg[1], 'spip-debug-arg');
170
-		} else {
171
-			// message SQL: interpreter
172
-			$msg = debusquer_requete($msg);
173
-		}
174
-	}
175
-	// FIXME: le fond n'est pas la si on n'est pas dans un squelette
176
-	// cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur
177
-	$fond = $GLOBALS['fond'] ?? '';
178
-	// une erreur critique sort $message en array
179
-	$debug = is_array($msg) ? $msg[1] : $msg;
180
-	spip_log('Debug: ' . $debug . ' (' . $fond . ')');
181
-
182
-	return $msg;
164
+    if (is_array($msg)) {
165
+        // si c'est un texte, c'est une traduction a faire, mais
166
+        // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments)
167
+        if (!is_numeric($msg[0]) and count($msg) == 2) {
168
+            // message avec argument: instancier
169
+            $msg = _T($msg[0], $msg[1], 'spip-debug-arg');
170
+        } else {
171
+            // message SQL: interpreter
172
+            $msg = debusquer_requete($msg);
173
+        }
174
+    }
175
+    // FIXME: le fond n'est pas la si on n'est pas dans un squelette
176
+    // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur
177
+    $fond = $GLOBALS['fond'] ?? '';
178
+    // une erreur critique sort $message en array
179
+    $debug = is_array($msg) ? $msg[1] : $msg;
180
+    spip_log('Debug: ' . $debug . ' (' . $fond . ')');
181
+
182
+    return $msg;
183 183
 }
184 184
 
185 185
 function debusquer_bandeau($erreurs) {
186 186
 
187
-	if (!empty($erreurs)) {
188
-		$n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')];
187
+    if (!empty($erreurs)) {
188
+        $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')];
189 189
 
190
-		return debusquer_navigation($erreurs, $n);
191
-	} elseif (!empty($GLOBALS['tableau_des_temps'])) {
192
-		include_spip('public/tracer');
193
-		[$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']);
190
+        return debusquer_navigation($erreurs, $n);
191
+    } elseif (!empty($GLOBALS['tableau_des_temps'])) {
192
+        include_spip('public/tracer');
193
+        [$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']);
194 194
 
195
-		return debusquer_navigation($temps, $nav, 'debug-profile');
196
-	} else {
197
-		return '';
198
-	}
195
+        return debusquer_navigation($temps, $nav, 'debug-profile');
196
+    } else {
197
+        return '';
198
+    }
199 199
 }
200 200
 
201 201
 /**
@@ -205,42 +205,42 @@  discard block
 block discarded – undo
205 205
  * @return string Code HTML
206 206
  **/
207 207
 function debusquer_contexte($env) {
208
-	if (is_string($env) and is_array($env_tab = @unserialize($env))) {
209
-		$env = $env_tab;
210
-	}
211
-
212
-	if (!$env) {
213
-		return '';
214
-	}
215
-	$res = '';
216
-	foreach ($env as $nom => $valeur) {
217
-		if (is_array($valeur)) {
218
-			$valeur_simple = [];
219
-			foreach ($valeur as $v) {
220
-				if (is_array($v)) {
221
-					$valeur_simple[] = 'array:' . count($v);
222
-				} elseif (is_object($v)) {
223
-					$valeur_simple[] = get_class($v);
224
-				} elseif (is_string($v)) {
225
-					$valeur_simple[] = "'" . $v . "'";
226
-				} else {
227
-					$valeur_simple[] = $v;
228
-				}
229
-			}
230
-			$n = count($valeur);
231
-			$valeur = (($n > 3) ? 'array:' . $n . ' ' : '');
232
-			$valeur .= '[' . join(', ', $valeur_simple) . ']';
233
-		} elseif (is_object($valeur)) {
234
-			$valeur = get_class($valeur);
235
-		} elseif (is_string($valeur)) {
236
-			$valeur = "'" . $valeur . "'";
237
-		}
238
-		$res .= "\n<tr><td><strong>" . nl2br(entites_html($nom))
239
-			. '</strong></td><td>:&nbsp;' . nl2br(entites_html($valeur))
240
-			. "</td></tr>\n";
241
-	}
242
-
243
-	return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n";
208
+    if (is_string($env) and is_array($env_tab = @unserialize($env))) {
209
+        $env = $env_tab;
210
+    }
211
+
212
+    if (!$env) {
213
+        return '';
214
+    }
215
+    $res = '';
216
+    foreach ($env as $nom => $valeur) {
217
+        if (is_array($valeur)) {
218
+            $valeur_simple = [];
219
+            foreach ($valeur as $v) {
220
+                if (is_array($v)) {
221
+                    $valeur_simple[] = 'array:' . count($v);
222
+                } elseif (is_object($v)) {
223
+                    $valeur_simple[] = get_class($v);
224
+                } elseif (is_string($v)) {
225
+                    $valeur_simple[] = "'" . $v . "'";
226
+                } else {
227
+                    $valeur_simple[] = $v;
228
+                }
229
+            }
230
+            $n = count($valeur);
231
+            $valeur = (($n > 3) ? 'array:' . $n . ' ' : '');
232
+            $valeur .= '[' . join(', ', $valeur_simple) . ']';
233
+        } elseif (is_object($valeur)) {
234
+            $valeur = get_class($valeur);
235
+        } elseif (is_string($valeur)) {
236
+            $valeur = "'" . $valeur . "'";
237
+        }
238
+        $res .= "\n<tr><td><strong>" . nl2br(entites_html($nom))
239
+            . '</strong></td><td>:&nbsp;' . nl2br(entites_html($valeur))
240
+            . "</td></tr>\n";
241
+    }
242
+
243
+    return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n";
244 244
 }
245 245
 
246 246
 // Affichage du tableau des erreurs ou des temps de calcul
@@ -248,66 +248,66 @@  discard block
 block discarded – undo
248 248
 
249 249
 function debusquer_navigation($tableau, $caption = [], $id = 'debug-nav') {
250 250
 
251
-	if (_request('exec') == 'valider_xml') {
252
-		return '';
253
-	}
254
-	$GLOBALS['bouton_admin_debug'] = true;
255
-	$res = '';
256
-	$href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug'));
257
-	foreach ($tableau as $i => $err) {
258
-		$boucle = $ligne = $skel = '';
259
-		[$msg, $lieu] = $err;
260
-		if (is_object($lieu)) {
261
-			$ligne = $lieu->ligne;
262
-			$boucle = !empty($lieu->id_boucle) ? $lieu->id_boucle : '';
263
-			if (isset($lieu->descr['nom'])) {
264
-				$nom_code = $lieu->descr['nom'];
265
-				$skel = $lieu->descr['sourcefile'];
266
-				$h2 = parametre_url($href, 'var_mode_objet', $nom_code);
267
-				$h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne;
268
-				$skel = "<a href='$h3'><b>$skel</b></a>";
269
-				if ($boucle) {
270
-					$h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle');
271
-					$boucle = "<a href='$h3'><b>$boucle</b></a>";
272
-				}
273
-			}
274
-		}
275
-
276
-		$j = ($i + 1);
277
-		$res .= "<tr id='req$j'><td style='text-align: right'>"
278
-			. $j
279
-			. "&nbsp;</td><td style='text-align: left'>"
280
-			. (is_array($msg) ? implode('', $msg) : $msg)
281
-			. "</td><td style='text-align: left'>"
282
-			. ($skel ?: '&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;')
283
-			. "</td><td class='spip-debug-arg' style='text-align: left'>"
284
-			. ($boucle ?: '&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;')
285
-			. "</td><td style='text-align: right'>"
286
-			. $ligne
287
-			. "</td></tr>\n";
288
-	}
289
-
290
-	return "\n<table id='$id'>"
291
-	. "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">"
292
-	. $caption[0]
251
+    if (_request('exec') == 'valider_xml') {
252
+        return '';
253
+    }
254
+    $GLOBALS['bouton_admin_debug'] = true;
255
+    $res = '';
256
+    $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug'));
257
+    foreach ($tableau as $i => $err) {
258
+        $boucle = $ligne = $skel = '';
259
+        [$msg, $lieu] = $err;
260
+        if (is_object($lieu)) {
261
+            $ligne = $lieu->ligne;
262
+            $boucle = !empty($lieu->id_boucle) ? $lieu->id_boucle : '';
263
+            if (isset($lieu->descr['nom'])) {
264
+                $nom_code = $lieu->descr['nom'];
265
+                $skel = $lieu->descr['sourcefile'];
266
+                $h2 = parametre_url($href, 'var_mode_objet', $nom_code);
267
+                $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne;
268
+                $skel = "<a href='$h3'><b>$skel</b></a>";
269
+                if ($boucle) {
270
+                    $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle');
271
+                    $boucle = "<a href='$h3'><b>$boucle</b></a>";
272
+                }
273
+            }
274
+        }
275
+
276
+        $j = ($i + 1);
277
+        $res .= "<tr id='req$j'><td style='text-align: right'>"
278
+            . $j
279
+            . "&nbsp;</td><td style='text-align: left'>"
280
+            . (is_array($msg) ? implode('', $msg) : $msg)
281
+            . "</td><td style='text-align: left'>"
282
+            . ($skel ?: '&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;')
283
+            . "</td><td class='spip-debug-arg' style='text-align: left'>"
284
+            . ($boucle ?: '&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;')
285
+            . "</td><td style='text-align: right'>"
286
+            . $ligne
287
+            . "</td></tr>\n";
288
+    }
289
+
290
+    return "\n<table id='$id'>"
291
+    . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">"
292
+    . $caption[0]
293 293
 ## aide locale courte a ecrire, avec lien vers une grosse page de documentation
294 294
 #		aider('erreur_compilation'),
295
-	. '</caption>'
296
-	//  fausse caption du chrono (mais vraie nav)
297
-	. (!empty($caption[1]) ? $caption[1] : '')
298
-	. '<tr><th>'
299
-	. _T('numero')
300
-	. '</th><th>'
301
-	. _T('public:message')
302
-	. '</th><th>'
303
-	. _T('squelette')
304
-	. '</th><th>'
305
-	. _T('zbug_boucle')
306
-	. '</th><th>'
307
-	. _T('ligne')
308
-	. '</th></tr>'
309
-	. $res
310
-	. '</table>';
295
+    . '</caption>'
296
+    //  fausse caption du chrono (mais vraie nav)
297
+    . (!empty($caption[1]) ? $caption[1] : '')
298
+    . '<tr><th>'
299
+    . _T('numero')
300
+    . '</th><th>'
301
+    . _T('public:message')
302
+    . '</th><th>'
303
+    . _T('squelette')
304
+    . '</th><th>'
305
+    . _T('zbug_boucle')
306
+    . '</th><th>'
307
+    . _T('ligne')
308
+    . '</th></tr>'
309
+    . $res
310
+    . '</table>';
311 311
 }
312 312
 
313 313
 
@@ -327,514 +327,514 @@  discard block
 block discarded – undo
327 327
  *    ou un tableau si l'erreur est critique
328 328
  **/
329 329
 function debusquer_requete($message) {
330
-	[$errno, $msg, $query] = $message;
331
-
332
-	// FIXME: ces écritures mélangent divers syntaxe des moteurs SQL
333
-	// il serait plus prudent certainement d'avoir une fonction d'analyse par moteur
334
-	if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) {
335
-		$errno = $regs[2];
336
-	} elseif (
337
-		is_numeric($errno) and ($errno == 1030 or $errno <= 1026)
338
-		and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs)
339
-	) {
340
-		$errno = $regs[1];
341
-	}
342
-
343
-	// Erreur systeme
344
-	if (is_numeric($errno) and $errno > 0 and $errno < 200) {
345
-		$retour = '<tt><br /><br /><blink>'
346
-			. _T('info_erreur_systeme', ['errsys' => $errno])
347
-			. "</blink><br />\n<b>"
348
-			. _T(
349
-				'info_erreur_systeme2',
350
-				['script' => generer_url_ecrire('base_repair')]
351
-			)
352
-			. '</b><br />';
353
-		spip_log("Erreur systeme $errno");
354
-
355
-		return [$retour, ''];
356
-	}
357
-
358
-	// Requete erronee
359
-	$err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n"
360
-		. spip_htmlspecialchars($msg)
361
-		. "\n<br /><span style='color: red'><b>"
362
-		. spip_htmlspecialchars($query)
363
-		. '</b></span></tt><br />';
364
-
365
-	//. aider('erreur_mysql');
366
-
367
-	return $err;
330
+    [$errno, $msg, $query] = $message;
331
+
332
+    // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL
333
+    // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur
334
+    if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) {
335
+        $errno = $regs[2];
336
+    } elseif (
337
+        is_numeric($errno) and ($errno == 1030 or $errno <= 1026)
338
+        and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs)
339
+    ) {
340
+        $errno = $regs[1];
341
+    }
342
+
343
+    // Erreur systeme
344
+    if (is_numeric($errno) and $errno > 0 and $errno < 200) {
345
+        $retour = '<tt><br /><br /><blink>'
346
+            . _T('info_erreur_systeme', ['errsys' => $errno])
347
+            . "</blink><br />\n<b>"
348
+            . _T(
349
+                'info_erreur_systeme2',
350
+                ['script' => generer_url_ecrire('base_repair')]
351
+            )
352
+            . '</b><br />';
353
+        spip_log("Erreur systeme $errno");
354
+
355
+        return [$retour, ''];
356
+    }
357
+
358
+    // Requete erronee
359
+    $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n"
360
+        . spip_htmlspecialchars($msg)
361
+        . "\n<br /><span style='color: red'><b>"
362
+        . spip_htmlspecialchars($query)
363
+        . '</b></span></tt><br />';
364
+
365
+    //. aider('erreur_mysql');
366
+
367
+    return $err;
368 368
 }
369 369
 
370 370
 
371 371
 function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = '') {
372 372
 
373
-	$id = $nom . $boucle;
374
-	if (is_array($GLOBALS['debug_objets']['sequence'][$id])) {
375
-		foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) {
376
-			if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) {
377
-				$y = substr_count($v[0], "\n");
378
-			} else {
379
-				if ($v[1][0] == '#') { // balise dynamique
380
-				$incl = $GLOBALS['debug_objets']['resultat'][$v[2]];
381
-				} else // inclusion
382
-				{
383
-					$incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])];
384
-				}
385
-				$y = substr_count($incl, "\n")
386
-					+ substr_count($r[1], "\n")
387
-					+ substr_count($r[3], "\n");
388
-			}
389
-			if ($n <= ($y + $debut)) {
390
-				if ($v[1][0] == '?') {
391
-					return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1));
392
-				} elseif ($v[1][0] == '!') {
393
-					if ($incl = trouve_squelette_inclus($v[1])) {
394
-						return trouve_boucle_debug($n, $incl, $debut);
395
-					}
396
-				}
397
-
398
-				return [$nom, $boucle, $v[2] - 1 + $n - $debut];
399
-			}
400
-			$debut += $y;
401
-		}
402
-	}
403
-
404
-	return [$nom, $boucle, $n - $debut];
373
+    $id = $nom . $boucle;
374
+    if (is_array($GLOBALS['debug_objets']['sequence'][$id])) {
375
+        foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) {
376
+            if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) {
377
+                $y = substr_count($v[0], "\n");
378
+            } else {
379
+                if ($v[1][0] == '#') { // balise dynamique
380
+                $incl = $GLOBALS['debug_objets']['resultat'][$v[2]];
381
+                } else // inclusion
382
+                {
383
+                    $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])];
384
+                }
385
+                $y = substr_count($incl, "\n")
386
+                    + substr_count($r[1], "\n")
387
+                    + substr_count($r[3], "\n");
388
+            }
389
+            if ($n <= ($y + $debut)) {
390
+                if ($v[1][0] == '?') {
391
+                    return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1));
392
+                } elseif ($v[1][0] == '!') {
393
+                    if ($incl = trouve_squelette_inclus($v[1])) {
394
+                        return trouve_boucle_debug($n, $incl, $debut);
395
+                    }
396
+                }
397
+
398
+                return [$nom, $boucle, $v[2] - 1 + $n - $debut];
399
+            }
400
+            $debut += $y;
401
+        }
402
+    }
403
+
404
+    return [$nom, $boucle, $n - $debut];
405 405
 }
406 406
 
407 407
 function trouve_squelette_inclus($script) {
408 408
 
409
-	preg_match('/include\(.(.*).php3?.\);/', $script, $reg);
410
-	// si le script X.php n'est pas ecrire/public.php
411
-	// on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux)
412
-	if ($reg[1] == 'ecrire/public') { // si c'est bien ecrire/public on cherche le param 'fond'
413
-	if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) { // a defaut on cherche le param 'page'
414
-		if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) {
415
-				$reg[1] = 'inconnu';
416
-		}
417
-	}
418
-	}
419
-	$incl = ',' . $reg[1] . '[.]\w$,';
420
-
421
-	foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) {
422
-		if (preg_match($incl, $v)) {
423
-			return $k;
424
-		}
425
-	}
426
-
427
-	return '';
409
+    preg_match('/include\(.(.*).php3?.\);/', $script, $reg);
410
+    // si le script X.php n'est pas ecrire/public.php
411
+    // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux)
412
+    if ($reg[1] == 'ecrire/public') { // si c'est bien ecrire/public on cherche le param 'fond'
413
+    if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) { // a defaut on cherche le param 'page'
414
+        if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) {
415
+                $reg[1] = 'inconnu';
416
+        }
417
+    }
418
+    }
419
+    $incl = ',' . $reg[1] . '[.]\w$,';
420
+
421
+    foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) {
422
+        if (preg_match($incl, $v)) {
423
+            return $k;
424
+        }
425
+    }
426
+
427
+    return '';
428 428
 }
429 429
 
430 430
 function reference_boucle_debug($n, $nom, $self) {
431
-	[$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom);
432
-
433
-	if (!$boucle) {
434
-		return !$ligne ? '' :
435
-			(' (' .
436
-				(($nom != $skel) ? _T('squelette_inclus_ligne') :
437
-					_T('squelette_ligne')) .
438
-				" <a href='$self&amp;var_mode_objet=$skel&amp;var_mode_affiche=squelette&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)");
439
-	} else {
440
-		$self .= "&amp;var_mode_objet=$skel$boucle&amp;var_mode_affiche=boucle";
441
-
442
-		return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" :
443
-			" (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
444
-	}
431
+    [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom);
432
+
433
+    if (!$boucle) {
434
+        return !$ligne ? '' :
435
+            (' (' .
436
+                (($nom != $skel) ? _T('squelette_inclus_ligne') :
437
+                    _T('squelette_ligne')) .
438
+                " <a href='$self&amp;var_mode_objet=$skel&amp;var_mode_affiche=squelette&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)");
439
+    } else {
440
+        $self .= "&amp;var_mode_objet=$skel$boucle&amp;var_mode_affiche=boucle";
441
+
442
+        return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" :
443
+            " (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
444
+    }
445 445
 }
446 446
 
447 447
 // affiche un texte avec numero de ligne et ancre.
448 448
 
449 449
 function ancre_texte($texte, $fautifs = [], $nocpt = false) {
450 450
 
451
-	$var_mode_ligne = _request('var_mode_ligne');
452
-	if ($var_mode_ligne) {
453
-		$fautifs[] = [$var_mode_ligne];
454
-	}
455
-	$res = '';
456
-
457
-	$s = highlight_string($texte, true);
458
-	if (substr($s, 0, 6) == '<code>') {
459
-		$s = substr($s, 6);
460
-		$res = '<code>';
461
-	}
462
-
463
-	$s = preg_replace(
464
-		',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,',
465
-		'<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>',
466
-		$s
467
-	);
468
-
469
-
470
-	$tableau = explode('<br />', $s);
471
-
472
-	$format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n";
473
-
474
-	$format10 = str_replace('white', 'lightgrey', $format);
475
-	$formaterr = 'color: red;';
476
-	$i = 1;
477
-	$flignes = [];
478
-	$loc = [0, 0];
479
-	foreach ($fautifs as $lc) {
480
-		if (is_array($lc)) {
481
-			$l = array_shift($lc);
482
-			$flignes[$l] = $lc;
483
-		} else {
484
-			$flignes[$lc] = $loc;
485
-		}
486
-	}
487
-
488
-	$ancre = md5($texte);
489
-	foreach ($tableau as $ligne) {
490
-		if (isset($flignes[$i])) {
491
-			$ligne = str_replace('&nbsp;', ' ', $ligne);
492
-			$indexmesg = $flignes[$i][1];
493
-			$err = textebrut($flignes[$i][2]);
494
-			// tentative de pointer sur la colonne fautive;
495
-			// marche pas car highlight_string rajoute des entites. A revoir.
496
-			// $m = $flignes[$i][0];
497
-			// $ligne = substr($ligne, 0, $m-1) .
498
-			// sprintf($formaterr, substr($ligne,$m));
499
-			$bg = $formaterr;
500
-		} else {
501
-			$indexmesg = $ancre;
502
-			$err = $bg = '';
503
-		}
504
-		$res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne);
505
-		$i++;
506
-	}
507
-
508
-	return "<div id='T$ancre'>"
509
-	. '<div onclick="'
510
-	. "jQuery(this).parent().find('a').toggle();"
511
-	. '" title="'
512
-	. _T('masquer_colonne')
513
-	. '" style="cursor: pointer;">'
514
-	. ($nocpt ? '' : _T('info_numero_abbreviation'))
515
-	. '</div>
451
+    $var_mode_ligne = _request('var_mode_ligne');
452
+    if ($var_mode_ligne) {
453
+        $fautifs[] = [$var_mode_ligne];
454
+    }
455
+    $res = '';
456
+
457
+    $s = highlight_string($texte, true);
458
+    if (substr($s, 0, 6) == '<code>') {
459
+        $s = substr($s, 6);
460
+        $res = '<code>';
461
+    }
462
+
463
+    $s = preg_replace(
464
+        ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,',
465
+        '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>',
466
+        $s
467
+    );
468
+
469
+
470
+    $tableau = explode('<br />', $s);
471
+
472
+    $format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n";
473
+
474
+    $format10 = str_replace('white', 'lightgrey', $format);
475
+    $formaterr = 'color: red;';
476
+    $i = 1;
477
+    $flignes = [];
478
+    $loc = [0, 0];
479
+    foreach ($fautifs as $lc) {
480
+        if (is_array($lc)) {
481
+            $l = array_shift($lc);
482
+            $flignes[$l] = $lc;
483
+        } else {
484
+            $flignes[$lc] = $loc;
485
+        }
486
+    }
487
+
488
+    $ancre = md5($texte);
489
+    foreach ($tableau as $ligne) {
490
+        if (isset($flignes[$i])) {
491
+            $ligne = str_replace('&nbsp;', ' ', $ligne);
492
+            $indexmesg = $flignes[$i][1];
493
+            $err = textebrut($flignes[$i][2]);
494
+            // tentative de pointer sur la colonne fautive;
495
+            // marche pas car highlight_string rajoute des entites. A revoir.
496
+            // $m = $flignes[$i][0];
497
+            // $ligne = substr($ligne, 0, $m-1) .
498
+            // sprintf($formaterr, substr($ligne,$m));
499
+            $bg = $formaterr;
500
+        } else {
501
+            $indexmesg = $ancre;
502
+            $err = $bg = '';
503
+        }
504
+        $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne);
505
+        $i++;
506
+    }
507
+
508
+    return "<div id='T$ancre'>"
509
+    . '<div onclick="'
510
+    . "jQuery(this).parent().find('a').toggle();"
511
+    . '" title="'
512
+    . _T('masquer_colonne')
513
+    . '" style="cursor: pointer;">'
514
+    . ($nocpt ? '' : _T('info_numero_abbreviation'))
515
+    . '</div>
516 516
 	' . $res . "</div>\n";
517 517
 }
518 518
 
519 519
 // l'environnement graphique du debuggueur
520 520
 
521 521
 function debusquer_squelette($fonc, $mode, $self) {
522
-	$legend = null;
523
-	$texte = '';
524
-
525
-	if ($mode !== 'validation') {
526
-		if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) {
527
-			$res = "<div id='spip-boucles'>\n"
528
-				. debusquer_navigation_squelettes($self)
529
-				. '</div>';
530
-		} else {
531
-			$res = '';
532
-		}
533
-		if ($fonc) {
534
-			$id = " id='$fonc'";
535
-			if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) {
536
-				[$legend, $texte, $res2] = debusquer_source($fonc, $mode);
537
-				$texte .= $res2;
538
-			} elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) {
539
-				$legend = _T('zbug_' . $mode);
540
-				$texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout'];
541
-				$texte = ancre_texte($texte, ['', '']);
542
-			}
543
-		} else {
544
-			if (strlen(trim($res))) {
545
-				return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>";
546
-			} else {
547
-				// cas de l'appel sur erreur: montre la page
548
-				return $GLOBALS['debug_objets']['resultat']['tout'] ?? '';
549
-			}
550
-		}
551
-	} else {
552
-		$valider = charger_fonction('valider', 'xml');
553
-		$val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']);
554
-		// Si erreur, signaler leur nombre dans le formulaire admin
555
-		$GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : '';
556
-		[$texte, $err] = emboite_texte($val, $fonc, $self);
557
-		if ($err === false) {
558
-			$err = _T('impossible');
559
-		} elseif ($err === true) {
560
-			$err = _T('correcte');
561
-		} else {
562
-			$err = ": $err";
563
-		}
564
-		$legend = _T('validation') . ' ' . $err;
565
-		$res = $id = '';
566
-	}
567
-
568
-	return !trim($texte) ? '' : (
569
-		"<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res"
570
-		. "<div id='debug_boucle'><fieldset$id><legend>"
571
-		. "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> &#8593; "
572
-		. ($legend ?: $mode)
573
-		. '</a></legend>'
574
-		. $texte
575
-		. '</fieldset></div>'
576
-		. '</div>');
522
+    $legend = null;
523
+    $texte = '';
524
+
525
+    if ($mode !== 'validation') {
526
+        if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) {
527
+            $res = "<div id='spip-boucles'>\n"
528
+                . debusquer_navigation_squelettes($self)
529
+                . '</div>';
530
+        } else {
531
+            $res = '';
532
+        }
533
+        if ($fonc) {
534
+            $id = " id='$fonc'";
535
+            if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) {
536
+                [$legend, $texte, $res2] = debusquer_source($fonc, $mode);
537
+                $texte .= $res2;
538
+            } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) {
539
+                $legend = _T('zbug_' . $mode);
540
+                $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout'];
541
+                $texte = ancre_texte($texte, ['', '']);
542
+            }
543
+        } else {
544
+            if (strlen(trim($res))) {
545
+                return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>";
546
+            } else {
547
+                // cas de l'appel sur erreur: montre la page
548
+                return $GLOBALS['debug_objets']['resultat']['tout'] ?? '';
549
+            }
550
+        }
551
+    } else {
552
+        $valider = charger_fonction('valider', 'xml');
553
+        $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']);
554
+        // Si erreur, signaler leur nombre dans le formulaire admin
555
+        $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : '';
556
+        [$texte, $err] = emboite_texte($val, $fonc, $self);
557
+        if ($err === false) {
558
+            $err = _T('impossible');
559
+        } elseif ($err === true) {
560
+            $err = _T('correcte');
561
+        } else {
562
+            $err = ": $err";
563
+        }
564
+        $legend = _T('validation') . ' ' . $err;
565
+        $res = $id = '';
566
+    }
567
+
568
+    return !trim($texte) ? '' : (
569
+        "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res"
570
+        . "<div id='debug_boucle'><fieldset$id><legend>"
571
+        . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> &#8593; "
572
+        . ($legend ?: $mode)
573
+        . '</a></legend>'
574
+        . $texte
575
+        . '</fieldset></div>'
576
+        . '</div>');
577 577
 }
578 578
 
579 579
 
580 580
 function emboite_texte($res, $fonc = '', $self = '') {
581
-	$errs = $res->err;
582
-	$texte = $res->entete . ($errs ? '' : $res->page);
583
-
584
-	if (!$texte and !$errs) {
585
-		return [ancre_texte('', ['', '']), false];
586
-	}
587
-	if (!$errs) {
588
-		return [ancre_texte($texte, ['', '']), true];
589
-	}
590
-
591
-	if (!isset($GLOBALS['debug_objets'])) {
592
-		$colors = ['#e0e0f0', '#f8f8ff'];
593
-		$encore = count_occ($errs);
594
-		$encore2 = [];
595
-		$fautifs = [];
596
-
597
-		$err = '<tr><th>'
598
-			. _T('numero')
599
-			. '</th><th>'
600
-			. _T('occurence')
601
-			. '</th><th>'
602
-			. _T('ligne')
603
-			. '</th><th>'
604
-			. _T('colonne')
605
-			. '</th><th>'
606
-			. _T('erreur')
607
-			. '</th></tr>';
608
-
609
-		$i = 0;
610
-		$style = "style='text-align: right; padding-right: 5px'";
611
-		foreach ($errs as $r) {
612
-			$i++;
613
-			[$msg, $ligne, $col] = $r;
614
-			#spip_log("$r = list($msg, $ligne, $col");
615
-			if (isset($encore2[$msg])) {
616
-				$ref = ++$encore2[$msg];
617
-			} else {
618
-				$encore2[$msg] = $ref = 1;
619
-			}
620
-			$err .= "<tr  style='background-color: "
621
-				. $colors[$i % 2]
622
-				. "'><td $style><a href='#debut_err'>"
623
-				. $i
624
-				. "</a></td><td $style>"
625
-				. "$ref/$encore[$msg]</td>"
626
-				. "<td $style><a href='#L"
627
-				. $ligne
628
-				. "' id='T$i'>"
629
-				. $ligne
630
-				. "</a></td><td $style>"
631
-				. $col
632
-				. "</td><td>$msg</td></tr>\n";
633
-			$fautifs[] = [$ligne, $col, $i, $msg];
634
-		}
635
-		$err = "<h2 style='text-align: center'>"
636
-			. $i
637
-			. "<a href='#fin_err'>"
638
-			. ' ' . _T('erreur_texte')
639
-			. "</a></h2><table id='debut_err' style='width: 100%'>"
640
-			. $err
641
-			. " </table><a id='fin_err'></a>";
642
-
643
-		return [ancre_texte($texte, $fautifs), $err];
644
-	} else {
645
-		[$msg, $fermant, $ouvrant] = $errs[0];
646
-		$rf = reference_boucle_debug($fermant, $fonc, $self);
647
-		$ro = reference_boucle_debug($ouvrant, $fonc, $self);
648
-		$err = $msg .
649
-			"<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" .
650
-			"<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro";
651
-
652
-		return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err];
653
-	}
581
+    $errs = $res->err;
582
+    $texte = $res->entete . ($errs ? '' : $res->page);
583
+
584
+    if (!$texte and !$errs) {
585
+        return [ancre_texte('', ['', '']), false];
586
+    }
587
+    if (!$errs) {
588
+        return [ancre_texte($texte, ['', '']), true];
589
+    }
590
+
591
+    if (!isset($GLOBALS['debug_objets'])) {
592
+        $colors = ['#e0e0f0', '#f8f8ff'];
593
+        $encore = count_occ($errs);
594
+        $encore2 = [];
595
+        $fautifs = [];
596
+
597
+        $err = '<tr><th>'
598
+            . _T('numero')
599
+            . '</th><th>'
600
+            . _T('occurence')
601
+            . '</th><th>'
602
+            . _T('ligne')
603
+            . '</th><th>'
604
+            . _T('colonne')
605
+            . '</th><th>'
606
+            . _T('erreur')
607
+            . '</th></tr>';
608
+
609
+        $i = 0;
610
+        $style = "style='text-align: right; padding-right: 5px'";
611
+        foreach ($errs as $r) {
612
+            $i++;
613
+            [$msg, $ligne, $col] = $r;
614
+            #spip_log("$r = list($msg, $ligne, $col");
615
+            if (isset($encore2[$msg])) {
616
+                $ref = ++$encore2[$msg];
617
+            } else {
618
+                $encore2[$msg] = $ref = 1;
619
+            }
620
+            $err .= "<tr  style='background-color: "
621
+                . $colors[$i % 2]
622
+                . "'><td $style><a href='#debut_err'>"
623
+                . $i
624
+                . "</a></td><td $style>"
625
+                . "$ref/$encore[$msg]</td>"
626
+                . "<td $style><a href='#L"
627
+                . $ligne
628
+                . "' id='T$i'>"
629
+                . $ligne
630
+                . "</a></td><td $style>"
631
+                . $col
632
+                . "</td><td>$msg</td></tr>\n";
633
+            $fautifs[] = [$ligne, $col, $i, $msg];
634
+        }
635
+        $err = "<h2 style='text-align: center'>"
636
+            . $i
637
+            . "<a href='#fin_err'>"
638
+            . ' ' . _T('erreur_texte')
639
+            . "</a></h2><table id='debut_err' style='width: 100%'>"
640
+            . $err
641
+            . " </table><a id='fin_err'></a>";
642
+
643
+        return [ancre_texte($texte, $fautifs), $err];
644
+    } else {
645
+        [$msg, $fermant, $ouvrant] = $errs[0];
646
+        $rf = reference_boucle_debug($fermant, $fonc, $self);
647
+        $ro = reference_boucle_debug($ouvrant, $fonc, $self);
648
+        $err = $msg .
649
+            "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" .
650
+            "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro";
651
+
652
+        return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err];
653
+    }
654 654
 }
655 655
 
656 656
 function count_occ($regs) {
657
-	$encore = [];
658
-	foreach ($regs as $r) {
659
-		if (isset($encore[$r[0]])) {
660
-			$encore[$r[0]]++;
661
-		} else {
662
-			$encore[$r[0]] = 1;
663
-		}
664
-	}
665
-
666
-	return $encore;
657
+    $encore = [];
658
+    foreach ($regs as $r) {
659
+        if (isset($encore[$r[0]])) {
660
+            $encore[$r[0]]++;
661
+        } else {
662
+            $encore[$r[0]] = 1;
663
+        }
664
+    }
665
+
666
+    return $encore;
667 667
 }
668 668
 
669 669
 function debusquer_navigation_squelettes($self) {
670 670
 
671
-	$res = '';
672
-	$boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : '';
673
-	$contexte = $GLOBALS['debug_objets']['contexte'];
674
-	$t_skel = _T('squelette');
675
-	foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) {
676
-		$self2 = parametre_url($self, 'var_mode_objet', $nom);
677
-		$nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile);
678
-		$temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T(
679
-			'zbug_profile',
680
-			['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]]
681
-		);
682
-
683
-		$res .= "<fieldset id='f_" . $nom . "'><legend>"
684
-			. $t_skel
685
-			. ' '
686
-			. $sourcefile
687
-			. "&nbsp;:\n<a href='$self2&amp;var_mode_affiche=squelette#f_$nom'>"
688
-			. $t_skel
689
-			. "</a>\n<a href='$self2&amp;var_mode_affiche=resultat#f_$nom'>"
690
-			. _T('zbug_resultat')
691
-			. "</a>\n<a href='$self2&amp;var_mode_affiche=code#f_$nom'>"
692
-			. _T('zbug_code')
693
-			. "</a>\n<a href='"
694
-			. str_replace('var_mode=debug', 'var_profile=1&amp;var_mode=recalcul', $self)
695
-			. "'>"
696
-			. _T('zbug_calcul')
697
-			. '</a></legend>'
698
-			. (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />"))
699
-			. debusquer_contexte($contexte[$sourcefile])
700
-		. (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n"))
701
-		. "</fieldset>\n";
702
-	}
703
-
704
-	return $res;
671
+    $res = '';
672
+    $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : '';
673
+    $contexte = $GLOBALS['debug_objets']['contexte'];
674
+    $t_skel = _T('squelette');
675
+    foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) {
676
+        $self2 = parametre_url($self, 'var_mode_objet', $nom);
677
+        $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile);
678
+        $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T(
679
+            'zbug_profile',
680
+            ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]]
681
+        );
682
+
683
+        $res .= "<fieldset id='f_" . $nom . "'><legend>"
684
+            . $t_skel
685
+            . ' '
686
+            . $sourcefile
687
+            . "&nbsp;:\n<a href='$self2&amp;var_mode_affiche=squelette#f_$nom'>"
688
+            . $t_skel
689
+            . "</a>\n<a href='$self2&amp;var_mode_affiche=resultat#f_$nom'>"
690
+            . _T('zbug_resultat')
691
+            . "</a>\n<a href='$self2&amp;var_mode_affiche=code#f_$nom'>"
692
+            . _T('zbug_code')
693
+            . "</a>\n<a href='"
694
+            . str_replace('var_mode=debug', 'var_profile=1&amp;var_mode=recalcul', $self)
695
+            . "'>"
696
+            . _T('zbug_calcul')
697
+            . '</a></legend>'
698
+            . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />"))
699
+            . debusquer_contexte($contexte[$sourcefile])
700
+        . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n"))
701
+        . "</fieldset>\n";
702
+    }
703
+
704
+    return $res;
705 705
 }
706 706
 
707 707
 function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source) {
708
-	$i = 0;
709
-	$res = '';
710
-	$var_mode_objet = _request('var_mode_objet');
711
-	$gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : '';
712
-
713
-	foreach ($boucles as $objet => $boucle) {
714
-		if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) {
715
-			$i++;
716
-			$nom = $boucle->id_boucle;
717
-			$req = $boucle->type_requete;
718
-			$crit = public_decompiler($boucle, $gram, 0, 'criteres');
719
-			$self2 = $self . '&amp;var_mode_objet=' . $objet;
720
-
721
-			$res .= "\n<tr style='background-color: " .
722
-				($i % 2 ? '#e0e0f0' : '#f8f8ff') .
723
-				"'><td  align='right'>$i</td><td>\n" .
724
-				"<a  class='debug_link_boucle' href='" .
725
-				$self2 .
726
-				"&amp;var_mode_affiche=boucle#f_$nom_skel'>" .
727
-				_T('zbug_boucle') .
728
-				"</a></td><td>\n<a class='debug_link_boucle' href='" .
729
-				$self2 .
730
-				"&amp;var_mode_affiche=resultat#f_$nom_skel'>" .
731
-				_T('zbug_resultat') .
732
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
733
-				$self2 .
734
-				"&amp;var_mode_affiche=code#f_$nom_skel'>" .
735
-				_T('zbug_code') .
736
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
737
-				str_replace('var_mode=', 'var_profile=', $self2) .
738
-				"'>" .
739
-				_T('zbug_calcul') .
740
-				"</a></td><td>\n" .
741
-				(($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) .
742
-				"</td><td>\n" .
743
-				$req .
744
-				"</td><td>\n" .
745
-				spip_htmlspecialchars($crit) .
746
-				'</td></tr>';
747
-		}
748
-	}
749
-
750
-	return $res;
708
+    $i = 0;
709
+    $res = '';
710
+    $var_mode_objet = _request('var_mode_objet');
711
+    $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : '';
712
+
713
+    foreach ($boucles as $objet => $boucle) {
714
+        if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) {
715
+            $i++;
716
+            $nom = $boucle->id_boucle;
717
+            $req = $boucle->type_requete;
718
+            $crit = public_decompiler($boucle, $gram, 0, 'criteres');
719
+            $self2 = $self . '&amp;var_mode_objet=' . $objet;
720
+
721
+            $res .= "\n<tr style='background-color: " .
722
+                ($i % 2 ? '#e0e0f0' : '#f8f8ff') .
723
+                "'><td  align='right'>$i</td><td>\n" .
724
+                "<a  class='debug_link_boucle' href='" .
725
+                $self2 .
726
+                "&amp;var_mode_affiche=boucle#f_$nom_skel'>" .
727
+                _T('zbug_boucle') .
728
+                "</a></td><td>\n<a class='debug_link_boucle' href='" .
729
+                $self2 .
730
+                "&amp;var_mode_affiche=resultat#f_$nom_skel'>" .
731
+                _T('zbug_resultat') .
732
+                "</a></td><td>\n<a class='debug_link_resultat' href='" .
733
+                $self2 .
734
+                "&amp;var_mode_affiche=code#f_$nom_skel'>" .
735
+                _T('zbug_code') .
736
+                "</a></td><td>\n<a class='debug_link_resultat' href='" .
737
+                str_replace('var_mode=', 'var_profile=', $self2) .
738
+                "'>" .
739
+                _T('zbug_calcul') .
740
+                "</a></td><td>\n" .
741
+                (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) .
742
+                "</td><td>\n" .
743
+                $req .
744
+                "</td><td>\n" .
745
+                spip_htmlspecialchars($crit) .
746
+                '</td></tr>';
747
+        }
748
+    }
749
+
750
+    return $res;
751 751
 }
752 752
 
753 753
 function debusquer_source($objet, $affiche) {
754
-	$quoi = $GLOBALS['debug_objets'][$affiche][$objet];
755
-	if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) {
756
-		$nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle;
757
-	} else {
758
-		$nom = $GLOBALS['debug_objets']['sourcefile'][$objet];
759
-	}
760
-	$res2 = '';
761
-
762
-	if ($affiche == 'resultat') {
763
-		$legend = $nom;
764
-		$req = $GLOBALS['debug_objets']['requete'][$objet];
765
-		if (function_exists('_mysql_traite_query')) {
766
-			$c = strtolower(_request('connect') ?? '');
767
-			$c = $GLOBALS['connexions'][$c ?: 0]['prefixe'];
768
-			$req = _mysql_traite_query($req, '', $c);
769
-		}
770
-		//  permettre le copier/coller facile
771
-		// $res = ancre_texte($req, array(), true);
772
-		$res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n";
773
-		//  formatage et affichage des resultats bruts de la requete
774
-		$ress_req = spip_query($req);
775
-		$brut_sql = '';
776
-		$num = 1;
777
-		//  eviter l'affichage de milliers de lignes
778
-		//  personnalisation possible dans mes_options
779
-		$max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50;
780
-		while ($retours_sql = sql_fetch($ress_req)) {
781
-			if ($num <= $max_aff) {
782
-				$brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>';
783
-				$brut_sql .= '<p>';
784
-				foreach ($retours_sql as $key => $val) {
785
-					$brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n";
786
-				}
787
-				$brut_sql .= '</p>';
788
-			}
789
-			$num++;
790
-		}
791
-		$res2 = interdire_scripts($brut_sql);
792
-		foreach ($quoi as $view) {
793
-			//  ne pas afficher les $contexte_inclus
794
-			$view = preg_replace(',<\?php.+\?[>],Uims', '', $view);
795
-			if ($view) {
796
-				$res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>';
797
-			}
798
-		}
799
-	} elseif ($affiche == 'code') {
800
-		$legend = $nom;
801
-		$res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>');
802
-	} elseif ($affiche == 'boucle') {
803
-		$legend = _T('zbug_boucle') . ' ' . $nom;
804
-		// Le compilateur prefixe le nom des boucles par l'extension du fichier source.
805
-		$gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : '';
806
-		$res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle'));
807
-	} elseif ($affiche == 'squelette') {
808
-		$legend = $GLOBALS['debug_objets']['sourcefile'][$objet];
809
-		$res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]);
810
-	}
811
-
812
-	return [$legend, $res, $res2];
754
+    $quoi = $GLOBALS['debug_objets'][$affiche][$objet];
755
+    if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) {
756
+        $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle;
757
+    } else {
758
+        $nom = $GLOBALS['debug_objets']['sourcefile'][$objet];
759
+    }
760
+    $res2 = '';
761
+
762
+    if ($affiche == 'resultat') {
763
+        $legend = $nom;
764
+        $req = $GLOBALS['debug_objets']['requete'][$objet];
765
+        if (function_exists('_mysql_traite_query')) {
766
+            $c = strtolower(_request('connect') ?? '');
767
+            $c = $GLOBALS['connexions'][$c ?: 0]['prefixe'];
768
+            $req = _mysql_traite_query($req, '', $c);
769
+        }
770
+        //  permettre le copier/coller facile
771
+        // $res = ancre_texte($req, array(), true);
772
+        $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n";
773
+        //  formatage et affichage des resultats bruts de la requete
774
+        $ress_req = spip_query($req);
775
+        $brut_sql = '';
776
+        $num = 1;
777
+        //  eviter l'affichage de milliers de lignes
778
+        //  personnalisation possible dans mes_options
779
+        $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50;
780
+        while ($retours_sql = sql_fetch($ress_req)) {
781
+            if ($num <= $max_aff) {
782
+                $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>';
783
+                $brut_sql .= '<p>';
784
+                foreach ($retours_sql as $key => $val) {
785
+                    $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n";
786
+                }
787
+                $brut_sql .= '</p>';
788
+            }
789
+            $num++;
790
+        }
791
+        $res2 = interdire_scripts($brut_sql);
792
+        foreach ($quoi as $view) {
793
+            //  ne pas afficher les $contexte_inclus
794
+            $view = preg_replace(',<\?php.+\?[>],Uims', '', $view);
795
+            if ($view) {
796
+                $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>';
797
+            }
798
+        }
799
+    } elseif ($affiche == 'code') {
800
+        $legend = $nom;
801
+        $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>');
802
+    } elseif ($affiche == 'boucle') {
803
+        $legend = _T('zbug_boucle') . ' ' . $nom;
804
+        // Le compilateur prefixe le nom des boucles par l'extension du fichier source.
805
+        $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : '';
806
+        $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle'));
807
+    } elseif ($affiche == 'squelette') {
808
+        $legend = $GLOBALS['debug_objets']['sourcefile'][$objet];
809
+        $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]);
810
+    }
811
+
812
+    return [$legend, $res, $res2];
813 813
 }
814 814
 
815 815
 function debusquer_entete($titre, $corps) {
816 816
 
817
-	include_spip('balise/formulaire_admin');
818
-	include_spip('public/assembler'); // pour inclure_balise_dynamique
819
-	include_spip('inc/texte'); // pour corriger_typo
820
-
821
-	return _DOCTYPE_ECRIRE .
822
-	html_lang_attributes() .
823
-	"<head>\n<title>" .
824
-	('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' .
825
-		_T('admin_debug') . ' ' . $titre . ' (' .
826
-		supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) .
827
-	")</title>\n" .
828
-	"<meta http-equiv='Content-Type' content='text/html" .
829
-	(($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') .
830
-	"' />\n" .
831
-	http_script('', 'jquery.js')
832
-	. "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css'))
833
-	. "' type='text/css' />" .
834
-	"</head>\n" .
835
-	"<body style='margin:0 10px;'>\n" .
836
-	"<div id='spip-debug-header'>" .
837
-	$corps .
838
-	inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) .
839
-	'</div></body></html>';
817
+    include_spip('balise/formulaire_admin');
818
+    include_spip('public/assembler'); // pour inclure_balise_dynamique
819
+    include_spip('inc/texte'); // pour corriger_typo
820
+
821
+    return _DOCTYPE_ECRIRE .
822
+    html_lang_attributes() .
823
+    "<head>\n<title>" .
824
+    ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' .
825
+        _T('admin_debug') . ' ' . $titre . ' (' .
826
+        supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) .
827
+    ")</title>\n" .
828
+    "<meta http-equiv='Content-Type' content='text/html" .
829
+    (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') .
830
+    "' />\n" .
831
+    http_script('', 'jquery.js')
832
+    . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css'))
833
+    . "' type='text/css' />" .
834
+    "</head>\n" .
835
+    "<body style='margin:0 10px;'>\n" .
836
+    "<div id='spip-debug-header'>" .
837
+    $corps .
838
+    inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) .
839
+    '</div></body></html>';
840 840
 }
Please login to merge, or discard this patch.
Spacing   +86 added lines, -89 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		if (!$fonc) {
149 149
 			$fonc = $GLOBALS['debug_objets']['principal'];
150 150
 		}
151
-		$titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : ''));
151
+		$titre = !$mode ? $fonc : ($mode.(isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' '.$GLOBALS['debug_objets']['sourcefile'][$fonc] : ''));
152 152
 	}
153 153
 	if ($message === false) {
154 154
 		lang_select();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	$fond = $GLOBALS['fond'] ?? '';
178 178
 	// une erreur critique sort $message en array
179 179
 	$debug = is_array($msg) ? $msg[1] : $msg;
180
-	spip_log('Debug: ' . $debug . ' (' . $fond . ')');
180
+	spip_log('Debug: '.$debug.' ('.$fond.')');
181 181
 
182 182
 	return $msg;
183 183
 }
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 function debusquer_bandeau($erreurs) {
186 186
 
187 187
 	if (!empty($erreurs)) {
188
-		$n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')];
188
+		$n = [(is_countable($erreurs) ? count($erreurs) : 0).' '._T('zbug_erreur_squelette')];
189 189
 
190 190
 		return debusquer_navigation($erreurs, $n);
191 191
 	} elseif (!empty($GLOBALS['tableau_des_temps'])) {
@@ -218,25 +218,25 @@  discard block
 block discarded – undo
218 218
 			$valeur_simple = [];
219 219
 			foreach ($valeur as $v) {
220 220
 				if (is_array($v)) {
221
-					$valeur_simple[] = 'array:' . count($v);
221
+					$valeur_simple[] = 'array:'.count($v);
222 222
 				} elseif (is_object($v)) {
223 223
 					$valeur_simple[] = get_class($v);
224 224
 				} elseif (is_string($v)) {
225
-					$valeur_simple[] = "'" . $v . "'";
225
+					$valeur_simple[] = "'".$v."'";
226 226
 				} else {
227 227
 					$valeur_simple[] = $v;
228 228
 				}
229 229
 			}
230 230
 			$n = count($valeur);
231
-			$valeur = (($n > 3) ? 'array:' . $n . ' ' : '');
232
-			$valeur .= '[' . join(', ', $valeur_simple) . ']';
231
+			$valeur = (($n > 3) ? 'array:'.$n.' ' : '');
232
+			$valeur .= '['.join(', ', $valeur_simple).']';
233 233
 		} elseif (is_object($valeur)) {
234 234
 			$valeur = get_class($valeur);
235 235
 		} elseif (is_string($valeur)) {
236
-			$valeur = "'" . $valeur . "'";
236
+			$valeur = "'".$valeur."'";
237 237
 		}
238
-		$res .= "\n<tr><td><strong>" . nl2br(entites_html($nom))
239
-			. '</strong></td><td>:&nbsp;' . nl2br(entites_html($valeur))
238
+		$res .= "\n<tr><td><strong>".nl2br(entites_html($nom))
239
+			. '</strong></td><td>:&nbsp;'.nl2br(entites_html($valeur))
240 240
 			. "</td></tr>\n";
241 241
 	}
242 242
 
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 				$nom_code = $lieu->descr['nom'];
265 265
 				$skel = $lieu->descr['sourcefile'];
266 266
 				$h2 = parametre_url($href, 'var_mode_objet', $nom_code);
267
-				$h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne;
267
+				$h3 = parametre_url($h2, 'var_mode_affiche', 'squelette').'#L'.$ligne;
268 268
 				$skel = "<a href='$h3'><b>$skel</b></a>";
269 269
 				if ($boucle) {
270
-					$h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle');
270
+					$h3 = parametre_url($h2.$boucle, 'var_mode_affiche', 'boucle');
271 271
 					$boucle = "<a href='$h3'><b>$boucle</b></a>";
272 272
 				}
273 273
 			}
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	}
357 357
 
358 358
 	// Requete erronee
359
-	$err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n"
359
+	$err = '<b>'._T('avis_erreur_mysql')." $errno</b><br /><tt>\n"
360 360
 		. spip_htmlspecialchars($msg)
361 361
 		. "\n<br /><span style='color: red'><b>"
362 362
 		. spip_htmlspecialchars($query)
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 
371 371
 function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = '') {
372 372
 
373
-	$id = $nom . $boucle;
373
+	$id = $nom.$boucle;
374 374
 	if (is_array($GLOBALS['debug_objets']['sequence'][$id])) {
375 375
 		foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) {
376 376
 			if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) {
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		}
417 417
 	}
418 418
 	}
419
-	$incl = ',' . $reg[1] . '[.]\w$,';
419
+	$incl = ','.$reg[1].'[.]\w$,';
420 420
 
421 421
 	foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) {
422 422
 		if (preg_match($incl, $v)) {
@@ -431,16 +431,13 @@  discard block
 block discarded – undo
431 431
 	[$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom);
432 432
 
433 433
 	if (!$boucle) {
434
-		return !$ligne ? '' :
435
-			(' (' .
436
-				(($nom != $skel) ? _T('squelette_inclus_ligne') :
437
-					_T('squelette_ligne')) .
434
+		return !$ligne ? '' : (' ('.
435
+				(($nom != $skel) ? _T('squelette_inclus_ligne') : _T('squelette_ligne')).
438 436
 				" <a href='$self&amp;var_mode_objet=$skel&amp;var_mode_affiche=squelette&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)");
439 437
 	} else {
440 438
 		$self .= "&amp;var_mode_objet=$skel$boucle&amp;var_mode_affiche=boucle";
441 439
 
442
-		return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" :
443
-			" (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
440
+		return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : " (boucle $boucle ligne\n<a href='$self&amp;var_mode_ligne=$ligne#L$ligne'>$ligne</a>)";
444 441
 	}
445 442
 }
446 443
 
@@ -462,14 +459,14 @@  discard block
 block discarded – undo
462 459
 
463 460
 	$s = preg_replace(
464 461
 		',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,',
465
-		'<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>',
462
+		'<\1>\2</\1><br />'."\n".'<\1>\3</\1>',
466 463
 		$s
467 464
 	);
468 465
 
469 466
 
470 467
 	$tableau = explode('<br />', $s);
471 468
 
472
-	$format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n";
469
+	$format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: ".($nocpt ? 'hidden' : 'visible').";%s' href='#T%s' title=\"%s\">%0".strval(@strlen(count($tableau)))."d</a></span> %s<br />\n";
473 470
 
474 471
 	$format10 = str_replace('white', 'lightgrey', $format);
475 472
 	$formaterr = 'color: red;';
@@ -513,7 +510,7 @@  discard block
 block discarded – undo
513 510
 	. '" style="cursor: pointer;">'
514 511
 	. ($nocpt ? '' : _T('info_numero_abbreviation'))
515 512
 	. '</div>
516
-	' . $res . "</div>\n";
513
+	' . $res."</div>\n";
517 514
 }
518 515
 
519 516
 // l'environnement graphique du debuggueur
@@ -535,14 +532,14 @@  discard block
 block discarded – undo
535 532
 			if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) {
536 533
 				[$legend, $texte, $res2] = debusquer_source($fonc, $mode);
537 534
 				$texte .= $res2;
538
-			} elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) {
539
-				$legend = _T('zbug_' . $mode);
540
-				$texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout'];
535
+			} elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc.'tout'])) {
536
+				$legend = _T('zbug_'.$mode);
537
+				$texte = $GLOBALS['debug_objets'][$mode][$fonc.'tout'];
541 538
 				$texte = ancre_texte($texte, ['', '']);
542 539
 			}
543 540
 		} else {
544 541
 			if (strlen(trim($res))) {
545
-				return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>";
542
+				return "<img src='".chemin_image('debug-xx.svg')."' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>";
546 543
 			} else {
547 544
 				// cas de l'appel sur erreur: montre la page
548 545
 				return $GLOBALS['debug_objets']['resultat']['tout'] ?? '';
@@ -550,7 +547,7 @@  discard block
 block discarded – undo
550 547
 		}
551 548
 	} else {
552 549
 		$valider = charger_fonction('valider', 'xml');
553
-		$val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']);
550
+		$val = $valider($GLOBALS['debug_objets']['validation'][$fonc.'tout']);
554 551
 		// Si erreur, signaler leur nombre dans le formulaire admin
555 552
 		$GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : '';
556 553
 		[$texte, $err] = emboite_texte($val, $fonc, $self);
@@ -561,14 +558,14 @@  discard block
 block discarded – undo
561 558
 		} else {
562 559
 			$err = ": $err";
563 560
 		}
564
-		$legend = _T('validation') . ' ' . $err;
561
+		$legend = _T('validation').' '.$err;
565 562
 		$res = $id = '';
566 563
 	}
567 564
 
568 565
 	return !trim($texte) ? '' : (
569
-		"<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res"
566
+		"<img src='".chemin_image('debug-xx.svg')."' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res"
570 567
 		. "<div id='debug_boucle'><fieldset$id><legend>"
571
-		. "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> &#8593; "
568
+		. "<a href='".$self.'#f_'.substr($fonc, 0, 37)."'> &#8593; "
572 569
 		. ($legend ?: $mode)
573 570
 		. '</a></legend>'
574 571
 		. $texte
@@ -579,7 +576,7 @@  discard block
 block discarded – undo
579 576
 
580 577
 function emboite_texte($res, $fonc = '', $self = '') {
581 578
 	$errs = $res->err;
582
-	$texte = $res->entete . ($errs ? '' : $res->page);
579
+	$texte = $res->entete.($errs ? '' : $res->page);
583 580
 
584 581
 	if (!$texte and !$errs) {
585 582
 		return [ancre_texte('', ['', '']), false];
@@ -635,7 +632,7 @@  discard block
 block discarded – undo
635 632
 		$err = "<h2 style='text-align: center'>"
636 633
 			. $i
637 634
 			. "<a href='#fin_err'>"
638
-			. ' ' . _T('erreur_texte')
635
+			. ' '._T('erreur_texte')
639 636
 			. "</a></h2><table id='debut_err' style='width: 100%'>"
640 637
 			. $err
641 638
 			. " </table><a id='fin_err'></a>";
@@ -645,9 +642,9 @@  discard block
 block discarded – undo
645 642
 		[$msg, $fermant, $ouvrant] = $errs[0];
646 643
 		$rf = reference_boucle_debug($fermant, $fonc, $self);
647 644
 		$ro = reference_boucle_debug($ouvrant, $fonc, $self);
648
-		$err = $msg .
649
-			"<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" .
650
-			"<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro";
645
+		$err = $msg.
646
+			"<a href='#L".$fermant."'>$fermant</a>$rf<br />".
647
+			"<a href='#L".$ouvrant."'>$ouvrant</a>$ro";
651 648
 
652 649
 		return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err];
653 650
 	}
@@ -680,7 +677,7 @@  discard block
 block discarded – undo
680 677
 			['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]]
681 678
 		);
682 679
 
683
-		$res .= "<fieldset id='f_" . $nom . "'><legend>"
680
+		$res .= "<fieldset id='f_".$nom."'><legend>"
684 681
 			. $t_skel
685 682
 			. ' '
686 683
 			. $sourcefile
@@ -695,7 +692,7 @@  discard block
 block discarded – undo
695 692
 			. "'>"
696 693
 			. _T('zbug_calcul')
697 694
 			. '</a></legend>'
698
-			. (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />"))
695
+			. (!$temps ? '' : ("\n<span style='display:block;float:".$GLOBALS['spip_lang_right']."'>$temps</span><br />"))
699 696
 			. debusquer_contexte($contexte[$sourcefile])
700 697
 		. (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n"))
701 698
 		. "</fieldset>\n";
@@ -716,33 +713,33 @@  discard block
 block discarded – undo
716 713
 			$nom = $boucle->id_boucle;
717 714
 			$req = $boucle->type_requete;
718 715
 			$crit = public_decompiler($boucle, $gram, 0, 'criteres');
719
-			$self2 = $self . '&amp;var_mode_objet=' . $objet;
720
-
721
-			$res .= "\n<tr style='background-color: " .
722
-				($i % 2 ? '#e0e0f0' : '#f8f8ff') .
723
-				"'><td  align='right'>$i</td><td>\n" .
724
-				"<a  class='debug_link_boucle' href='" .
725
-				$self2 .
726
-				"&amp;var_mode_affiche=boucle#f_$nom_skel'>" .
727
-				_T('zbug_boucle') .
728
-				"</a></td><td>\n<a class='debug_link_boucle' href='" .
729
-				$self2 .
730
-				"&amp;var_mode_affiche=resultat#f_$nom_skel'>" .
731
-				_T('zbug_resultat') .
732
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
733
-				$self2 .
734
-				"&amp;var_mode_affiche=code#f_$nom_skel'>" .
735
-				_T('zbug_code') .
736
-				"</a></td><td>\n<a class='debug_link_resultat' href='" .
737
-				str_replace('var_mode=', 'var_profile=', $self2) .
738
-				"'>" .
739
-				_T('zbug_calcul') .
740
-				"</a></td><td>\n" .
741
-				(($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) .
742
-				"</td><td>\n" .
743
-				$req .
744
-				"</td><td>\n" .
745
-				spip_htmlspecialchars($crit) .
716
+			$self2 = $self.'&amp;var_mode_objet='.$objet;
717
+
718
+			$res .= "\n<tr style='background-color: ".
719
+				($i % 2 ? '#e0e0f0' : '#f8f8ff').
720
+				"'><td  align='right'>$i</td><td>\n".
721
+				"<a  class='debug_link_boucle' href='".
722
+				$self2.
723
+				"&amp;var_mode_affiche=boucle#f_$nom_skel'>".
724
+				_T('zbug_boucle').
725
+				"</a></td><td>\n<a class='debug_link_boucle' href='".
726
+				$self2.
727
+				"&amp;var_mode_affiche=resultat#f_$nom_skel'>".
728
+				_T('zbug_resultat').
729
+				"</a></td><td>\n<a class='debug_link_resultat' href='".
730
+				$self2.
731
+				"&amp;var_mode_affiche=code#f_$nom_skel'>".
732
+				_T('zbug_code').
733
+				"</a></td><td>\n<a class='debug_link_resultat' href='".
734
+				str_replace('var_mode=', 'var_profile=', $self2).
735
+				"'>".
736
+				_T('zbug_calcul').
737
+				"</a></td><td>\n".
738
+				(($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom).
739
+				"</td><td>\n".
740
+				$req.
741
+				"</td><td>\n".
742
+				spip_htmlspecialchars($crit).
746 743
 				'</td></tr>';
747 744
 		}
748 745
 	}
@@ -769,7 +766,7 @@  discard block
 block discarded – undo
769 766
 		}
770 767
 		//  permettre le copier/coller facile
771 768
 		// $res = ancre_texte($req, array(), true);
772
-		$res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n";
769
+		$res = "<div id='T".md5($req)."'>\n<pre>\n".$req."</pre>\n</div>\n";
773 770
 		//  formatage et affichage des resultats bruts de la requete
774 771
 		$ress_req = spip_query($req);
775 772
 		$brut_sql = '';
@@ -779,10 +776,10 @@  discard block
 block discarded – undo
779 776
 		$max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50;
780 777
 		while ($retours_sql = sql_fetch($ress_req)) {
781 778
 			if ($num <= $max_aff) {
782
-				$brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>';
779
+				$brut_sql .= '<h3>'.($num == 1 ? $num.' sur '.sql_count($ress_req) : $num).'</h3>';
783 780
 				$brut_sql .= '<p>';
784 781
 				foreach ($retours_sql as $key => $val) {
785
-					$brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n";
782
+					$brut_sql .= '<strong>'.$key.'</strong> => '.spip_htmlspecialchars(couper($val, 150))."<br />\n";
786 783
 				}
787 784
 				$brut_sql .= '</p>';
788 785
 			}
@@ -793,14 +790,14 @@  discard block
 block discarded – undo
793 790
 			//  ne pas afficher les $contexte_inclus
794 791
 			$view = preg_replace(',<\?php.+\?[>],Uims', '', $view);
795 792
 			if ($view) {
796
-				$res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>';
793
+				$res2 .= "\n<br /><fieldset>".interdire_scripts($view).'</fieldset>';
797 794
 			}
798 795
 		}
799 796
 	} elseif ($affiche == 'code') {
800 797
 		$legend = $nom;
801
-		$res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>');
798
+		$res = ancre_texte('<'."?php\n".$quoi."\n?".'>');
802 799
 	} elseif ($affiche == 'boucle') {
803
-		$legend = _T('zbug_boucle') . ' ' . $nom;
800
+		$legend = _T('zbug_boucle').' '.$nom;
804 801
 		// Le compilateur prefixe le nom des boucles par l'extension du fichier source.
805 802
 		$gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : '';
806 803
 		$res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle'));
@@ -818,23 +815,23 @@  discard block
 block discarded – undo
818 815
 	include_spip('public/assembler'); // pour inclure_balise_dynamique
819 816
 	include_spip('inc/texte'); // pour corriger_typo
820 817
 
821
-	return _DOCTYPE_ECRIRE .
822
-	html_lang_attributes() .
823
-	"<head>\n<title>" .
824
-	('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' .
825
-		_T('admin_debug') . ' ' . $titre . ' (' .
826
-		supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) .
827
-	")</title>\n" .
828
-	"<meta http-equiv='Content-Type' content='text/html" .
829
-	(($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') .
830
-	"' />\n" .
818
+	return _DOCTYPE_ECRIRE.
819
+	html_lang_attributes().
820
+	"<head>\n<title>".
821
+	('SPIP '.$GLOBALS['spip_version_affichee'].' '.
822
+		_T('admin_debug').' '.$titre.' ('.
823
+		supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))).
824
+	")</title>\n".
825
+	"<meta http-equiv='Content-Type' content='text/html".
826
+	(($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '').
827
+	"' />\n".
831 828
 	http_script('', 'jquery.js')
832
-	. "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css'))
833
-	. "' type='text/css' />" .
834
-	"</head>\n" .
835
-	"<body style='margin:0 10px;'>\n" .
836
-	"<div id='spip-debug-header'>" .
837
-	$corps .
838
-	inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) .
829
+	. "<link rel='stylesheet' href='".url_absolue(find_in_path('spip_admin.css'))
830
+	. "' type='text/css' />".
831
+	"</head>\n".
832
+	"<body style='margin:0 10px;'>\n".
833
+	"<div id='spip-debug-header'>".
834
+	$corps.
835
+	inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false).
839 836
 	'</div></body></html>';
840 837
 }
Please login to merge, or discard this patch.