Completed
Push — master ( 9ef159...478ba3 )
by cam
01:13
created
ecrire/plugins/afficher_plugin.php 2 patches
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.
Indentation   +303 added lines, -303 removed lines patch added patch discarded remove patch
@@ -17,212 +17,212 @@  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
-	// sinon prendre le squelette std sur le nom std
128
-	return recuperer_fond(
129
-		'prive/squelettes/inclure/cfg',
130
-		[
131
-			'script' => 'configurer_' . $prefix,
132
-			'nom' => $nom
133
-		]
134
-	);
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
+    // sinon prendre le squelette std sur le nom std
128
+    return recuperer_fond(
129
+        'prive/squelettes/inclure/cfg',
130
+        [
131
+            'script' => 'configurer_' . $prefix,
132
+            'nom' => $nom
133
+        ]
134
+    );
135 135
 }
136 136
 
137 137
 // checkbox pour activer ou desactiver
138 138
 // si ce n'est pas une extension
139 139
 
140 140
 function plugin_checkbox($id_input, $file, $actif) {
141
-	$name = substr(md5($file), 0, 16);
142
-
143
-	return "<div class='check'>\n"
144
-	. "<input type='checkbox' name='s$name' id='label_$id_input'"
145
-	. ($actif ? " checked='checked'" : '')
146
-	. " class='checkbox'  value='O' />"
147
-	. "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>'
148
-	. '</div>';
141
+    $name = substr(md5($file), 0, 16);
142
+
143
+    return "<div class='check'>\n"
144
+    . "<input type='checkbox' name='s$name' id='label_$id_input'"
145
+    . ($actif ? " checked='checked'" : '')
146
+    . " class='checkbox'  value='O' />"
147
+    . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>'
148
+    . '</div>';
149 149
 }
150 150
 
151 151
 function plugin_nom($info, $dir_plugins, $plug_file) {
152
-	$prefix = $info['prefix'];
153
-	$dir = "$dir_plugins$plug_file";
154
-	// Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom"
155
-	if ($info['dtd'] == 'paquet') {
156
-		$nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix");
157
-		if (!$nom) {
158
-			$nom = typo($info['nom']);
159
-		}
160
-	} else {
161
-		$nom = typo(attribut_html($info['nom']));
162
-	}
163
-
164
-	return trim($nom);
152
+    $prefix = $info['prefix'];
153
+    $dir = "$dir_plugins$plug_file";
154
+    // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom"
155
+    if ($info['dtd'] == 'paquet') {
156
+        $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix");
157
+        if (!$nom) {
158
+            $nom = typo($info['nom']);
159
+        }
160
+    } else {
161
+        $nom = typo(attribut_html($info['nom']));
162
+    }
163
+
164
+    return trim($nom);
165 165
 }
166 166
 
167 167
 // Cartouche Resume
168 168
 function plugin_resume($info, $dir_plugins, $plug_file, $url_page) {
169
-	$prefix = $info['prefix'];
170
-	$dir = "$dir_plugins$plug_file";
171
-	$slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix"));
172
-	// une seule ligne dans le slogan : couper si besoin
173
-	if (($p = strpos($slogan, '<br />')) !== false) {
174
-		$slogan = substr($slogan, 0, $p);
175
-	}
176
-	// couper par securite
177
-	$slogan = couper($slogan, 80);
178
-
179
-	$nom = plugin_nom($info, $dir_plugins, $plug_file);
180
-
181
-	$url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE)));
182
-
183
-	$icon_class = 'icon';
184
-	$img = '';
185
-	if (isset($info['logo']) and $i = trim($info['logo'])) {
186
-		$img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]);
187
-		if (!extraire_attribut($img, 'src')) {
188
-			$img = '';
189
-		}
190
-	}
191
-	if (!$img) {
192
-		$img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'");
193
-		$icon_class .= ' no-logo';
194
-	}
195
-
196
-	$i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>";
197
-
198
-	return "<div class='resume'>"
199
-	. "<h3><a href='$url' rel='info'>"
200
-	. $nom
201
-	. '</a></h3>'
202
-	. " <span class='version'>" . $info['version'] . '</span>'
203
-	. " <span class='etat'> - "
204
-	. plugin_etat_en_clair($info['etat'])
205
-	. '</span>'
206
-	. "<div class='short'>" . $slogan . '</div>'
207
-	. $i
208
-	. '</div>';
169
+    $prefix = $info['prefix'];
170
+    $dir = "$dir_plugins$plug_file";
171
+    $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix"));
172
+    // une seule ligne dans le slogan : couper si besoin
173
+    if (($p = strpos($slogan, '<br />')) !== false) {
174
+        $slogan = substr($slogan, 0, $p);
175
+    }
176
+    // couper par securite
177
+    $slogan = couper($slogan, 80);
178
+
179
+    $nom = plugin_nom($info, $dir_plugins, $plug_file);
180
+
181
+    $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE)));
182
+
183
+    $icon_class = 'icon';
184
+    $img = '';
185
+    if (isset($info['logo']) and $i = trim($info['logo'])) {
186
+        $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]);
187
+        if (!extraire_attribut($img, 'src')) {
188
+            $img = '';
189
+        }
190
+    }
191
+    if (!$img) {
192
+        $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'");
193
+        $icon_class .= ' no-logo';
194
+    }
195
+
196
+    $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>";
197
+
198
+    return "<div class='resume'>"
199
+    . "<h3><a href='$url' rel='info'>"
200
+    . $nom
201
+    . '</a></h3>'
202
+    . " <span class='version'>" . $info['version'] . '</span>'
203
+    . " <span class='etat'> - "
204
+    . plugin_etat_en_clair($info['etat'])
205
+    . '</span>'
206
+    . "<div class='short'>" . $slogan . '</div>'
207
+    . $i
208
+    . '</div>';
209 209
 }
210 210
 
211 211
 function plugin_desintalle($plug_file, $nom, $dir_plugins = null) {
212
-	if (!$dir_plugins) {
213
-		$dir_plugins = _DIR_PLUGINS;
214
-	}
212
+    if (!$dir_plugins) {
213
+        $dir_plugins = _DIR_PLUGINS;
214
+    }
215 215
 
216
-	$action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin');
217
-	$text = _T('bouton_desinstaller');
218
-	$text2 = _T('info_desinstaller_plugin');
219
-	$file = basename($plug_file);
216
+    $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin');
217
+    $text = _T('bouton_desinstaller');
218
+    $text2 = _T('info_desinstaller_plugin');
219
+    $file = basename($plug_file);
220 220
 
221
-	return "<div class='actions'>[" .
222
-	"<a href='$action'
221
+    return "<div class='actions'>[" .
222
+    "<a href='$action'
223 223
 		onclick='return confirm(\"$text $nom ?\\n$text2\")'>"
224
-	. $text
225
-	. '</a>]</div>';
224
+    . $text
225
+    . '</a>]</div>';
226 226
 }
227 227
 
228 228
 /**
@@ -236,145 +236,145 @@  discard block
 block discarded – undo
236 236
  *     Traduction de l'état dans la langue en cours
237 237
  **/
238 238
 function plugin_etat_en_clair($etat) {
239
-	if (!in_array($etat, ['stable', 'test', 'experimental'])) {
240
-		$etat = 'developpement';
241
-	}
239
+    if (!in_array($etat, ['stable', 'test', 'experimental'])) {
240
+        $etat = 'developpement';
241
+    }
242 242
 
243
-	return _T('plugin_etat_' . $etat);
243
+    return _T('plugin_etat_' . $etat);
244 244
 }
245 245
 
246 246
 function plugin_propre($texte, $module = '', $propre = 'propre') {
247
-	// retirer le retour a la racine du module, car le find_in_path se fait depuis la racine
248
-	if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) {
249
-		$module = substr($module, strlen(_DIR_RACINE));
250
-	}
251
-	if (preg_match('|^\w+_[\w_]+$|', $texte)) {
252
-		$texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]);
253
-	}
254
-
255
-	return $propre($texte);
247
+    // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine
248
+    if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) {
249
+        $module = substr($module, strlen(_DIR_RACINE));
250
+    }
251
+    if (preg_match('|^\w+_[\w_]+$|', $texte)) {
252
+        $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]);
253
+    }
254
+
255
+    return $propre($texte);
256 256
 }
257 257
 
258 258
 function plugin_typo($texte, $module = '') {
259
-	return plugin_propre($texte, $module, 'typo');
259
+    return plugin_propre($texte, $module, 'typo');
260 260
 }
261 261
 
262 262
 
263 263
 function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) {
264
-	$log = null;
265
-	if (!$dir_plugins) {
266
-		$dir_plugins = _DIR_PLUGINS;
267
-	}
268
-
269
-	$prefix = $info['prefix'];
270
-	$dir = "$dir_plugins$plug_file/lang/paquet-$prefix";
271
-
272
-	$s = '';
273
-	// TODO: le traiter_multi ici n'est pas beau
274
-	// cf. description du plugin/_stable_/ortho/plugin.xml
275
-	// concerne les anciens plugin.xml donc on devrait plus en avoir besoin
276
-	$description = '';
277
-	if (isset($info['description'])) {
278
-		$description = plugin_propre($info['description'], $dir);
279
-	}
280
-
281
-	if (
282
-		isset($info['documentation'])
283
-		and $lien = $info['documentation']
284
-	) {
285
-		$description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>';
286
-	}
287
-	$s .= "<dd class='desc'>" . $description . "</dd>\n";
288
-
289
-	if (isset($info['auteur'])) {
290
-		if (is_array($info['auteur'])) {
291
-			$a = formater_credits($info['auteur'], ', ');
292
-		} // pour compat mais ne doit plus arriver
293
-		else {
294
-			$a = trim($info['auteur']);
295
-		}
296
-		if ($a) {
297
-			$s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre(
298
-				$a,
299
-				$dir
300
-			)) . "</dd>\n";
301
-		}
302
-	}
303
-
304
-	if (isset($info['credit'])) {
305
-		if ($a = formater_credits($info['credit'], ', ')) {
306
-			$s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre(
307
-				$a,
308
-				$dir
309
-			)) . "</dd>\n";
310
-		}
311
-	}
312
-
313
-	if (isset($info['licence'])) {
314
-		if (is_array($info['licence'])) {
315
-			$a = formater_credits($info['licence'], ', ');
316
-		} // pour compat mais ne doit plus arriver
317
-		else {
318
-			$a = trim($info['licence']);
319
-		}
320
-		if ($a) {
321
-			$s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre(
322
-				$a,
323
-				$dir
324
-			)) . "</dd>\n";
325
-		}
326
-	}
327
-
328
-	$s = "<dl class='description'>$s</dl>";
329
-
330
-	//
331
-	// Ajouter les infos techniques
332
-	//
333
-	$infotech = [];
334
-
335
-	$version = '<dt>' . _T('version') . '</dt><dd>' . $info['version'];
336
-	// Version VCS
337
-	if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) {
338
-		$version .= ' ' . $vcs;
339
-	}
340
-	$version .= '</dd>';
341
-	$infotech[] = $version;
342
-	$infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>';
343
-	// source zip le cas echeant
344
-	$infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log)
345
-		and preg_match(',^source:(.*)$,m', $log, $r))
346
-		? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>'
347
-		: '';
348
-
349
-	$infotech[] = !$info['necessite'] ? '' :
350
-		('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(
351
-			' ',
352
-			array_map('array_shift', $info['necessite'])
353
-		) . '</dd>');
354
-
355
-	$s .= "<dl class='tech'>"
356
-		. join('', $infotech)
357
-		. '</dl>';
358
-
359
-
360
-	return $s;
264
+    $log = null;
265
+    if (!$dir_plugins) {
266
+        $dir_plugins = _DIR_PLUGINS;
267
+    }
268
+
269
+    $prefix = $info['prefix'];
270
+    $dir = "$dir_plugins$plug_file/lang/paquet-$prefix";
271
+
272
+    $s = '';
273
+    // TODO: le traiter_multi ici n'est pas beau
274
+    // cf. description du plugin/_stable_/ortho/plugin.xml
275
+    // concerne les anciens plugin.xml donc on devrait plus en avoir besoin
276
+    $description = '';
277
+    if (isset($info['description'])) {
278
+        $description = plugin_propre($info['description'], $dir);
279
+    }
280
+
281
+    if (
282
+        isset($info['documentation'])
283
+        and $lien = $info['documentation']
284
+    ) {
285
+        $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>';
286
+    }
287
+    $s .= "<dd class='desc'>" . $description . "</dd>\n";
288
+
289
+    if (isset($info['auteur'])) {
290
+        if (is_array($info['auteur'])) {
291
+            $a = formater_credits($info['auteur'], ', ');
292
+        } // pour compat mais ne doit plus arriver
293
+        else {
294
+            $a = trim($info['auteur']);
295
+        }
296
+        if ($a) {
297
+            $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre(
298
+                $a,
299
+                $dir
300
+            )) . "</dd>\n";
301
+        }
302
+    }
303
+
304
+    if (isset($info['credit'])) {
305
+        if ($a = formater_credits($info['credit'], ', ')) {
306
+            $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre(
307
+                $a,
308
+                $dir
309
+            )) . "</dd>\n";
310
+        }
311
+    }
312
+
313
+    if (isset($info['licence'])) {
314
+        if (is_array($info['licence'])) {
315
+            $a = formater_credits($info['licence'], ', ');
316
+        } // pour compat mais ne doit plus arriver
317
+        else {
318
+            $a = trim($info['licence']);
319
+        }
320
+        if ($a) {
321
+            $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre(
322
+                $a,
323
+                $dir
324
+            )) . "</dd>\n";
325
+        }
326
+    }
327
+
328
+    $s = "<dl class='description'>$s</dl>";
329
+
330
+    //
331
+    // Ajouter les infos techniques
332
+    //
333
+    $infotech = [];
334
+
335
+    $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version'];
336
+    // Version VCS
337
+    if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) {
338
+        $version .= ' ' . $vcs;
339
+    }
340
+    $version .= '</dd>';
341
+    $infotech[] = $version;
342
+    $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>';
343
+    // source zip le cas echeant
344
+    $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log)
345
+        and preg_match(',^source:(.*)$,m', $log, $r))
346
+        ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>'
347
+        : '';
348
+
349
+    $infotech[] = !$info['necessite'] ? '' :
350
+        ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(
351
+            ' ',
352
+            array_map('array_shift', $info['necessite'])
353
+        ) . '</dd>');
354
+
355
+    $s .= "<dl class='tech'>"
356
+        . join('', $infotech)
357
+        . '</dl>';
358
+
359
+
360
+    return $s;
361 361
 }
362 362
 
363 363
 function formater_credits($infos, $sep = ', ') {
364
-	$texte = '';
365
-
366
-	foreach ($infos as $_credit) {
367
-		if ($texte) {
368
-			$texte .= $sep;
369
-		}
370
-		// Si le credit en cours n'est pas un array c'est donc un copyright
371
-		$texte .=
372
-			(!is_array($_credit))
373
-				? PtoBR(propre($_credit))
374
-				: ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') .
375
-				$_credit['nom'] .
376
-				($_credit['url'] ? '</a>' : '');
377
-	}
378
-
379
-	return $texte;
364
+    $texte = '';
365
+
366
+    foreach ($infos as $_credit) {
367
+        if ($texte) {
368
+            $texte .= $sep;
369
+        }
370
+        // Si le credit en cours n'est pas un array c'est donc un copyright
371
+        $texte .=
372
+            (!is_array($_credit))
373
+                ? PtoBR(propre($_credit))
374
+                : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') .
375
+                $_credit['nom'] .
376
+                ($_credit['url'] ? '</a>' : '');
377
+    }
378
+
379
+    return $texte;
380 380
 }
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/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
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.
Indentation   +389 added lines, -389 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)(\b[^>]*)?>(.*)</\1>,UimsS');
@@ -196,67 +196,67 @@  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
-	if (
210
-		($preg or strpos($letexte, '<') !== false)
211
-		and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
212
-	) {
213
-		foreach ($matches as $regs) {
214
-			// echappements tels quels ?
215
-			if ($no_transform) {
216
-				$echap = $regs[0];
217
-			} // sinon les traiter selon le cas
218
-			else {
219
-				if (
220
-					function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
221
-					or function_exists($f = $f . '_dist')
222
-				) {
223
-					$echap = $f($regs);
224
-				}
225
-			}
226
-
227
-			$p = strpos($letexte, (string) $regs[0]);
228
-			$letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
229
-		}
230
-	}
231
-
232
-	if ($no_transform) {
233
-		return $letexte;
234
-	}
235
-
236
-	// Echapper le php pour faire joli (ici, c'est pas pour la securite)
237
-	// seulement si on a echappe les <script>
238
-	// (derogatoire car on ne peut pas faire passer < ? ... ? >
239
-	// dans une callback autonommee
240
-	if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
241
-		if (
242
-			strpos($letexte, '<' . '?') !== false and preg_match_all(
243
-				',<[?].*($|[?]>),UisS',
244
-				$letexte,
245
-				$matches,
246
-				PREG_SET_ORDER
247
-			)
248
-		) {
249
-			foreach ($matches as $regs) {
250
-				$letexte = str_replace(
251
-					$regs[0],
252
-					code_echappement(highlight_string($regs[0], true), $source),
253
-					$letexte
254
-				);
255
-			}
256
-		}
257
-	}
258
-
259
-	return $letexte;
205
+    if (!is_string($letexte) or !strlen($letexte)) {
206
+        return $letexte;
207
+    }
208
+
209
+    if (
210
+        ($preg or strpos($letexte, '<') !== false)
211
+        and preg_match_all($preg ?: _PROTEGE_BLOCS, $letexte, $matches, PREG_SET_ORDER)
212
+    ) {
213
+        foreach ($matches as $regs) {
214
+            // echappements tels quels ?
215
+            if ($no_transform) {
216
+                $echap = $regs[0];
217
+            } // sinon les traiter selon le cas
218
+            else {
219
+                if (
220
+                    function_exists($f = $callback_prefix . 'traiter_echap_' . strtolower($regs[1]))
221
+                    or function_exists($f = $f . '_dist')
222
+                ) {
223
+                    $echap = $f($regs);
224
+                }
225
+            }
226
+
227
+            $p = strpos($letexte, (string) $regs[0]);
228
+            $letexte = substr_replace($letexte, code_echappement($echap, $source, $no_transform), $p, strlen($regs[0]));
229
+        }
230
+    }
231
+
232
+    if ($no_transform) {
233
+        return $letexte;
234
+    }
235
+
236
+    // Echapper le php pour faire joli (ici, c'est pas pour la securite)
237
+    // seulement si on a echappe les <script>
238
+    // (derogatoire car on ne peut pas faire passer < ? ... ? >
239
+    // dans une callback autonommee
240
+    if (strpos($preg ?: _PROTEGE_BLOCS, 'script') !== false) {
241
+        if (
242
+            strpos($letexte, '<' . '?') !== false and preg_match_all(
243
+                ',<[?].*($|[?]>),UisS',
244
+                $letexte,
245
+                $matches,
246
+                PREG_SET_ORDER
247
+            )
248
+        ) {
249
+            foreach ($matches as $regs) {
250
+                $letexte = str_replace(
251
+                    $regs[0],
252
+                    code_echappement(highlight_string($regs[0], true), $source),
253
+                    $letexte
254
+                );
255
+            }
256
+        }
257
+    }
258
+
259
+    return $letexte;
260 260
 }
261 261
 
262 262
 //
@@ -264,57 +264,57 @@  discard block
 block discarded – undo
264 264
 // Rq: $source sert a faire des echappements "a soi" qui ne sont pas nettoyes
265 265
 // par propre() : exemple dans multi et dans typo()
266 266
 function echappe_retour($letexte, $source = '', $filtre = '') {
267
-	if (strpos($letexte, (string) "base64$source")) {
268
-		# spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
269
-		$max_prof = 5;
270
-		while (
271
-			strpos($letexte, '<') !== false
272
-			and
273
-			preg_match_all(
274
-				',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
275
-				$letexte,
276
-				$regs,
277
-				PREG_SET_ORDER
278
-			)
279
-			and $max_prof--
280
-		) {
281
-			foreach ($regs as $reg) {
282
-				$rempl = base64_decode(extraire_attribut($reg[0], 'title'));
283
-				// recherche d'attributs supplementaires
284
-				$at = [];
285
-				foreach (['lang', 'dir'] as $attr) {
286
-					if ($a = extraire_attribut($reg[0], $attr)) {
287
-						$at[$attr] = $a;
288
-					}
289
-				}
290
-				if ($at) {
291
-					$rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
292
-					foreach ($at as $attr => $a) {
293
-						$rempl = inserer_attribut($rempl, $attr, $a);
294
-					}
295
-				}
296
-				if ($filtre) {
297
-					$rempl = $filtre($rempl);
298
-				}
299
-				$letexte = str_replace($reg[0], $rempl, $letexte);
300
-			}
301
-		}
302
-	}
303
-
304
-	return $letexte;
267
+    if (strpos($letexte, (string) "base64$source")) {
268
+        # spip_log(spip_htmlspecialchars($letexte));  ## pour les curieux
269
+        $max_prof = 5;
270
+        while (
271
+            strpos($letexte, '<') !== false
272
+            and
273
+            preg_match_all(
274
+                ',<(span|div)\sclass=[\'"]base64' . $source . '[\'"]\s(.*)>\s*</\1>,UmsS',
275
+                $letexte,
276
+                $regs,
277
+                PREG_SET_ORDER
278
+            )
279
+            and $max_prof--
280
+        ) {
281
+            foreach ($regs as $reg) {
282
+                $rempl = base64_decode(extraire_attribut($reg[0], 'title'));
283
+                // recherche d'attributs supplementaires
284
+                $at = [];
285
+                foreach (['lang', 'dir'] as $attr) {
286
+                    if ($a = extraire_attribut($reg[0], $attr)) {
287
+                        $at[$attr] = $a;
288
+                    }
289
+                }
290
+                if ($at) {
291
+                    $rempl = '<' . $reg[1] . '>' . $rempl . '</' . $reg[1] . '>';
292
+                    foreach ($at as $attr => $a) {
293
+                        $rempl = inserer_attribut($rempl, $attr, $a);
294
+                    }
295
+                }
296
+                if ($filtre) {
297
+                    $rempl = $filtre($rempl);
298
+                }
299
+                $letexte = str_replace($reg[0], $rempl, $letexte);
300
+            }
301
+        }
302
+    }
303
+
304
+    return $letexte;
305 305
 }
306 306
 
307 307
 // Reinserer le javascript de confiance (venant des modeles)
308 308
 
309 309
 function echappe_retour_modeles($letexte, $interdire_scripts = false) {
310
-	$letexte = echappe_retour($letexte);
310
+    $letexte = echappe_retour($letexte);
311 311
 
312
-	// Dans les appels directs hors squelette, securiser aussi ici
313
-	if ($interdire_scripts) {
314
-		$letexte = interdire_scripts($letexte);
315
-	}
312
+    // Dans les appels directs hors squelette, securiser aussi ici
313
+    if ($interdire_scripts) {
314
+        $letexte = interdire_scripts($letexte);
315
+    }
316 316
 
317
-	return trim($letexte);
317
+    return trim($letexte);
318 318
 }
319 319
 
320 320
 
@@ -342,131 +342,131 @@  discard block
 block discarded – undo
342 342
  *     Texte coupé
343 343
  **/
344 344
 function couper($texte, $taille = 50, $suite = null) {
345
-	if (!($length = strlen($texte)) or $taille <= 0) {
346
-		return '';
347
-	}
348
-	$offset = 400 + 2 * $taille;
349
-	while (
350
-		$offset < $length
351
-		and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
352
-	) {
353
-		$offset = 2 * $offset;
354
-	}
355
-	if (
356
-		$offset < $length
357
-		&& ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
358
-	) {
359
-		$p_tag_fermant = strpos($texte, '>', $offset);
360
-		if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
361
-			$offset = $p_tag_fermant + 1;
362
-		} // prolonger la coupe jusqu'au tag fermant suivant eventuel
363
-	}
364
-	$texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
365
-
366
-	if (!function_exists('nettoyer_raccourcis_typo')) {
367
-		include_spip('inc/lien');
368
-	}
369
-	$texte = nettoyer_raccourcis_typo($texte);
370
-
371
-	// balises de sauts de ligne et paragraphe
372
-	$texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
373
-	$texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
374
-
375
-	// on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
376
-	$texte = str_replace("\n\n", "\r", $texte);
377
-
378
-	// supprimer les tags
379
-	$texte = supprimer_tags($texte);
380
-	$texte = trim(str_replace("\n", ' ', $texte));
381
-	$texte .= "\n";  // marquer la fin
382
-
383
-	// corriger la longueur de coupe
384
-	// en fonction de la presence de caracteres utf
385
-	if ($GLOBALS['meta']['charset'] == 'utf-8') {
386
-		$long = charset2unicode($texte);
387
-		$long = spip_substr($long, 0, max($taille, 1));
388
-		$nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
389
-		$taille += $nbcharutf;
390
-	}
391
-
392
-
393
-	// couper au mot precedent
394
-	$long = spip_substr($texte, 0, max($taille - 4, 1));
395
-	$u = $GLOBALS['meta']['pcre_u'];
396
-	$court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
397
-	if (is_null($suite)) {
398
-		$suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
399
-	}
400
-	$points = $suite;
401
-
402
-	// trop court ? ne pas faire de (...)
403
-	if (spip_strlen($court) < max(0.75 * $taille, 2)) {
404
-		$points = '';
405
-		$long = spip_substr($texte, 0, $taille);
406
-		$texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
407
-		// encore trop court ? couper au caractere
408
-		if (spip_strlen($texte) < 0.75 * $taille) {
409
-			$texte = $long;
410
-		}
411
-	} else {
412
-		$texte = $court;
413
-	}
414
-
415
-	if (strpos($texte, "\n")) {  // la fin est encore la : c'est qu'on n'a pas de texte de suite
416
-	$points = '';
417
-	}
418
-
419
-	// remettre les paragraphes
420
-	$texte = preg_replace("/\r+/", "\n\n", $texte);
421
-
422
-	// supprimer l'eventuelle entite finale mal coupee
423
-	$texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
424
-
425
-	return quote_amp(trim($texte)) . $points;
345
+    if (!($length = strlen($texte)) or $taille <= 0) {
346
+        return '';
347
+    }
348
+    $offset = 400 + 2 * $taille;
349
+    while (
350
+        $offset < $length
351
+        and strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', substr($texte, 0, $offset))) < $taille
352
+    ) {
353
+        $offset = 2 * $offset;
354
+    }
355
+    if (
356
+        $offset < $length
357
+        && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null
358
+    ) {
359
+        $p_tag_fermant = strpos($texte, '>', $offset);
360
+        if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) {
361
+            $offset = $p_tag_fermant + 1;
362
+        } // prolonger la coupe jusqu'au tag fermant suivant eventuel
363
+    }
364
+    $texte = substr($texte, 0, $offset); /* eviter de travailler sur 10ko pour extraire 150 caracteres */
365
+
366
+    if (!function_exists('nettoyer_raccourcis_typo')) {
367
+        include_spip('inc/lien');
368
+    }
369
+    $texte = nettoyer_raccourcis_typo($texte);
370
+
371
+    // balises de sauts de ligne et paragraphe
372
+    $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r", $texte);
373
+    $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte);
374
+
375
+    // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier
376
+    $texte = str_replace("\n\n", "\r", $texte);
377
+
378
+    // supprimer les tags
379
+    $texte = supprimer_tags($texte);
380
+    $texte = trim(str_replace("\n", ' ', $texte));
381
+    $texte .= "\n";  // marquer la fin
382
+
383
+    // corriger la longueur de coupe
384
+    // en fonction de la presence de caracteres utf
385
+    if ($GLOBALS['meta']['charset'] == 'utf-8') {
386
+        $long = charset2unicode($texte);
387
+        $long = spip_substr($long, 0, max($taille, 1));
388
+        $nbcharutf = preg_match_all('/(&#[0-9]{3,6};)/S', $long, $matches);
389
+        $taille += $nbcharutf;
390
+    }
391
+
392
+
393
+    // couper au mot precedent
394
+    $long = spip_substr($texte, 0, max($taille - 4, 1));
395
+    $u = $GLOBALS['meta']['pcre_u'];
396
+    $court = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
397
+    if (is_null($suite)) {
398
+        $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : '&nbsp;(...)');
399
+    }
400
+    $points = $suite;
401
+
402
+    // trop court ? ne pas faire de (...)
403
+    if (spip_strlen($court) < max(0.75 * $taille, 2)) {
404
+        $points = '';
405
+        $long = spip_substr($texte, 0, $taille);
406
+        $texte = preg_replace("/([^\s][\s]+)[^\s]*\n?$/" . $u, "\\1", $long);
407
+        // encore trop court ? couper au caractere
408
+        if (spip_strlen($texte) < 0.75 * $taille) {
409
+            $texte = $long;
410
+        }
411
+    } else {
412
+        $texte = $court;
413
+    }
414
+
415
+    if (strpos($texte, "\n")) {  // la fin est encore la : c'est qu'on n'a pas de texte de suite
416
+    $points = '';
417
+    }
418
+
419
+    // remettre les paragraphes
420
+    $texte = preg_replace("/\r+/", "\n\n", $texte);
421
+
422
+    // supprimer l'eventuelle entite finale mal coupee
423
+    $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte);
424
+
425
+    return quote_amp(trim($texte)) . $points;
426 426
 }
427 427
 
428 428
 
429 429
 function protege_js_modeles($t) {
430
-	if (isset($GLOBALS['visiteur_session'])) {
431
-		if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
432
-			if (!defined('_PROTEGE_JS_MODELES')) {
433
-				include_spip('inc/acces');
434
-				define('_PROTEGE_JS_MODELES', creer_uniqid());
435
-			}
436
-			foreach ($r as $regs) {
437
-				$t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
438
-			}
439
-		}
440
-		if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
441
-			if (!defined('_PROTEGE_PHP_MODELES')) {
442
-				include_spip('inc/acces');
443
-				define('_PROTEGE_PHP_MODELES', creer_uniqid());
444
-			}
445
-			foreach ($r as $regs) {
446
-				$t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
447
-			}
448
-		}
449
-	}
450
-
451
-	return $t;
430
+    if (isset($GLOBALS['visiteur_session'])) {
431
+        if (preg_match_all(',<script.*?($|</script.),isS', $t, $r, PREG_SET_ORDER)) {
432
+            if (!defined('_PROTEGE_JS_MODELES')) {
433
+                include_spip('inc/acces');
434
+                define('_PROTEGE_JS_MODELES', creer_uniqid());
435
+            }
436
+            foreach ($r as $regs) {
437
+                $t = str_replace($regs[0], code_echappement($regs[0], 'javascript' . _PROTEGE_JS_MODELES), $t);
438
+            }
439
+        }
440
+        if (preg_match_all(',<\?php.*?($|\?' . '>),isS', $t, $r, PREG_SET_ORDER)) {
441
+            if (!defined('_PROTEGE_PHP_MODELES')) {
442
+                include_spip('inc/acces');
443
+                define('_PROTEGE_PHP_MODELES', creer_uniqid());
444
+            }
445
+            foreach ($r as $regs) {
446
+                $t = str_replace($regs[0], code_echappement($regs[0], 'php' . _PROTEGE_PHP_MODELES), $t);
447
+            }
448
+        }
449
+    }
450
+
451
+    return $t;
452 452
 }
453 453
 
454 454
 
455 455
 function echapper_faux_tags($letexte) {
456
-	if (strpos($letexte, '<') === false) {
457
-		return $letexte;
458
-	}
459
-	$textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
460
-
461
-	$letexte = '';
462
-	while (is_countable($textMatches) ? count($textMatches) : 0) {
463
-		// un texte a echapper
464
-		$letexte .= str_replace('<', '&lt;', array_shift($textMatches));
465
-		// un tag html qui a servit a faite le split
466
-		$letexte .= array_shift($textMatches);
467
-	}
468
-
469
-	return $letexte;
456
+    if (strpos($letexte, '<') === false) {
457
+        return $letexte;
458
+    }
459
+    $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE);
460
+
461
+    $letexte = '';
462
+    while (is_countable($textMatches) ? count($textMatches) : 0) {
463
+        // un texte a echapper
464
+        $letexte .= str_replace('<', '&lt;', array_shift($textMatches));
465
+        // un tag html qui a servit a faite le split
466
+        $letexte .= array_shift($textMatches);
467
+    }
468
+
469
+    return $letexte;
470 470
 }
471 471
 
472 472
 /**
@@ -479,47 +479,47 @@  discard block
 block discarded – undo
479 479
  * @return string
480 480
  */
481 481
 function echapper_html_suspect($texte, $strict = true) {
482
-	static $echapper_html_suspect;
483
-	if (!$texte or !is_string($texte)) {
484
-		return $texte;
485
-	}
486
-
487
-	if (!isset($echapper_html_suspect)) {
488
-		$echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
489
-	}
490
-	// si fonction personalisee, on delegue
491
-	if ($echapper_html_suspect) {
492
-		return $echapper_html_suspect($texte, $strict);
493
-	}
494
-
495
-	if (
496
-		strpos($texte, '<') === false
497
-		or strpos($texte, '=') === false
498
-	) {
499
-		return $texte;
500
-	}
501
-
502
-	// quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
503
-	// car sinon on declenche sur les modeles ou ressources
504
-	if (
505
-		!$strict and
506
-		(strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
507
-	) {
508
-		return $texte;
509
-	}
510
-
511
-	// on teste sur strlen car safehtml supprime le contenu dangereux
512
-	// mais il peut aussi changer des ' en " sur les attributs html,
513
-	// donc un test d'egalite est trop strict
514
-	if (strlen(safehtml($texte)) !== strlen($texte)) {
515
-		$texte = str_replace('<', '&lt;', $texte);
516
-		if (!function_exists('attribut_html')) {
517
-			include_spip('inc/filtres');
518
-		}
519
-		$texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
520
-	}
521
-
522
-	return $texte;
482
+    static $echapper_html_suspect;
483
+    if (!$texte or !is_string($texte)) {
484
+        return $texte;
485
+    }
486
+
487
+    if (!isset($echapper_html_suspect)) {
488
+        $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true);
489
+    }
490
+    // si fonction personalisee, on delegue
491
+    if ($echapper_html_suspect) {
492
+        return $echapper_html_suspect($texte, $strict);
493
+    }
494
+
495
+    if (
496
+        strpos($texte, '<') === false
497
+        or strpos($texte, '=') === false
498
+    ) {
499
+        return $texte;
500
+    }
501
+
502
+    // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx=
503
+    // car sinon on declenche sur les modeles ou ressources
504
+    if (
505
+        !$strict and
506
+        (strpos($texte, 'on') === false or !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte))
507
+    ) {
508
+        return $texte;
509
+    }
510
+
511
+    // on teste sur strlen car safehtml supprime le contenu dangereux
512
+    // mais il peut aussi changer des ' en " sur les attributs html,
513
+    // donc un test d'egalite est trop strict
514
+    if (strlen(safehtml($texte)) !== strlen($texte)) {
515
+        $texte = str_replace('<', '&lt;', $texte);
516
+        if (!function_exists('attribut_html')) {
517
+            include_spip('inc/filtres');
518
+        }
519
+        $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte;
520
+    }
521
+
522
+    return $texte;
523 523
 }
524 524
 
525 525
 
@@ -540,30 +540,30 @@  discard block
 block discarded – undo
540 540
  *      Texte sécurisé
541 541
  **/
542 542
 function safehtml($t) {
543
-	static $safehtml;
544
-
545
-	if (!$t or !is_string($t)) {
546
-		return $t;
547
-	}
548
-	# attention safehtml nettoie deux ou trois caracteres de plus. A voir
549
-	if (strpos($t, '<') === false) {
550
-		return str_replace("\x00", '', $t);
551
-	}
552
-
553
-	if (!function_exists('interdire_scripts')) {
554
-		include_spip('inc/texte');
555
-	}
556
-	$t = interdire_scripts($t); // jolifier le php
557
-	$t = echappe_js($t);
558
-
559
-	if (!isset($safehtml)) {
560
-		$safehtml = charger_fonction('safehtml', 'inc', true);
561
-	}
562
-	if ($safehtml) {
563
-		$t = $safehtml($t);
564
-	}
565
-
566
-	return interdire_scripts($t); // interdire le php (2 precautions)
543
+    static $safehtml;
544
+
545
+    if (!$t or !is_string($t)) {
546
+        return $t;
547
+    }
548
+    # attention safehtml nettoie deux ou trois caracteres de plus. A voir
549
+    if (strpos($t, '<') === false) {
550
+        return str_replace("\x00", '', $t);
551
+    }
552
+
553
+    if (!function_exists('interdire_scripts')) {
554
+        include_spip('inc/texte');
555
+    }
556
+    $t = interdire_scripts($t); // jolifier le php
557
+    $t = echappe_js($t);
558
+
559
+    if (!isset($safehtml)) {
560
+        $safehtml = charger_fonction('safehtml', 'inc', true);
561
+    }
562
+    if ($safehtml) {
563
+        $t = $safehtml($t);
564
+    }
565
+
566
+    return interdire_scripts($t); // interdire le php (2 precautions)
567 567
 }
568 568
 
569 569
 
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
  *     Texte sans les modèles d'image
586 586
  **/
587 587
 function supprime_img($letexte, $message = null) {
588
-	if ($message === null) {
589
-		$message = '(' . _T('img_indisponible') . ')';
590
-	}
591
-
592
-	return preg_replace(
593
-		',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
594
-		$message,
595
-		$letexte
596
-	);
588
+    if ($message === null) {
589
+        $message = '(' . _T('img_indisponible') . ')';
590
+    }
591
+
592
+    return preg_replace(
593
+        ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i',
594
+        $message,
595
+        $letexte
596
+    );
597 597
 }
Please login to merge, or discard this patch.
ecrire/xml/valider.php 2 patches
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.
Indentation   +293 added lines, -293 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
 /**
@@ -22,320 +22,320 @@  discard block
 block discarded – undo
22 22
  *     on a les memes methodes et variables que l'indenteur
23 23
  **/
24 24
 class ValidateurXML {
25
-	public function validerElement($phraseur, $name, $attrs) {
26
-		if (!($p = isset($this->dtc->elements[$name]))) {
27
-			if ($p = strpos($name, ':')) {
28
-				$name = substr($name, $p + 1);
29
-				$p = isset($this->dtc->elements[$name]);
30
-			}
31
-			if (!$p) {
32
-				coordonnees_erreur($this, " <b>$name</b>&nbsp;: "
33
-					. _T('zxml_inconnu_balise'));
25
+    public function validerElement($phraseur, $name, $attrs) {
26
+        if (!($p = isset($this->dtc->elements[$name]))) {
27
+            if ($p = strpos($name, ':')) {
28
+                $name = substr($name, $p + 1);
29
+                $p = isset($this->dtc->elements[$name]);
30
+            }
31
+            if (!$p) {
32
+                coordonnees_erreur($this, " <b>$name</b>&nbsp;: "
33
+                    . _T('zxml_inconnu_balise'));
34 34
 
35
-				return;
36
-			}
37
-		}
38
-		// controler les filles illegitimes, ca suffit
39
-		$depth = $this->depth;
40
-		$ouvrant = $this->ouvrant;
41
-		#spip_log("trouve $name apres " . $ouvrant[$depth]);
42
-		if (isset($ouvrant[$depth])) {
43
-			if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) {
44
-				$pere = $r[1];
45
-				#spip_log("pere $pere");
46
-				if (isset($this->dtc->elements[$pere])) {
47
-					$fils = $this->dtc->elements[$pere];
48
-					#spip_log("rejeton $name fils " . @join(',',$fils));
49
-					if (!($p = @in_array($name, $fils))) {
50
-						if ($p = strpos($name, ':')) {
51
-							$p = substr($name, $p + 1);
52
-							$p = @in_array($p, $fils);
53
-						}
54
-					}
55
-					if (!$p) {
56
-						$bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]);
57
-						coordonnees_erreur($this, " <b>$name</b> "
58
-							. _T('zxml_non_fils')
59
-							. ' <b>'
60
-							. $pere
61
-							. '</b>'
62
-							. (!$bons_peres ? ''
63
-								: ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
64
-					} elseif ($this->dtc->regles[$pere][0] == '/') {
65
-						$frat = substr($depth, 2);
66
-						if (!isset($this->fratrie[$frat])) {
67
-							$this->fratrie[$frat] = '';
68
-						}
69
-						$this->fratrie[$frat] .= "$name ";
70
-					}
71
-				}
72
-			}
73
-		}
74
-		// Init de la suite des balises a memoriser si regle difficile
75
-		if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') {
76
-			$this->fratrie[$depth] = '';
77
-		}
78
-		if (isset($this->dtc->attributs[$name])) {
79
-			foreach ($this->dtc->attributs[$name] as $n => $v) {
80
-				if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) {
81
-					coordonnees_erreur($this, " <b>$n</b>"
82
-						. '&nbsp;:&nbsp;'
83
-						. _T('zxml_obligatoire_attribut')
84
-						. " <b>$name</b>");
85
-				}
86
-			}
87
-		}
88
-	}
35
+                return;
36
+            }
37
+        }
38
+        // controler les filles illegitimes, ca suffit
39
+        $depth = $this->depth;
40
+        $ouvrant = $this->ouvrant;
41
+        #spip_log("trouve $name apres " . $ouvrant[$depth]);
42
+        if (isset($ouvrant[$depth])) {
43
+            if (preg_match('/^\s*(\w+)/', $ouvrant[$depth], $r)) {
44
+                $pere = $r[1];
45
+                #spip_log("pere $pere");
46
+                if (isset($this->dtc->elements[$pere])) {
47
+                    $fils = $this->dtc->elements[$pere];
48
+                    #spip_log("rejeton $name fils " . @join(',',$fils));
49
+                    if (!($p = @in_array($name, $fils))) {
50
+                        if ($p = strpos($name, ':')) {
51
+                            $p = substr($name, $p + 1);
52
+                            $p = @in_array($p, $fils);
53
+                        }
54
+                    }
55
+                    if (!$p) {
56
+                        $bons_peres = @join('</b>, <b>', $this->dtc->peres[$name]);
57
+                        coordonnees_erreur($this, " <b>$name</b> "
58
+                            . _T('zxml_non_fils')
59
+                            . ' <b>'
60
+                            . $pere
61
+                            . '</b>'
62
+                            . (!$bons_peres ? ''
63
+                                : ('<p style="font-size: 80%"> ' . _T('zxml_mais_de') . ' <b>' . $bons_peres . '</b></p>')));
64
+                    } elseif ($this->dtc->regles[$pere][0] == '/') {
65
+                        $frat = substr($depth, 2);
66
+                        if (!isset($this->fratrie[$frat])) {
67
+                            $this->fratrie[$frat] = '';
68
+                        }
69
+                        $this->fratrie[$frat] .= "$name ";
70
+                    }
71
+                }
72
+            }
73
+        }
74
+        // Init de la suite des balises a memoriser si regle difficile
75
+        if ($this->dtc->regles[$name] and $this->dtc->regles[$name][0] == '/') {
76
+            $this->fratrie[$depth] = '';
77
+        }
78
+        if (isset($this->dtc->attributs[$name])) {
79
+            foreach ($this->dtc->attributs[$name] as $n => $v) {
80
+                if (($v[1] == '#REQUIRED') and (!isset($attrs[$n]))) {
81
+                    coordonnees_erreur($this, " <b>$n</b>"
82
+                        . '&nbsp;:&nbsp;'
83
+                        . _T('zxml_obligatoire_attribut')
84
+                        . " <b>$name</b>");
85
+                }
86
+            }
87
+        }
88
+    }
89 89
 
90
-	public function validerAttribut($phraseur, $name, $val, $bal) {
91
-		// Si la balise est inconnue, eviter d'insister
92
-		if (!isset($this->dtc->attributs[$bal])) {
93
-			return;
94
-		}
90
+    public function validerAttribut($phraseur, $name, $val, $bal) {
91
+        // Si la balise est inconnue, eviter d'insister
92
+        if (!isset($this->dtc->attributs[$bal])) {
93
+            return;
94
+        }
95 95
 
96
-		$a = $this->dtc->attributs[$bal];
97
-		if (!isset($a[$name])) {
98
-			$bons = join(', ', array_keys($a));
99
-			if ($bons) {
100
-				$bons = " title=' " .
101
-					_T('zxml_connus_attributs') .
102
-					'&nbsp;: ' .
103
-					$bons .
104
-					"'";
105
-			}
106
-			$bons .= " style='font-weight: bold'";
107
-			coordonnees_erreur($this, " <b>$name</b> "
108
-				. _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
109
-				. " <a$bons>$bal</a> ("
110
-				. _T('zxml_survoler')
111
-				. ')');
112
-		} else {
113
-			$type = $a[$name][0];
114
-			if (!preg_match('/^\w+$/', $type)) {
115
-				$this->valider_motif($phraseur, $name, $val, $bal, $type);
116
-			} else {
117
-				if (method_exists($this, $f = 'validerAttribut_' . $type)) {
118
-					$this->$f($phraseur, $name, $val, $bal);
119
-				}
120
-			}
121
-			#		else spip_log("$type type d'attribut inconnu");
122
-		}
123
-	}
96
+        $a = $this->dtc->attributs[$bal];
97
+        if (!isset($a[$name])) {
98
+            $bons = join(', ', array_keys($a));
99
+            if ($bons) {
100
+                $bons = " title=' " .
101
+                    _T('zxml_connus_attributs') .
102
+                    '&nbsp;: ' .
103
+                    $bons .
104
+                    "'";
105
+            }
106
+            $bons .= " style='font-weight: bold'";
107
+            coordonnees_erreur($this, " <b>$name</b> "
108
+                . _T('zxml_inconnu_attribut') . ' ' . _T('zxml_de')
109
+                . " <a$bons>$bal</a> ("
110
+                . _T('zxml_survoler')
111
+                . ')');
112
+        } else {
113
+            $type = $a[$name][0];
114
+            if (!preg_match('/^\w+$/', $type)) {
115
+                $this->valider_motif($phraseur, $name, $val, $bal, $type);
116
+            } else {
117
+                if (method_exists($this, $f = 'validerAttribut_' . $type)) {
118
+                    $this->$f($phraseur, $name, $val, $bal);
119
+                }
120
+            }
121
+            #		else spip_log("$type type d'attribut inconnu");
122
+        }
123
+    }
124 124
 
125
-	public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) {
126
-		$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN);
127
-	}
125
+    public function validerAttribut_NMTOKEN($phraseur, $name, $val, $bal) {
126
+        $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKEN);
127
+    }
128 128
 
129
-	public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) {
130
-		$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS);
131
-	}
129
+    public function validerAttribut_NMTOKENS($phraseur, $name, $val, $bal) {
130
+        $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_NMTOKENS);
131
+    }
132 132
 
133
-	public function validerAttribut_ID($phraseur, $name, $val, $bal) {
134
-		if (isset($this->ids[$val])) {
135
-			[$l, $c] = $this->ids[$val];
136
-			coordonnees_erreur($this, " <p><b>$val</b> "
137
-				. _T('zxml_valeur_attribut')
138
-				. " <b>$name</b> "
139
-				. _T('zxml_de')
140
-				. " <b>$bal</b> "
141
-				. _T('zxml_vu')
142
-				. " (L$l,C$c)");
143
-		} else {
144
-			$this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID);
145
-			$this->ids[$val] = [xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
146
-		}
147
-	}
133
+    public function validerAttribut_ID($phraseur, $name, $val, $bal) {
134
+        if (isset($this->ids[$val])) {
135
+            [$l, $c] = $this->ids[$val];
136
+            coordonnees_erreur($this, " <p><b>$val</b> "
137
+                . _T('zxml_valeur_attribut')
138
+                . " <b>$name</b> "
139
+                . _T('zxml_de')
140
+                . " <b>$bal</b> "
141
+                . _T('zxml_vu')
142
+                . " (L$l,C$c)");
143
+        } else {
144
+            $this->valider_motif($phraseur, $name, $val, $bal, _REGEXP_ID);
145
+            $this->ids[$val] = [xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
146
+        }
147
+    }
148 148
 
149
-	public function validerAttribut_IDREF($phraseur, $name, $val, $bal) {
150
-		$this->idrefs[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
151
-	}
149
+    public function validerAttribut_IDREF($phraseur, $name, $val, $bal) {
150
+        $this->idrefs[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
151
+    }
152 152
 
153
-	public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) {
154
-		$this->idrefss[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
155
-	}
153
+    public function validerAttribut_IDREFS($phraseur, $name, $val, $bal) {
154
+        $this->idrefss[] = [$val, xml_get_current_line_number($phraseur), xml_get_current_column_number($phraseur)];
155
+    }
156 156
 
157
-	public function valider_motif($phraseur, $name, $val, $bal, $motif) {
158
-		if (!preg_match($motif, $val)) {
159
-			coordonnees_erreur($this, "<b>$val</b> "
160
-				. _T('zxml_valeur_attribut')
161
-				. " <b>$name</b> "
162
-				. _T('zxml_de')
163
-				. " <b>$bal</b> "
164
-				. _T('zxml_non_conforme')
165
-				. '</p><p>'
166
-				. '<b>' . $motif . '</b>');
167
-		}
168
-	}
157
+    public function valider_motif($phraseur, $name, $val, $bal, $motif) {
158
+        if (!preg_match($motif, $val)) {
159
+            coordonnees_erreur($this, "<b>$val</b> "
160
+                . _T('zxml_valeur_attribut')
161
+                . " <b>$name</b> "
162
+                . _T('zxml_de')
163
+                . " <b>$bal</b> "
164
+                . _T('zxml_non_conforme')
165
+                . '</p><p>'
166
+                . '<b>' . $motif . '</b>');
167
+        }
168
+    }
169 169
 
170
-	public function valider_idref($nom, $ligne, $col) {
171
-		if (!isset($this->ids[$nom])) {
172
-			$this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
173
-		}
174
-	}
170
+    public function valider_idref($nom, $ligne, $col) {
171
+        if (!isset($this->ids[$nom])) {
172
+            $this->err[] = [" <p><b>$nom</b> " . _T('zxml_inconnu_id'), $ligne, $col];
173
+        }
174
+    }
175 175
 
176
-	public function valider_passe2() {
177
-		if (!$this->err) {
178
-			foreach ($this->idrefs as $idref) {
179
-				[$nom, $ligne, $col] = $idref;
180
-				$this->valider_idref($nom, $ligne, $col);
181
-			}
182
-			foreach ($this->idrefss as $idref) {
183
-				[$noms, $ligne, $col] = $idref;
184
-				foreach (preg_split('/\s+/', $noms) as $nom) {
185
-					$this->valider_idref($nom, $ligne, $col);
186
-				}
187
-			}
188
-		}
189
-	}
176
+    public function valider_passe2() {
177
+        if (!$this->err) {
178
+            foreach ($this->idrefs as $idref) {
179
+                [$nom, $ligne, $col] = $idref;
180
+                $this->valider_idref($nom, $ligne, $col);
181
+            }
182
+            foreach ($this->idrefss as $idref) {
183
+                [$noms, $ligne, $col] = $idref;
184
+                foreach (preg_split('/\s+/', $noms) as $nom) {
185
+                    $this->valider_idref($nom, $ligne, $col);
186
+                }
187
+            }
188
+        }
189
+    }
190 190
 
191
-	public function debutElement($phraseur, $name, $attrs) {
192
-		if ($this->dtc->elements) {
193
-			$this->validerElement($phraseur, $name, $attrs);
194
-		}
191
+    public function debutElement($phraseur, $name, $attrs) {
192
+        if ($this->dtc->elements) {
193
+            $this->validerElement($phraseur, $name, $attrs);
194
+        }
195 195
 
196
-		if ($f = $this->process['debut']) {
197
-			$f($this, $name, $attrs);
198
-		}
199
-		$depth = $this->depth;
200
-		$this->debuts[$depth] = strlen($this->res);
201
-		foreach ($attrs as $k => $v) {
202
-			$this->validerAttribut($phraseur, $k, $v, $name);
203
-		}
204
-	}
196
+        if ($f = $this->process['debut']) {
197
+            $f($this, $name, $attrs);
198
+        }
199
+        $depth = $this->depth;
200
+        $this->debuts[$depth] = strlen($this->res);
201
+        foreach ($attrs as $k => $v) {
202
+            $this->validerAttribut($phraseur, $k, $v, $name);
203
+        }
204
+    }
205 205
 
206
-	public function finElement($phraseur, $name) {
207
-		$depth = $this->depth;
208
-		$contenu = $this->contenu;
206
+    public function finElement($phraseur, $name) {
207
+        $depth = $this->depth;
208
+        $contenu = $this->contenu;
209 209
 
210
-		$n = strlen($this->res);
211
-		$c = strlen(trim($contenu[$depth]));
212
-		$k = $this->debuts[$depth];
210
+        $n = strlen($this->res);
211
+        $c = strlen(trim($contenu[$depth]));
212
+        $k = $this->debuts[$depth];
213 213
 
214
-		$regle = $this->dtc->regles[$name] ?? false;
215
-		$vide = ($regle == 'EMPTY');
216
-		// controler que les balises devant etre vides le sont
217
-		if ($vide) {
218
-			if ($n <> ($k + $c)) {
219
-				coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
220
-			}
221
-			// pour les regles PCDATA ou iteration de disjonction, tout est fait
222
-		} elseif ($regle and ($regle != '*')) {
223
-			if ($regle == '+') {
224
-				// iteration de disjonction non vide: 1 balise au -
225
-				if ($n == $k) {
226
-					coordonnees_erreur($this, "<p>\n<b>$name</b> "
227
-						. _T('zxml_vide_balise'));
228
-				}
229
-			} else {
230
-				$f = $this->fratrie[substr($depth, 2)] ?? null;
231
-				if (is_null($f) or !preg_match($regle, $f)) {
232
-					coordonnees_erreur(
233
-						$this,
234
-						" <p>\n<b>$name</b> "
235
-						. _T('zxml_succession_fils_incorrecte')
236
-						. '&nbsp;: <b>'
237
-						. $f
238
-						. '</b>'
239
-					);
240
-				}
241
-			}
242
-		}
243
-		if ($f = $this->process['fin']) {
244
-			$f($this, $name, $vide);
245
-		}
246
-	}
214
+        $regle = $this->dtc->regles[$name] ?? false;
215
+        $vide = ($regle == 'EMPTY');
216
+        // controler que les balises devant etre vides le sont
217
+        if ($vide) {
218
+            if ($n <> ($k + $c)) {
219
+                coordonnees_erreur($this, " <p><b>$name</b> " . _T('zxml_nonvide_balise'));
220
+            }
221
+            // pour les regles PCDATA ou iteration de disjonction, tout est fait
222
+        } elseif ($regle and ($regle != '*')) {
223
+            if ($regle == '+') {
224
+                // iteration de disjonction non vide: 1 balise au -
225
+                if ($n == $k) {
226
+                    coordonnees_erreur($this, "<p>\n<b>$name</b> "
227
+                        . _T('zxml_vide_balise'));
228
+                }
229
+            } else {
230
+                $f = $this->fratrie[substr($depth, 2)] ?? null;
231
+                if (is_null($f) or !preg_match($regle, $f)) {
232
+                    coordonnees_erreur(
233
+                        $this,
234
+                        " <p>\n<b>$name</b> "
235
+                        . _T('zxml_succession_fils_incorrecte')
236
+                        . '&nbsp;: <b>'
237
+                        . $f
238
+                        . '</b>'
239
+                    );
240
+                }
241
+            }
242
+        }
243
+        if ($f = $this->process['fin']) {
244
+            $f($this, $name, $vide);
245
+        }
246
+    }
247 247
 
248
-	public function textElement($phraseur, $data) {
249
-		if (trim($data)) {
250
-			$d = $this->depth;
251
-			$d = $this->ouvrant[$d];
252
-			preg_match('/^\s*(\S+)/', $d, $m);
253
-			if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
254
-				coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
255
-					. _T('zxml_nonvide_balise')); // message a affiner
256
-			}
257
-		}
258
-		if ($f = $this->process['text']) {
259
-			$f($this, $data);
260
-		}
261
-	}
248
+    public function textElement($phraseur, $data) {
249
+        if (trim($data)) {
250
+            $d = $this->depth;
251
+            $d = $this->ouvrant[$d];
252
+            preg_match('/^\s*(\S+)/', $d, $m);
253
+            if (isset($this->dtc->pcdata[$m[1]]) and ($this->dtc->pcdata[$m[1]])) {
254
+                coordonnees_erreur($this, ' <p><b>' . $m[1] . '</b> '
255
+                    . _T('zxml_nonvide_balise')); // message a affiner
256
+            }
257
+        }
258
+        if ($f = $this->process['text']) {
259
+            $f($this, $data);
260
+        }
261
+    }
262 262
 
263
-	public function piElement($phraseur, $target, $data) {
264
-		if ($f = $this->process['pi']) {
265
-			$f($this, $target, $data);
266
-		}
267
-	}
263
+    public function piElement($phraseur, $target, $data) {
264
+        if ($f = $this->process['pi']) {
265
+            $f($this, $target, $data);
266
+        }
267
+    }
268 268
 
269
-	// Denonciation des entitees XML inconnues
270
-	// Pour contourner le bug de conception de SAX qui ne signale pas si elles
271
-	// sont dans un attribut, les  entites les plus frequentes ont ete
272
-	// transcodees au prealable  (sauf & < > " que SAX traite correctement).
273
-	// On ne les verra donc pas passer a cette etape, contrairement a ce que
274
-	// le source de la page laisse legitimement supposer.
269
+    // Denonciation des entitees XML inconnues
270
+    // Pour contourner le bug de conception de SAX qui ne signale pas si elles
271
+    // sont dans un attribut, les  entites les plus frequentes ont ete
272
+    // transcodees au prealable  (sauf & < > " que SAX traite correctement).
273
+    // On ne les verra donc pas passer a cette etape, contrairement a ce que
274
+    // le source de la page laisse legitimement supposer.
275 275
 
276
-	public function defaultElement($phraseur, $data) {
277
-		if (
278
-			!preg_match('/^<!--/', $data)
279
-			and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))
280
-		) {
281
-			foreach ($r as $m) {
282
-				[$t, $e] = $m;
283
-				if (!isset($this->dtc->entites[$e])) {
284
-					coordonnees_erreur($this, " <b>$e</b> "
285
-						. _T('zxml_inconnu_entite')
286
-						. ' ');
287
-				}
288
-			}
289
-		}
290
-		if (isset($this->process['default']) and ($f = $this->process['default'])) {
291
-			$f($this, $data);
292
-		}
293
-	}
276
+    public function defaultElement($phraseur, $data) {
277
+        if (
278
+            !preg_match('/^<!--/', $data)
279
+            and (preg_match_all('/&([^;]*)?/', $data, $r, PREG_SET_ORDER))
280
+        ) {
281
+            foreach ($r as $m) {
282
+                [$t, $e] = $m;
283
+                if (!isset($this->dtc->entites[$e])) {
284
+                    coordonnees_erreur($this, " <b>$e</b> "
285
+                        . _T('zxml_inconnu_entite')
286
+                        . ' ');
287
+                }
288
+            }
289
+        }
290
+        if (isset($this->process['default']) and ($f = $this->process['default'])) {
291
+            $f($this, $data);
292
+        }
293
+    }
294 294
 
295
-	public function phraserTout($phraseur, $data) {
296
-		xml_parsestring($this, $data);
295
+    public function phraserTout($phraseur, $data) {
296
+        xml_parsestring($this, $data);
297 297
 
298
-		if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
299
-			$this->err[] = ['DOCTYPE ?', 0, 0];
300
-		} else {
301
-			$this->valider_passe2();
302
-		}
303
-	}
298
+        if (!$this->dtc or preg_match(',^' . _MESSAGE_DOCTYPE . ',', $data)) {
299
+            $this->err[] = ['DOCTYPE ?', 0, 0];
300
+        } else {
301
+            $this->valider_passe2();
302
+        }
303
+    }
304 304
 
305
-	/**
306
-	 * Constructeur
307
-	 *
308
-	 * @param array $process ?
309
-	 **/
310
-	public function __construct($process = []) {
311
-		if (is_array($process)) {
312
-			$this->process = $process;
313
-		}
314
-	}
305
+    /**
306
+     * Constructeur
307
+     *
308
+     * @param array $process ?
309
+     **/
310
+    public function __construct($process = []) {
311
+        if (is_array($process)) {
312
+            $this->process = $process;
313
+        }
314
+    }
315 315
 
316
-	public $ids = [];
317
-	public $idrefs = [];
318
-	public $idrefss = [];
319
-	public $debuts = [];
320
-	public $fratrie = [];
316
+    public $ids = [];
317
+    public $idrefs = [];
318
+    public $idrefss = [];
319
+    public $debuts = [];
320
+    public $fratrie = [];
321 321
 
322
-	public $dtc = null;
323
-	public $sax = null;
324
-	public $depth = '';
325
-	public $entete = '';
326
-	public $page = '';
327
-	public $res = '';
328
-	public $err = [];
329
-	public $contenu = [];
330
-	public $ouvrant = [];
331
-	public $reperes = [];
332
-	public $process = [
333
-		'debut' => 'xml_debutElement',
334
-		'fin' => 'xml_finElement',
335
-		'text' => 'xml_textElement',
336
-		'pi' => 'xml_piElement',
337
-		'default' => 'xml_defaultElement'
338
-	];
322
+    public $dtc = null;
323
+    public $sax = null;
324
+    public $depth = '';
325
+    public $entete = '';
326
+    public $page = '';
327
+    public $res = '';
328
+    public $err = [];
329
+    public $contenu = [];
330
+    public $ouvrant = [];
331
+    public $reperes = [];
332
+    public $process = [
333
+        'debut' => 'xml_debutElement',
334
+        'fin' => 'xml_finElement',
335
+        'text' => 'xml_textElement',
336
+        'pi' => 'xml_piElement',
337
+        'default' => 'xml_defaultElement'
338
+    ];
339 339
 }
340 340
 
341 341
 
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
  *
346 346
  **/
347 347
 function xml_valider_dist($page, $apply = false, $process = false, $doctype = '', $charset = null) {
348
-	$f = new ValidateurXML($process);
349
-	$sax = charger_fonction('sax', 'xml');
348
+    $f = new ValidateurXML($process);
349
+    $sax = charger_fonction('sax', 'xml');
350 350
 
351
-	return $sax($page, $apply, $f, $doctype, $charset);
351
+    return $sax($page, $apply, $f, $doctype, $charset);
352 352
 }
Please login to merge, or discard this patch.
ecrire/install/etape_ldap4.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -11,96 +11,96 @@
 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('auth/ldap');
18 18
 
19 19
 function install_etape_ldap4_dist() {
20
-	$adresse_ldap = _request('adresse_ldap');
21
-	$login_ldap = _request('login_ldap');
22
-	$pass_ldap = _request('pass_ldap');
23
-	$port_ldap = _request('port_ldap');
24
-	$base_ldap = _request('base_ldap');
25
-	$base_ldap_text = _request('base_ldap_text');
26
-	if (!$base_ldap) {
27
-		$base_ldap = $base_ldap_text;
28
-	}
29
-
30
-	echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"');
31
-
32
-	$ldap_link = ldap_connect($adresse_ldap, $port_ldap);
33
-	@ldap_bind($ldap_link, $login_ldap, $pass_ldap);
34
-
35
-	// Essayer de verifier le chemin fourni
36
-	$r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', '');
37
-	$fail = (ldap_errno($ldap_link) == 32);
38
-
39
-	if ($fail) {
40
-		echo info_etape(_T('info_chemin_acces_annuaire')),
41
-		info_progression_etape(3, 'etape_ldap', 'install/', true),
42
-			"<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'),
43
-			' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>';
44
-	} else {
45
-		info_etape(_T('info_reglage_ldap'));
46
-		echo info_progression_etape(4, 'etape_ldap', 'install/');
47
-
48
-		$statuts = liste_statuts_ldap();
49
-		$statut_ldap = defined('_INSTALL_STATUT_LDAP')
50
-			? _INSTALL_STATUT_LDAP
51
-			: $GLOBALS['liste_des_statuts']['info_redacteurs'];
52
-
53
-
54
-		$res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap'])
55
-			. "<input type='hidden' name='etape' value='ldap5' />"
56
-			. "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />"
57
-			. fieldset(
58
-				_T('info_statut_utilisateurs_1'),
59
-				[
60
-					'statut_ldap' => [
61
-						'label' => _T('info_statut_utilisateurs_2') . '<br />',
62
-						'valeur' => $statut_ldap,
63
-						'alternatives' => $statuts
64
-					]
65
-				]
66
-			)
67
-			. install_ldap_correspondances()
68
-			. bouton_suivant();
69
-
70
-		echo generer_form_ecrire('install', $res);
71
-	}
72
-
73
-	echo install_fin_html();
20
+    $adresse_ldap = _request('adresse_ldap');
21
+    $login_ldap = _request('login_ldap');
22
+    $pass_ldap = _request('pass_ldap');
23
+    $port_ldap = _request('port_ldap');
24
+    $base_ldap = _request('base_ldap');
25
+    $base_ldap_text = _request('base_ldap_text');
26
+    if (!$base_ldap) {
27
+        $base_ldap = $base_ldap_text;
28
+    }
29
+
30
+    echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"');
31
+
32
+    $ldap_link = ldap_connect($adresse_ldap, $port_ldap);
33
+    @ldap_bind($ldap_link, $login_ldap, $pass_ldap);
34
+
35
+    // Essayer de verifier le chemin fourni
36
+    $r = @ldap_compare($ldap_link, $base_ldap, 'objectClass', '');
37
+    $fail = (ldap_errno($ldap_link) == 32);
38
+
39
+    if ($fail) {
40
+        echo info_etape(_T('info_chemin_acces_annuaire')),
41
+        info_progression_etape(3, 'etape_ldap', 'install/', true),
42
+            "<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'),
43
+            ' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>';
44
+    } else {
45
+        info_etape(_T('info_reglage_ldap'));
46
+        echo info_progression_etape(4, 'etape_ldap', 'install/');
47
+
48
+        $statuts = liste_statuts_ldap();
49
+        $statut_ldap = defined('_INSTALL_STATUT_LDAP')
50
+            ? _INSTALL_STATUT_LDAP
51
+            : $GLOBALS['liste_des_statuts']['info_redacteurs'];
52
+
53
+
54
+        $res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap'])
55
+            . "<input type='hidden' name='etape' value='ldap5' />"
56
+            . "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />"
57
+            . fieldset(
58
+                _T('info_statut_utilisateurs_1'),
59
+                [
60
+                    'statut_ldap' => [
61
+                        'label' => _T('info_statut_utilisateurs_2') . '<br />',
62
+                        'valeur' => $statut_ldap,
63
+                        'alternatives' => $statuts
64
+                    ]
65
+                ]
66
+            )
67
+            . install_ldap_correspondances()
68
+            . bouton_suivant();
69
+
70
+        echo generer_form_ecrire('install', $res);
71
+    }
72
+
73
+    echo install_fin_html();
74 74
 }
75 75
 
76 76
 function liste_statuts_ldap() {
77
-	$recom = [
78
-		'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'),
79
-		'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'),
80
-		'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />')
81
-	];
82
-
83
-	$res = [];
84
-	foreach ($GLOBALS['liste_des_statuts'] as $k => $v) {
85
-		if (isset($recom[$k])) {
86
-			$res[$v] = $recom[$k];
87
-		}
88
-	}
89
-
90
-	return $res;
77
+    $recom = [
78
+        'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'),
79
+        'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'),
80
+        'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />')
81
+    ];
82
+
83
+    $res = [];
84
+    foreach ($GLOBALS['liste_des_statuts'] as $k => $v) {
85
+        if (isset($recom[$k])) {
86
+            $res[$v] = $recom[$k];
87
+        }
88
+    }
89
+
90
+    return $res;
91 91
 }
92 92
 
93 93
 function install_ldap_correspondances() {
94
-	$champs = [];
95
-	foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) {
96
-		$nom = 'ldap_' . $champ;
97
-		$val = is_array($v) ? join(',', $v) : strval($v);
98
-		$champs[$nom] = [
99
-			'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />',
100
-			'valeur' => $val
101
-		];
102
-	}
103
-
104
-	return !$champs ?
105
-		'' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />');
94
+    $champs = [];
95
+    foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) {
96
+        $nom = 'ldap_' . $champ;
97
+        $val = is_array($v) ? join(',', $v) : strval($v);
98
+        $champs[$nom] = [
99
+            'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />',
100
+            'valeur' => $val
101
+        ];
102
+    }
103
+
104
+    return !$champs ?
105
+        '' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />');
106 106
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 	if ($fail) {
40 40
 		echo info_etape(_T('info_chemin_acces_annuaire')),
41 41
 		info_progression_etape(3, 'etape_ldap', 'install/', true),
42
-			"<div class='error'><p><b>" . _T('avis_operation_echec') . '</b></p><p>' . _T('avis_chemin_invalide_1'),
43
-			' (<tt>' . spip_htmlspecialchars($base_ldap) . '</tt>) ' . _T('avis_chemin_invalide_2') . '</p></div>';
42
+			"<div class='error'><p><b>"._T('avis_operation_echec').'</b></p><p>'._T('avis_chemin_invalide_1'),
43
+			' (<tt>'.spip_htmlspecialchars($base_ldap).'</tt>) '._T('avis_chemin_invalide_2').'</p></div>';
44 44
 	} else {
45 45
 		info_etape(_T('info_reglage_ldap'));
46 46
 		echo info_progression_etape(4, 'etape_ldap', 'install/');
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 
54 54
 		$res = install_propager(['adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap'])
55 55
 			. "<input type='hidden' name='etape' value='ldap5' />"
56
-			. "<input type='hidden' name='base_ldap' value='" . spip_htmlentities($base_ldap) . "' />"
56
+			. "<input type='hidden' name='base_ldap' value='".spip_htmlentities($base_ldap)."' />"
57 57
 			. fieldset(
58 58
 				_T('info_statut_utilisateurs_1'),
59 59
 				[
60 60
 					'statut_ldap' => [
61
-						'label' => _T('info_statut_utilisateurs_2') . '<br />',
61
+						'label' => _T('info_statut_utilisateurs_2').'<br />',
62 62
 						'valeur' => $statut_ldap,
63 63
 						'alternatives' => $statuts
64 64
 					]
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 
76 76
 function liste_statuts_ldap() {
77 77
 	$recom = [
78
-		'info_administrateurs' => ('<b>' . _T('info_administrateur_1') . '</b> ' . _T('info_administrateur_2') . '<br />'),
79
-		'info_redacteurs' => ('<b>' . _T('info_redacteur_1') . '</b> ' . _T('info_redacteur_2') . '<br />'),
80
-		'info_visiteurs' => ('<b>' . _T('info_visiteur_1') . '</b> ' . _T('info_visiteur_2') . '<br />')
78
+		'info_administrateurs' => ('<b>'._T('info_administrateur_1').'</b> '._T('info_administrateur_2').'<br />'),
79
+		'info_redacteurs' => ('<b>'._T('info_redacteur_1').'</b> '._T('info_redacteur_2').'<br />'),
80
+		'info_visiteurs' => ('<b>'._T('info_visiteur_1').'</b> '._T('info_visiteur_2').'<br />')
81 81
 	];
82 82
 
83 83
 	$res = [];
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 function install_ldap_correspondances() {
94 94
 	$champs = [];
95 95
 	foreach (is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : [] as $champ => $v) {
96
-		$nom = 'ldap_' . $champ;
96
+		$nom = 'ldap_'.$champ;
97 97
 		$val = is_array($v) ? join(',', $v) : strval($v);
98 98
 		$champs[$nom] = [
99
-			'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]) . '<br />',
99
+			'label' => _T('ldap_correspondance', ['champ' => "<tt>$champ</tt>"]).'<br />',
100 100
 			'valeur' => $val
101 101
 		];
102 102
 	}
103 103
 
104 104
 	return !$champs ?
105
-		'' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2') . '<br /><br />');
105
+		'' : fieldset(_T('ldap_correspondance_1'), $champs, '', _T('ldap_correspondance_2').'<br /><br />');
106 106
 }
Please login to merge, or discard this patch.
ecrire/install/etape_3.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		= spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db);
45 45
 
46 46
 	$GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
47
-		= $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
47
+		= $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']];
48 48
 
49 49
 	$fquery = sql_serveur('query', $server_db);
50 50
 	if ($choix_db == 'new_spip') {
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 			if (!$ok) {
55 55
 				$re = "Impossible de creer la base $re";
56 56
 				spip_log($re);
57
-				return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->";
57
+				return '<p>'._T('avis_connexion_erreur_creer_base')."</p><!--\n$re\n-->";
58 58
 			}
59 59
 		} else {
60 60
 			$re = "Le nom de la base doit correspondre a $re";
61 61
 			spip_log($re);
62 62
 
63
-			return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->";
63
+			return '<p>'._T('avis_connexion_erreur_nom_base')."</p><!--\n$re\n-->";
64 64
 		}
65 65
 	}
66 66
 
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 		= spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db);
72 72
 
73 73
 	$GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
74
-		= $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
74
+		= $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']];
75 75
 
76 76
 	// Completer le tableau decrivant la connexion
77 77
 
78 78
 	$GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix;
79 79
 	$GLOBALS['connexions'][$server_db]['db'] = $sel_db;
80 80
 
81
-	$old = sql_showbase($table_prefix . '_meta', $server_db);
81
+	$old = sql_showbase($table_prefix.'_meta', $server_db);
82 82
 	if ($old) {
83 83
 		$old = sql_fetch($old, $server_db);
84 84
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				$charset['charset'];
98 98
 			$charsetbase = $charset['charset'];
99 99
 		} else {
100
-			spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL');
100
+			spip_log(_DEFAULT_CHARSET.' inconnu du serveur SQL');
101 101
 			$charsetbase = 'standard';
102 102
 		}
103 103
 		spip_log("Creation des tables. Codage $charsetbase");
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		if ($r) {
148 148
 			$r = sql_fetch($r, $server_db);
149 149
 		}
150
-		$version_installee = !$r ? 0 : (double)$r['valeur'];
150
+		$version_installee = !$r ? 0 : (double) $r['valeur'];
151 151
 		if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
152 152
 			$fupdateq(
153 153
 				'spip_meta',
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 				'',
157 157
 				$server_db
158 158
 			);
159
-			spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']);
159
+			spip_log('nouvelle version installee: '.$GLOBALS['spip_version_base']);
160 160
 		}
161 161
 		// eliminer la derniere operation d'admin mal terminee
162 162
 		// notamment la mise a jour
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	if ($chmod_db) {
184 184
 		install_fichier_connexion(
185 185
 			_FILE_CHMOD_TMP,
186
-			"if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n"
186
+			"if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', ".sprintf('0%3o', $chmod_db).");\n"
187 187
 		);
188 188
 	}
189 189
 
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
 
247 247
 
248 248
 function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) {
249
-	return info_progression_etape(3, 'etape_', 'install/') .
249
+	return info_progression_etape(3, 'etape_', 'install/').
250 250
 	info_etape(
251 251
 		_T('info_informations_personnelles'),
252
-		'<b>' . _T('texte_informations_personnelles_1') . '</b>' .
253
-		aider('install5', true) .
254
-		'<p>' .
252
+		'<b>'._T('texte_informations_personnelles_1').'</b>'.
253
+		aider('install5', true).
254
+		'<p>'.
255 255
 		($auteur_obligatoire ?
256 256
 			''
257 257
 			:
258
-			_T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides')
258
+			_T('texte_informations_personnelles_2').' '._T('info_laisser_champs_vides')
259 259
 		)
260 260
 	)
261 261
 	. generer_form_ecrire('install', (
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
 			_T('info_identification_publique'),
266 266
 			[
267 267
 				'nom' => [
268
-					'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n",
268
+					'label' => '<b>'._T('entree_signature')."</b><br />\n"._T('entree_nom_pseudo_1')."\n",
269 269
 					'valeur' => $nom,
270 270
 					'required' => $auteur_obligatoire,
271 271
 				],
272 272
 				'email' => [
273
-					'label' => '<b>' . _T('entree_adresse_email') . "</b>\n",
273
+					'label' => '<b>'._T('entree_adresse_email')."</b>\n",
274 274
 					'valeur' => $email,
275 275
 				]
276 276
 			]
@@ -280,23 +280,23 @@  discard block
 block discarded – undo
280 280
 			_T('entree_identifiants_connexion'),
281 281
 			[
282 282
 				'login' => [
283
-					'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T(
283
+					'label' => '<b>'._T('entree_login')."</b><br />\n"._T(
284 284
 						'info_login_trop_court_car_pluriel',
285 285
 						['nb' => _LOGIN_TROP_COURT]
286
-					) . "\n",
286
+					)."\n",
287 287
 					'valeur' => $login,
288 288
 					'required' => $auteur_obligatoire,
289 289
 				],
290 290
 				'pass' => [
291
-					'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T(
291
+					'label' => '<b>'._T('entree_mot_passe')."</b><br />\n"._T(
292 292
 						'info_passe_trop_court_car_pluriel',
293 293
 						['nb' => _PASS_LONGUEUR_MINI]
294
-					) . "\n",
294
+					)."\n",
295 295
 					'valeur' => $pass,
296 296
 					'required' => $auteur_obligatoire,
297 297
 				],
298 298
 				'pass_verif' => [
299
-					'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n",
299
+					'label' => '<b>'._T('info_confirmer_passe')."</b><br />\n",
300 300
 					'valeur' => $pass,
301 301
 					'required' => $auteur_obligatoire,
302 302
 				]
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 
341 341
 		if ($res) {
342 342
 			$res = info_progression_etape(2, 'etape_', 'install/', true)
343
-				. "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>'
343
+				. "<div class='error'><h3>"._T('avis_operation_echec').'</h3>'
344 344
 				. $res
345
-				. '<p>' . _T('texte_operation_echec') . '</p>'
345
+				. '<p>'._T('texte_operation_echec').'</p>'
346 346
 				. '</div>';
347 347
 		}
348 348
 	} else {
Please login to merge, or discard this patch.
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/headers');
@@ -19,199 +19,199 @@  discard block
 block discarded – undo
19 19
 
20 20
 function install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db) {
21 21
 
22
-	// Prefix des tables :
23
-	// S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer
24
-	// a partir de ce qui est envoye a l'installation
25
-	if (!defined('_INSTALL_TABLE_PREFIX')) {
26
-		$table_prefix = ($GLOBALS['table_prefix'] != 'spip')
27
-			? $GLOBALS['table_prefix']
28
-			: preparer_prefixe_tables(_request('tprefix'));
29
-		// S'il est vide on remet spip
30
-		if (!$table_prefix) {
31
-			$table_prefix = 'spip';
32
-		}
33
-	} else {
34
-		$table_prefix = _INSTALL_TABLE_PREFIX;
35
-	}
36
-
37
-	if (preg_match(',(.*):(.*),', $adresse_db, $r)) {
38
-		[, $adresse_db, $port] = $r;
39
-	} else {
40
-		$port = '';
41
-	}
42
-
43
-	$GLOBALS['connexions'][$server_db]
44
-		= spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db);
45
-
46
-	$GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
47
-		= $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
48
-
49
-	$fquery = sql_serveur('query', $server_db);
50
-	if ($choix_db == 'new_spip') {
51
-		$re = ',^[a-z_][a-z_0-9-]*$,i';
52
-		if (preg_match($re, $sel_db)) {
53
-			$ok = sql_create_base($sel_db, $server_db);
54
-			if (!$ok) {
55
-				$re = "Impossible de creer la base $re";
56
-				spip_log($re);
57
-				return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->";
58
-			}
59
-		} else {
60
-			$re = "Le nom de la base doit correspondre a $re";
61
-			spip_log($re);
62
-
63
-			return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->";
64
-		}
65
-	}
66
-
67
-	// on rejoue la connexion apres avoir teste si il faut lui indiquer
68
-	// un sql_mode
69
-	install_mode_appel($server_db, false);
70
-	$GLOBALS['connexions'][$server_db]
71
-		= spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db);
72
-
73
-	$GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
74
-		= $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
75
-
76
-	// Completer le tableau decrivant la connexion
77
-
78
-	$GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix;
79
-	$GLOBALS['connexions'][$server_db]['db'] = $sel_db;
80
-
81
-	$old = sql_showbase($table_prefix . '_meta', $server_db);
82
-	if ($old) {
83
-		$old = sql_fetch($old, $server_db);
84
-	}
85
-	if (!$old) {
86
-		// Si possible, demander au serveur d'envoyer les textes
87
-		// dans le codage std de SPIP,
88
-		$charset = sql_get_charset(_DEFAULT_CHARSET, $server_db);
89
-
90
-		if ($charset) {
91
-			sql_set_charset($charset['charset'], $server_db);
92
-			$GLOBALS['meta']['charset_sql_base'] =
93
-				$charset['charset'];
94
-			$GLOBALS['meta']['charset_collation_sql_base'] =
95
-				$charset['collation'];
96
-			$GLOBALS['meta']['charset_sql_connexion'] =
97
-				$charset['charset'];
98
-			$charsetbase = $charset['charset'];
99
-		} else {
100
-			spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL');
101
-			$charsetbase = 'standard';
102
-		}
103
-		spip_log("Creation des tables. Codage $charsetbase");
104
-		creer_base($server_db); // AT LAST
105
-		// memoriser avec quel charset on l'a creee
106
-
107
-		if ($charset) {
108
-			$t = [
109
-				'nom' => 'charset_sql_base',
110
-				'valeur' => $charset['charset'],
111
-				'impt' => 'non'
112
-			];
113
-			@sql_insertq('spip_meta', $t, [], $server_db);
114
-			$t['nom'] = 'charset_collation_sql_base';
115
-			$t['valeur'] = $charset['collation'];
116
-			@sql_insertq('spip_meta', $t, [], $server_db);
117
-			$t['nom'] = 'charset_sql_connexion';
118
-			$t['valeur'] = $charset['charset'];
119
-			@sql_insertq('spip_meta', $t, [], $server_db);
120
-		}
121
-		$t = [
122
-			'nom' => 'version_installee',
123
-			'valeur' => $GLOBALS['spip_version_base'],
124
-			'impt' => 'non'
125
-		];
126
-		@sql_insertq('spip_meta', $t, [], $server_db);
127
-		$t['nom'] = 'nouvelle_install';
128
-		$t['valeur'] = 1;
129
-		@sql_insertq('spip_meta', $t, [], $server_db);
130
-		// positionner la langue par defaut du site si un cookie de lang a ete mis
131
-		if (isset($_COOKIE['spip_lang_ecrire'])) {
132
-			@sql_insertq(
133
-				'spip_meta',
134
-				['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']],
135
-				[],
136
-				$server_db
137
-			);
138
-		}
139
-	} else {
140
-		// pour recreer les tables disparues au besoin
141
-		spip_log('Table des Meta deja la. Verification des autres.');
142
-		creer_base($server_db);
143
-		$fupdateq = sql_serveur('updateq', $server_db);
144
-
145
-		$r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db);
146
-
147
-		if ($r) {
148
-			$r = sql_fetch($r, $server_db);
149
-		}
150
-		$version_installee = !$r ? 0 : (double)$r['valeur'];
151
-		if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
152
-			$fupdateq(
153
-				'spip_meta',
154
-				['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'],
155
-				"nom='version_installee'",
156
-				'',
157
-				$server_db
158
-			);
159
-			spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']);
160
-		}
161
-		// eliminer la derniere operation d'admin mal terminee
162
-		// notamment la mise a jour
163
-		@$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR  nom='admin'", $server_db);
164
-	}
165
-
166
-	// recuperer le charset de la connexion dans les meta
167
-	$charset = '';
168
-	$r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db);
169
-	if ($r) {
170
-		$r = sql_fetch($r, $server_db);
171
-	}
172
-	if ($r) {
173
-		$charset = $r['valeur'];
174
-	}
175
-
176
-	$ligne_rappel = install_mode_appel($server_db);
177
-
178
-	$result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db);
179
-	if (!$result_ok) {
180
-		return "<!--\nvielle = $old rappel= $ligne_rappel\n-->";
181
-	}
182
-
183
-	if ($chmod_db) {
184
-		install_fichier_connexion(
185
-			_FILE_CHMOD_TMP,
186
-			"if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n"
187
-		);
188
-	}
189
-
190
-	// si ce fichier existe a cette etape c'est qu'il provient
191
-	// d'une installation qui ne l'a pas cree correctement.
192
-	// Le supprimer pour que _FILE_CONNECT_TMP prime.
193
-
194
-	if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) {
195
-		spip_unlink(_FILE_CONNECT);
196
-	}
197
-
198
-	install_fichier_connexion(
199
-		_FILE_CONNECT_TMP,
200
-		$ligne_rappel
201
-		. install_connexion(
202
-			$adresse_db,
203
-			$port,
204
-			$login_db,
205
-			$pass_db,
206
-			$sel_db,
207
-			$server_db,
208
-			$table_prefix,
209
-			'',
210
-			$charset
211
-		)
212
-	);
213
-
214
-	return '';
22
+    // Prefix des tables :
23
+    // S'il n'est pas defini par mes_options/inc/mutualiser, on va le creer
24
+    // a partir de ce qui est envoye a l'installation
25
+    if (!defined('_INSTALL_TABLE_PREFIX')) {
26
+        $table_prefix = ($GLOBALS['table_prefix'] != 'spip')
27
+            ? $GLOBALS['table_prefix']
28
+            : preparer_prefixe_tables(_request('tprefix'));
29
+        // S'il est vide on remet spip
30
+        if (!$table_prefix) {
31
+            $table_prefix = 'spip';
32
+        }
33
+    } else {
34
+        $table_prefix = _INSTALL_TABLE_PREFIX;
35
+    }
36
+
37
+    if (preg_match(',(.*):(.*),', $adresse_db, $r)) {
38
+        [, $adresse_db, $port] = $r;
39
+    } else {
40
+        $port = '';
41
+    }
42
+
43
+    $GLOBALS['connexions'][$server_db]
44
+        = spip_connect_db($adresse_db, $port, $login_db, $pass_db, '', $server_db);
45
+
46
+    $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
47
+        = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
48
+
49
+    $fquery = sql_serveur('query', $server_db);
50
+    if ($choix_db == 'new_spip') {
51
+        $re = ',^[a-z_][a-z_0-9-]*$,i';
52
+        if (preg_match($re, $sel_db)) {
53
+            $ok = sql_create_base($sel_db, $server_db);
54
+            if (!$ok) {
55
+                $re = "Impossible de creer la base $re";
56
+                spip_log($re);
57
+                return '<p>' . _T('avis_connexion_erreur_creer_base') . "</p><!--\n$re\n-->";
58
+            }
59
+        } else {
60
+            $re = "Le nom de la base doit correspondre a $re";
61
+            spip_log($re);
62
+
63
+            return '<p>' . _T('avis_connexion_erreur_nom_base') . "</p><!--\n$re\n-->";
64
+        }
65
+    }
66
+
67
+    // on rejoue la connexion apres avoir teste si il faut lui indiquer
68
+    // un sql_mode
69
+    install_mode_appel($server_db, false);
70
+    $GLOBALS['connexions'][$server_db]
71
+        = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $sel_db, $server_db);
72
+
73
+    $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']]
74
+        = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']];
75
+
76
+    // Completer le tableau decrivant la connexion
77
+
78
+    $GLOBALS['connexions'][$server_db]['prefixe'] = $table_prefix;
79
+    $GLOBALS['connexions'][$server_db]['db'] = $sel_db;
80
+
81
+    $old = sql_showbase($table_prefix . '_meta', $server_db);
82
+    if ($old) {
83
+        $old = sql_fetch($old, $server_db);
84
+    }
85
+    if (!$old) {
86
+        // Si possible, demander au serveur d'envoyer les textes
87
+        // dans le codage std de SPIP,
88
+        $charset = sql_get_charset(_DEFAULT_CHARSET, $server_db);
89
+
90
+        if ($charset) {
91
+            sql_set_charset($charset['charset'], $server_db);
92
+            $GLOBALS['meta']['charset_sql_base'] =
93
+                $charset['charset'];
94
+            $GLOBALS['meta']['charset_collation_sql_base'] =
95
+                $charset['collation'];
96
+            $GLOBALS['meta']['charset_sql_connexion'] =
97
+                $charset['charset'];
98
+            $charsetbase = $charset['charset'];
99
+        } else {
100
+            spip_log(_DEFAULT_CHARSET . ' inconnu du serveur SQL');
101
+            $charsetbase = 'standard';
102
+        }
103
+        spip_log("Creation des tables. Codage $charsetbase");
104
+        creer_base($server_db); // AT LAST
105
+        // memoriser avec quel charset on l'a creee
106
+
107
+        if ($charset) {
108
+            $t = [
109
+                'nom' => 'charset_sql_base',
110
+                'valeur' => $charset['charset'],
111
+                'impt' => 'non'
112
+            ];
113
+            @sql_insertq('spip_meta', $t, [], $server_db);
114
+            $t['nom'] = 'charset_collation_sql_base';
115
+            $t['valeur'] = $charset['collation'];
116
+            @sql_insertq('spip_meta', $t, [], $server_db);
117
+            $t['nom'] = 'charset_sql_connexion';
118
+            $t['valeur'] = $charset['charset'];
119
+            @sql_insertq('spip_meta', $t, [], $server_db);
120
+        }
121
+        $t = [
122
+            'nom' => 'version_installee',
123
+            'valeur' => $GLOBALS['spip_version_base'],
124
+            'impt' => 'non'
125
+        ];
126
+        @sql_insertq('spip_meta', $t, [], $server_db);
127
+        $t['nom'] = 'nouvelle_install';
128
+        $t['valeur'] = 1;
129
+        @sql_insertq('spip_meta', $t, [], $server_db);
130
+        // positionner la langue par defaut du site si un cookie de lang a ete mis
131
+        if (isset($_COOKIE['spip_lang_ecrire'])) {
132
+            @sql_insertq(
133
+                'spip_meta',
134
+                ['nom' => 'langue_site', 'valeur' => $_COOKIE['spip_lang_ecrire']],
135
+                [],
136
+                $server_db
137
+            );
138
+        }
139
+    } else {
140
+        // pour recreer les tables disparues au besoin
141
+        spip_log('Table des Meta deja la. Verification des autres.');
142
+        creer_base($server_db);
143
+        $fupdateq = sql_serveur('updateq', $server_db);
144
+
145
+        $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='version_installee'", $server_db);
146
+
147
+        if ($r) {
148
+            $r = sql_fetch($r, $server_db);
149
+        }
150
+        $version_installee = !$r ? 0 : (double)$r['valeur'];
151
+        if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) {
152
+            $fupdateq(
153
+                'spip_meta',
154
+                ['valeur' => $GLOBALS['spip_version_base'], 'impt' => 'non'],
155
+                "nom='version_installee'",
156
+                '',
157
+                $server_db
158
+            );
159
+            spip_log('nouvelle version installee: ' . $GLOBALS['spip_version_base']);
160
+        }
161
+        // eliminer la derniere operation d'admin mal terminee
162
+        // notamment la mise a jour
163
+        @$fquery("DELETE FROM spip_meta WHERE nom='import_all' OR  nom='admin'", $server_db);
164
+    }
165
+
166
+    // recuperer le charset de la connexion dans les meta
167
+    $charset = '';
168
+    $r = $fquery("SELECT valeur FROM spip_meta WHERE nom='charset_sql_connexion'", $server_db);
169
+    if ($r) {
170
+        $r = sql_fetch($r, $server_db);
171
+    }
172
+    if ($r) {
173
+        $charset = $r['valeur'];
174
+    }
175
+
176
+    $ligne_rappel = install_mode_appel($server_db);
177
+
178
+    $result_ok = @$fquery('SELECT COUNT(*) FROM spip_meta', $server_db);
179
+    if (!$result_ok) {
180
+        return "<!--\nvielle = $old rappel= $ligne_rappel\n-->";
181
+    }
182
+
183
+    if ($chmod_db) {
184
+        install_fichier_connexion(
185
+            _FILE_CHMOD_TMP,
186
+            "if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', " . sprintf('0%3o', $chmod_db) . ");\n"
187
+        );
188
+    }
189
+
190
+    // si ce fichier existe a cette etape c'est qu'il provient
191
+    // d'une installation qui ne l'a pas cree correctement.
192
+    // Le supprimer pour que _FILE_CONNECT_TMP prime.
193
+
194
+    if (_FILE_CONNECT and file_exists(_FILE_CONNECT)) {
195
+        spip_unlink(_FILE_CONNECT);
196
+    }
197
+
198
+    install_fichier_connexion(
199
+        _FILE_CONNECT_TMP,
200
+        $ligne_rappel
201
+        . install_connexion(
202
+            $adresse_db,
203
+            $port,
204
+            $login_db,
205
+            $pass_db,
206
+            $sel_db,
207
+            $server_db,
208
+            $table_prefix,
209
+            '',
210
+            $charset
211
+        )
212
+    );
213
+
214
+    return '';
215 215
 }
216 216
 
217 217
 /**
@@ -226,166 +226,166 @@  discard block
 block discarded – undo
226 226
  * @return string Le préfixe corrigé
227 227
  */
228 228
 function preparer_prefixe_tables($prefixe) {
229
-	return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe))));
229
+    return trim(preg_replace(',^[0-9]+,', '', preg_replace(',[^a-z0-9],', '', strtolower($prefixe))));
230 230
 }
231 231
 
232 232
 function install_propose_ldap() {
233
-	return generer_form_ecrire('install', (
234
-	fieldset(
235
-		_T('info_authentification_externe'),
236
-		[
237
-			'etape' => [
238
-				'label' => _T('texte_annuaire_ldap_1'),
239
-				'valeur' => 'ldap1',
240
-				'hidden' => true
241
-			]
242
-		],
243
-		bouton_suivant(_T('bouton_acces_ldap'))
244
-	)));
233
+    return generer_form_ecrire('install', (
234
+    fieldset(
235
+        _T('info_authentification_externe'),
236
+        [
237
+            'etape' => [
238
+                'label' => _T('texte_annuaire_ldap_1'),
239
+                'valeur' => 'ldap1',
240
+                'hidden' => true
241
+            ]
242
+        ],
243
+        bouton_suivant(_T('bouton_acces_ldap'))
244
+    )));
245 245
 }
246 246
 
247 247
 
248 248
 function install_premier_auteur($email, $login, $nom, $pass, $hidden, $auteur_obligatoire) {
249
-	return info_progression_etape(3, 'etape_', 'install/') .
250
-	info_etape(
251
-		_T('info_informations_personnelles'),
252
-		'<b>' . _T('texte_informations_personnelles_1') . '</b>' .
253
-		aider('install5', true) .
254
-		'<p>' .
255
-		($auteur_obligatoire ?
256
-			''
257
-			:
258
-			_T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides')
259
-		)
260
-	)
261
-	. generer_form_ecrire('install', (
262
-		"\n<input type='hidden' name='etape' value='3b' />"
263
-		. $hidden
264
-		. fieldset(
265
-			_T('info_identification_publique'),
266
-			[
267
-				'nom' => [
268
-					'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n",
269
-					'valeur' => $nom,
270
-					'required' => $auteur_obligatoire,
271
-				],
272
-				'email' => [
273
-					'label' => '<b>' . _T('entree_adresse_email') . "</b>\n",
274
-					'valeur' => $email,
275
-				]
276
-			]
277
-		)
278
-
279
-		. fieldset(
280
-			_T('entree_identifiants_connexion'),
281
-			[
282
-				'login' => [
283
-					'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T(
284
-						'info_login_trop_court_car_pluriel',
285
-						['nb' => _LOGIN_TROP_COURT]
286
-					) . "\n",
287
-					'valeur' => $login,
288
-					'required' => $auteur_obligatoire,
289
-				],
290
-				'pass' => [
291
-					'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T(
292
-						'info_passe_trop_court_car_pluriel',
293
-						['nb' => _PASS_LONGUEUR_MINI]
294
-					) . "\n",
295
-					'valeur' => $pass,
296
-					'required' => $auteur_obligatoire,
297
-				],
298
-				'pass_verif' => [
299
-					'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n",
300
-					'valeur' => $pass,
301
-					'required' => $auteur_obligatoire,
302
-				]
303
-			]
304
-		)
305
-		. bouton_suivant()));
249
+    return info_progression_etape(3, 'etape_', 'install/') .
250
+    info_etape(
251
+        _T('info_informations_personnelles'),
252
+        '<b>' . _T('texte_informations_personnelles_1') . '</b>' .
253
+        aider('install5', true) .
254
+        '<p>' .
255
+        ($auteur_obligatoire ?
256
+            ''
257
+            :
258
+            _T('texte_informations_personnelles_2') . ' ' . _T('info_laisser_champs_vides')
259
+        )
260
+    )
261
+    . generer_form_ecrire('install', (
262
+        "\n<input type='hidden' name='etape' value='3b' />"
263
+        . $hidden
264
+        . fieldset(
265
+            _T('info_identification_publique'),
266
+            [
267
+                'nom' => [
268
+                    'label' => '<b>' . _T('entree_signature') . "</b><br />\n" . _T('entree_nom_pseudo_1') . "\n",
269
+                    'valeur' => $nom,
270
+                    'required' => $auteur_obligatoire,
271
+                ],
272
+                'email' => [
273
+                    'label' => '<b>' . _T('entree_adresse_email') . "</b>\n",
274
+                    'valeur' => $email,
275
+                ]
276
+            ]
277
+        )
278
+
279
+        . fieldset(
280
+            _T('entree_identifiants_connexion'),
281
+            [
282
+                'login' => [
283
+                    'label' => '<b>' . _T('entree_login') . "</b><br />\n" . _T(
284
+                        'info_login_trop_court_car_pluriel',
285
+                        ['nb' => _LOGIN_TROP_COURT]
286
+                    ) . "\n",
287
+                    'valeur' => $login,
288
+                    'required' => $auteur_obligatoire,
289
+                ],
290
+                'pass' => [
291
+                    'label' => '<b>' . _T('entree_mot_passe') . "</b><br />\n" . _T(
292
+                        'info_passe_trop_court_car_pluriel',
293
+                        ['nb' => _PASS_LONGUEUR_MINI]
294
+                    ) . "\n",
295
+                    'valeur' => $pass,
296
+                    'required' => $auteur_obligatoire,
297
+                ],
298
+                'pass_verif' => [
299
+                    'label' => '<b>' . _T('info_confirmer_passe') . "</b><br />\n",
300
+                    'valeur' => $pass,
301
+                    'required' => $auteur_obligatoire,
302
+                ]
303
+            ]
304
+        )
305
+        . bouton_suivant()));
306 306
 }
307 307
 
308 308
 function install_etape_3_dist() {
309
-	$ldap_present = _request('ldap_present');
310
-
311
-	if (!$ldap_present) {
312
-		$adresse_db = defined('_INSTALL_HOST_DB')
313
-			? _INSTALL_HOST_DB
314
-			: _request('adresse_db');
315
-
316
-		$login_db = defined('_INSTALL_USER_DB')
317
-			? _INSTALL_USER_DB
318
-			: _request('login_db');
319
-
320
-		$pass_db = defined('_INSTALL_PASS_DB')
321
-			? _INSTALL_PASS_DB
322
-			: _request('pass_db');
323
-
324
-		$server_db = defined('_INSTALL_SERVER_DB')
325
-			? _INSTALL_SERVER_DB
326
-			: _request('server_db');
327
-
328
-		$chmod_db = defined('_SPIP_CHMOD')
329
-			? _SPIP_CHMOD
330
-			: _request('chmod');
331
-
332
-		$choix_db = defined('_INSTALL_NAME_DB')
333
-			? _INSTALL_NAME_DB
334
-			: _request('choix_db');
335
-
336
-		$sel_db = ($choix_db == 'new_spip')
337
-			? _request('table_new') : $choix_db;
338
-
339
-		$res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db);
340
-
341
-		if ($res) {
342
-			$res = info_progression_etape(2, 'etape_', 'install/', true)
343
-				. "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>'
344
-				. $res
345
-				. '<p>' . _T('texte_operation_echec') . '</p>'
346
-				. '</div>';
347
-		}
348
-	} else {
349
-		$res = '';
350
-		[$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP);
351
-		$GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db);
352
-	}
353
-
354
-	if (!$res) {
355
-		if (file_exists(_FILE_CONNECT_TMP)) {
356
-			include(_FILE_CONNECT_TMP);
357
-		} else {
358
-			redirige_url_ecrire('install');
359
-		}
360
-
361
-		if (file_exists(_FILE_CHMOD_TMP)) {
362
-			include(_FILE_CHMOD_TMP);
363
-		} else {
364
-			redirige_url_ecrire('install');
365
-		}
366
-
367
-		$hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db)
368
-			. (defined('_INSTALL_NAME_DB') ? ''
369
-				: "\n<input type='hidden' name='sel_db' value=\"".spip_htmlspecialchars($sel_db)."\" />");
370
-
371
-		$auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db));
372
-
373
-		$res = "<div class='success'><b>"
374
-			. _T('info_base_installee')
375
-			. '</b></div>'
376
-			. install_premier_auteur(
377
-				_request('email'),
378
-				_request('login'),
379
-				_request('nom'),
380
-				_request('pass'),
381
-				$hidden,
382
-				$auteur_obligatoire
383
-			)
384
-			. (($ldap_present or !function_exists('ldap_connect'))
385
-				? '' : install_propose_ldap());
386
-	}
387
-
388
-	echo install_debut_html();
389
-	echo $res;
390
-	echo install_fin_html();
309
+    $ldap_present = _request('ldap_present');
310
+
311
+    if (!$ldap_present) {
312
+        $adresse_db = defined('_INSTALL_HOST_DB')
313
+            ? _INSTALL_HOST_DB
314
+            : _request('adresse_db');
315
+
316
+        $login_db = defined('_INSTALL_USER_DB')
317
+            ? _INSTALL_USER_DB
318
+            : _request('login_db');
319
+
320
+        $pass_db = defined('_INSTALL_PASS_DB')
321
+            ? _INSTALL_PASS_DB
322
+            : _request('pass_db');
323
+
324
+        $server_db = defined('_INSTALL_SERVER_DB')
325
+            ? _INSTALL_SERVER_DB
326
+            : _request('server_db');
327
+
328
+        $chmod_db = defined('_SPIP_CHMOD')
329
+            ? _SPIP_CHMOD
330
+            : _request('chmod');
331
+
332
+        $choix_db = defined('_INSTALL_NAME_DB')
333
+            ? _INSTALL_NAME_DB
334
+            : _request('choix_db');
335
+
336
+        $sel_db = ($choix_db == 'new_spip')
337
+            ? _request('table_new') : $choix_db;
338
+
339
+        $res = install_bases($adresse_db, $login_db, $pass_db, $server_db, $choix_db, $sel_db, $chmod_db);
340
+
341
+        if ($res) {
342
+            $res = info_progression_etape(2, 'etape_', 'install/', true)
343
+                . "<div class='error'><h3>" . _T('avis_operation_echec') . '</h3>'
344
+                . $res
345
+                . '<p>' . _T('texte_operation_echec') . '</p>'
346
+                . '</div>';
347
+        }
348
+    } else {
349
+        $res = '';
350
+        [$adresse_db, $login_db, $pass_db, $sel_db, $server_db] = analyse_fichier_connection(_FILE_CONNECT_TMP);
351
+        $GLOBALS['connexions'][$server_db] = spip_connect_db($adresse_db, $sel_db, $login_db, $pass_db, $sel_db, $server_db);
352
+    }
353
+
354
+    if (!$res) {
355
+        if (file_exists(_FILE_CONNECT_TMP)) {
356
+            include(_FILE_CONNECT_TMP);
357
+        } else {
358
+            redirige_url_ecrire('install');
359
+        }
360
+
361
+        if (file_exists(_FILE_CHMOD_TMP)) {
362
+            include(_FILE_CHMOD_TMP);
363
+        } else {
364
+            redirige_url_ecrire('install');
365
+        }
366
+
367
+        $hidden = predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db)
368
+            . (defined('_INSTALL_NAME_DB') ? ''
369
+                : "\n<input type='hidden' name='sel_db' value=\"".spip_htmlspecialchars($sel_db)."\" />");
370
+
371
+        $auteur_obligatoire = ($ldap_present ? 0 : !sql_countsel('spip_auteurs', '', '', '', $server_db));
372
+
373
+        $res = "<div class='success'><b>"
374
+            . _T('info_base_installee')
375
+            . '</b></div>'
376
+            . install_premier_auteur(
377
+                _request('email'),
378
+                _request('login'),
379
+                _request('nom'),
380
+                _request('pass'),
381
+                $hidden,
382
+                $auteur_obligatoire
383
+            )
384
+            . (($ldap_present or !function_exists('ldap_connect'))
385
+                ? '' : install_propose_ldap());
386
+    }
387
+
388
+    echo install_debut_html();
389
+    echo $res;
390
+    echo install_fin_html();
391 391
 }
Please login to merge, or discard this patch.