Completed
Push — master ( a15233...457c22 )
by cam
01:25
created
ecrire/plugins/afficher_liste.php 1 patch
Indentation   +75 added lines, -75 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
 include_spip('inc/charsets');
17 17
 
@@ -27,90 +27,90 @@  discard block
 block discarded – undo
27 27
  * @return string
28 28
  */
29 29
 function plugins_afficher_liste_dist(
30
-	$url_page,
31
-	$liste_plugins,
32
-	$liste_plugins_checked,
33
-	$liste_plugins_actifs,
34
-	$dir_plugins = _DIR_PLUGINS,
35
-	$afficher_un = 'afficher_plugin'
30
+    $url_page,
31
+    $liste_plugins,
32
+    $liste_plugins_checked,
33
+    $liste_plugins_actifs,
34
+    $dir_plugins = _DIR_PLUGINS,
35
+    $afficher_un = 'afficher_plugin'
36 36
 ) {
37
-	$get_infos = charger_fonction('get_infos', 'plugins');
38
-	$ligne_plug = charger_fonction($afficher_un, 'plugins');
37
+    $get_infos = charger_fonction('get_infos', 'plugins');
38
+    $ligne_plug = charger_fonction($afficher_un, 'plugins');
39 39
 
40
-	$all_infos = $get_infos($liste_plugins, false, $dir_plugins);
40
+    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
41 41
 
42
-	$all_infos = pipeline(
43
-		'filtrer_liste_plugins',
44
-		[
45
-			'args' => [
46
-				'liste_plugins' => $liste_plugins,
47
-				'liste_plugins_checked' => $liste_plugins_checked,
48
-				'liste_plugins_actifs' => $liste_plugins_actifs,
49
-				'dir_plugins' => $dir_plugins
50
-			],
51
-			'data' => $all_infos
52
-		]
53
-	);
42
+    $all_infos = pipeline(
43
+        'filtrer_liste_plugins',
44
+        [
45
+            'args' => [
46
+                'liste_plugins' => $liste_plugins,
47
+                'liste_plugins_checked' => $liste_plugins_checked,
48
+                'liste_plugins_actifs' => $liste_plugins_actifs,
49
+                'dir_plugins' => $dir_plugins
50
+            ],
51
+            'data' => $all_infos
52
+        ]
53
+    );
54 54
 
55
-	$liste_plugins = array_flip($liste_plugins);
56
-	foreach ($liste_plugins as $chemin => $v) {
57
-		// des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
-		if (isset($all_infos[$chemin])) {
59
-			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
-		} else {
61
-			unset($liste_plugins[$chemin]);
62
-		}
63
-	}
64
-	asort($liste_plugins);
65
-	$exposed = urldecode(_request('plugin') ?? '');
55
+    $liste_plugins = array_flip($liste_plugins);
56
+    foreach ($liste_plugins as $chemin => $v) {
57
+        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
+        if (isset($all_infos[$chemin])) {
59
+            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
+        } else {
61
+            unset($liste_plugins[$chemin]);
62
+        }
63
+    }
64
+    asort($liste_plugins);
65
+    $exposed = urldecode(_request('plugin') ?? '');
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
68
-	$fast_liste_plugins_actifs = [];
69
-	$fast_liste_plugins_checked = [];
70
-	if (is_array($liste_plugins_actifs)) {
71
-		$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
-	}
73
-	if (is_array($liste_plugins_checked)) {
74
-		$fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
-	}
67
+    $block_par_lettre = false;//count($liste_plugins)>10;
68
+    $fast_liste_plugins_actifs = [];
69
+    $fast_liste_plugins_checked = [];
70
+    if (is_array($liste_plugins_actifs)) {
71
+        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
+    }
73
+    if (is_array($liste_plugins_checked)) {
74
+        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
+    }
76 76
 
77
-	$res = '';
78
-	$block = '';
79
-	$initiale = '';
80
-	$block_actif = false;
81
-	foreach ($liste_plugins as $plug => $nom) {
82
-		if (($i = substr($nom, 0, 1)) !== $initiale) {
83
-			$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
-			$initiale = $i;
85
-			$block = '';
86
-			$block_actif = false;
87
-		}
88
-		// le rep suivant
89
-		$actif = isset($fast_liste_plugins_actifs[$plug]);
90
-		$checked = isset($fast_liste_plugins_checked[$plug]);
91
-		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
93
-			$dir_plugins,
94
-			strlen(_DIR_RACINE)
95
-		) . $plug));
96
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
97
-	}
98
-	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99
-	$class = basename($dir_plugins);
77
+    $res = '';
78
+    $block = '';
79
+    $initiale = '';
80
+    $block_actif = false;
81
+    foreach ($liste_plugins as $plug => $nom) {
82
+        if (($i = substr($nom, 0, 1)) !== $initiale) {
83
+            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
+            $initiale = $i;
85
+            $block = '';
86
+            $block_actif = false;
87
+        }
88
+        // le rep suivant
89
+        $actif = isset($fast_liste_plugins_actifs[$plug]);
90
+        $checked = isset($fast_liste_plugins_checked[$plug]);
91
+        $block_actif = $block_actif | $actif;
92
+        $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
93
+            $dir_plugins,
94
+            strlen(_DIR_RACINE)
95
+        ) . $plug));
96
+        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
97
+    }
98
+    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99
+    $class = basename($dir_plugins);
100 100
 
101
-	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
101
+    return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
102 102
 }
103 103
 
104 104
 
105 105
 function affiche_block_initiale($initiale, $block, $block_actif) {
106
-	if (strlen($block)) {
107
-		return "<li class='item'>"
108
-		. bouton_block_depliable($initiale, $block_actif ? true : false)
109
-		. debut_block_depliable($block_actif)
110
-		. "<ul>$block</ul>"
111
-		. fin_block()
112
-		. '</li>';
113
-	}
106
+    if (strlen($block)) {
107
+        return "<li class='item'>"
108
+        . bouton_block_depliable($initiale, $block_actif ? true : false)
109
+        . debut_block_depliable($block_actif)
110
+        . "<ul>$block</ul>"
111
+        . fin_block()
112
+        . '</li>';
113
+    }
114 114
 
115
-	return '';
115
+    return '';
116 116
 }
Please login to merge, or discard this patch.
ecrire/balise/url_.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  **/
20 20
 
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 /**
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
  *     Code compilé
38 38
  **/
39 39
 function generer_generer_url($type, $p) {
40
-	$_id = interprete_argument_balise(1, $p);
40
+    $_id = interprete_argument_balise(1, $p);
41 41
 
42
-	if (!$_id) {
43
-		$primary = id_table_objet($type);
44
-		$_id = champ_sql($primary, $p);
45
-	}
42
+    if (!$_id) {
43
+        $primary = id_table_objet($type);
44
+        $_id = champ_sql($primary, $p);
45
+    }
46 46
 
47
-	return generer_generer_url_arg($type, $p, $_id);
47
+    return generer_generer_url_arg($type, $p, $_id);
48 48
 }
49 49
 
50 50
 /**
@@ -73,28 +73,28 @@  discard block
 block discarded – undo
73 73
  *     Code compilé
74 74
  **/
75 75
 function generer_generer_url_arg($type, $p, $_id) {
76
-	if ($s = trouver_nom_serveur_distant($p)) {
77
-		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
78
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
79
-			return $f($type, $_id, $s);
80
-		}
81
-		if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
82
-			return null;
83
-		}
84
-		$s = _q($s);
85
-		# exception des urls de documents sur un serveur distant...
86
-		if ($type == 'document') {
87
-			return
88
-				"quete_meta('adresse_site', $s) . '/' .\n\t" .
89
-				"quete_meta('dir_img', $s) . \n\t" .
90
-				"quete_fichier($_id,$s)";
91
-		}
92
-		$s = ", '', '', $s, quete_meta('type_urls', $s)";
93
-	} else {
94
-		$s = ", '', '', true";
95
-	}
96
-
97
-	return "urlencode_1738(generer_objet_url($_id, '$type'$s))";
76
+    if ($s = trouver_nom_serveur_distant($p)) {
77
+        // si une fonction de generation des url a ete definie pour ce connect l'utiliser
78
+        if (function_exists($f = 'generer_generer_url_' . $s)) {
79
+            return $f($type, $_id, $s);
80
+        }
81
+        if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) {
82
+            return null;
83
+        }
84
+        $s = _q($s);
85
+        # exception des urls de documents sur un serveur distant...
86
+        if ($type == 'document') {
87
+            return
88
+                "quete_meta('adresse_site', $s) . '/' .\n\t" .
89
+                "quete_meta('dir_img', $s) . \n\t" .
90
+                "quete_fichier($_id,$s)";
91
+        }
92
+        $s = ", '', '', $s, quete_meta('type_urls', $s)";
93
+    } else {
94
+        $s = ", '', '', true";
95
+    }
96
+
97
+    return "urlencode_1738(generer_objet_url($_id, '$type'$s))";
98 98
 }
99 99
 
100 100
 
@@ -119,27 +119,27 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function balise_URL__dist($p) {
121 121
 
122
-	$nom = $p->nom_champ;
123
-	if ($nom === 'URL_') {
124
-		$msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']];
125
-		erreur_squelette($msg, $p);
126
-		$p->interdire_scripts = false;
127
-
128
-		return $p;
129
-	} elseif ($f = charger_fonction($nom, 'balise', true)) {
130
-		return $f($p);
131
-	} else {
132
-		$nom = strtolower($nom);
133
-		$code = generer_generer_url(substr($nom, 4), $p);
134
-		$code = champ_sql($nom, $p, $code);
135
-		$p->code = $code;
136
-		if (!$p->etoile) {
137
-			$p->code = "vider_url($code)";
138
-		}
139
-		$p->interdire_scripts = false;
140
-
141
-		return $p;
142
-	}
122
+    $nom = $p->nom_champ;
123
+    if ($nom === 'URL_') {
124
+        $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']];
125
+        erreur_squelette($msg, $p);
126
+        $p->interdire_scripts = false;
127
+
128
+        return $p;
129
+    } elseif ($f = charger_fonction($nom, 'balise', true)) {
130
+        return $f($p);
131
+    } else {
132
+        $nom = strtolower($nom);
133
+        $code = generer_generer_url(substr($nom, 4), $p);
134
+        $code = champ_sql($nom, $p, $code);
135
+        $p->code = $code;
136
+        if (!$p->etoile) {
137
+            $p->code = "vider_url($code)";
138
+        }
139
+        $p->interdire_scripts = false;
140
+
141
+        return $p;
142
+    }
143 143
 }
144 144
 
145 145
 /**
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
  */
164 164
 function balise_URL_ARTICLE_dist($p) {
165 165
 
166
-	// Cas particulier des boucles (SYNDIC_ARTICLES)
167
-	if ($p->type_requete == 'syndic_articles') {
168
-		$code = champ_sql('url', $p);
169
-	} else {
170
-		$code = generer_generer_url('article', $p);
171
-	}
166
+    // Cas particulier des boucles (SYNDIC_ARTICLES)
167
+    if ($p->type_requete == 'syndic_articles') {
168
+        $code = champ_sql('url', $p);
169
+    } else {
170
+        $code = generer_generer_url('article', $p);
171
+    }
172 172
 
173
-	$p->code = $code;
174
-	if (!$p->etoile) {
175
-		$p->code = "vider_url($code)";
176
-	}
177
-	$p->interdire_scripts = false;
173
+    $p->code = $code;
174
+    if (!$p->etoile) {
175
+        $p->code = "vider_url($code)";
176
+    }
177
+    $p->interdire_scripts = false;
178 178
 
179
-	return $p;
179
+    return $p;
180 180
 }
181 181
 
182 182
 /**
@@ -196,21 +196,21 @@  discard block
 block discarded – undo
196 196
  *     Pile complétée par le code à générer
197 197
  */
198 198
 function balise_URL_SITE_dist($p) {
199
-	$code = champ_sql('url_site', $p, '');
200
-	if (!$code) {
201
-		$code = generer_generer_url('site', $p);
202
-		if ($code === null) {
203
-			return null;
204
-		}
205
-	} else {
206
-		if (!$p->etoile) {
207
-			$code = "calculer_url($code,'','url', \$connect)";
208
-		}
209
-	}
210
-	$p->code = $code;
211
-	$p->interdire_scripts = false;
212
-
213
-	return $p;
199
+    $code = champ_sql('url_site', $p, '');
200
+    if (!$code) {
201
+        $code = generer_generer_url('site', $p);
202
+        if ($code === null) {
203
+            return null;
204
+        }
205
+    } else {
206
+        if (!$p->etoile) {
207
+            $code = "calculer_url($code,'','url', \$connect)";
208
+        }
209
+    }
210
+    $p->code = $code;
211
+    $p->interdire_scripts = false;
212
+
213
+    return $p;
214 214
 }
215 215
 
216 216
 // Autres balises URL_*, qui ne concernent pas une table
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
  *     Pile complétée par le code à générer
230 230
  */
231 231
 function balise_URL_SITE_SPIP_dist($p) {
232
-	$p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
233
-	$p->code = 'spip_htmlspecialchars(' . $p->code . ')';
234
-	$p->interdire_scripts = false;
232
+    $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')";
233
+    $p->code = 'spip_htmlspecialchars(' . $p->code . ')';
234
+    $p->interdire_scripts = false;
235 235
 
236
-	return $p;
236
+    return $p;
237 237
 }
238 238
 
239 239
 
@@ -262,42 +262,42 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function balise_URL_PAGE_dist($p) {
264 264
 
265
-	$code = interprete_argument_balise(1, $p);
266
-	$args = interprete_argument_balise(2, $p);
267
-	if ($args == null) {
268
-		$args = "''";
269
-	}
270
-
271
-	if ($s = trouver_nom_serveur_distant($p)) {
272
-		// si une fonction de generation des url a ete definie pour ce connect l'utiliser
273
-		// elle devra aussi traiter le cas derogatoire type=page
274
-		if (function_exists($f = 'generer_generer_url_' . $s)) {
275
-			if ($args and $args !== "''") {
276
-				$code .= ", $args";
277
-			}
278
-			$code = $f('page', $code, $s);
279
-			$p->code = $code;
280
-			return $p;
281
-		}
282
-		$s = 'connect=' . addslashes($s);
283
-		$args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
284
-	}
285
-
286
-	if (!$code) {
287
-		$noentities = $p->etoile ? "'&'" : '';
288
-		$code = "url_de_base() . preg_replace(',^./,', '', self($noentities))";
289
-	} else {
290
-		if (!$args) {
291
-			$args = "''";
292
-		}
293
-		$noentities = $p->etoile ? ', true' : '';
294
-		$code = "generer_url_public($code, $args$noentities)";
295
-	}
296
-	$p->code = $code;
297
-	spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
298
-
299
-	#$p->interdire_scripts = true;
300
-	return $p;
265
+    $code = interprete_argument_balise(1, $p);
266
+    $args = interprete_argument_balise(2, $p);
267
+    if ($args == null) {
268
+        $args = "''";
269
+    }
270
+
271
+    if ($s = trouver_nom_serveur_distant($p)) {
272
+        // si une fonction de generation des url a ete definie pour ce connect l'utiliser
273
+        // elle devra aussi traiter le cas derogatoire type=page
274
+        if (function_exists($f = 'generer_generer_url_' . $s)) {
275
+            if ($args and $args !== "''") {
276
+                $code .= ", $args";
277
+            }
278
+            $code = $f('page', $code, $s);
279
+            $p->code = $code;
280
+            return $p;
281
+        }
282
+        $s = 'connect=' . addslashes($s);
283
+        $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'");
284
+    }
285
+
286
+    if (!$code) {
287
+        $noentities = $p->etoile ? "'&'" : '';
288
+        $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))";
289
+    } else {
290
+        if (!$args) {
291
+            $args = "''";
292
+        }
293
+        $noentities = $p->etoile ? ', true' : '';
294
+        $code = "generer_url_public($code, $args$noentities)";
295
+    }
296
+    $p->code = $code;
297
+    spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO);
298
+
299
+    #$p->interdire_scripts = true;
300
+    return $p;
301 301
 }
302 302
 
303 303
 
@@ -324,24 +324,24 @@  discard block
 block discarded – undo
324 324
  */
325 325
 function balise_URL_ECRIRE_dist($p) {
326 326
 
327
-	$code = interprete_argument_balise(1, $p);
328
-	if (!$code) {
329
-		$fonc = "''";
330
-	} else {
331
-		$fonc = $code;
332
-		$args = interprete_argument_balise(2, $p);
333
-		if ($args === null) {
334
-			$args = "''";
335
-		}
336
-		$noentities = $p->etoile ? ', true' : '';
337
-		if (($args != "''") or $noentities) {
338
-			$fonc .= ",$args$noentities";
339
-		}
340
-	}
341
-	$p->code = 'generer_url_ecrire(' . $fonc . ')';
342
-	$p->interdire_scripts = false;
343
-
344
-	return $p;
327
+    $code = interprete_argument_balise(1, $p);
328
+    if (!$code) {
329
+        $fonc = "''";
330
+    } else {
331
+        $fonc = $code;
332
+        $args = interprete_argument_balise(2, $p);
333
+        if ($args === null) {
334
+            $args = "''";
335
+        }
336
+        $noentities = $p->etoile ? ', true' : '';
337
+        if (($args != "''") or $noentities) {
338
+            $fonc .= ",$args$noentities";
339
+        }
340
+    }
341
+    $p->code = 'generer_url_ecrire(' . $fonc . ')';
342
+    $p->interdire_scripts = false;
343
+
344
+    return $p;
345 345
 }
346 346
 
347 347
 
@@ -367,24 +367,24 @@  discard block
 block discarded – undo
367 367
  *     Pile complétée par le code à générer
368 368
  */
369 369
 function balise_URL_ACTION_AUTEUR_dist($p) {
370
-	$p->descr['session'] = true;
371
-
372
-	$p->code = interprete_argument_balise(1, $p);
373
-
374
-	$args = interprete_argument_balise(2, $p);
375
-	if ($args != "''" && $args !== null) {
376
-		$p->code .= ',' . $args;
377
-	}
378
-	$redirect = interprete_argument_balise(3, $p);
379
-	if ($redirect != "''" && $redirect !== null) {
380
-		if ($args == "''" || $args === null) {
381
-			$p->code .= ",''";
382
-		}
383
-		$p->code .= ',' . $redirect;
384
-	}
385
-
386
-	$p->code = 'generer_action_auteur(' . $p->code . ')';
387
-	$p->interdire_scripts = false;
388
-
389
-	return $p;
370
+    $p->descr['session'] = true;
371
+
372
+    $p->code = interprete_argument_balise(1, $p);
373
+
374
+    $args = interprete_argument_balise(2, $p);
375
+    if ($args != "''" && $args !== null) {
376
+        $p->code .= ',' . $args;
377
+    }
378
+    $redirect = interprete_argument_balise(3, $p);
379
+    if ($redirect != "''" && $redirect !== null) {
380
+        if ($args == "''" || $args === null) {
381
+            $p->code .= ",''";
382
+        }
383
+        $p->code .= ',' . $redirect;
384
+    }
385
+
386
+    $p->code = 'generer_action_auteur(' . $p->code . ')';
387
+    $p->interdire_scripts = false;
388
+
389
+    return $p;
390 390
 }
Please login to merge, or discard this patch.
ecrire/inc/pipelines_ecrire.php 1 patch
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Pipelines
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -35,36 +35,36 @@  discard block
 block discarded – undo
35 35
  * @return string          Contenu complété des scripts javascripts, dont jQuery
36 36
  **/
37 37
 function f_jQuery_prive($texte) {
38
-	$x = '';
39
-	$jquery_plugins = pipeline(
40
-		'jquery_plugins',
41
-		[
42
-			'prive/javascript/jquery.js',
43
-			'prive/javascript/jquery.form.js',
44
-			'prive/javascript/jquery.autosave.js',
45
-			'prive/javascript/jquery.placeholder-label.js',
46
-			'prive/javascript/ajaxCallback.js',
47
-			'prive/javascript/js.cookie.js',
48
-			'prive/javascript/spip_barre.js',
49
-		]
50
-	);
51
-	foreach (array_unique($jquery_plugins) as $script) {
52
-		if ($script = find_in_path(supprimer_timestamp($script))) {
53
-			$script = timestamp($script);
54
-			$x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
55
-		}
56
-	}
57
-	// inserer avant le premier script externe ou a la fin
58
-	if (
59
-		preg_match(',<script[^><]*src=,', $texte, $match)
60
-		and $p = strpos($texte, (string) $match[0])
61
-	) {
62
-		$texte = substr_replace($texte, $x, $p, 0);
63
-	} else {
64
-		$texte .= $x;
65
-	}
38
+    $x = '';
39
+    $jquery_plugins = pipeline(
40
+        'jquery_plugins',
41
+        [
42
+            'prive/javascript/jquery.js',
43
+            'prive/javascript/jquery.form.js',
44
+            'prive/javascript/jquery.autosave.js',
45
+            'prive/javascript/jquery.placeholder-label.js',
46
+            'prive/javascript/ajaxCallback.js',
47
+            'prive/javascript/js.cookie.js',
48
+            'prive/javascript/spip_barre.js',
49
+        ]
50
+    );
51
+    foreach (array_unique($jquery_plugins) as $script) {
52
+        if ($script = find_in_path(supprimer_timestamp($script))) {
53
+            $script = timestamp($script);
54
+            $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n";
55
+        }
56
+    }
57
+    // inserer avant le premier script externe ou a la fin
58
+    if (
59
+        preg_match(',<script[^><]*src=,', $texte, $match)
60
+        and $p = strpos($texte, (string) $match[0])
61
+    ) {
62
+        $texte = substr_replace($texte, $x, $p, 0);
63
+    } else {
64
+        $texte .= $x;
65
+    }
66 66
 
67
-	return $texte;
67
+    return $texte;
68 68
 }
69 69
 
70 70
 
@@ -77,42 +77,42 @@  discard block
 block discarded – undo
77 77
  * @return string
78 78
  */
79 79
 function affichage_final_prive_title_auto($texte) {
80
-	if (
81
-		strpos($texte, '<title>') === false
82
-		and
83
-		(preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match)
84
-			or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match))
85
-		and $match = textebrut(trim($match[1]))
86
-		and ($p = strpos($texte, '<head>')) !== false
87
-	) {
88
-		if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
89
-			$nom_site_spip = _T('info_mon_site_spip');
90
-		}
80
+    if (
81
+        strpos($texte, '<title>') === false
82
+        and
83
+        (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match)
84
+            or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match))
85
+        and $match = textebrut(trim($match[1]))
86
+        and ($p = strpos($texte, '<head>')) !== false
87
+    ) {
88
+        if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) {
89
+            $nom_site_spip = _T('info_mon_site_spip');
90
+        }
91 91
 
92
-		$titre = '<title>['
93
-			. $nom_site_spip
94
-			. '] ' . $match
95
-			. '</title>';
92
+        $titre = '<title>['
93
+            . $nom_site_spip
94
+            . '] ' . $match
95
+            . '</title>';
96 96
 
97
-		$texte = substr_replace($texte, $titre, $p + 6, 0);
98
-	}
97
+        $texte = substr_replace($texte, $titre, $p + 6, 0);
98
+    }
99 99
 
100
-	return $texte;
100
+    return $texte;
101 101
 }
102 102
 
103 103
 
104 104
 // Fonction standard pour le pipeline 'boite_infos'
105 105
 function f_boite_infos($flux) {
106
-	$args = $flux['args'];
107
-	$type = $args['type'];
108
-	unset($args['row']);
109
-	if (!trouver_fond($type, 'prive/objets/infos/')) {
110
-		$type = 'objet';
111
-	}
112
-	$args['espace_prive'] = 1;
113
-	$flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args);
106
+    $args = $flux['args'];
107
+    $type = $args['type'];
108
+    unset($args['row']);
109
+    if (!trouver_fond($type, 'prive/objets/infos/')) {
110
+        $type = 'objet';
111
+    }
112
+    $args['espace_prive'] = 1;
113
+    $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args);
114 114
 
115
-	return $flux;
115
+    return $flux;
116 116
 }
117 117
 
118 118
 
@@ -131,97 +131,97 @@  discard block
 block discarded – undo
131 131
  * @return array Données du pipeline
132 132
  */
133 133
 function f_afficher_blocs_ecrire($flux) {
134
-	static $o = [];
135
-	if (is_string($fond = $flux['args']['fond'])) {
136
-		$exec = $flux['args']['contexte']['exec'] ?? _request('exec');
137
-		if (!isset($o[$exec])) {
138
-			$o[$exec] = trouver_objet_exec($exec);
139
-		}
140
-		// cas particulier
141
-		if ($exec == 'infos_perso') {
142
-			$flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'];
143
-		}
144
-		$typepage = ($flux['args']['contexte']['type-page'] ?? $exec);
145
-		if ($fond == "prive/squelettes/navigation/$typepage") {
146
-			$flux['data']['texte'] = pipeline(
147
-				'affiche_gauche',
148
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
149
-			);
150
-		} elseif ($fond == "prive/squelettes/extra/$typepage") {
151
-			include_spip('inc/presentation_mini');
152
-			$flux['data']['texte'] = pipeline(
153
-				'affiche_droite',
154
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
155
-			) . liste_objets_bloques(
156
-				$exec,
157
-				$flux['args']['contexte']
158
-			);
159
-		} elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) {
160
-			// id non defini sur les formulaire de nouveaux objets
161
-			$id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0;
162
-			$flux['data']['texte'] = pipeline(
163
-				'affiche_hierarchie',
164
-				['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']]
165
-			);
166
-		} elseif ($fond == "prive/squelettes/contenu/$typepage") {
167
-			// Préparation du marqueur affiche_milieu
168
-			// Si c'est la page d'un objet pas en édition, on l'encapsule dans un div
169
-			$est_page_objet = !empty($o[$exec]['type']);
170
-			$est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true);
171
-			$encapsuler_milieu = ($est_page_objet and !$est_en_edition);
172
-			$flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur(
173
-				$flux['data']['texte'],
174
-				'<!--affiche_milieu-->',
175
-				'<div id=["\']wysiwyg',
176
-				$encapsuler_milieu ? '<div class="affiche_milieu">' : '',
177
-				$encapsuler_milieu ? '</div>' : ''
178
-			);
179
-			if (
180
-				$o[$exec]
181
-				and $objet = $o[$exec]['type']
182
-				and $o[$exec]['edition'] == false
183
-				and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']])
184
-				and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])
185
-			) {
186
-				// inserer le formulaire de traduction
187
-				$flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond(
188
-					'prive/objets/editer/traductions',
189
-					['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1]
190
-				) . '<!--affiche_milieu-->', $flux['data']['texte']);
191
-				$flux['data']['texte'] = pipeline('afficher_fiche_objet', [
192
-					'args' => [
193
-						'contexte' => $flux['args']['contexte'],
194
-						'type' => $objet,
195
-						'id' => $id
196
-					],
197
-					'data' => $flux['data']['texte']
198
-				]);
199
-			}
200
-			$flux['data']['texte'] = pipeline(
201
-				'affiche_milieu',
202
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
203
-			);
204
-		} elseif ($fond == 'prive/squelettes/inclure/pied') {
205
-			$flux['data']['texte'] = pipeline(
206
-				'affiche_pied',
207
-				['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
208
-			);
209
-		} elseif (
210
-			strncmp($fond, 'prive/objets/contenu/', 21) == 0
211
-			and $objet = basename($fond)
212
-			and $objet == substr($fond, 21)
213
-			and isset($o[$objet])
214
-			and $o[$objet]
215
-		) {
216
-			$id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]);
217
-			$flux['data']['texte'] = pipeline('afficher_contenu_objet', [
218
-				'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']],
219
-				'data' => $flux['data']['texte']
220
-			]);
221
-		}
222
-	}
134
+    static $o = [];
135
+    if (is_string($fond = $flux['args']['fond'])) {
136
+        $exec = $flux['args']['contexte']['exec'] ?? _request('exec');
137
+        if (!isset($o[$exec])) {
138
+            $o[$exec] = trouver_objet_exec($exec);
139
+        }
140
+        // cas particulier
141
+        if ($exec == 'infos_perso') {
142
+            $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur'];
143
+        }
144
+        $typepage = ($flux['args']['contexte']['type-page'] ?? $exec);
145
+        if ($fond == "prive/squelettes/navigation/$typepage") {
146
+            $flux['data']['texte'] = pipeline(
147
+                'affiche_gauche',
148
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
149
+            );
150
+        } elseif ($fond == "prive/squelettes/extra/$typepage") {
151
+            include_spip('inc/presentation_mini');
152
+            $flux['data']['texte'] = pipeline(
153
+                'affiche_droite',
154
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
155
+            ) . liste_objets_bloques(
156
+                $exec,
157
+                $flux['args']['contexte']
158
+            );
159
+        } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) {
160
+            // id non defini sur les formulaire de nouveaux objets
161
+            $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0;
162
+            $flux['data']['texte'] = pipeline(
163
+                'affiche_hierarchie',
164
+                ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']]
165
+            );
166
+        } elseif ($fond == "prive/squelettes/contenu/$typepage") {
167
+            // Préparation du marqueur affiche_milieu
168
+            // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div
169
+            $est_page_objet = !empty($o[$exec]['type']);
170
+            $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true);
171
+            $encapsuler_milieu = ($est_page_objet and !$est_en_edition);
172
+            $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur(
173
+                $flux['data']['texte'],
174
+                '<!--affiche_milieu-->',
175
+                '<div id=["\']wysiwyg',
176
+                $encapsuler_milieu ? '<div class="affiche_milieu">' : '',
177
+                $encapsuler_milieu ? '</div>' : ''
178
+            );
179
+            if (
180
+                $o[$exec]
181
+                and $objet = $o[$exec]['type']
182
+                and $o[$exec]['edition'] == false
183
+                and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']])
184
+                and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])
185
+            ) {
186
+                // inserer le formulaire de traduction
187
+                $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond(
188
+                    'prive/objets/editer/traductions',
189
+                    ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1]
190
+                ) . '<!--affiche_milieu-->', $flux['data']['texte']);
191
+                $flux['data']['texte'] = pipeline('afficher_fiche_objet', [
192
+                    'args' => [
193
+                        'contexte' => $flux['args']['contexte'],
194
+                        'type' => $objet,
195
+                        'id' => $id
196
+                    ],
197
+                    'data' => $flux['data']['texte']
198
+                ]);
199
+            }
200
+            $flux['data']['texte'] = pipeline(
201
+                'affiche_milieu',
202
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
203
+            );
204
+        } elseif ($fond == 'prive/squelettes/inclure/pied') {
205
+            $flux['data']['texte'] = pipeline(
206
+                'affiche_pied',
207
+                ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']]
208
+            );
209
+        } elseif (
210
+            strncmp($fond, 'prive/objets/contenu/', 21) == 0
211
+            and $objet = basename($fond)
212
+            and $objet == substr($fond, 21)
213
+            and isset($o[$objet])
214
+            and $o[$objet]
215
+        ) {
216
+            $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]);
217
+            $flux['data']['texte'] = pipeline('afficher_contenu_objet', [
218
+                'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']],
219
+                'data' => $flux['data']['texte']
220
+            ]);
221
+        }
222
+    }
223 223
 
224
-	return $flux;
224
+    return $flux;
225 225
 }
226 226
 
227 227
 /**
@@ -249,36 +249,36 @@  discard block
 block discarded – undo
249 249
  */
250 250
 function afficher_blocs_ecrire_preparer_marqueur(?string $texte, string $marqueur, string $inserer_avant, string $ouvrir = '', string $fermer = ''): ?string {
251 251
 
252
-	if ($texte) {
253
-		$encapsuler = (($ouvrir and $fermer) ? true : false);
254
-		$marqueur_pos = strpos($texte, $marqueur);
255
-		$full_marqueur = "$ouvrir$marqueur$fermer";
252
+    if ($texte) {
253
+        $encapsuler = (($ouvrir and $fermer) ? true : false);
254
+        $marqueur_pos = strpos($texte, $marqueur);
255
+        $full_marqueur = "$ouvrir$marqueur$fermer";
256 256
 
257
-		// Le marqueur est absent : on l'ajoute avant l'élément indiqué
258
-		if ($marqueur_pos  === false) {
259
-			$texte = preg_replace(
260
-				",$inserer_avant,",
261
-				"$full_marqueur\\0",
262
-				$texte
263
-			);
264
-		// Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes.
265
-		// Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante.
266
-		// Il ne faut donc aucun espace blanc en trop.
267
-		} elseif (
268
-			$marqueur_pos !== false
269
-			and $encapsuler
270
-			and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir
271
-		) {
272
-			$texte = substr_replace(
273
-				$texte,
274
-				$full_marqueur,
275
-				$marqueur_pos,
276
-				strlen($marqueur)
277
-			);
278
-		}
279
-	}
257
+        // Le marqueur est absent : on l'ajoute avant l'élément indiqué
258
+        if ($marqueur_pos  === false) {
259
+            $texte = preg_replace(
260
+                ",$inserer_avant,",
261
+                "$full_marqueur\\0",
262
+                $texte
263
+            );
264
+        // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes.
265
+        // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante.
266
+        // Il ne faut donc aucun espace blanc en trop.
267
+        } elseif (
268
+            $marqueur_pos !== false
269
+            and $encapsuler
270
+            and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir
271
+        ) {
272
+            $texte = substr_replace(
273
+                $texte,
274
+                $full_marqueur,
275
+                $marqueur_pos,
276
+                strlen($marqueur)
277
+            );
278
+        }
279
+    }
280 280
 
281
-	return $texte;
281
+    return $texte;
282 282
 }
283 283
 
284 284
 /**
@@ -289,23 +289,23 @@  discard block
 block discarded – undo
289 289
  * @return string
290 290
  */
291 291
 function f_queue_affiche_milieu($flux) {
292
-	$args = $flux['args'];
293
-	$res = '';
294
-	foreach ($args as $key => $arg) {
295
-		if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) {
296
-			$objet = preg_replace(',^id_,', '', $key);
297
-			$res .= recuperer_fond(
298
-				'modeles/object_jobs_list',
299
-				['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1],
300
-				['ajax' => true]
301
-			);
302
-		}
303
-	}
304
-	if ($res) {
305
-		$flux['data'] = $res . $flux['data'];
306
-	}
292
+    $args = $flux['args'];
293
+    $res = '';
294
+    foreach ($args as $key => $arg) {
295
+        if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) {
296
+            $objet = preg_replace(',^id_,', '', $key);
297
+            $res .= recuperer_fond(
298
+                'modeles/object_jobs_list',
299
+                ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1],
300
+                ['ajax' => true]
301
+            );
302
+        }
303
+    }
304
+    if ($res) {
305
+        $flux['data'] = $res . $flux['data'];
306
+    }
307 307
 
308
-	return $flux;
308
+    return $flux;
309 309
 }
310 310
 
311 311
 /**
@@ -319,39 +319,39 @@  discard block
 block discarded – undo
319 319
  * @return array|bool
320 320
  */
321 321
 function trouver_objet_exec(?string $exec) {
322
-	static $objet_exec = [];
323
-	if (!$exec) {
324
-		return false;
325
-	}
326
-	// cas particulier
327
-	if ($exec === 'infos_perso') {
328
-		$exec = 'auteur';
329
-		set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']);
330
-	}
331
-	if (!isset($objet_exec[$exec])) {
332
-		$objet_exec[$exec] = false;
333
-		$infos = lister_tables_objets_sql();
334
-		foreach ($infos as $t => $info) {
335
-			if ($exec === $info['url_edit'] and $info['editable']) {
336
-				return $objet_exec[$exec] = [
337
-					'edition' => $exec == $info['url_voir'] ? '' : true,
338
-					'table_objet_sql' => $t,
339
-					'table' => $info['table_objet'],
340
-					'type' => $info['type'],
341
-					'id_table_objet' => id_table_objet($info['type'])
342
-				];
343
-			}
344
-			if ($exec === $info['url_voir']) {
345
-				return $objet_exec[$exec] = [
346
-					'edition' => false,
347
-					'table_objet_sql' => $t,
348
-					'table' => $info['table_objet'],
349
-					'type' => $info['type'],
350
-					'id_table_objet' => id_table_objet($info['type'])
351
-				];
352
-			}
353
-		}
354
-	}
322
+    static $objet_exec = [];
323
+    if (!$exec) {
324
+        return false;
325
+    }
326
+    // cas particulier
327
+    if ($exec === 'infos_perso') {
328
+        $exec = 'auteur';
329
+        set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']);
330
+    }
331
+    if (!isset($objet_exec[$exec])) {
332
+        $objet_exec[$exec] = false;
333
+        $infos = lister_tables_objets_sql();
334
+        foreach ($infos as $t => $info) {
335
+            if ($exec === $info['url_edit'] and $info['editable']) {
336
+                return $objet_exec[$exec] = [
337
+                    'edition' => $exec == $info['url_voir'] ? '' : true,
338
+                    'table_objet_sql' => $t,
339
+                    'table' => $info['table_objet'],
340
+                    'type' => $info['type'],
341
+                    'id_table_objet' => id_table_objet($info['type'])
342
+                ];
343
+            }
344
+            if ($exec === $info['url_voir']) {
345
+                return $objet_exec[$exec] = [
346
+                    'edition' => false,
347
+                    'table_objet_sql' => $t,
348
+                    'table' => $info['table_objet'],
349
+                    'type' => $info['type'],
350
+                    'id_table_objet' => id_table_objet($info['type'])
351
+                ];
352
+            }
353
+        }
354
+    }
355 355
 
356
-	return $objet_exec[$exec];
356
+    return $objet_exec[$exec];
357 357
 }
Please login to merge, or discard this patch.
prive/transmettre/rss/a_suivre_fonctions.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (!defined('_ECRIRE_INC_VERSION')) {
4
-	return;
4
+    return;
5 5
 }
6 6
 
7 7
 function trier_rss($texte) {
8
-	if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) {
9
-		$placeholder = '<!--REINSERT-->';
10
-		$items = [];
11
-		foreach ($matches as $match) {
12
-			if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) {
13
-				$items[strtotime($r[1])] = trim($match[0]);
14
-				$texte = str_replace($match[0], unique($placeholder), $texte);
15
-			}
16
-		}
17
-		krsort($items);
18
-		$texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte);
19
-	}
8
+    if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) {
9
+        $placeholder = '<!--REINSERT-->';
10
+        $items = [];
11
+        foreach ($matches as $match) {
12
+            if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) {
13
+                $items[strtotime($r[1])] = trim($match[0]);
14
+                $texte = str_replace($match[0], unique($placeholder), $texte);
15
+            }
16
+        }
17
+        krsort($items);
18
+        $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte);
19
+    }
20 20
 
21
-	return $texte;
21
+    return $texte;
22 22
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_plugin.php 1 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/admin.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -45,29 +45,29 @@  discard block
 block discarded – undo
45 45
  *     sinon code HTML de la page après le traitement effectué.
46 46
  **/
47 47
 function inc_admin_dist($script, $titre, $comment = '', $anonymous = false) {
48
-	$reprise = true;
49
-	if (
50
-		!isset($GLOBALS['meta'][$script])
51
-		or !isset($GLOBALS['meta']['admin'])
52
-	) {
53
-		$reprise = false;
54
-		$res = debut_admin($script, $titre, $comment);
55
-		if ($res) {
56
-			return $res;
57
-		}
58
-		spip_log("meta: $script " . print_r($_POST, true));
59
-		ecrire_meta($script, serialize($_POST));
60
-	}
48
+    $reprise = true;
49
+    if (
50
+        !isset($GLOBALS['meta'][$script])
51
+        or !isset($GLOBALS['meta']['admin'])
52
+    ) {
53
+        $reprise = false;
54
+        $res = debut_admin($script, $titre, $comment);
55
+        if ($res) {
56
+            return $res;
57
+        }
58
+        spip_log("meta: $script " . print_r($_POST, true));
59
+        ecrire_meta($script, serialize($_POST));
60
+    }
61 61
 
62
-	$res = admin_verifie_session($script, $anonymous);
63
-	if ($res) {
64
-		return $res;
65
-	}
66
-	$base = charger_fonction($script, 'base');
67
-	$base($titre, $reprise);
68
-	fin_admin($script);
62
+    $res = admin_verifie_session($script, $anonymous);
63
+    if ($res) {
64
+        return $res;
65
+    }
66
+    $base = charger_fonction($script, 'base');
67
+    $base($titre, $reprise);
68
+    fin_admin($script);
69 69
 
70
-	return '';
70
+    return '';
71 71
 }
72 72
 
73 73
 /**
@@ -98,35 +98,35 @@  discard block
 block discarded – undo
98 98
  *     Code HTML si message d'erreur, '' sinon;
99 99
  */
100 100
 function admin_verifie_session($script, $anonymous = false) {
101
-	include_spip('base/abstract_sql');
102
-	$pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']);
103
-	$signal = fichier_admin($script, "$script$pref");
104
-	$valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
105
-	if ($valeur === null) {
106
-		ecrire_meta('admin', $signal, 'non');
107
-	} else {
108
-		if (!$anonymous and ($valeur != $signal)) {
109
-			if (
110
-				!preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)
111
-				or intval($l[2]) != $GLOBALS['visiteur_session']['id_auteur']
112
-			) {
113
-				include_spip('inc/minipres');
114
-				spip_log("refus de lancer $script, priorite a $valeur");
101
+    include_spip('base/abstract_sql');
102
+    $pref = sprintf('_%d_', $GLOBALS['visiteur_session']['id_auteur']);
103
+    $signal = fichier_admin($script, "$script$pref");
104
+    $valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
105
+    if ($valeur === null) {
106
+        ecrire_meta('admin', $signal, 'non');
107
+    } else {
108
+        if (!$anonymous and ($valeur != $signal)) {
109
+            if (
110
+                !preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']['admin'], $l)
111
+                or intval($l[2]) != $GLOBALS['visiteur_session']['id_auteur']
112
+            ) {
113
+                include_spip('inc/minipres');
114
+                spip_log("refus de lancer $script, priorite a $valeur");
115 115
 
116
-				return minipres(_T('info_travaux_texte'), '', ['status' => 503]);
117
-			}
118
-		}
119
-	}
120
-	$journal = 'spip';
121
-	if (autoriser('configurer')) {
122
-		// c'est une action webmestre, soit par ftp soit par statut webmestre
123
-		$journal = 'webmestre';
124
-	}
125
-	// on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
116
+                return minipres(_T('info_travaux_texte'), '', ['status' => 503]);
117
+            }
118
+        }
119
+    }
120
+    $journal = 'spip';
121
+    if (autoriser('configurer')) {
122
+        // c'est une action webmestre, soit par ftp soit par statut webmestre
123
+        $journal = 'webmestre';
124
+    }
125
+    // on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
126 126
 
127
-	spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal);
127
+    spip_log("admin $pref" . ($valeur ? ' (reprise)' : ' (init)'), $journal);
128 128
 
129
-	return '';
129
+    return '';
130 130
 }
131 131
 
132 132
 /**
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
  *     Chemin du répertoire.
140 140
  **/
141 141
 function dir_admin() {
142
-	if (autoriser('configurer')) {
143
-		return _DIR_TMP;
144
-	} else {
145
-		return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
146
-	}
142
+    if (autoriser('configurer')) {
143
+        return _DIR_TMP;
144
+    } else {
145
+        return _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
146
+    }
147 147
 }
148 148
 
149 149
 /**
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
  *     Nom du fichier
161 161
  **/
162 162
 function fichier_admin($action, $pref = 'admin_') {
163
-	return $pref .
164
-	substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10);
163
+    return $pref .
164
+    substr(md5($action . (time() & ~2047) . $GLOBALS['visiteur_session']['login']), 0, 10);
165 165
 }
166 166
 
167 167
 /**
@@ -187,73 +187,73 @@  discard block
 block discarded – undo
187 187
  *     sinon chaîne vide si déjà fait.
188 188
  **/
189 189
 function debut_admin($script, $action = '', $corps = '') {
190
-	if ((!$action) || !(autoriser('webmestre') or autoriser('chargerftp'))) {
191
-		include_spip('inc/minipres');
190
+    if ((!$action) || !(autoriser('webmestre') or autoriser('chargerftp'))) {
191
+        include_spip('inc/minipres');
192 192
 
193
-		return minipres();
194
-	} else {
195
-		$dir = dir_admin();
196
-		$signal = fichier_admin($script);
197
-		if (@file_exists($dir . $signal)) {
198
-			spip_log("Action admin: $action");
193
+        return minipres();
194
+    } else {
195
+        $dir = dir_admin();
196
+        $signal = fichier_admin($script);
197
+        if (@file_exists($dir . $signal)) {
198
+            spip_log("Action admin: $action");
199 199
 
200
-			return '';
201
-		}
202
-		include_spip('inc/minipres');
200
+            return '';
201
+        }
202
+        include_spip('inc/minipres');
203 203
 
204
-		// Si on est un super-admin, un bouton de validation suffit
205
-		// sauf dans les cas destroy
206
-		if (
207
-			(autoriser('webmestre') or $script === 'repair')
208
-			and $script != 'delete_all'
209
-		) {
210
-			if (_request('validation_admin') == $signal) {
211
-				spip_log("Action super-admin: $action");
204
+        // Si on est un super-admin, un bouton de validation suffit
205
+        // sauf dans les cas destroy
206
+        if (
207
+            (autoriser('webmestre') or $script === 'repair')
208
+            and $script != 'delete_all'
209
+        ) {
210
+            if (_request('validation_admin') == $signal) {
211
+                spip_log("Action super-admin: $action");
212 212
 
213
-				return '';
214
-			}
215
-			$corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />';
216
-			$suivant = _T('bouton_valider');
217
-			$js = '';
218
-		} else {
219
-			// cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
220
-			// l'insertion du script a cet endroit n'est pas xhtml licite
221
-			// mais evite de l'embarquer dans toutes les pages minipres
222
-			$corps .= http_script('', 'spip_barre.js');
213
+                return '';
214
+            }
215
+            $corps .= '<input type="hidden" name="validation_admin" value="' . $signal . '" />';
216
+            $suivant = _T('bouton_valider');
217
+            $js = '';
218
+        } else {
219
+            // cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
220
+            // l'insertion du script a cet endroit n'est pas xhtml licite
221
+            // mais evite de l'embarquer dans toutes les pages minipres
222
+            $corps .= http_script('', 'spip_barre.js');
223 223
 
224
-			$corps .= '<fieldset><legend>'
225
-				. _T('info_authentification_ftp')
226
-				. aider('ftp_auth')
227
-				. "</legend>\n<label for='fichier'>"
228
-				. _T('info_creer_repertoire')
229
-				. "</label>\n"
230
-				. "<span id='signal' class='formo'>" . $signal . '</span>'
231
-				. "<input type='hidden' id='fichier' name='fichier' value='"
232
-				. $signal
233
-				. "' />"
234
-				. _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)])
235
-				. '</fieldset>';
224
+            $corps .= '<fieldset><legend>'
225
+                . _T('info_authentification_ftp')
226
+                . aider('ftp_auth')
227
+                . "</legend>\n<label for='fichier'>"
228
+                . _T('info_creer_repertoire')
229
+                . "</label>\n"
230
+                . "<span id='signal' class='formo'>" . $signal . '</span>'
231
+                . "<input type='hidden' id='fichier' name='fichier' value='"
232
+                . $signal
233
+                . "' />"
234
+                . _T('info_creer_repertoire_2', ['repertoire' => joli_repertoire($dir)])
235
+                . '</fieldset>';
236 236
 
237
-			$suivant = _T('bouton_recharger_page');
237
+            $suivant = _T('bouton_recharger_page');
238 238
 
239
-			// code volontairement tordu:
240
-			// provoquer la copie dans le presse papier du nom du repertoire
241
-			// en remettant a vide le champ pour que ca marche aussi en cas
242
-			// de JavaScript inactif.
243
-			$js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
244
-		}
239
+            // code volontairement tordu:
240
+            // provoquer la copie dans le presse papier du nom du repertoire
241
+            // en remettant a vide le champ pour que ca marche aussi en cas
242
+            // de JavaScript inactif.
243
+            $js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
244
+        }
245 245
 
246
-		// admin/xxx correspond
247
-		// a exec/base_xxx de preference
248
-		// et exec/xxx sinon (compat)
249
-		if (tester_url_ecrire("base_$script")) {
250
-			$script = "base_$script";
251
-		}
252
-		$form = copy_request($script, $corps, $suivant);
253
-		$info_action = _T('info_action', ['action' => "$action"]);
246
+        // admin/xxx correspond
247
+        // a exec/base_xxx de preference
248
+        // et exec/xxx sinon (compat)
249
+        if (tester_url_ecrire("base_$script")) {
250
+            $script = "base_$script";
251
+        }
252
+        $form = copy_request($script, $corps, $suivant);
253
+        $info_action = _T('info_action', ['action' => "$action"]);
254 254
 
255
-		return minipres($info_action, $form, ['onload' => $js]);
256
-	}
255
+        return minipres($info_action, $form, ['onload' => $js]);
256
+    }
257 257
 }
258 258
 
259 259
 /**
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
  *     Nom de l'action (en base) qui a été exécutée
265 265
  **/
266 266
 function fin_admin($action) {
267
-	$signal = dir_admin() . fichier_admin($action);
268
-	spip_unlink($signal);
269
-	if ($action != 'delete_all') {
270
-		effacer_meta($action);
271
-		effacer_meta('admin');
272
-		spip_log("efface les meta admin et $action ");
273
-	}
267
+    $signal = dir_admin() . fichier_admin($action);
268
+    spip_unlink($signal);
269
+    if ($action != 'delete_all') {
270
+        effacer_meta($action);
271
+        effacer_meta('admin');
272
+        spip_log("efface les meta admin et $action ");
273
+    }
274 274
 }
275 275
 
276 276
 /**
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
  *     Code HTML du formulaire
290 290
  **/
291 291
 function copy_request($script, $suite, $submit = '') {
292
-	include_spip('inc/filtres');
293
-	foreach (array_merge($_POST, $_GET) as $n => $c) {
294
-		if (!in_array($n, ['fichier', 'exec', 'validation_admin']) and !is_array($c)) {
295
-			$suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" .
296
-				entites_html($c) .
297
-				"'  />";
298
-		}
299
-	}
292
+    include_spip('inc/filtres');
293
+    foreach (array_merge($_POST, $_GET) as $n => $c) {
294
+        if (!in_array($n, ['fichier', 'exec', 'validation_admin']) and !is_array($c)) {
295
+            $suite .= "\n<input type='hidden' name='" . spip_htmlspecialchars($n) . "' value='" .
296
+                entites_html($c) .
297
+                "'  />";
298
+        }
299
+    }
300 300
 
301
-	return generer_form_ecrire($script, $suite, '', $submit);
301
+    return generer_form_ecrire($script, $suite, '', $submit);
302 302
 }
Please login to merge, or discard this patch.
ecrire/action/converser.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Langue
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/cookie');
@@ -30,21 +30,21 @@  discard block
 block discarded – undo
30 30
  * @return void
31 31
  */
32 32
 function action_converser_dist() {
33
-	$update_session = false;
34
-	if (_request('arg') and spip_connect()) {
35
-		$securiser_action = charger_fonction('securiser_action', 'inc');
36
-		$securiser_action();
37
-		$update_session = true;
38
-	}
33
+    $update_session = false;
34
+    if (_request('arg') and spip_connect()) {
35
+        $securiser_action = charger_fonction('securiser_action', 'inc');
36
+        $securiser_action();
37
+        $update_session = true;
38
+    }
39 39
 
40
-	$lang = action_converser_changer_langue($update_session);
41
-	$redirect = rawurldecode(_request('redirect'));
40
+    $lang = action_converser_changer_langue($update_session);
41
+    $redirect = rawurldecode(_request('redirect'));
42 42
 
43
-	if (!$redirect) {
44
-		$redirect = _DIR_RESTREINT_ABS;
45
-	}
46
-	$redirect = parametre_url($redirect, 'lang', $lang, '&');
47
-	redirige_par_entete($redirect, true);
43
+    if (!$redirect) {
44
+        $redirect = _DIR_RESTREINT_ABS;
45
+    }
46
+    $redirect = parametre_url($redirect, 'lang', $lang, '&');
47
+    redirige_par_entete($redirect, true);
48 48
 }
49 49
 
50 50
 /**
@@ -56,23 +56,23 @@  discard block
 block discarded – undo
56 56
  * @return string
57 57
  */
58 58
 function action_converser_changer_langue($update_session) {
59
-	if ($lang = _request('var_lang')) {
60
-		action_converser_post($lang);
61
-	} elseif ($lang = _request('var_lang_ecrire')) {
62
-		if ($update_session) {
63
-			sql_updateq('spip_auteurs', ['lang' => $lang], 'id_auteur = ' . $GLOBALS['visiteur_session']['id_auteur']);
64
-			$GLOBALS['visiteur_session']['lang'] = $lang;
65
-			$session = charger_fonction('session', 'inc');
66
-			if ($spip_session = $session($GLOBALS['visiteur_session'])) {
67
-				spip_setcookie('spip_session', $spip_session, [
68
-					'expires' => time() + 3600 * 24 * 14
69
-				]);
70
-			}
71
-		}
72
-		action_converser_post($lang, true);
73
-	}
59
+    if ($lang = _request('var_lang')) {
60
+        action_converser_post($lang);
61
+    } elseif ($lang = _request('var_lang_ecrire')) {
62
+        if ($update_session) {
63
+            sql_updateq('spip_auteurs', ['lang' => $lang], 'id_auteur = ' . $GLOBALS['visiteur_session']['id_auteur']);
64
+            $GLOBALS['visiteur_session']['lang'] = $lang;
65
+            $session = charger_fonction('session', 'inc');
66
+            if ($spip_session = $session($GLOBALS['visiteur_session'])) {
67
+                spip_setcookie('spip_session', $spip_session, [
68
+                    'expires' => time() + 3600 * 24 * 14
69
+                ]);
70
+            }
71
+        }
72
+        action_converser_post($lang, true);
73
+    }
74 74
 
75
-	return $lang;
75
+    return $lang;
76 76
 }
77 77
 
78 78
 /**
@@ -83,17 +83,17 @@  discard block
 block discarded – undo
83 83
  * @return void
84 84
  */
85 85
 function action_converser_post($lang, $ecrire = false) {
86
-	if ($lang) {
87
-		include_spip('inc/lang');
88
-		if (changer_langue($lang)) {
89
-			spip_setcookie('spip_lang', $_COOKIE['spip_lang'] = $lang, [
90
-				'expires' => time() + 365 * 24 * 3600
91
-			]);
92
-			if ($ecrire) {
93
-				spip_setcookie('spip_lang_ecrire', $_COOKIE['spip_lang_ecrire'] = $lang, [
94
-					'expires' => time() + 365 * 24 * 3600
95
-				]);
96
-			}
97
-		}
98
-	}
86
+    if ($lang) {
87
+        include_spip('inc/lang');
88
+        if (changer_langue($lang)) {
89
+            spip_setcookie('spip_lang', $_COOKIE['spip_lang'] = $lang, [
90
+                'expires' => time() + 365 * 24 * 3600
91
+            ]);
92
+            if ($ecrire) {
93
+                spip_setcookie('spip_lang_ecrire', $_COOKIE['spip_lang_ecrire'] = $lang, [
94
+                    'expires' => time() + 365 * 24 * 3600
95
+                ]);
96
+            }
97
+        }
98
+    }
99 99
 }
Please login to merge, or discard this patch.
ecrire/action/logout.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/cookie');
@@ -34,73 +34,73 @@  discard block
 block discarded – undo
34 34
  *
35 35
  */
36 36
 function action_logout_dist() {
37
-	$logout = _request('logout');
38
-	$url = securiser_redirect_action(_request('url'));
39
-	// cas particulier, logout dans l'espace public
40
-	if ($logout == 'public' and !$url) {
41
-		$url = url_de_base();
42
-	}
37
+    $logout = _request('logout');
38
+    $url = securiser_redirect_action(_request('url'));
39
+    // cas particulier, logout dans l'espace public
40
+    if ($logout == 'public' and !$url) {
41
+        $url = url_de_base();
42
+    }
43 43
 
44
-	// seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee)
45
-	if (
46
-		isset($GLOBALS['visiteur_session']['id_auteur'])
47
-		and is_numeric($GLOBALS['visiteur_session']['id_auteur'])
48
-		// des sessions anonymes avec id_auteur=0 existent, mais elle n'ont pas de statut : double check
49
-		and isset($GLOBALS['visiteur_session']['statut'])
50
-	) {
51
-		// il faut un jeton pour fermer la session (eviter les CSRF)
52
-		if (
53
-			!$jeton = _request('jeton')
54
-			or !verifier_jeton_logout($jeton, $GLOBALS['visiteur_session'])
55
-		) {
56
-			$jeton = generer_jeton_logout($GLOBALS['visiteur_session']);
57
-			$action = generer_url_action('logout', "jeton=$jeton");
58
-			$action = parametre_url($action, 'logout', _request('logout'));
59
-			$action = parametre_url($action, 'url', _request('url'));
60
-			include_spip('inc/minipres');
61
-			include_spip('inc/filtres');
62
-			$texte = bouton_action(_T('spip:icone_deconnecter'), $action);
63
-			$texte = "<div class='boutons'>$texte</div>";
64
-			$texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>';
65
-			$res = minipres(_T('spip:icone_deconnecter'), $texte, ['all_inline' => true]);
66
-			echo $res;
44
+    // seul le loge peut se deloger (mais id_auteur peut valoir 0 apres une restauration avortee)
45
+    if (
46
+        isset($GLOBALS['visiteur_session']['id_auteur'])
47
+        and is_numeric($GLOBALS['visiteur_session']['id_auteur'])
48
+        // des sessions anonymes avec id_auteur=0 existent, mais elle n'ont pas de statut : double check
49
+        and isset($GLOBALS['visiteur_session']['statut'])
50
+    ) {
51
+        // il faut un jeton pour fermer la session (eviter les CSRF)
52
+        if (
53
+            !$jeton = _request('jeton')
54
+            or !verifier_jeton_logout($jeton, $GLOBALS['visiteur_session'])
55
+        ) {
56
+            $jeton = generer_jeton_logout($GLOBALS['visiteur_session']);
57
+            $action = generer_url_action('logout', "jeton=$jeton");
58
+            $action = parametre_url($action, 'logout', _request('logout'));
59
+            $action = parametre_url($action, 'url', _request('url'));
60
+            include_spip('inc/minipres');
61
+            include_spip('inc/filtres');
62
+            $texte = bouton_action(_T('spip:icone_deconnecter'), $action);
63
+            $texte = "<div class='boutons'>$texte</div>";
64
+            $texte .= '<script type="text/javascript">document.write("<style>body{visibility:hidden;}</style>");window.document.forms[0].submit();</script>';
65
+            $res = minipres(_T('spip:icone_deconnecter'), $texte, ['all_inline' => true]);
66
+            echo $res;
67 67
 
68
-			return;
69
-		}
68
+            return;
69
+        }
70 70
 
71
-		include_spip('inc/auth');
72
-		auth_trace($GLOBALS['visiteur_session'], '0000-00-00 00:00:00');
73
-		// le logout explicite vaut destruction de toutes les sessions
74
-		if (isset($_COOKIE['spip_session'])) {
75
-			$session = charger_fonction('session', 'inc');
76
-			$session($GLOBALS['visiteur_session']['id_auteur']);
77
-			spip_setcookie('spip_session', $_COOKIE['spip_session'], [
78
-				'expires' => time() - 3600
79
-			]);
80
-		}
81
-		// si authentification http, et que la personne est loge,
82
-		// pour se deconnecter, il faut proposer un nouveau formulaire de connexion http
83
-		if (
84
-			isset($_SERVER['PHP_AUTH_USER'])
85
-			and !$GLOBALS['ignore_auth_http']
86
-			and $GLOBALS['auth_can_disconnect']
87
-		) {
88
-			ask_php_auth(
89
-				_T('login_deconnexion_ok'),
90
-				_T('login_verifiez_navigateur'),
91
-				_T('login_retour_public'),
92
-				'redirect=' . _DIR_RESTREINT_ABS,
93
-				_T('login_test_navigateur'),
94
-				true
95
-			);
96
-		}
97
-	}
71
+        include_spip('inc/auth');
72
+        auth_trace($GLOBALS['visiteur_session'], '0000-00-00 00:00:00');
73
+        // le logout explicite vaut destruction de toutes les sessions
74
+        if (isset($_COOKIE['spip_session'])) {
75
+            $session = charger_fonction('session', 'inc');
76
+            $session($GLOBALS['visiteur_session']['id_auteur']);
77
+            spip_setcookie('spip_session', $_COOKIE['spip_session'], [
78
+                'expires' => time() - 3600
79
+            ]);
80
+        }
81
+        // si authentification http, et que la personne est loge,
82
+        // pour se deconnecter, il faut proposer un nouveau formulaire de connexion http
83
+        if (
84
+            isset($_SERVER['PHP_AUTH_USER'])
85
+            and !$GLOBALS['ignore_auth_http']
86
+            and $GLOBALS['auth_can_disconnect']
87
+        ) {
88
+            ask_php_auth(
89
+                _T('login_deconnexion_ok'),
90
+                _T('login_verifiez_navigateur'),
91
+                _T('login_retour_public'),
92
+                'redirect=' . _DIR_RESTREINT_ABS,
93
+                _T('login_test_navigateur'),
94
+                true
95
+            );
96
+        }
97
+    }
98 98
 
99
-	// Rediriger en contrant le cache navigateur (Safari3)
100
-	include_spip('inc/headers');
101
-	redirige_par_entete($url
102
-		? parametre_url($url, 'var_hasard', uniqid(random_int(0, mt_getrandmax())), '&')
103
-		: generer_url_public('login'));
99
+    // Rediriger en contrant le cache navigateur (Safari3)
100
+    include_spip('inc/headers');
101
+    redirige_par_entete($url
102
+        ? parametre_url($url, 'var_hasard', uniqid(random_int(0, mt_getrandmax())), '&')
103
+        : generer_url_public('login'));
104 104
 }
105 105
 
106 106
 /**
@@ -111,17 +111,17 @@  discard block
 block discarded – undo
111 111
  * @return string
112 112
  */
113 113
 function generer_jeton_logout($session, $alea = null) {
114
-	if (is_null($alea)) {
115
-		include_spip('inc/acces');
116
-		$alea = charger_aleas();
117
-	}
114
+    if (is_null($alea)) {
115
+        include_spip('inc/acces');
116
+        $alea = charger_aleas();
117
+    }
118 118
 
119
-	$jeton = md5($session['date_session']
120
-		. $session['id_auteur']
121
-		. $session['statut']
122
-		. $alea);
119
+    $jeton = md5($session['date_session']
120
+        . $session['id_auteur']
121
+        . $session['statut']
122
+        . $alea);
123 123
 
124
-	return $jeton;
124
+    return $jeton;
125 125
 }
126 126
 
127 127
 /**
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
  * @return bool
136 136
  */
137 137
 function verifier_jeton_logout($jeton, $session) {
138
-	if (generer_jeton_logout($session) === $jeton) {
139
-		return true;
140
-	}
138
+    if (generer_jeton_logout($session) === $jeton) {
139
+        return true;
140
+    }
141 141
 
142
-	if (generer_jeton_logout($session, $GLOBALS['meta']['alea_ephemere_ancien']) === $jeton) {
143
-		return true;
144
-	}
142
+    if (generer_jeton_logout($session, $GLOBALS['meta']['alea_ephemere_ancien']) === $jeton) {
143
+        return true;
144
+    }
145 145
 
146
-	return false;
146
+    return false;
147 147
 }
Please login to merge, or discard this patch.
ecrire/action/instituer_langue_objet.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -31,43 +31,43 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function action_instituer_langue_objet_dist($objet, $id, $id_rubrique, $changer_lang, $serveur = '') {
34
-	if ($changer_lang) {
35
-		$table_objet_sql = table_objet_sql($objet);
36
-		$id_table_objet = id_table_objet($objet);
37
-		$trouver_table = charger_fonction('trouver_table', 'base');
38
-		$desc = $trouver_table($table_objet_sql, $serveur);
34
+    if ($changer_lang) {
35
+        $table_objet_sql = table_objet_sql($objet);
36
+        $id_table_objet = id_table_objet($objet);
37
+        $trouver_table = charger_fonction('trouver_table', 'base');
38
+        $desc = $trouver_table($table_objet_sql, $serveur);
39 39
 
40
-		$set = [];
41
-		if (isset($desc['field']['langue_choisie'])) {
42
-			$set['langue_choisie'] = 'oui';
43
-		}
40
+        $set = [];
41
+        if (isset($desc['field']['langue_choisie'])) {
42
+            $set['langue_choisie'] = 'oui';
43
+        }
44 44
 
45
-		if ($changer_lang != 'herit') {
46
-			$set['lang'] = $changer_lang;
47
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur);
48
-			include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees
49
-			if ($table_objet_sql == 'spip_rubriques') {
50
-				calculer_langues_rubriques();
51
-			}
52
-			$langues = calculer_langues_utilisees($serveur);
53
-			ecrire_meta('langues_utilisees', $langues);
54
-		} else {
55
-			$langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
56
-			if (!$langue_parent) {
57
-				$langue_parent = $GLOBALS['meta']['langue_site'];
58
-			}
59
-			$changer_lang = $langue_parent;
60
-			$set['lang'] = $changer_lang;
61
-			if (isset($set['langue_choisie'])) {
62
-				$set['langue_choisie'] = 'non';
63
-			}
64
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur);
65
-			if ($table_objet_sql == 'spip_rubriques') {
66
-				include_spip('inc/rubriques');
67
-				calculer_langues_rubriques();
68
-			}
69
-		}
70
-	}
45
+        if ($changer_lang != 'herit') {
46
+            $set['lang'] = $changer_lang;
47
+            sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur);
48
+            include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees
49
+            if ($table_objet_sql == 'spip_rubriques') {
50
+                calculer_langues_rubriques();
51
+            }
52
+            $langues = calculer_langues_utilisees($serveur);
53
+            ecrire_meta('langues_utilisees', $langues);
54
+        } else {
55
+            $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
56
+            if (!$langue_parent) {
57
+                $langue_parent = $GLOBALS['meta']['langue_site'];
58
+            }
59
+            $changer_lang = $langue_parent;
60
+            $set['lang'] = $changer_lang;
61
+            if (isset($set['langue_choisie'])) {
62
+                $set['langue_choisie'] = 'non';
63
+            }
64
+            sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id), [], $serveur);
65
+            if ($table_objet_sql == 'spip_rubriques') {
66
+                include_spip('inc/rubriques');
67
+                calculer_langues_rubriques();
68
+            }
69
+        }
70
+    }
71 71
 
72
-	return $changer_lang;
72
+    return $changer_lang;
73 73
 }
Please login to merge, or discard this patch.