Completed
Push — master ( 923621...1c404c )
by cam
08:12
created
ecrire/inc/plugin.php 3 patches
Indentation   +913 added lines, -913 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  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
 /** l'adresse du repertoire de telechargement et de decompactage des plugins */
24 24
 if (!defined('_DIR_PLUGINS_AUTO')) {
25
-	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
25
+    define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
26 26
 }
27 27
 
28 28
 #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins.
@@ -47,26 +47,26 @@  discard block
 block discarded – undo
47 47
  * @return array
48 48
 **/
49 49
 function liste_plugin_files($dir_plugins = null) {
50
-	static $plugin_files = array();
51
-	if (is_null($dir_plugins)) {
52
-		$dir_plugins = _DIR_PLUGINS;
53
-	}
54
-	if (!isset($plugin_files[$dir_plugins])
55
-		or count($plugin_files[$dir_plugins]) == 0
56
-	) {
57
-		$plugin_files[$dir_plugins] = array();
58
-		foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
59
-			$plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
60
-		}
61
-
62
-		sort($plugin_files[$dir_plugins]);
63
-		// et on lit le XML de tous les plugins pour le mettre en cache
64
-		// et en profiter pour nettoyer ceux qui n'existent plus du cache
65
-		$get_infos = charger_fonction('get_infos', 'plugins');
66
-		$get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
67
-	}
68
-
69
-	return $plugin_files[$dir_plugins];
50
+    static $plugin_files = array();
51
+    if (is_null($dir_plugins)) {
52
+        $dir_plugins = _DIR_PLUGINS;
53
+    }
54
+    if (!isset($plugin_files[$dir_plugins])
55
+        or count($plugin_files[$dir_plugins]) == 0
56
+    ) {
57
+        $plugin_files[$dir_plugins] = array();
58
+        foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
59
+            $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
60
+        }
61
+
62
+        sort($plugin_files[$dir_plugins]);
63
+        // et on lit le XML de tous les plugins pour le mettre en cache
64
+        // et en profiter pour nettoyer ceux qui n'existent plus du cache
65
+        $get_infos = charger_fonction('get_infos', 'plugins');
66
+        $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
67
+    }
68
+
69
+    return $plugin_files[$dir_plugins];
70 70
 }
71 71
 
72 72
 /**
@@ -82,44 +82,44 @@  discard block
 block discarded – undo
82 82
  *     Liste complète des répeertoires
83 83
 **/
84 84
 function fast_find_plugin_dirs($dir, $max_prof = 100) {
85
-	$fichiers = array();
86
-	// revenir au repertoire racine si on a recu dossier/truc
87
-	// pour regarder dossier/truc/ ne pas oublier le / final
88
-	$dir = preg_replace(',/[^/]*$,', '', $dir);
89
-	if ($dir == '') {
90
-		$dir = '.';
91
-	}
92
-
93
-	if (!is_dir($dir)) {
94
-		return $fichiers;
95
-	}
96
-	if (is_plugin_dir($dir, '')) {
97
-		$fichiers[] = $dir;
98
-
99
-		return $fichiers;
100
-	}
101
-	if ($max_prof <= 0) {
102
-		return $fichiers;
103
-	}
104
-
105
-	$subdirs = array();
106
-	if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
107
-		while (($f = readdir($d)) !== false) {
108
-			if ($f[0] != '.' # ignorer . .. .svn etc
109
-				and $f != 'CVS'
110
-				and is_dir($f = "$dir/$f")
111
-			) {
112
-				$subdirs[] = $f;
113
-			}
114
-		}
115
-		closedir($d);
116
-	}
117
-
118
-	foreach ($subdirs as $d) {
119
-		$fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
120
-	}
121
-
122
-	return $fichiers;
85
+    $fichiers = array();
86
+    // revenir au repertoire racine si on a recu dossier/truc
87
+    // pour regarder dossier/truc/ ne pas oublier le / final
88
+    $dir = preg_replace(',/[^/]*$,', '', $dir);
89
+    if ($dir == '') {
90
+        $dir = '.';
91
+    }
92
+
93
+    if (!is_dir($dir)) {
94
+        return $fichiers;
95
+    }
96
+    if (is_plugin_dir($dir, '')) {
97
+        $fichiers[] = $dir;
98
+
99
+        return $fichiers;
100
+    }
101
+    if ($max_prof <= 0) {
102
+        return $fichiers;
103
+    }
104
+
105
+    $subdirs = array();
106
+    if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
107
+        while (($f = readdir($d)) !== false) {
108
+            if ($f[0] != '.' # ignorer . .. .svn etc
109
+                and $f != 'CVS'
110
+                and is_dir($f = "$dir/$f")
111
+            ) {
112
+                $subdirs[] = $f;
113
+            }
114
+        }
115
+        closedir($d);
116
+    }
117
+
118
+    foreach ($subdirs as $d) {
119
+        $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
120
+    }
121
+
122
+    return $fichiers;
123 123
 }
124 124
 
125 125
 /**
@@ -140,27 +140,27 @@  discard block
 block discarded – undo
140 140
 **/
141 141
 function is_plugin_dir($dir, $dir_plugins = null) {
142 142
 
143
-	if (is_array($dir)) {
144
-		foreach ($dir as $k => $d) {
145
-			if (!is_plugin_dir($d, $dir_plugins)) {
146
-				unset($dir[$k]);
147
-			}
148
-		}
149
-
150
-		return $dir;
151
-	}
152
-	if (is_null($dir_plugins)) {
153
-		$dir_plugins = _DIR_PLUGINS;
154
-	}
155
-	$search = array("$dir_plugins$dir/plugin.xml", "$dir_plugins$dir/paquet.xml");
156
-
157
-	foreach ($search as $s) {
158
-		if (file_exists($s)) {
159
-			return $dir;
160
-		}
161
-	}
162
-
163
-	return '';
143
+    if (is_array($dir)) {
144
+        foreach ($dir as $k => $d) {
145
+            if (!is_plugin_dir($d, $dir_plugins)) {
146
+                unset($dir[$k]);
147
+            }
148
+        }
149
+
150
+        return $dir;
151
+    }
152
+    if (is_null($dir_plugins)) {
153
+        $dir_plugins = _DIR_PLUGINS;
154
+    }
155
+    $search = array("$dir_plugins$dir/plugin.xml", "$dir_plugins$dir/paquet.xml");
156
+
157
+    foreach ($search as $s) {
158
+        if (file_exists($s)) {
159
+            return $dir;
160
+        }
161
+    }
162
+
163
+    return '';
164 164
 }
165 165
 
166 166
 /** Regexp d'extraction des informations d'un intervalle de compatibilité */
@@ -187,51 +187,51 @@  discard block
 block discarded – undo
187 187
  **/
188 188
 function plugin_version_compatible($intervalle, $version, $avec_quoi = '') {
189 189
 
190
-	if (!strlen($intervalle)) {
191
-		return true;
192
-	}
193
-	if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
194
-		return false;
195
-	}
196
-	// Extraction des bornes et traitement de * pour la borne sup :
197
-	// -- on autorise uniquement les ecritures 3.0.*, 3.*
198
-	$minimum = $regs[1];
199
-	$maximum = $regs[2];
200
-
201
-	//  si une version SPIP de compatibilité a été définie (dans
202
-	//  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
203
-	//  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
204
-	//  avec la version de SPIP (ne nuit donc pas aux tests de necessite
205
-	//  entre plugins)
206
-	if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
207
-		if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
208
-			return true;
209
-		}
210
-		// si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
211
-		// cas du plugin qui n'est compatible qu'avec cette nouvelle version
212
-	}
213
-
214
-	$minimum_inc = $intervalle{0} == "[";
215
-	$maximum_inc = substr($intervalle, -1) == "]";
216
-
217
-	if (strlen($minimum)) {
218
-		if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
219
-			return false;
220
-		}
221
-		if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
222
-			return false;
223
-		}
224
-	}
225
-	if (strlen($maximum)) {
226
-		if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
227
-			return false;
228
-		}
229
-		if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
230
-			return false;
231
-		}
232
-	}
233
-
234
-	return true;
190
+    if (!strlen($intervalle)) {
191
+        return true;
192
+    }
193
+    if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
194
+        return false;
195
+    }
196
+    // Extraction des bornes et traitement de * pour la borne sup :
197
+    // -- on autorise uniquement les ecritures 3.0.*, 3.*
198
+    $minimum = $regs[1];
199
+    $maximum = $regs[2];
200
+
201
+    //  si une version SPIP de compatibilité a été définie (dans
202
+    //  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
203
+    //  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
204
+    //  avec la version de SPIP (ne nuit donc pas aux tests de necessite
205
+    //  entre plugins)
206
+    if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
207
+        if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
208
+            return true;
209
+        }
210
+        // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
211
+        // cas du plugin qui n'est compatible qu'avec cette nouvelle version
212
+    }
213
+
214
+    $minimum_inc = $intervalle{0} == "[";
215
+    $maximum_inc = substr($intervalle, -1) == "]";
216
+
217
+    if (strlen($minimum)) {
218
+        if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
219
+            return false;
220
+        }
221
+        if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
222
+            return false;
223
+        }
224
+    }
225
+    if (strlen($maximum)) {
226
+        if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
227
+            return false;
228
+        }
229
+        if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
230
+            return false;
231
+        }
232
+    }
233
+
234
+    return true;
235 235
 }
236 236
 
237 237
 /**
@@ -248,62 +248,62 @@  discard block
 block discarded – undo
248 248
  * @return array
249 249
  */
250 250
 function liste_plugin_valides($liste_plug, $force = false) {
251
-	$liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
252
-	$get_infos = charger_fonction('get_infos', 'plugins');
253
-	$infos = array(
254
-		// lister les extensions qui sont automatiquement actives
255
-		'_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
256
-		'_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
257
-	);
258
-
259
-	// creer une premiere liste non ordonnee mais qui ne retient
260
-	// que les plugins valides, et dans leur derniere version en cas de doublon
261
-	$infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
262
-	$infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
263
-	$infos['_DIR_RESTREINT']['SPIP']['chemin'] = array();
264
-	$liste_non_classee = array(
265
-		'SPIP' => array(
266
-			'nom' => 'SPIP',
267
-			'etat' => 'stable',
268
-			'version' => $GLOBALS['spip_version_branche'],
269
-			'dir_type' => '_DIR_RESTREINT',
270
-			'dir' => '',
271
-		)
272
-	);
273
-
274
-	$invalides = array();
275
-	foreach ($liste_ext as $plug) {
276
-		if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
277
-			plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
278
-		}
279
-	}
280
-	foreach ($liste_plug as $plug) {
281
-		if (isset($infos['_DIR_PLUGINS'][$plug])) {
282
-			$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
283
-			if (is_array($r)) {
284
-				$invalides = array_merge($invalides, $r);
285
-			}
286
-		}
287
-	}
288
-
289
-	if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
290
-		$infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
291
-		foreach ($liste_plug as $plug) {
292
-			if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
293
-				$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
294
-				if (is_array($r)) {
295
-					$invalides = array_merge($invalides, $r);
296
-				}
297
-			}
298
-		}
299
-	}
300
-
301
-	plugin_fixer_procure($liste_non_classee, $infos);
302
-
303
-	// les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
304
-	$invalides = array_diff_key($invalides, $liste_non_classee);
305
-
306
-	return array($infos, $liste_non_classee, $invalides);
251
+    $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
252
+    $get_infos = charger_fonction('get_infos', 'plugins');
253
+    $infos = array(
254
+        // lister les extensions qui sont automatiquement actives
255
+        '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
256
+        '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
257
+    );
258
+
259
+    // creer une premiere liste non ordonnee mais qui ne retient
260
+    // que les plugins valides, et dans leur derniere version en cas de doublon
261
+    $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
262
+    $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
263
+    $infos['_DIR_RESTREINT']['SPIP']['chemin'] = array();
264
+    $liste_non_classee = array(
265
+        'SPIP' => array(
266
+            'nom' => 'SPIP',
267
+            'etat' => 'stable',
268
+            'version' => $GLOBALS['spip_version_branche'],
269
+            'dir_type' => '_DIR_RESTREINT',
270
+            'dir' => '',
271
+        )
272
+    );
273
+
274
+    $invalides = array();
275
+    foreach ($liste_ext as $plug) {
276
+        if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
277
+            plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
278
+        }
279
+    }
280
+    foreach ($liste_plug as $plug) {
281
+        if (isset($infos['_DIR_PLUGINS'][$plug])) {
282
+            $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
283
+            if (is_array($r)) {
284
+                $invalides = array_merge($invalides, $r);
285
+            }
286
+        }
287
+    }
288
+
289
+    if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
290
+        $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
291
+        foreach ($liste_plug as $plug) {
292
+            if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
293
+                $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
294
+                if (is_array($r)) {
295
+                    $invalides = array_merge($invalides, $r);
296
+                }
297
+            }
298
+        }
299
+    }
300
+
301
+    plugin_fixer_procure($liste_non_classee, $infos);
302
+
303
+    // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
304
+    $invalides = array_diff_key($invalides, $liste_non_classee);
305
+
306
+    return array($infos, $liste_non_classee, $invalides);
307 307
 }
308 308
 
309 309
 /**
@@ -323,29 +323,29 @@  discard block
 block discarded – undo
323 323
  *   array description short si on ne le retient pas (pour memorisation dans une table des erreurs)
324 324
  */
325 325
 function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) {
326
-	$i = $infos[$dir_type][$plug];
327
-	$p = strtoupper($i['prefix']);
328
-	$short_desc = array(
329
-		'nom' => $i['nom'],
330
-		'etat' => $i['etat'],
331
-		'version' => $i['version'],
332
-		'dir' => $plug,
333
-		'dir_type' => $dir_type
334
-	);
335
-	if (isset($i['erreur']) and $i['erreur']) {
336
-		$short_desc['erreur'] = $i['erreur'];
337
-		return array($p=>$short_desc);
338
-	}
339
-	if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
340
-		return array($p=>$short_desc);
341
-	}
342
-	if (!isset($liste[$p])
343
-		or spip_version_compare($i['version'], $liste[$p]['version'], '>')
344
-	) {
345
-		$liste[$p] = $short_desc;
346
-	}
347
-	// ok le plugin etait deja dans la liste ou on a choisi une version plus recente
348
-	return $p;
326
+    $i = $infos[$dir_type][$plug];
327
+    $p = strtoupper($i['prefix']);
328
+    $short_desc = array(
329
+        'nom' => $i['nom'],
330
+        'etat' => $i['etat'],
331
+        'version' => $i['version'],
332
+        'dir' => $plug,
333
+        'dir_type' => $dir_type
334
+    );
335
+    if (isset($i['erreur']) and $i['erreur']) {
336
+        $short_desc['erreur'] = $i['erreur'];
337
+        return array($p=>$short_desc);
338
+    }
339
+    if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
340
+        return array($p=>$short_desc);
341
+    }
342
+    if (!isset($liste[$p])
343
+        or spip_version_compare($i['version'], $liste[$p]['version'], '>')
344
+    ) {
345
+        $liste[$p] = $short_desc;
346
+    }
347
+    // ok le plugin etait deja dans la liste ou on a choisi une version plus recente
348
+    return $p;
349 349
 }
350 350
 
351 351
 /**
@@ -361,46 +361,46 @@  discard block
 block discarded – undo
361 361
  * @param array $infos
362 362
  */
363 363
 function plugin_fixer_procure(&$liste, &$infos) {
364
-	foreach ($liste as $p => $resume) {
365
-		$i = $infos[$resume['dir_type']][$resume['dir']];
366
-		if (isset($i['procure']) and $i['procure']) {
367
-			foreach ($i['procure'] as $procure) {
368
-				$p = strtoupper($procure['nom']);
369
-				$dir = $resume['dir'];
370
-				if ($dir) {
371
-					$dir .= "/";
372
-				}
373
-				$dir .= "procure:" . $procure['nom'];
374
-
375
-				$procure['etat'] = '?';
376
-				$procure['dir_type'] = $resume['dir_type'];
377
-				$procure['dir'] = $dir;
378
-
379
-				// si ce plugin n'est pas deja procure, ou dans une version plus ancienne
380
-				// on ajoute cette version a la liste
381
-				if (!isset($liste[$p])
382
-					or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
383
-				) {
384
-					$liste[$p] = $procure;
385
-
386
-					// on fournit une information minimale pour ne pas perturber la compilation
387
-					$infos[$resume['dir_type']][$dir] = array(
388
-						'prefix' => $procure['nom'],
389
-						'nom' => $procure['nom'],
390
-						'etat' => $procure['etat'],
391
-						'version' => $procure['version'],
392
-						'chemin' => array(),
393
-						'necessite' => array(),
394
-						'utilise' => array(),
395
-						'lib' => array(),
396
-						'menu' => array(),
397
-						'onglet' => array(),
398
-						'procure' => array(),
399
-					);
400
-				}
401
-			}
402
-		}
403
-	}
364
+    foreach ($liste as $p => $resume) {
365
+        $i = $infos[$resume['dir_type']][$resume['dir']];
366
+        if (isset($i['procure']) and $i['procure']) {
367
+            foreach ($i['procure'] as $procure) {
368
+                $p = strtoupper($procure['nom']);
369
+                $dir = $resume['dir'];
370
+                if ($dir) {
371
+                    $dir .= "/";
372
+                }
373
+                $dir .= "procure:" . $procure['nom'];
374
+
375
+                $procure['etat'] = '?';
376
+                $procure['dir_type'] = $resume['dir_type'];
377
+                $procure['dir'] = $dir;
378
+
379
+                // si ce plugin n'est pas deja procure, ou dans une version plus ancienne
380
+                // on ajoute cette version a la liste
381
+                if (!isset($liste[$p])
382
+                    or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
383
+                ) {
384
+                    $liste[$p] = $procure;
385
+
386
+                    // on fournit une information minimale pour ne pas perturber la compilation
387
+                    $infos[$resume['dir_type']][$dir] = array(
388
+                        'prefix' => $procure['nom'],
389
+                        'nom' => $procure['nom'],
390
+                        'etat' => $procure['etat'],
391
+                        'version' => $procure['version'],
392
+                        'chemin' => array(),
393
+                        'necessite' => array(),
394
+                        'utilise' => array(),
395
+                        'lib' => array(),
396
+                        'menu' => array(),
397
+                        'onglet' => array(),
398
+                        'procure' => array(),
399
+                    );
400
+                }
401
+            }
402
+        }
403
+    }
404 404
 }
405 405
 
406 406
 /**
@@ -414,19 +414,19 @@  discard block
 block discarded – undo
414 414
  * @return array
415 415
  */
416 416
 function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) {
417
-	foreach ($liste as $prefix => $infos) {
418
-		if (!$dir_plugins
419
-			or (
420
-				defined($infos['dir_type'])
421
-				and constant($infos['dir_type']) == $dir_plugins)
422
-		) {
423
-			$liste[$prefix] = $infos['dir'];
424
-		} else {
425
-			unset($liste[$prefix]);
426
-		}
427
-	}
428
-
429
-	return $liste;
417
+    foreach ($liste as $prefix => $infos) {
418
+        if (!$dir_plugins
419
+            or (
420
+                defined($infos['dir_type'])
421
+                and constant($infos['dir_type']) == $dir_plugins)
422
+        ) {
423
+            $liste[$prefix] = $infos['dir'];
424
+        } else {
425
+            unset($liste[$prefix]);
426
+        }
427
+    }
428
+
429
+    return $liste;
430 430
 }
431 431
 
432 432
 /**
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
  * @return array
442 442
  */
443 443
 function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) {
444
-	include_spip('plugins/installer');
444
+    include_spip('plugins/installer');
445 445
 
446
-	return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
446
+    return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
447 447
 }
448 448
 
449 449
 /**
@@ -474,53 +474,53 @@  discard block
 block discarded – undo
474 474
  *                qui n'ont pas satisfait leurs dépendances
475 475
 **/
476 476
 function plugin_trier($infos, $liste_non_classee) {
477
-	$toute_la_liste = $liste_non_classee;
478
-	$liste = $ordre = array();
479
-	$count = 0;
480
-
481
-	while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
482
-		#echo "tour::";var_dump($liste_non_classee);
483
-		$count = $c;
484
-		foreach ($liste_non_classee as $p => $resume) {
485
-			$plug = $resume['dir'];
486
-			$dir_type = $resume['dir_type'];
487
-			$info1 = $infos[$dir_type][$plug];
488
-			// si des plugins sont necessaires,
489
-			// on ne peut inserer qu'apres eux
490
-			foreach ($info1['necessite'] as $need) {
491
-				$nom = strtoupper($need['nom']);
492
-				$compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
493
-				if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
494
-					$info1 = false;
495
-					break;
496
-				}
497
-			}
498
-			if (!$info1) {
499
-				continue;
500
-			}
501
-			// idem si des plugins sont utiles,
502
-			// sauf si ils sont de toute facon absents de la liste
503
-			foreach ($info1['utilise'] as $need) {
504
-				$nom = strtoupper($need['nom']);
505
-				$compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
506
-				if (isset($toute_la_liste[$nom])) {
507
-					if (!isset($liste[$nom]) or
508
-						!plugin_version_compatible($compat, $liste[$nom]['version'])
509
-					) {
510
-						$info1 = false;
511
-						break;
512
-					}
513
-				}
514
-			}
515
-			if ($info1) {
516
-				$ordre[$p] = $info1;
517
-				$liste[$p] = $liste_non_classee[$p];
518
-				unset($liste_non_classee[$p]);
519
-			}
520
-		}
521
-	}
522
-
523
-	return array($liste, $ordre, $liste_non_classee);
477
+    $toute_la_liste = $liste_non_classee;
478
+    $liste = $ordre = array();
479
+    $count = 0;
480
+
481
+    while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
482
+        #echo "tour::";var_dump($liste_non_classee);
483
+        $count = $c;
484
+        foreach ($liste_non_classee as $p => $resume) {
485
+            $plug = $resume['dir'];
486
+            $dir_type = $resume['dir_type'];
487
+            $info1 = $infos[$dir_type][$plug];
488
+            // si des plugins sont necessaires,
489
+            // on ne peut inserer qu'apres eux
490
+            foreach ($info1['necessite'] as $need) {
491
+                $nom = strtoupper($need['nom']);
492
+                $compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
493
+                if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
494
+                    $info1 = false;
495
+                    break;
496
+                }
497
+            }
498
+            if (!$info1) {
499
+                continue;
500
+            }
501
+            // idem si des plugins sont utiles,
502
+            // sauf si ils sont de toute facon absents de la liste
503
+            foreach ($info1['utilise'] as $need) {
504
+                $nom = strtoupper($need['nom']);
505
+                $compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
506
+                if (isset($toute_la_liste[$nom])) {
507
+                    if (!isset($liste[$nom]) or
508
+                        !plugin_version_compatible($compat, $liste[$nom]['version'])
509
+                    ) {
510
+                        $info1 = false;
511
+                        break;
512
+                    }
513
+                }
514
+            }
515
+            if ($info1) {
516
+                $ordre[$p] = $info1;
517
+                $liste[$p] = $liste_non_classee[$p];
518
+                unset($liste_non_classee[$p]);
519
+            }
520
+        }
521
+    }
522
+
523
+    return array($liste, $ordre, $liste_non_classee);
524 524
 }
525 525
 
526 526
 /**
@@ -537,40 +537,40 @@  discard block
 block discarded – undo
537 537
  *     Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent
538 538
 **/
539 539
 function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = array()) {
540
-	static $erreurs = array();
541
-
542
-	if (!is_array($liste)) {
543
-		$liste = array();
544
-	}
545
-
546
-	// les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
547
-	$liste = array_diff_key($liste, $liste_non_classee);
548
-
549
-	foreach ($liste_non_classee as $p => $resume) {
550
-		$dir_type = $resume['dir_type'];
551
-		$plug = $resume['dir'];
552
-		$k = $infos[$dir_type][$plug];
553
-
554
-		$plug = constant($dir_type) . $plug;
555
-		if (!isset($msg[$p])) {
556
-			if (isset($resume['erreur']) and $resume['erreur']) {
557
-				$msg[$p] = array($resume['erreur']);
558
-			}
559
-			elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
560
-				$msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite'));
561
-			}
562
-			elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
563
-				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
564
-			}
565
-		} else {
566
-			foreach ($msg[$p] as $c => $l) {
567
-				$msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
568
-			}
569
-		}
570
-		$erreurs[$plug] = $msg[$p];
571
-	}
572
-
573
-	ecrire_meta('plugin_erreur_activation', serialize($erreurs));
540
+    static $erreurs = array();
541
+
542
+    if (!is_array($liste)) {
543
+        $liste = array();
544
+    }
545
+
546
+    // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
547
+    $liste = array_diff_key($liste, $liste_non_classee);
548
+
549
+    foreach ($liste_non_classee as $p => $resume) {
550
+        $dir_type = $resume['dir_type'];
551
+        $plug = $resume['dir'];
552
+        $k = $infos[$dir_type][$plug];
553
+
554
+        $plug = constant($dir_type) . $plug;
555
+        if (!isset($msg[$p])) {
556
+            if (isset($resume['erreur']) and $resume['erreur']) {
557
+                $msg[$p] = array($resume['erreur']);
558
+            }
559
+            elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
560
+                $msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite'));
561
+            }
562
+            elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
563
+                $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
564
+            }
565
+        } else {
566
+            foreach ($msg[$p] as $c => $l) {
567
+                $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
568
+            }
569
+        }
570
+        $erreurs[$plug] = $msg[$p];
571
+    }
572
+
573
+    ecrire_meta('plugin_erreur_activation', serialize($erreurs));
574 574
 }
575 575
 
576 576
 /**
@@ -585,25 +585,25 @@  discard block
 block discarded – undo
585 585
  *     - Liste des erreurs ou code HTML des erreurs
586 586
 **/
587 587
 function plugin_donne_erreurs($raw = false, $raz = true) {
588
-	if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
589
-		return $raw ? array() : '';
590
-	}
591
-	$list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
592
-	// Compat ancienne version
593
-	if (!$list) {
594
-		$list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
595
-	} elseif (!$raw) {
596
-		foreach ($list as $plug => $msg) {
597
-			$list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
598
-				. "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
599
-		}
600
-		$list = "<ul>" . join("\n", $list) . "</ul>";
601
-	}
602
-	if ($raz) {
603
-		effacer_meta('plugin_erreur_activation');
604
-	}
605
-
606
-	return $list;
588
+    if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
589
+        return $raw ? array() : '';
590
+    }
591
+    $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
592
+    // Compat ancienne version
593
+    if (!$list) {
594
+        $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
595
+    } elseif (!$raw) {
596
+        foreach ($list as $plug => $msg) {
597
+            $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
598
+                . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
599
+        }
600
+        $list = "<ul>" . join("\n", $list) . "</ul>";
601
+    }
602
+    if ($raz) {
603
+        effacer_meta('plugin_erreur_activation');
604
+    }
605
+
606
+    return $list;
607 607
 }
608 608
 
609 609
 /**
@@ -623,21 +623,21 @@  discard block
 block discarded – undo
623 623
  *
624 624
  **/
625 625
 function plugin_necessite($n, $liste, $balise = 'necessite') {
626
-	$msg = array();
627
-	foreach ($n as $need) {
628
-		$id = strtoupper($need['nom']);
629
-		$r = plugin_controler_necessite(
630
-			$liste, 
631
-			$id, 
632
-			isset($need['compatibilite']) ? $need['compatibilite'] : '', 
633
-			$balise
634
-		);
635
-		if ($r) {
636
-			$msg[] = $r;
637
-		}
638
-	}
639
-
640
-	return $msg;
626
+    $msg = array();
627
+    foreach ($n as $need) {
628
+        $id = strtoupper($need['nom']);
629
+        $r = plugin_controler_necessite(
630
+            $liste, 
631
+            $id, 
632
+            isset($need['compatibilite']) ? $need['compatibilite'] : '', 
633
+            $balise
634
+        );
635
+        if ($r) {
636
+            $msg[] = $r;
637
+        }
638
+    }
639
+
640
+    return $msg;
641 641
 }
642 642
 
643 643
 /**
@@ -659,16 +659,16 @@  discard block
 block discarded – undo
659 659
  *    Message d'erreur lorsque la dépendance est absente.
660 660
  **/
661 661
 function plugin_controler_necessite($liste, $nom, $intervalle, $balise) {
662
-	if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
663
-		return '';
664
-	}
665
-
666
-	return plugin_message_incompatibilite(
667
-		$intervalle, 
668
-		(isset($liste[$nom]) ? $liste[$nom]['version'] : ""), 
669
-		$nom, 
670
-		$balise
671
-	);
662
+    if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
663
+        return '';
664
+    }
665
+
666
+    return plugin_message_incompatibilite(
667
+        $intervalle, 
668
+        (isset($liste[$nom]) ? $liste[$nom]['version'] : ""), 
669
+        $nom, 
670
+        $balise
671
+    );
672 672
 }
673 673
 
674 674
 /**
@@ -685,70 +685,70 @@  discard block
 block discarded – undo
685 685
  */
686 686
 function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) {
687 687
 
688
-	// prendre en compte les erreurs de dépendances à PHP
689
-	// ou à une extension PHP avec des messages d'erreurs dédiés.
690
-	$type = 'plugin';
691
-	if ($nom === 'SPIP') {
692
-		$type = 'spip';
693
-	} elseif ($nom === 'PHP') {
694
-		$type = 'php';
695
-	} elseif (strncmp($nom, 'PHP:', 4) === 0) {
696
-		$type = 'extension_php';
697
-		list(,$nom) = explode(':', $nom, 2);
698
-	}
699
-
700
-	if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
701
-		$minimum = $regs[1];
702
-		$maximum = $regs[2];
703
-
704
-		$minimum_inclus = $intervalle{0} == "[";
705
-		$maximum_inclus = substr($intervalle, -1) == "]";
706
-
707
-		if (strlen($minimum)) {
708
-			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
709
-				return _T("plugin_${balise}_${type}", array(
710
-					'plugin' => $nom,
711
-					'version' => ' &ge; ' . $minimum
712
-				));
713
-			}
714
-			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
715
-				return _T("plugin_${balise}_${type}", array(
716
-					'plugin' => $nom,
717
-					'version' => ' &gt; ' . $minimum
718
-				));
719
-			}
720
-		}
721
-
722
-		if (strlen($maximum)) {
723
-			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
724
-				return _T("plugin_${balise}_${type}", array(
725
-					'plugin' => $nom,
726
-					'version' => ' &le; ' . $maximum
727
-				));
728
-			}
729
-			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
730
-				return _T("plugin_${balise}_plugin", array(
731
-					'plugin' => $nom,
732
-					'version' => ' &lt; ' . $maximum
733
-				));
734
-			}
735
-		}
736
-	}
737
-
738
-	// note : il ne peut pas y avoir d'erreur sur
739
-	// - un 'utilise' sans version.
740
-	// - un 'php' sans version.
741
-	return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom));
688
+    // prendre en compte les erreurs de dépendances à PHP
689
+    // ou à une extension PHP avec des messages d'erreurs dédiés.
690
+    $type = 'plugin';
691
+    if ($nom === 'SPIP') {
692
+        $type = 'spip';
693
+    } elseif ($nom === 'PHP') {
694
+        $type = 'php';
695
+    } elseif (strncmp($nom, 'PHP:', 4) === 0) {
696
+        $type = 'extension_php';
697
+        list(,$nom) = explode(':', $nom, 2);
698
+    }
699
+
700
+    if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
701
+        $minimum = $regs[1];
702
+        $maximum = $regs[2];
703
+
704
+        $minimum_inclus = $intervalle{0} == "[";
705
+        $maximum_inclus = substr($intervalle, -1) == "]";
706
+
707
+        if (strlen($minimum)) {
708
+            if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
709
+                return _T("plugin_${balise}_${type}", array(
710
+                    'plugin' => $nom,
711
+                    'version' => ' &ge; ' . $minimum
712
+                ));
713
+            }
714
+            if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
715
+                return _T("plugin_${balise}_${type}", array(
716
+                    'plugin' => $nom,
717
+                    'version' => ' &gt; ' . $minimum
718
+                ));
719
+            }
720
+        }
721
+
722
+        if (strlen($maximum)) {
723
+            if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
724
+                return _T("plugin_${balise}_${type}", array(
725
+                    'plugin' => $nom,
726
+                    'version' => ' &le; ' . $maximum
727
+                ));
728
+            }
729
+            if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
730
+                return _T("plugin_${balise}_plugin", array(
731
+                    'plugin' => $nom,
732
+                    'version' => ' &lt; ' . $maximum
733
+                ));
734
+            }
735
+        }
736
+    }
737
+
738
+    // note : il ne peut pas y avoir d'erreur sur
739
+    // - un 'utilise' sans version.
740
+    // - un 'php' sans version.
741
+    return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom));
742 742
 }
743 743
 
744 744
 
745 745
 function plugin_controler_lib($lib, $url) {
746
-	/* Feature sortie du core, voir STP
746
+    /* Feature sortie du core, voir STP
747 747
 	 * if ($url) {
748 748
 		include_spip('inc/charger_plugin');
749 749
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
750 750
 	}*/
751
-	return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
751
+    return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
752 752
 }
753 753
 
754 754
 
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
  *     true si il y a eu des modifications sur la liste des plugins actifs, false sinon
764 764
  **/
765 765
 function actualise_plugins_actifs($pipe_recherche = false) {
766
-	return ecrire_plugin_actifs('', $pipe_recherche, 'force');
766
+    return ecrire_plugin_actifs('', $pipe_recherche, 'force');
767 767
 }
768 768
 
769 769
 
@@ -790,113 +790,113 @@  discard block
 block discarded – undo
790 790
  **/
791 791
 function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') {
792 792
 
793
-	// creer le repertoire cache/ si necessaire ! (installation notamment)
794
-	$cache = sous_repertoire(_DIR_CACHE, '', false, true);
795
-
796
-	// Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
797
-	if (!$cache and !spip_connect()) {
798
-		return false;
799
-	}
800
-
801
-	if ($operation != 'raz') {
802
-		$plugin_valides = liste_chemin_plugin_actifs();
803
-		$plugin_valides = is_plugin_dir($plugin_valides);
804
-		if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
805
-			$plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
806
-			$plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
807
-			$plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
808
-		}
809
-		// si des plugins sont en attentes (coches mais impossible a activer)
810
-		// on les reinjecte ici
811
-		if (isset($GLOBALS['meta']['plugin_attente'])
812
-			and $a = unserialize($GLOBALS['meta']['plugin_attente'])
813
-		) {
814
-			$plugin_valides = $plugin_valides + liste_chemin_plugin($a);
815
-		}
816
-
817
-		if ($operation == 'ajoute') {
818
-			$plugin = array_merge($plugin_valides, $plugin);
819
-		} elseif ($operation == 'enleve') {
820
-			$plugin = array_diff($plugin_valides, $plugin);
821
-		} else {
822
-			$plugin = $plugin_valides;
823
-		}
824
-	}
825
-	$actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
826
-
827
-	// si une fonction de gestion de dependances existe, l'appeler ici
828
-	if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) {
829
-		$plugin = $ajouter_dependances($plugin);
830
-	}
831
-
832
-	// recharger le xml des plugins a activer
833
-	// on force le reload ici, meme si le fichier xml n'a pas change
834
-	// pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
835
-	// pourra etre evite quand on ne supportera plus les plugin.xml
836
-	// en deplacant la detection de ces fichiers dans la compilation ci dessous
837
-	list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true);
838
-	// trouver l'ordre d'activation
839
-	list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste);
840
-	if ($invalides or $reste) {
841
-		plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
842
-	}
843
-
844
-	// Ignorer les plugins necessitant une lib absente
845
-	// et preparer la meta d'entete Http
846
-	$err = $msg = $header = array();
847
-	foreach ($plugin_valides as $p => $resume) {
848
-		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
849
-		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
850
-			$header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
851
-		}
852
-		if ($resume['dir']) {
853
-			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
854
-				if (!find_in_path($l['nom'], 'lib/')) {
855
-					$err[$p] = $resume;
856
-					$msg[$p][] = $l;
857
-					unset($plugin_valides[$p]);
858
-				}
859
-			}
860
-		}
861
-	}
862
-	if ($err) {
863
-		plugins_erreurs($err, '', $infos, $msg);
864
-	}
865
-
866
-	if (isset($GLOBALS['meta']['message_crash_plugins'])) {
867
-		effacer_meta('message_crash_plugins');
868
-	}
869
-	ecrire_meta('plugin', serialize($plugin_valides));
870
-	$liste = array_diff_key($liste, $plugin_valides);
871
-	ecrire_meta('plugin_attente', serialize($liste));
872
-	$header = strtolower(implode(",", $header));
873
-	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
874
-		ecrire_fichier(_DIR_VAR . "config.txt",
875
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
876
-	} else {
877
-		@unlink(_DIR_VAR . "config.txt");
878
-	}
879
-	// generer charger_plugins_chemin.php
880
-	plugins_precompile_chemin($plugin_valides, $ordre);
881
-	// generer les fichiers
882
-	// - charger_plugins_options.php
883
-	// - charger_plugins_fonctions.php
884
-	plugins_precompile_xxxtions($plugin_valides, $ordre);
885
-	// charger les chemins des plugins et les fichiers d'options 
886
-	// (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
887
-	plugins_amorcer_plugins_actifs();
888
-	// mise a jour de la matrice des pipelines
889
-	$prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
890
-	// generer le fichier _CACHE_PIPELINE
891
-	pipeline_precompile($prepend_code);
892
-
893
-	if (spip_connect()) {
894
-		// lancer et initialiser les nouveaux crons !
895
-		include_spip('inc/genie');
896
-		genie_queue_watch_dist();
897
-	}
898
-
899
-	return ($GLOBALS['meta']['plugin'] != $actifs_avant);
793
+    // creer le repertoire cache/ si necessaire ! (installation notamment)
794
+    $cache = sous_repertoire(_DIR_CACHE, '', false, true);
795
+
796
+    // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
797
+    if (!$cache and !spip_connect()) {
798
+        return false;
799
+    }
800
+
801
+    if ($operation != 'raz') {
802
+        $plugin_valides = liste_chemin_plugin_actifs();
803
+        $plugin_valides = is_plugin_dir($plugin_valides);
804
+        if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
805
+            $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
806
+            $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
807
+            $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
808
+        }
809
+        // si des plugins sont en attentes (coches mais impossible a activer)
810
+        // on les reinjecte ici
811
+        if (isset($GLOBALS['meta']['plugin_attente'])
812
+            and $a = unserialize($GLOBALS['meta']['plugin_attente'])
813
+        ) {
814
+            $plugin_valides = $plugin_valides + liste_chemin_plugin($a);
815
+        }
816
+
817
+        if ($operation == 'ajoute') {
818
+            $plugin = array_merge($plugin_valides, $plugin);
819
+        } elseif ($operation == 'enleve') {
820
+            $plugin = array_diff($plugin_valides, $plugin);
821
+        } else {
822
+            $plugin = $plugin_valides;
823
+        }
824
+    }
825
+    $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
826
+
827
+    // si une fonction de gestion de dependances existe, l'appeler ici
828
+    if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) {
829
+        $plugin = $ajouter_dependances($plugin);
830
+    }
831
+
832
+    // recharger le xml des plugins a activer
833
+    // on force le reload ici, meme si le fichier xml n'a pas change
834
+    // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
835
+    // pourra etre evite quand on ne supportera plus les plugin.xml
836
+    // en deplacant la detection de ces fichiers dans la compilation ci dessous
837
+    list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true);
838
+    // trouver l'ordre d'activation
839
+    list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste);
840
+    if ($invalides or $reste) {
841
+        plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
842
+    }
843
+
844
+    // Ignorer les plugins necessitant une lib absente
845
+    // et preparer la meta d'entete Http
846
+    $err = $msg = $header = array();
847
+    foreach ($plugin_valides as $p => $resume) {
848
+        // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
849
+        if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
850
+            $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
851
+        }
852
+        if ($resume['dir']) {
853
+            foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
854
+                if (!find_in_path($l['nom'], 'lib/')) {
855
+                    $err[$p] = $resume;
856
+                    $msg[$p][] = $l;
857
+                    unset($plugin_valides[$p]);
858
+                }
859
+            }
860
+        }
861
+    }
862
+    if ($err) {
863
+        plugins_erreurs($err, '', $infos, $msg);
864
+    }
865
+
866
+    if (isset($GLOBALS['meta']['message_crash_plugins'])) {
867
+        effacer_meta('message_crash_plugins');
868
+    }
869
+    ecrire_meta('plugin', serialize($plugin_valides));
870
+    $liste = array_diff_key($liste, $plugin_valides);
871
+    ecrire_meta('plugin_attente', serialize($liste));
872
+    $header = strtolower(implode(",", $header));
873
+    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
874
+        ecrire_fichier(_DIR_VAR . "config.txt",
875
+            (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
876
+    } else {
877
+        @unlink(_DIR_VAR . "config.txt");
878
+    }
879
+    // generer charger_plugins_chemin.php
880
+    plugins_precompile_chemin($plugin_valides, $ordre);
881
+    // generer les fichiers
882
+    // - charger_plugins_options.php
883
+    // - charger_plugins_fonctions.php
884
+    plugins_precompile_xxxtions($plugin_valides, $ordre);
885
+    // charger les chemins des plugins et les fichiers d'options 
886
+    // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
887
+    plugins_amorcer_plugins_actifs();
888
+    // mise a jour de la matrice des pipelines
889
+    $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
890
+    // generer le fichier _CACHE_PIPELINE
891
+    pipeline_precompile($prepend_code);
892
+
893
+    if (spip_connect()) {
894
+        // lancer et initialiser les nouveaux crons !
895
+        include_spip('inc/genie');
896
+        genie_queue_watch_dist();
897
+    }
898
+
899
+    return ($GLOBALS['meta']['plugin'] != $actifs_avant);
900 900
 }
901 901
 
902 902
 /**
@@ -915,56 +915,56 @@  discard block
 block discarded – undo
915 915
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
916 916
 **/
917 917
 function plugins_precompile_chemin($plugin_valides, $ordre) {
918
-	$chemins = array();
919
-	$contenu = "";
920
-	foreach ($ordre as $p => $info) {
921
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
922
-		if (isset($plugin_valides[$p])) {
923
-			$dir_type = $plugin_valides[$p]['dir_type'];
924
-			$plug = $plugin_valides[$p]['dir'];
925
-			// definir le plugin, donc le path avant l'include du fichier options
926
-			// permet de faire des include_spip pour attraper un inc_ du plugin
927
-
928
-			$dir = $dir_type . ".'" . $plug . "/'";
929
-
930
-			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
931
-			if (
932
-				$prefix !== "SPIP"
933
-				and strpos($dir, ":") === false // exclure le cas des procure:
934
-			) {
935
-				$contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
936
-				foreach ($info['chemin'] as $chemin) {
937
-					if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'],
938
-							$GLOBALS['spip_version_branche'], 'spip')
939
-					) {
940
-						$dir = $chemin['path'];
941
-						if (strlen($dir) and $dir{0} == "/") {
942
-							$dir = substr($dir, 1);
943
-						}
944
-						if (strlen($dir) and $dir == "./") {
945
-							$dir = '';
946
-						}
947
-						if (strlen($dir)) {
948
-							$dir = rtrim($dir, '/') . '/';
949
-						}
950
-						if (!isset($chemin['type']) or $chemin['type'] == 'public') {
951
-							$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
952
-						}
953
-						if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
954
-							$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
955
-						}
956
-					}
957
-				}
958
-			}
959
-		}
960
-	}
961
-	if (count($chemins)) {
962
-		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
963
-				array_reverse($chemins['public'])) . ")));\n"
964
-			. "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
965
-	}
966
-
967
-	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
918
+    $chemins = array();
919
+    $contenu = "";
920
+    foreach ($ordre as $p => $info) {
921
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
922
+        if (isset($plugin_valides[$p])) {
923
+            $dir_type = $plugin_valides[$p]['dir_type'];
924
+            $plug = $plugin_valides[$p]['dir'];
925
+            // definir le plugin, donc le path avant l'include du fichier options
926
+            // permet de faire des include_spip pour attraper un inc_ du plugin
927
+
928
+            $dir = $dir_type . ".'" . $plug . "/'";
929
+
930
+            $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
931
+            if (
932
+                $prefix !== "SPIP"
933
+                and strpos($dir, ":") === false // exclure le cas des procure:
934
+            ) {
935
+                $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
936
+                foreach ($info['chemin'] as $chemin) {
937
+                    if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'],
938
+                            $GLOBALS['spip_version_branche'], 'spip')
939
+                    ) {
940
+                        $dir = $chemin['path'];
941
+                        if (strlen($dir) and $dir{0} == "/") {
942
+                            $dir = substr($dir, 1);
943
+                        }
944
+                        if (strlen($dir) and $dir == "./") {
945
+                            $dir = '';
946
+                        }
947
+                        if (strlen($dir)) {
948
+                            $dir = rtrim($dir, '/') . '/';
949
+                        }
950
+                        if (!isset($chemin['type']) or $chemin['type'] == 'public') {
951
+                            $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
952
+                        }
953
+                        if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
954
+                            $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
955
+                        }
956
+                    }
957
+                }
958
+            }
959
+        }
960
+    }
961
+    if (count($chemins)) {
962
+        $contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
963
+                array_reverse($chemins['public'])) . ")));\n"
964
+            . "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
965
+    }
966
+
967
+    ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
968 968
 }
969 969
 
970 970
 /**
@@ -982,65 +982,65 @@  discard block
 block discarded – undo
982 982
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
983 983
 **/
984 984
 function plugins_precompile_xxxtions($plugin_valides, $ordre) {
985
-	$contenu = array('options' => '', 'fonctions' => '');
986
-	$boutons = array();
987
-	$onglets = array();
988
-	$sign = "";
989
-
990
-	foreach ($ordre as $p => $info) {
991
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
992
-		if (isset($plugin_valides[$p])) {
993
-			$dir_type = $plugin_valides[$p]['dir_type'];
994
-			$plug = $plugin_valides[$p]['dir'];
995
-			$dir = constant($dir_type);
996
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
997
-			if ($info['menu']) {
998
-				$boutons = array_merge($boutons, $info['menu']);
999
-			}
1000
-			if ($info['onglet']) {
1001
-				$onglets = array_merge($onglets, $info['onglet']);
1002
-			}
1003
-			foreach ($contenu as $charge => $v) {
1004
-				// si pas declare/detecte a la lecture du paquet.xml,
1005
-				// detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1006
-				// donc ni sa relecture, ni sa detection
1007
-				if (!isset($info[$charge])
1008
-					and $dir // exclure le cas du plugin "SPIP"
1009
-					and strpos($dir, ":") === false // exclure le cas des procure:
1010
-					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1011
-				) {
1012
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
1013
-						$info[$charge] = array($file);
1014
-					}
1015
-				}
1016
-				if (isset($info[$charge])) {
1017
-					$files = $info[$charge];
1018
-					foreach ($files as $k => $file) {
1019
-						// on genere un if file_exists devant chaque include
1020
-						// pour pouvoir garder le meme niveau d'erreur general
1021
-						$file = trim($file);
1022
-						if (!is_readable("$dir$plug/$file")
1023
-							// uniquement pour les paquet.xml
1024
-							and file_exists("$dir$plug/paquet.xml")
1025
-						) {
1026
-							unset($info[$charge][$k]);
1027
-						} else {
1028
-							$_file = $root_dir_type . ".'$plug/$file'";
1029
-							$contenu[$charge] .= "include_once_check($_file);\n";
1030
-						}
1031
-					}
1032
-				}
1033
-			}
1034
-			$sign .= md5(serialize($info));
1035
-		}
1036
-	}
1037
-
1038
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1039
-	$contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1040
-		. plugin_ongletbouton("onglets_plugins", $onglets);
1041
-
1042
-	ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1043
-	ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
985
+    $contenu = array('options' => '', 'fonctions' => '');
986
+    $boutons = array();
987
+    $onglets = array();
988
+    $sign = "";
989
+
990
+    foreach ($ordre as $p => $info) {
991
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
992
+        if (isset($plugin_valides[$p])) {
993
+            $dir_type = $plugin_valides[$p]['dir_type'];
994
+            $plug = $plugin_valides[$p]['dir'];
995
+            $dir = constant($dir_type);
996
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
997
+            if ($info['menu']) {
998
+                $boutons = array_merge($boutons, $info['menu']);
999
+            }
1000
+            if ($info['onglet']) {
1001
+                $onglets = array_merge($onglets, $info['onglet']);
1002
+            }
1003
+            foreach ($contenu as $charge => $v) {
1004
+                // si pas declare/detecte a la lecture du paquet.xml,
1005
+                // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1006
+                // donc ni sa relecture, ni sa detection
1007
+                if (!isset($info[$charge])
1008
+                    and $dir // exclure le cas du plugin "SPIP"
1009
+                    and strpos($dir, ":") === false // exclure le cas des procure:
1010
+                    and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1011
+                ) {
1012
+                    if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
1013
+                        $info[$charge] = array($file);
1014
+                    }
1015
+                }
1016
+                if (isset($info[$charge])) {
1017
+                    $files = $info[$charge];
1018
+                    foreach ($files as $k => $file) {
1019
+                        // on genere un if file_exists devant chaque include
1020
+                        // pour pouvoir garder le meme niveau d'erreur general
1021
+                        $file = trim($file);
1022
+                        if (!is_readable("$dir$plug/$file")
1023
+                            // uniquement pour les paquet.xml
1024
+                            and file_exists("$dir$plug/paquet.xml")
1025
+                        ) {
1026
+                            unset($info[$charge][$k]);
1027
+                        } else {
1028
+                            $_file = $root_dir_type . ".'$plug/$file'";
1029
+                            $contenu[$charge] .= "include_once_check($_file);\n";
1030
+                        }
1031
+                    }
1032
+                }
1033
+            }
1034
+            $sign .= md5(serialize($info));
1035
+        }
1036
+    }
1037
+
1038
+    $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1039
+    $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1040
+        . plugin_ongletbouton("onglets_plugins", $onglets);
1041
+
1042
+    ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1043
+    ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1044 1044
 }
1045 1045
 
1046 1046
 /**
@@ -1059,24 +1059,24 @@  discard block
 block discarded – undo
1059 1059
  * @return string Code php
1060 1060
  */
1061 1061
 function plugin_ongletbouton($nom, $val) {
1062
-	if (!$val) {
1063
-		$val = array();
1064
-	}
1065
-
1066
-	$val = serialize($val);
1067
-	$md5 = md5($val);
1068
-
1069
-	if (!defined("_UPDATED_$nom")) {
1070
-		define("_UPDATED_$nom", $val);
1071
-		define("_UPDATED_md5_$nom", $md5);
1072
-	}
1073
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1074
-
1075
-	return
1076
-		"if (!function_exists('$nom')) {\n"
1077
-		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1078
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1079
-		. "}\n";
1062
+    if (!$val) {
1063
+        $val = array();
1064
+    }
1065
+
1066
+    $val = serialize($val);
1067
+    $md5 = md5($val);
1068
+
1069
+    if (!defined("_UPDATED_$nom")) {
1070
+        define("_UPDATED_$nom", $val);
1071
+        define("_UPDATED_md5_$nom", $md5);
1072
+    }
1073
+    $val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1074
+
1075
+    return
1076
+        "if (!function_exists('$nom')) {\n"
1077
+        . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1078
+        . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1079
+        . "}\n";
1080 1080
 }
1081 1081
 
1082 1082
 /**
@@ -1091,15 +1091,15 @@  discard block
 block discarded – undo
1091 1091
 **/
1092 1092
 function plugins_amorcer_plugins_actifs() {
1093 1093
 
1094
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1095
-		include_once(_CACHE_PLUGINS_PATH);
1096
-	} 
1094
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1095
+        include_once(_CACHE_PLUGINS_PATH);
1096
+    } 
1097 1097
 
1098
-	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1099
-		include_once(_CACHE_PLUGINS_OPT);
1100
-	} else {
1101
-		spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1102
-	}
1098
+    if (@is_readable(_CACHE_PLUGINS_OPT)) {
1099
+        include_once(_CACHE_PLUGINS_OPT);
1100
+    } else {
1101
+        spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1102
+    }
1103 1103
 }
1104 1104
 
1105 1105
 /**
@@ -1122,136 +1122,136 @@  discard block
 block discarded – undo
1122 1122
  *     Couples (nom du pipeline => Code PHP à insérer au début du pipeline)
1123 1123
 **/
1124 1124
 function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) {
1125
-	static $liste_pipe_manquants = array();
1126
-	if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1127
-		$liste_pipe_manquants[] = $pipe_recherche;
1128
-	}
1129
-
1130
-	$prepend_code = array();
1131
-
1132
-	foreach ($ordre as $p => $info) {
1133
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1134
-		if (isset($plugin_valides[$p])) {
1135
-			$dir_type = $plugin_valides[$p]['dir_type'];
1136
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1137
-			$plug = $plugin_valides[$p]['dir'];
1138
-			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1139
-			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1140
-				foreach ($info['pipeline'] as $pipe) {
1141
-					$nom = $pipe['nom'];
1142
-					if (isset($pipe['action'])) {
1143
-						$action = $pipe['action'];
1144
-					} else {
1145
-						$action = $nom;
1146
-					}
1147
-					$nomlower = strtolower($nom);
1148
-					if ($nomlower != $nom
1149
-						and isset($GLOBALS['spip_pipeline'][$nom])
1150
-						and !isset($GLOBALS['spip_pipeline'][$nomlower])
1151
-					) {
1152
-						$GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1153
-						unset($GLOBALS['spip_pipeline'][$nom]);
1154
-					}
1155
-					$nom = $nomlower;
1156
-					// une action vide est une declaration qui ne doit pas etre compilee !
1157
-					if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1158
-					{
1159
-						$GLOBALS['spip_pipeline'][$nom] = "";
1160
-					}
1161
-					if ($action) {
1162
-						if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1163
-							$GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
1164
-								$GLOBALS['spip_pipeline'][$nom], 1);
1165
-						}
1166
-						if (isset($pipe['inclure'])) {
1167
-							$GLOBALS['spip_matrice']["$prefix$action"] =
1168
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1169
-						}
1170
-					}
1171
-				}
1172
-			}
1173
-			if (isset($info['genie']) and count($info['genie'])) {
1174
-				if (!isset($prepend_code['taches_generales_cron'])) {
1175
-					$prepend_code['taches_generales_cron'] = "";
1176
-				}
1177
-				foreach ($info['genie'] as $genie) {
1178
-					$nom = $prefix . $genie['nom'];
1179
-					$periode = max(60, intval($genie['periode']));
1180
-					if (charger_fonction($nom, "genie", true)) {
1181
-						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1182
-					} else {
1183
-						spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1184
-					}
1185
-				}
1186
-			}
1187
-			if (isset($info['style']) and count($info['style'])) {
1188
-				if (!isset($prepend_code['insert_head_css'])) {
1189
-					$prepend_code['insert_head_css'] = "";
1190
-				}
1191
-				if (!isset($prepend_code['header_prive_css'])) {
1192
-					$prepend_code['header_prive_css'] = "";
1193
-				}
1194
-				foreach ($info['style'] as $style) {
1195
-					if (isset($style['path']) and $style['path']) {
1196
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1197
-					} else {
1198
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1199
-					}
1200
-					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1201
-					if (isset($style['media']) and strlen($style['media'])) {
1202
-						$code .= " media=\"" . addslashes($style['media']) . "\"";
1203
-					}
1204
-					$code .= "/>';\n";
1205
-					if ($style['type'] != 'prive') {
1206
-						$prepend_code['insert_head_css'] .= $code;
1207
-					}
1208
-					if ($style['type'] != 'public') {
1209
-						$prepend_code['header_prive_css'] .= $code;
1210
-					}
1211
-				}
1212
-			}
1213
-			if (!isset($prepend_code['insert_head'])) {
1214
-				$prepend_code['insert_head'] = "";
1215
-			}
1216
-			if (!isset($prepend_code['header_prive'])) {
1217
-				$prepend_code['header_prive'] = "";
1218
-			}
1219
-			if (isset($info['script']) and count($info['script'])) {
1220
-				foreach ($info['script'] as $script) {
1221
-					if (isset($script['path']) and $script['path']) {
1222
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1223
-					} else {
1224
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1225
-					}
1226
-					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1227
-					if ($script['type'] != 'prive') {
1228
-						$prepend_code['insert_head'] .= $code;
1229
-					}
1230
-					if ($script['type'] != 'public') {
1231
-						$prepend_code['header_prive'] .= $code;
1232
-					}
1233
-				}
1234
-			}
1235
-		}
1236
-	}
1237
-
1238
-	$prepend_code['insert_head'] =
1239
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1240
-		. "\$val = minipipe('f_jQuery', \$val);\n"
1241
-		. $prepend_code['insert_head'];
1242
-	$prepend_code['header_prive'] =
1243
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1244
-		. "\$val = minipipe('f_jQuery_prive', \$val);\n"
1245
-		. $prepend_code['header_prive'];
1246
-
1247
-	// on ajoute les pipe qui ont ete recenses manquants
1248
-	foreach ($liste_pipe_manquants as $add_pipe) {
1249
-		if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1250
-			$GLOBALS['spip_pipeline'][$add_pipe] = '';
1251
-		}
1252
-	}
1253
-
1254
-	return $prepend_code;
1125
+    static $liste_pipe_manquants = array();
1126
+    if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1127
+        $liste_pipe_manquants[] = $pipe_recherche;
1128
+    }
1129
+
1130
+    $prepend_code = array();
1131
+
1132
+    foreach ($ordre as $p => $info) {
1133
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1134
+        if (isset($plugin_valides[$p])) {
1135
+            $dir_type = $plugin_valides[$p]['dir_type'];
1136
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1137
+            $plug = $plugin_valides[$p]['dir'];
1138
+            $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1139
+            if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1140
+                foreach ($info['pipeline'] as $pipe) {
1141
+                    $nom = $pipe['nom'];
1142
+                    if (isset($pipe['action'])) {
1143
+                        $action = $pipe['action'];
1144
+                    } else {
1145
+                        $action = $nom;
1146
+                    }
1147
+                    $nomlower = strtolower($nom);
1148
+                    if ($nomlower != $nom
1149
+                        and isset($GLOBALS['spip_pipeline'][$nom])
1150
+                        and !isset($GLOBALS['spip_pipeline'][$nomlower])
1151
+                    ) {
1152
+                        $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1153
+                        unset($GLOBALS['spip_pipeline'][$nom]);
1154
+                    }
1155
+                    $nom = $nomlower;
1156
+                    // une action vide est une declaration qui ne doit pas etre compilee !
1157
+                    if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1158
+                    {
1159
+                        $GLOBALS['spip_pipeline'][$nom] = "";
1160
+                    }
1161
+                    if ($action) {
1162
+                        if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1163
+                            $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
1164
+                                $GLOBALS['spip_pipeline'][$nom], 1);
1165
+                        }
1166
+                        if (isset($pipe['inclure'])) {
1167
+                            $GLOBALS['spip_matrice']["$prefix$action"] =
1168
+                                "$root_dir_type:$plug/" . $pipe['inclure'];
1169
+                        }
1170
+                    }
1171
+                }
1172
+            }
1173
+            if (isset($info['genie']) and count($info['genie'])) {
1174
+                if (!isset($prepend_code['taches_generales_cron'])) {
1175
+                    $prepend_code['taches_generales_cron'] = "";
1176
+                }
1177
+                foreach ($info['genie'] as $genie) {
1178
+                    $nom = $prefix . $genie['nom'];
1179
+                    $periode = max(60, intval($genie['periode']));
1180
+                    if (charger_fonction($nom, "genie", true)) {
1181
+                        $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1182
+                    } else {
1183
+                        spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1184
+                    }
1185
+                }
1186
+            }
1187
+            if (isset($info['style']) and count($info['style'])) {
1188
+                if (!isset($prepend_code['insert_head_css'])) {
1189
+                    $prepend_code['insert_head_css'] = "";
1190
+                }
1191
+                if (!isset($prepend_code['header_prive_css'])) {
1192
+                    $prepend_code['header_prive_css'] = "";
1193
+                }
1194
+                foreach ($info['style'] as $style) {
1195
+                    if (isset($style['path']) and $style['path']) {
1196
+                        $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1197
+                    } else {
1198
+                        $code = "if (\$f='" . addslashes($style['url']) . "') ";
1199
+                    }
1200
+                    $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1201
+                    if (isset($style['media']) and strlen($style['media'])) {
1202
+                        $code .= " media=\"" . addslashes($style['media']) . "\"";
1203
+                    }
1204
+                    $code .= "/>';\n";
1205
+                    if ($style['type'] != 'prive') {
1206
+                        $prepend_code['insert_head_css'] .= $code;
1207
+                    }
1208
+                    if ($style['type'] != 'public') {
1209
+                        $prepend_code['header_prive_css'] .= $code;
1210
+                    }
1211
+                }
1212
+            }
1213
+            if (!isset($prepend_code['insert_head'])) {
1214
+                $prepend_code['insert_head'] = "";
1215
+            }
1216
+            if (!isset($prepend_code['header_prive'])) {
1217
+                $prepend_code['header_prive'] = "";
1218
+            }
1219
+            if (isset($info['script']) and count($info['script'])) {
1220
+                foreach ($info['script'] as $script) {
1221
+                    if (isset($script['path']) and $script['path']) {
1222
+                        $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1223
+                    } else {
1224
+                        $code = "if (\$f='" . addslashes($script['url']) . "') ";
1225
+                    }
1226
+                    $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1227
+                    if ($script['type'] != 'prive') {
1228
+                        $prepend_code['insert_head'] .= $code;
1229
+                    }
1230
+                    if ($script['type'] != 'public') {
1231
+                        $prepend_code['header_prive'] .= $code;
1232
+                    }
1233
+                }
1234
+            }
1235
+        }
1236
+    }
1237
+
1238
+    $prepend_code['insert_head'] =
1239
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1240
+        . "\$val = minipipe('f_jQuery', \$val);\n"
1241
+        . $prepend_code['insert_head'];
1242
+    $prepend_code['header_prive'] =
1243
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1244
+        . "\$val = minipipe('f_jQuery_prive', \$val);\n"
1245
+        . $prepend_code['header_prive'];
1246
+
1247
+    // on ajoute les pipe qui ont ete recenses manquants
1248
+    foreach ($liste_pipe_manquants as $add_pipe) {
1249
+        if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1250
+            $GLOBALS['spip_pipeline'][$add_pipe] = '';
1251
+        }
1252
+    }
1253
+
1254
+    return $prepend_code;
1255 1255
 }
1256 1256
 
1257 1257
 /**
@@ -1278,44 +1278,44 @@  discard block
 block discarded – undo
1278 1278
 **/
1279 1279
 function pipeline_precompile($prepend_code = array()) {
1280 1280
 
1281
-	$content = "";
1282
-	foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1283
-		$s_inc = "";
1284
-		$s_call = "";
1285
-		$pipe = array_filter(explode('|', $pipeline));
1286
-		// Eclater le pipeline en filtres et appliquer chaque filtre
1287
-		foreach ($pipe as $fonc) {
1288
-			$fonc = trim($fonc);
1289
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1290
-			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1291
-				$file = $GLOBALS['spip_matrice'][$fonc];
1292
-				$file = "'$file'";
1293
-				// si un _DIR_XXX: est dans la chaine, on extrait la constante
1294
-				if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) {
1295
-					$dir = $regs[1];
1296
-					$root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1297
-					if (defined($root_dir)) {
1298
-						$dir = $root_dir;
1299
-					}
1300
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1301
-					$file = str_replace("''.", "", $file);
1302
-					$file = str_replace(constant($dir), '', $file);
1303
-				}
1304
-				$s_inc .= "include_once_check($file);\n";
1305
-			}
1306
-		}
1307
-		if (strlen($s_inc)) {
1308
-			$s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1309
-		}
1310
-		$content .= "// Pipeline $action \n"
1311
-			. "function execute_pipeline_$action(&\$val){\n"
1312
-			. $s_inc
1313
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1314
-			. $s_call
1315
-			. "return \$val;\n}\n";
1316
-	}
1317
-	ecrire_fichier_php(_CACHE_PIPELINES, $content);
1318
-	clear_path_cache();
1281
+    $content = "";
1282
+    foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1283
+        $s_inc = "";
1284
+        $s_call = "";
1285
+        $pipe = array_filter(explode('|', $pipeline));
1286
+        // Eclater le pipeline en filtres et appliquer chaque filtre
1287
+        foreach ($pipe as $fonc) {
1288
+            $fonc = trim($fonc);
1289
+            $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1290
+            if (isset($GLOBALS['spip_matrice'][$fonc])) {
1291
+                $file = $GLOBALS['spip_matrice'][$fonc];
1292
+                $file = "'$file'";
1293
+                // si un _DIR_XXX: est dans la chaine, on extrait la constante
1294
+                if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) {
1295
+                    $dir = $regs[1];
1296
+                    $root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1297
+                    if (defined($root_dir)) {
1298
+                        $dir = $root_dir;
1299
+                    }
1300
+                    $file = str_replace($regs[0], "'." . $dir . ".'", $file);
1301
+                    $file = str_replace("''.", "", $file);
1302
+                    $file = str_replace(constant($dir), '', $file);
1303
+                }
1304
+                $s_inc .= "include_once_check($file);\n";
1305
+            }
1306
+        }
1307
+        if (strlen($s_inc)) {
1308
+            $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1309
+        }
1310
+        $content .= "// Pipeline $action \n"
1311
+            . "function execute_pipeline_$action(&\$val){\n"
1312
+            . $s_inc
1313
+            . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1314
+            . $s_call
1315
+            . "return \$val;\n}\n";
1316
+    }
1317
+    ecrire_fichier_php(_CACHE_PIPELINES, $content);
1318
+    clear_path_cache();
1319 1319
 }
1320 1320
 
1321 1321
 
@@ -1328,12 +1328,12 @@  discard block
 block discarded – undo
1328 1328
  *     true si le plugin est actif, false sinon
1329 1329
 **/
1330 1330
 function plugin_est_installe($plug_path) {
1331
-	$plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array();
1332
-	if (!$plugin_installes) {
1333
-		return false;
1334
-	}
1331
+    $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array();
1332
+    if (!$plugin_installes) {
1333
+        return false;
1334
+    }
1335 1335
 
1336
-	return in_array($plug_path, $plugin_installes);
1336
+    return in_array($plug_path, $plugin_installes);
1337 1337
 }
1338 1338
 
1339 1339
 
@@ -1346,37 +1346,37 @@  discard block
 block discarded – undo
1346 1346
  * @uses plugins_installer_dist()
1347 1347
  **/
1348 1348
 function plugin_installes_meta() {
1349
-	if (isset($GLOBALS['fichier_php_compile_recent'])) {
1350
-		// attendre eventuellement l'invalidation du cache opcode
1351
-		spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1352
-	}
1353
-
1354
-	$installer_plugins = charger_fonction('installer', 'plugins');
1355
-	$meta_plug_installes = array();
1356
-	foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1357
-		if ($plug = $resume['dir']) {
1358
-			$infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1359
-			if ($infos) {
1360
-				if (!is_array($infos) or $infos['install_test'][0]) {
1361
-					$meta_plug_installes[] = $plug;
1362
-				}
1363
-				if (is_array($infos)) {
1364
-					list($ok, $trace) = $infos['install_test'];
1365
-					include_spip('inc/filtres_boites');
1366
-					echo "<div class='install-plugins svp_retour'>"
1367
-						. boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))),
1368
-							($ok ? 'success' : 'error'))
1369
-						. $trace
1370
-						. "<div class='result'>"
1371
-						. ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec"))
1372
-						. "</div>"
1373
-						. boite_fermer()
1374
-						. "</div>";
1375
-				}
1376
-			}
1377
-		}
1378
-	}
1379
-	ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1349
+    if (isset($GLOBALS['fichier_php_compile_recent'])) {
1350
+        // attendre eventuellement l'invalidation du cache opcode
1351
+        spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1352
+    }
1353
+
1354
+    $installer_plugins = charger_fonction('installer', 'plugins');
1355
+    $meta_plug_installes = array();
1356
+    foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1357
+        if ($plug = $resume['dir']) {
1358
+            $infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1359
+            if ($infos) {
1360
+                if (!is_array($infos) or $infos['install_test'][0]) {
1361
+                    $meta_plug_installes[] = $plug;
1362
+                }
1363
+                if (is_array($infos)) {
1364
+                    list($ok, $trace) = $infos['install_test'];
1365
+                    include_spip('inc/filtres_boites');
1366
+                    echo "<div class='install-plugins svp_retour'>"
1367
+                        . boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))),
1368
+                            ($ok ? 'success' : 'error'))
1369
+                        . $trace
1370
+                        . "<div class='result'>"
1371
+                        . ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec"))
1372
+                        . "</div>"
1373
+                        . boite_fermer()
1374
+                        . "</div>";
1375
+                }
1376
+            }
1377
+        }
1378
+    }
1379
+    ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1380 1380
 }
1381 1381
 
1382 1382
 /**
@@ -1390,29 +1390,29 @@  discard block
 block discarded – undo
1390 1390
  *     Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante
1391 1391
 **/
1392 1392
 function ecrire_fichier_php($nom, $contenu, $comment = '') {
1393
-	if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1394
-		$GLOBALS['fichier_php_compile_recent'] = 0;
1395
-	}
1396
-
1397
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1398
-	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1399
-	// si pas de modif on ne touche pas au fichier initial
1400
-	if (file_exists($nom)) {
1401
-		if (substr($nom, -4) == '.php') {
1402
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1403
-		}
1404
-		else {
1405
-			$fichier_tmp = $nom . '.tmp';
1406
-		}
1407
-		file_put_contents($fichier_tmp, $contenu);
1408
-		if(md5_file($nom) == md5_file($fichier_tmp)) {
1409
-			$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1410
-			@unlink($fichier_tmp);
1411
-			return;
1412
-		}
1413
-		@unlink($fichier_tmp);
1414
-	}
1415
-	ecrire_fichier($nom, $contenu);
1416
-	$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1417
-	spip_clear_opcode_cache(realpath($nom));
1393
+    if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1394
+        $GLOBALS['fichier_php_compile_recent'] = 0;
1395
+    }
1396
+
1397
+    $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1398
+    // si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1399
+    // si pas de modif on ne touche pas au fichier initial
1400
+    if (file_exists($nom)) {
1401
+        if (substr($nom, -4) == '.php') {
1402
+            $fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1403
+        }
1404
+        else {
1405
+            $fichier_tmp = $nom . '.tmp';
1406
+        }
1407
+        file_put_contents($fichier_tmp, $contenu);
1408
+        if(md5_file($nom) == md5_file($fichier_tmp)) {
1409
+            $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1410
+            @unlink($fichier_tmp);
1411
+            return;
1412
+        }
1413
+        @unlink($fichier_tmp);
1414
+    }
1415
+    ecrire_fichier($nom, $contenu);
1416
+    $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1417
+    spip_clear_opcode_cache(realpath($nom));
1418 1418
 }
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 /** l'adresse du repertoire de telechargement et de decompactage des plugins */
24 24
 if (!defined('_DIR_PLUGINS_AUTO')) {
25
-	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
25
+	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/');
26 26
 }
27 27
 
28 28
 #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins.
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 				if ($dir) {
371 371
 					$dir .= "/";
372 372
 				}
373
-				$dir .= "procure:" . $procure['nom'];
373
+				$dir .= "procure:".$procure['nom'];
374 374
 
375 375
 				$procure['etat'] = '?';
376 376
 				$procure['dir_type'] = $resume['dir_type'];
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 		$plug = $resume['dir'];
552 552
 		$k = $infos[$dir_type][$plug];
553 553
 
554
-		$plug = constant($dir_type) . $plug;
554
+		$plug = constant($dir_type).$plug;
555 555
 		if (!isset($msg[$p])) {
556 556
 			if (isset($resume['erreur']) and $resume['erreur']) {
557 557
 				$msg[$p] = array($resume['erreur']);
@@ -594,10 +594,10 @@  discard block
 block discarded – undo
594 594
 		$list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
595 595
 	} elseif (!$raw) {
596 596
 		foreach ($list as $plug => $msg) {
597
-			$list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
598
-				. "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
597
+			$list[$plug] = "<li>"._T('plugin_impossible_activer', array('plugin' => $plug))
598
+				. "<ul><li>".implode("</li><li>", $msg)."</li></ul></li>";
599 599
 		}
600
-		$list = "<ul>" . join("\n", $list) . "</ul>";
600
+		$list = "<ul>".join("\n", $list)."</ul>";
601 601
 	}
602 602
 	if ($raz) {
603 603
 		effacer_meta('plugin_erreur_activation');
@@ -708,13 +708,13 @@  discard block
 block discarded – undo
708 708
 			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
709 709
 				return _T("plugin_${balise}_${type}", array(
710 710
 					'plugin' => $nom,
711
-					'version' => ' &ge; ' . $minimum
711
+					'version' => ' &ge; '.$minimum
712 712
 				));
713 713
 			}
714 714
 			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
715 715
 				return _T("plugin_${balise}_${type}", array(
716 716
 					'plugin' => $nom,
717
-					'version' => ' &gt; ' . $minimum
717
+					'version' => ' &gt; '.$minimum
718 718
 				));
719 719
 			}
720 720
 		}
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
 			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
724 724
 				return _T("plugin_${balise}_${type}", array(
725 725
 					'plugin' => $nom,
726
-					'version' => ' &le; ' . $maximum
726
+					'version' => ' &le; '.$maximum
727 727
 				));
728 728
 			}
729 729
 			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
730 730
 				return _T("plugin_${balise}_plugin", array(
731 731
 					'plugin' => $nom,
732
-					'version' => ' &lt; ' . $maximum
732
+					'version' => ' &lt; '.$maximum
733 733
 				));
734 734
 			}
735 735
 		}
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 		include_spip('inc/charger_plugin');
749 749
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
750 750
 	}*/
751
-	return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
751
+	return _T('plugin_necessite_lib', array('lib' => $lib))." <a href='$url'>$url</a>";
752 752
 }
753 753
 
754 754
 
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 	foreach ($plugin_valides as $p => $resume) {
848 848
 		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
849 849
 		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
850
-			$header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
850
+			$header[] = $p.($resume['version'] ? "(".$resume['version'].")" : "");
851 851
 		}
852 852
 		if ($resume['dir']) {
853 853
 			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
@@ -871,10 +871,10 @@  discard block
 block discarded – undo
871 871
 	ecrire_meta('plugin_attente', serialize($liste));
872 872
 	$header = strtolower(implode(",", $header));
873 873
 	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
874
-		ecrire_fichier(_DIR_VAR . "config.txt",
875
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
874
+		ecrire_fichier(_DIR_VAR."config.txt",
875
+			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP").' '.$GLOBALS['spip_version_affichee']." @ www.spip.net + ".$header);
876 876
 	} else {
877
-		@unlink(_DIR_VAR . "config.txt");
877
+		@unlink(_DIR_VAR."config.txt");
878 878
 	}
879 879
 	// generer charger_plugins_chemin.php
880 880
 	plugins_precompile_chemin($plugin_valides, $ordre);
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 			// definir le plugin, donc le path avant l'include du fichier options
926 926
 			// permet de faire des include_spip pour attraper un inc_ du plugin
927 927
 
928
-			$dir = $dir_type . ".'" . $plug . "/'";
928
+			$dir = $dir_type.".'".$plug."/'";
929 929
 
930 930
 			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
931 931
 			if (
@@ -945,13 +945,13 @@  discard block
 block discarded – undo
945 945
 							$dir = '';
946 946
 						}
947 947
 						if (strlen($dir)) {
948
-							$dir = rtrim($dir, '/') . '/';
948
+							$dir = rtrim($dir, '/').'/';
949 949
 						}
950 950
 						if (!isset($chemin['type']) or $chemin['type'] == 'public') {
951
-							$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
951
+							$chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : "");
952 952
 						}
953 953
 						if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
954
-							$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
954
+							$chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : "");
955 955
 						}
956 956
 					}
957 957
 				}
@@ -959,9 +959,9 @@  discard block
 block discarded – undo
959 959
 		}
960 960
 	}
961 961
 	if (count($chemins)) {
962
-		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
963
-				array_reverse($chemins['public'])) . ")));\n"
964
-			. "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
962
+		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(".implode(',',
963
+				array_reverse($chemins['public'])).")));\n"
964
+			. "else _chemin(implode(':',array(".implode(',', array_reverse($chemins['prive'])).")));\n";
965 965
 	}
966 966
 
967 967
 	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 					and strpos($dir, ":") === false // exclure le cas des procure:
1010 1010
 					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1011 1011
 				) {
1012
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
1012
+					if (is_readable("$dir$plug/".($file = $info['prefix']."_".$charge.".php"))) {
1013 1013
 						$info[$charge] = array($file);
1014 1014
 					}
1015 1015
 				}
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 						) {
1026 1026
 							unset($info[$charge][$k]);
1027 1027
 						} else {
1028
-							$_file = $root_dir_type . ".'$plug/$file'";
1028
+							$_file = $root_dir_type.".'$plug/$file'";
1029 1029
 							$contenu[$charge] .= "include_once_check($_file);\n";
1030 1030
 						}
1031 1031
 					}
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		}
1036 1036
 	}
1037 1037
 
1038
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1038
+	$contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options'];
1039 1039
 	$contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1040 1040
 		. plugin_ongletbouton("onglets_plugins", $onglets);
1041 1041
 
@@ -1070,12 +1070,12 @@  discard block
 block discarded – undo
1070 1070
 		define("_UPDATED_$nom", $val);
1071 1071
 		define("_UPDATED_md5_$nom", $md5);
1072 1072
 	}
1073
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1073
+	$val = "unserialize('".str_replace("'", "\'", $val)."')";
1074 1074
 
1075 1075
 	return
1076 1076
 		"if (!function_exists('$nom')) {\n"
1077 1077
 		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1078
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1078
+		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n"
1079 1079
 		. "}\n";
1080 1080
 }
1081 1081
 
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1099 1099
 		include_once(_CACHE_PLUGINS_OPT);
1100 1100
 	} else {
1101
-		spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1101
+		spip_log("pipelines desactives: impossible de produire "._CACHE_PLUGINS_OPT);
1102 1102
 	}
1103 1103
 }
1104 1104
 
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 			$dir_type = $plugin_valides[$p]['dir_type'];
1136 1136
 			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1137 1137
 			$plug = $plugin_valides[$p]['dir'];
1138
-			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1138
+			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix']."_");
1139 1139
 			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1140 1140
 				foreach ($info['pipeline'] as $pipe) {
1141 1141
 					$nom = $pipe['nom'];
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 						}
1166 1166
 						if (isset($pipe['inclure'])) {
1167 1167
 							$GLOBALS['spip_matrice']["$prefix$action"] =
1168
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1168
+								"$root_dir_type:$plug/".$pipe['inclure'];
1169 1169
 						}
1170 1170
 					}
1171 1171
 				}
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 					$prepend_code['taches_generales_cron'] = "";
1176 1176
 				}
1177 1177
 				foreach ($info['genie'] as $genie) {
1178
-					$nom = $prefix . $genie['nom'];
1178
+					$nom = $prefix.$genie['nom'];
1179 1179
 					$periode = max(60, intval($genie['periode']));
1180 1180
 					if (charger_fonction($nom, "genie", true)) {
1181 1181
 						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
@@ -1193,13 +1193,13 @@  discard block
 block discarded – undo
1193 1193
 				}
1194 1194
 				foreach ($info['style'] as $style) {
1195 1195
 					if (isset($style['path']) and $style['path']) {
1196
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1196
+						$code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) ";
1197 1197
 					} else {
1198
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1198
+						$code = "if (\$f='".addslashes($style['url'])."') ";
1199 1199
 					}
1200 1200
 					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1201 1201
 					if (isset($style['media']) and strlen($style['media'])) {
1202
-						$code .= " media=\"" . addslashes($style['media']) . "\"";
1202
+						$code .= " media=\"".addslashes($style['media'])."\"";
1203 1203
 					}
1204 1204
 					$code .= "/>';\n";
1205 1205
 					if ($style['type'] != 'prive') {
@@ -1219,9 +1219,9 @@  discard block
 block discarded – undo
1219 1219
 			if (isset($info['script']) and count($info['script'])) {
1220 1220
 				foreach ($info['script'] as $script) {
1221 1221
 					if (isset($script['path']) and $script['path']) {
1222
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1222
+						$code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) ";
1223 1223
 					} else {
1224
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1224
+						$code = "if (\$f='".addslashes($script['url'])."') ";
1225 1225
 					}
1226 1226
 					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1227 1227
 					if ($script['type'] != 'prive') {
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 		// Eclater le pipeline en filtres et appliquer chaque filtre
1287 1287
 		foreach ($pipe as $fonc) {
1288 1288
 			$fonc = trim($fonc);
1289
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1289
+			$s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n";
1290 1290
 			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1291 1291
 				$file = $GLOBALS['spip_matrice'][$fonc];
1292 1292
 				$file = "'$file'";
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 					if (defined($root_dir)) {
1298 1298
 						$dir = $root_dir;
1299 1299
 					}
1300
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1300
+					$file = str_replace($regs[0], "'.".$dir.".'", $file);
1301 1301
 					$file = str_replace("''.", "", $file);
1302 1302
 					$file = str_replace(constant($dir), '', $file);
1303 1303
 				}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		$content .= "// Pipeline $action \n"
1311 1311
 			. "function execute_pipeline_$action(&\$val){\n"
1312 1312
 			. $s_inc
1313
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1313
+			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '')
1314 1314
 			. $s_call
1315 1315
 			. "return \$val;\n}\n";
1316 1316
 	}
@@ -1394,18 +1394,18 @@  discard block
 block discarded – undo
1394 1394
 		$GLOBALS['fichier_php_compile_recent'] = 0;
1395 1395
 	}
1396 1396
 
1397
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1397
+	$contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>';
1398 1398
 	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1399 1399
 	// si pas de modif on ne touche pas au fichier initial
1400 1400
 	if (file_exists($nom)) {
1401 1401
 		if (substr($nom, -4) == '.php') {
1402
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1402
+			$fichier_tmp = substr($nom, 0, -4).'.tmp.php';
1403 1403
 		}
1404 1404
 		else {
1405
-			$fichier_tmp = $nom . '.tmp';
1405
+			$fichier_tmp = $nom.'.tmp';
1406 1406
 		}
1407 1407
 		file_put_contents($fichier_tmp, $contenu);
1408
-		if(md5_file($nom) == md5_file($fichier_tmp)) {
1408
+		if (md5_file($nom) == md5_file($fichier_tmp)) {
1409 1409
 			$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1410 1410
 			@unlink($fichier_tmp);
1411 1411
 			return;
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -555,11 +555,9 @@  discard block
 block discarded – undo
555 555
 		if (!isset($msg[$p])) {
556 556
 			if (isset($resume['erreur']) and $resume['erreur']) {
557 557
 				$msg[$p] = array($resume['erreur']);
558
-			}
559
-			elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
558
+			} elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
560 559
 				$msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite'));
561
-			}
562
-			elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
560
+			} elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
563 561
 				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
564 562
 			}
565 563
 		} else {
@@ -1154,10 +1152,12 @@  discard block
 block discarded – undo
1154 1152
 					}
1155 1153
 					$nom = $nomlower;
1156 1154
 					// une action vide est une declaration qui ne doit pas etre compilee !
1157
-					if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1155
+					if (!isset($GLOBALS['spip_pipeline'][$nom])) {
1156
+					    // creer le pipeline eventuel
1158 1157
 					{
1159 1158
 						$GLOBALS['spip_pipeline'][$nom] = "";
1160 1159
 					}
1160
+					}
1161 1161
 					if ($action) {
1162 1162
 						if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1163 1163
 							$GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
@@ -1400,8 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 	if (file_exists($nom)) {
1401 1401
 		if (substr($nom, -4) == '.php') {
1402 1402
 			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1403
-		}
1404
-		else {
1403
+		} else {
1405 1404
 			$fichier_tmp = $nom . '.tmp';
1406 1405
 		}
1407 1406
 		file_put_contents($fichier_tmp, $contenu);
Please login to merge, or discard this patch.