Completed
Push — master ( b98ce9...923621 )
by cam
06:15
created
ecrire/inc/plugin.php 2 patches
Indentation   +891 added lines, -891 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,52 +248,52 @@  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
-	foreach ($liste_ext as $plug) {
275
-		if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
276
-			plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
277
-		}
278
-	}
279
-	foreach ($liste_plug as $plug) {
280
-		if (isset($infos['_DIR_PLUGINS'][$plug])) {
281
-			plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
282
-		}
283
-	}
284
-
285
-	if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
286
-		$infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
287
-		foreach ($liste_plug as $plug) {
288
-			if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
289
-				plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
290
-			}
291
-		}
292
-	}
293
-
294
-	plugin_fixer_procure($liste_non_classee, $infos);
295
-
296
-	return array($infos, $liste_non_classee);
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
+    foreach ($liste_ext as $plug) {
275
+        if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
276
+            plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
277
+        }
278
+    }
279
+    foreach ($liste_plug as $plug) {
280
+        if (isset($infos['_DIR_PLUGINS'][$plug])) {
281
+            plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
282
+        }
283
+    }
284
+
285
+    if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
286
+        $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
287
+        foreach ($liste_plug as $plug) {
288
+            if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
289
+                plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
290
+            }
291
+        }
292
+    }
293
+
294
+    plugin_fixer_procure($liste_non_classee, $infos);
295
+
296
+    return array($infos, $liste_non_classee);
297 297
 }
298 298
 
299 299
 /**
@@ -310,25 +310,25 @@  discard block
 block discarded – undo
310 310
  * @param string $dir_type
311 311
  */
312 312
 function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) {
313
-	$i = $infos[$dir_type][$plug];
314
-	if (isset($i['erreur']) and $i['erreur']) {
315
-		return;
316
-	}
317
-	if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
318
-		return;
319
-	}
320
-	$p = strtoupper($i['prefix']);
321
-	if (!isset($liste[$p])
322
-		or spip_version_compare($i['version'], $liste[$p]['version'], '>')
323
-	) {
324
-		$liste[$p] = array(
325
-			'nom' => $i['nom'],
326
-			'etat' => $i['etat'],
327
-			'version' => $i['version'],
328
-			'dir' => $plug,
329
-			'dir_type' => $dir_type
330
-		);
331
-	}
313
+    $i = $infos[$dir_type][$plug];
314
+    if (isset($i['erreur']) and $i['erreur']) {
315
+        return;
316
+    }
317
+    if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
318
+        return;
319
+    }
320
+    $p = strtoupper($i['prefix']);
321
+    if (!isset($liste[$p])
322
+        or spip_version_compare($i['version'], $liste[$p]['version'], '>')
323
+    ) {
324
+        $liste[$p] = array(
325
+            'nom' => $i['nom'],
326
+            'etat' => $i['etat'],
327
+            'version' => $i['version'],
328
+            'dir' => $plug,
329
+            'dir_type' => $dir_type
330
+        );
331
+    }
332 332
 }
333 333
 
334 334
 /**
@@ -344,46 +344,46 @@  discard block
 block discarded – undo
344 344
  * @param array $infos
345 345
  */
346 346
 function plugin_fixer_procure(&$liste, &$infos) {
347
-	foreach ($liste as $p => $resume) {
348
-		$i = $infos[$resume['dir_type']][$resume['dir']];
349
-		if (isset($i['procure']) and $i['procure']) {
350
-			foreach ($i['procure'] as $procure) {
351
-				$p = strtoupper($procure['nom']);
352
-				$dir = $resume['dir'];
353
-				if ($dir) {
354
-					$dir .= "/";
355
-				}
356
-				$dir .= "procure:" . $procure['nom'];
357
-
358
-				$procure['etat'] = '?';
359
-				$procure['dir_type'] = $resume['dir_type'];
360
-				$procure['dir'] = $dir;
361
-
362
-				// si ce plugin n'est pas deja procure, ou dans une version plus ancienne
363
-				// on ajoute cette version a la liste
364
-				if (!isset($liste[$p])
365
-					or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
366
-				) {
367
-					$liste[$p] = $procure;
368
-
369
-					// on fournit une information minimale pour ne pas perturber la compilation
370
-					$infos[$resume['dir_type']][$dir] = array(
371
-						'prefix' => $procure['nom'],
372
-						'nom' => $procure['nom'],
373
-						'etat' => $procure['etat'],
374
-						'version' => $procure['version'],
375
-						'chemin' => array(),
376
-						'necessite' => array(),
377
-						'utilise' => array(),
378
-						'lib' => array(),
379
-						'menu' => array(),
380
-						'onglet' => array(),
381
-						'procure' => array(),
382
-					);
383
-				}
384
-			}
385
-		}
386
-	}
347
+    foreach ($liste as $p => $resume) {
348
+        $i = $infos[$resume['dir_type']][$resume['dir']];
349
+        if (isset($i['procure']) and $i['procure']) {
350
+            foreach ($i['procure'] as $procure) {
351
+                $p = strtoupper($procure['nom']);
352
+                $dir = $resume['dir'];
353
+                if ($dir) {
354
+                    $dir .= "/";
355
+                }
356
+                $dir .= "procure:" . $procure['nom'];
357
+
358
+                $procure['etat'] = '?';
359
+                $procure['dir_type'] = $resume['dir_type'];
360
+                $procure['dir'] = $dir;
361
+
362
+                // si ce plugin n'est pas deja procure, ou dans une version plus ancienne
363
+                // on ajoute cette version a la liste
364
+                if (!isset($liste[$p])
365
+                    or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
366
+                ) {
367
+                    $liste[$p] = $procure;
368
+
369
+                    // on fournit une information minimale pour ne pas perturber la compilation
370
+                    $infos[$resume['dir_type']][$dir] = array(
371
+                        'prefix' => $procure['nom'],
372
+                        'nom' => $procure['nom'],
373
+                        'etat' => $procure['etat'],
374
+                        'version' => $procure['version'],
375
+                        'chemin' => array(),
376
+                        'necessite' => array(),
377
+                        'utilise' => array(),
378
+                        'lib' => array(),
379
+                        'menu' => array(),
380
+                        'onglet' => array(),
381
+                        'procure' => array(),
382
+                    );
383
+                }
384
+            }
385
+        }
386
+    }
387 387
 }
388 388
 
389 389
 /**
@@ -397,19 +397,19 @@  discard block
 block discarded – undo
397 397
  * @return array
398 398
  */
399 399
 function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) {
400
-	foreach ($liste as $prefix => $infos) {
401
-		if (!$dir_plugins
402
-			or (
403
-				defined($infos['dir_type'])
404
-				and constant($infos['dir_type']) == $dir_plugins)
405
-		) {
406
-			$liste[$prefix] = $infos['dir'];
407
-		} else {
408
-			unset($liste[$prefix]);
409
-		}
410
-	}
411
-
412
-	return $liste;
400
+    foreach ($liste as $prefix => $infos) {
401
+        if (!$dir_plugins
402
+            or (
403
+                defined($infos['dir_type'])
404
+                and constant($infos['dir_type']) == $dir_plugins)
405
+        ) {
406
+            $liste[$prefix] = $infos['dir'];
407
+        } else {
408
+            unset($liste[$prefix]);
409
+        }
410
+    }
411
+
412
+    return $liste;
413 413
 }
414 414
 
415 415
 /**
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
  * @return array
425 425
  */
426 426
 function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) {
427
-	include_spip('plugins/installer');
427
+    include_spip('plugins/installer');
428 428
 
429
-	return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
429
+    return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
430 430
 }
431 431
 
432 432
 /**
@@ -457,53 +457,53 @@  discard block
 block discarded – undo
457 457
  *                qui n'ont pas satisfait leurs dépendances
458 458
 **/
459 459
 function plugin_trier($infos, $liste_non_classee) {
460
-	$toute_la_liste = $liste_non_classee;
461
-	$liste = $ordre = array();
462
-	$count = 0;
463
-
464
-	while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
465
-		#echo "tour::";var_dump($liste_non_classee);
466
-		$count = $c;
467
-		foreach ($liste_non_classee as $p => $resume) {
468
-			$plug = $resume['dir'];
469
-			$dir_type = $resume['dir_type'];
470
-			$info1 = $infos[$dir_type][$plug];
471
-			// si des plugins sont necessaires,
472
-			// on ne peut inserer qu'apres eux
473
-			foreach ($info1['necessite'] as $need) {
474
-				$nom = strtoupper($need['nom']);
475
-				$compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
476
-				if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
477
-					$info1 = false;
478
-					break;
479
-				}
480
-			}
481
-			if (!$info1) {
482
-				continue;
483
-			}
484
-			// idem si des plugins sont utiles,
485
-			// sauf si ils sont de toute facon absents de la liste
486
-			foreach ($info1['utilise'] as $need) {
487
-				$nom = strtoupper($need['nom']);
488
-				$compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
489
-				if (isset($toute_la_liste[$nom])) {
490
-					if (!isset($liste[$nom]) or
491
-						!plugin_version_compatible($compat, $liste[$nom]['version'])
492
-					) {
493
-						$info1 = false;
494
-						break;
495
-					}
496
-				}
497
-			}
498
-			if ($info1) {
499
-				$ordre[$p] = $info1;
500
-				$liste[$p] = $liste_non_classee[$p];
501
-				unset($liste_non_classee[$p]);
502
-			}
503
-		}
504
-	}
505
-
506
-	return array($liste, $ordre, $liste_non_classee);
460
+    $toute_la_liste = $liste_non_classee;
461
+    $liste = $ordre = array();
462
+    $count = 0;
463
+
464
+    while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
465
+        #echo "tour::";var_dump($liste_non_classee);
466
+        $count = $c;
467
+        foreach ($liste_non_classee as $p => $resume) {
468
+            $plug = $resume['dir'];
469
+            $dir_type = $resume['dir_type'];
470
+            $info1 = $infos[$dir_type][$plug];
471
+            // si des plugins sont necessaires,
472
+            // on ne peut inserer qu'apres eux
473
+            foreach ($info1['necessite'] as $need) {
474
+                $nom = strtoupper($need['nom']);
475
+                $compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
476
+                if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
477
+                    $info1 = false;
478
+                    break;
479
+                }
480
+            }
481
+            if (!$info1) {
482
+                continue;
483
+            }
484
+            // idem si des plugins sont utiles,
485
+            // sauf si ils sont de toute facon absents de la liste
486
+            foreach ($info1['utilise'] as $need) {
487
+                $nom = strtoupper($need['nom']);
488
+                $compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
489
+                if (isset($toute_la_liste[$nom])) {
490
+                    if (!isset($liste[$nom]) or
491
+                        !plugin_version_compatible($compat, $liste[$nom]['version'])
492
+                    ) {
493
+                        $info1 = false;
494
+                        break;
495
+                    }
496
+                }
497
+            }
498
+            if ($info1) {
499
+                $ordre[$p] = $info1;
500
+                $liste[$p] = $liste_non_classee[$p];
501
+                unset($liste_non_classee[$p]);
502
+            }
503
+        }
504
+    }
505
+
506
+    return array($liste, $ordre, $liste_non_classee);
507 507
 }
508 508
 
509 509
 /**
@@ -520,34 +520,34 @@  discard block
 block discarded – undo
520 520
  *     Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent
521 521
 **/
522 522
 function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = array()) {
523
-	static $erreurs = array();
524
-
525
-	if (!is_array($liste)) {
526
-		$liste = array();
527
-	}
528
-
529
-	// les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
530
-	$liste = array_diff_key($liste, $liste_non_classee);
531
-
532
-	foreach ($liste_non_classee as $p => $resume) {
533
-		$dir_type = $resume['dir_type'];
534
-		$plug = $resume['dir'];
535
-		$k = $infos[$dir_type][$plug];
536
-
537
-		$plug = constant($dir_type) . $plug;
538
-		if (!isset($msg[$p])) {
539
-			if (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
540
-				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
541
-			}
542
-		} else {
543
-			foreach ($msg[$p] as $c => $l) {
544
-				$msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
545
-			}
546
-		}
547
-		$erreurs[$plug] = $msg[$p];
548
-	}
549
-
550
-	ecrire_meta('plugin_erreur_activation', serialize($erreurs));
523
+    static $erreurs = array();
524
+
525
+    if (!is_array($liste)) {
526
+        $liste = array();
527
+    }
528
+
529
+    // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
530
+    $liste = array_diff_key($liste, $liste_non_classee);
531
+
532
+    foreach ($liste_non_classee as $p => $resume) {
533
+        $dir_type = $resume['dir_type'];
534
+        $plug = $resume['dir'];
535
+        $k = $infos[$dir_type][$plug];
536
+
537
+        $plug = constant($dir_type) . $plug;
538
+        if (!isset($msg[$p])) {
539
+            if (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
540
+                $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
541
+            }
542
+        } else {
543
+            foreach ($msg[$p] as $c => $l) {
544
+                $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
545
+            }
546
+        }
547
+        $erreurs[$plug] = $msg[$p];
548
+    }
549
+
550
+    ecrire_meta('plugin_erreur_activation', serialize($erreurs));
551 551
 }
552 552
 
553 553
 /**
@@ -562,25 +562,25 @@  discard block
 block discarded – undo
562 562
  *     - Liste des erreurs ou code HTML des erreurs
563 563
 **/
564 564
 function plugin_donne_erreurs($raw = false, $raz = true) {
565
-	if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
566
-		return $raw ? array() : '';
567
-	}
568
-	$list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
569
-	// Compat ancienne version
570
-	if (!$list) {
571
-		$list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
572
-	} elseif (!$raw) {
573
-		foreach ($list as $plug => $msg) {
574
-			$list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
575
-				. "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
576
-		}
577
-		$list = "<ul>" . join("\n", $list) . "</ul>";
578
-	}
579
-	if ($raz) {
580
-		effacer_meta('plugin_erreur_activation');
581
-	}
582
-
583
-	return $list;
565
+    if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
566
+        return $raw ? array() : '';
567
+    }
568
+    $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
569
+    // Compat ancienne version
570
+    if (!$list) {
571
+        $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
572
+    } elseif (!$raw) {
573
+        foreach ($list as $plug => $msg) {
574
+            $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
575
+                . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
576
+        }
577
+        $list = "<ul>" . join("\n", $list) . "</ul>";
578
+    }
579
+    if ($raz) {
580
+        effacer_meta('plugin_erreur_activation');
581
+    }
582
+
583
+    return $list;
584 584
 }
585 585
 
586 586
 /**
@@ -600,21 +600,21 @@  discard block
 block discarded – undo
600 600
  *
601 601
  **/
602 602
 function plugin_necessite($n, $liste, $balise = 'necessite') {
603
-	$msg = array();
604
-	foreach ($n as $need) {
605
-		$id = strtoupper($need['nom']);
606
-		$r = plugin_controler_necessite(
607
-			$liste, 
608
-			$id, 
609
-			isset($need['compatibilite']) ? $need['compatibilite'] : '', 
610
-			$balise
611
-		);
612
-		if ($r) {
613
-			$msg[] = $r;
614
-		}
615
-	}
616
-
617
-	return $msg;
603
+    $msg = array();
604
+    foreach ($n as $need) {
605
+        $id = strtoupper($need['nom']);
606
+        $r = plugin_controler_necessite(
607
+            $liste, 
608
+            $id, 
609
+            isset($need['compatibilite']) ? $need['compatibilite'] : '', 
610
+            $balise
611
+        );
612
+        if ($r) {
613
+            $msg[] = $r;
614
+        }
615
+    }
616
+
617
+    return $msg;
618 618
 }
619 619
 
620 620
 /**
@@ -636,16 +636,16 @@  discard block
 block discarded – undo
636 636
  *    Message d'erreur lorsque la dépendance est absente.
637 637
  **/
638 638
 function plugin_controler_necessite($liste, $nom, $intervalle, $balise) {
639
-	if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
640
-		return '';
641
-	}
642
-
643
-	return plugin_message_incompatibilite(
644
-		$intervalle, 
645
-		(isset($liste[$nom]) ? $liste[$nom]['version'] : ""), 
646
-		$nom, 
647
-		$balise
648
-	);
639
+    if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
640
+        return '';
641
+    }
642
+
643
+    return plugin_message_incompatibilite(
644
+        $intervalle, 
645
+        (isset($liste[$nom]) ? $liste[$nom]['version'] : ""), 
646
+        $nom, 
647
+        $balise
648
+    );
649 649
 }
650 650
 
651 651
 /**
@@ -662,68 +662,68 @@  discard block
 block discarded – undo
662 662
  */
663 663
 function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) {
664 664
 
665
-	// prendre en compte les erreurs de dépendances à PHP
666
-	// ou à une extension PHP avec des messages d'erreurs dédiés.
667
-	$type = 'plugin';
668
-	if ($nom === 'PHP') {
669
-		$type = 'php';
670
-	} elseif (strncmp($nom, 'PHP:', 4) === 0) {
671
-		$type = 'extension_php';
672
-		list(,$nom) = explode(':', $nom, 2);
673
-	}
674
-
675
-	if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
676
-		$minimum = $regs[1];
677
-		$maximum = $regs[2];
678
-
679
-		$minimum_inclus = $intervalle{0} == "[";
680
-		$maximum_inclus = substr($intervalle, -1) == "]";
681
-
682
-		if (strlen($minimum)) {
683
-			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
684
-				return _T("plugin_${balise}_${type}", array(
685
-					'plugin' => $nom,
686
-					'version' => ' &ge; ' . $minimum
687
-				));
688
-			}
689
-			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
690
-				return _T("plugin_${balise}_${type}", array(
691
-					'plugin' => $nom,
692
-					'version' => ' &gt; ' . $minimum
693
-				));
694
-			}
695
-		}
696
-
697
-		if (strlen($maximum)) {
698
-			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
699
-				return _T("plugin_${balise}_${type}", array(
700
-					'plugin' => $nom,
701
-					'version' => ' &le; ' . $maximum
702
-				));
703
-			}
704
-			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
705
-				return _T("plugin_${balise}_plugin", array(
706
-					'plugin' => $nom,
707
-					'version' => ' &lt; ' . $maximum
708
-				));
709
-			}
710
-		}
711
-	}
712
-
713
-	// note : il ne peut pas y avoir d'erreur sur
714
-	// - un 'utilise' sans version.
715
-	// - un 'php' sans version.
716
-	return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom));
665
+    // prendre en compte les erreurs de dépendances à PHP
666
+    // ou à une extension PHP avec des messages d'erreurs dédiés.
667
+    $type = 'plugin';
668
+    if ($nom === 'PHP') {
669
+        $type = 'php';
670
+    } elseif (strncmp($nom, 'PHP:', 4) === 0) {
671
+        $type = 'extension_php';
672
+        list(,$nom) = explode(':', $nom, 2);
673
+    }
674
+
675
+    if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
676
+        $minimum = $regs[1];
677
+        $maximum = $regs[2];
678
+
679
+        $minimum_inclus = $intervalle{0} == "[";
680
+        $maximum_inclus = substr($intervalle, -1) == "]";
681
+
682
+        if (strlen($minimum)) {
683
+            if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
684
+                return _T("plugin_${balise}_${type}", array(
685
+                    'plugin' => $nom,
686
+                    'version' => ' &ge; ' . $minimum
687
+                ));
688
+            }
689
+            if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
690
+                return _T("plugin_${balise}_${type}", array(
691
+                    'plugin' => $nom,
692
+                    'version' => ' &gt; ' . $minimum
693
+                ));
694
+            }
695
+        }
696
+
697
+        if (strlen($maximum)) {
698
+            if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
699
+                return _T("plugin_${balise}_${type}", array(
700
+                    'plugin' => $nom,
701
+                    'version' => ' &le; ' . $maximum
702
+                ));
703
+            }
704
+            if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
705
+                return _T("plugin_${balise}_plugin", array(
706
+                    'plugin' => $nom,
707
+                    'version' => ' &lt; ' . $maximum
708
+                ));
709
+            }
710
+        }
711
+    }
712
+
713
+    // note : il ne peut pas y avoir d'erreur sur
714
+    // - un 'utilise' sans version.
715
+    // - un 'php' sans version.
716
+    return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom));
717 717
 }
718 718
 
719 719
 
720 720
 function plugin_controler_lib($lib, $url) {
721
-	/* Feature sortie du core, voir STP
721
+    /* Feature sortie du core, voir STP
722 722
 	 * if ($url) {
723 723
 		include_spip('inc/charger_plugin');
724 724
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
725 725
 	}*/
726
-	return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
726
+    return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
727 727
 }
728 728
 
729 729
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
  *     true si il y a eu des modifications sur la liste des plugins actifs, false sinon
739 739
  **/
740 740
 function actualise_plugins_actifs($pipe_recherche = false) {
741
-	return ecrire_plugin_actifs('', $pipe_recherche, 'force');
741
+    return ecrire_plugin_actifs('', $pipe_recherche, 'force');
742 742
 }
743 743
 
744 744
 
@@ -765,113 +765,113 @@  discard block
 block discarded – undo
765 765
  **/
766 766
 function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') {
767 767
 
768
-	// creer le repertoire cache/ si necessaire ! (installation notamment)
769
-	$cache = sous_repertoire(_DIR_CACHE, '', false, true);
770
-
771
-	// Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
772
-	if (!$cache and !spip_connect()) {
773
-		return false;
774
-	}
775
-
776
-	if ($operation != 'raz') {
777
-		$plugin_valides = liste_chemin_plugin_actifs();
778
-		$plugin_valides = is_plugin_dir($plugin_valides);
779
-		if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
780
-			$plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
781
-			$plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
782
-			$plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
783
-		}
784
-		// si des plugins sont en attentes (coches mais impossible a activer)
785
-		// on les reinjecte ici
786
-		if (isset($GLOBALS['meta']['plugin_attente'])
787
-			and $a = unserialize($GLOBALS['meta']['plugin_attente'])
788
-		) {
789
-			$plugin_valides = $plugin_valides + liste_chemin_plugin($a);
790
-		}
791
-
792
-		if ($operation == 'ajoute') {
793
-			$plugin = array_merge($plugin_valides, $plugin);
794
-		} elseif ($operation == 'enleve') {
795
-			$plugin = array_diff($plugin_valides, $plugin);
796
-		} else {
797
-			$plugin = $plugin_valides;
798
-		}
799
-	}
800
-	$actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
801
-
802
-	// si une fonction de gestion de dependances existe, l'appeler ici
803
-	if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) {
804
-		$plugin = $ajouter_dependances($plugin);
805
-	}
806
-
807
-	// recharger le xml des plugins a activer
808
-	// on force le reload ici, meme si le fichier xml n'a pas change
809
-	// pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
810
-	// pourra etre evite quand on ne supportera plus les plugin.xml
811
-	// en deplacant la detection de ces fichiers dans la compilation ci dessous
812
-	list($infos, $liste) = liste_plugin_valides($plugin, true);
813
-	// trouver l'ordre d'activation
814
-	list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste);
815
-	if ($reste) {
816
-		plugins_erreurs($reste, $liste, $infos);
817
-	}
818
-
819
-	// Ignorer les plugins necessitant une lib absente
820
-	// et preparer la meta d'entete Http
821
-	$err = $msg = $header = array();
822
-	foreach ($plugin_valides as $p => $resume) {
823
-		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
824
-		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
825
-			$header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
826
-		}
827
-		if ($resume['dir']) {
828
-			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
829
-				if (!find_in_path($l['nom'], 'lib/')) {
830
-					$err[$p] = $resume;
831
-					$msg[$p][] = $l;
832
-					unset($plugin_valides[$p]);
833
-				}
834
-			}
835
-		}
836
-	}
837
-	if ($err) {
838
-		plugins_erreurs($err, '', $infos, $msg);
839
-	}
840
-
841
-	if (isset($GLOBALS['meta']['message_crash_plugins'])) {
842
-		effacer_meta('message_crash_plugins');
843
-	}
844
-	ecrire_meta('plugin', serialize($plugin_valides));
845
-	$liste = array_diff_key($liste, $plugin_valides);
846
-	ecrire_meta('plugin_attente', serialize($liste));
847
-	$header = strtolower(implode(",", $header));
848
-	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
849
-		ecrire_fichier(_DIR_VAR . "config.txt",
850
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
851
-	} else {
852
-		@unlink(_DIR_VAR . "config.txt");
853
-	}
854
-	// generer charger_plugins_chemin.php
855
-	plugins_precompile_chemin($plugin_valides, $ordre);
856
-	// generer les fichiers
857
-	// - charger_plugins_options.php
858
-	// - charger_plugins_fonctions.php
859
-	plugins_precompile_xxxtions($plugin_valides, $ordre);
860
-	// charger les chemins des plugins et les fichiers d'options 
861
-	// (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
862
-	plugins_amorcer_plugins_actifs();
863
-	// mise a jour de la matrice des pipelines
864
-	$prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
865
-	// generer le fichier _CACHE_PIPELINE
866
-	pipeline_precompile($prepend_code);
867
-
868
-	if (spip_connect()) {
869
-		// lancer et initialiser les nouveaux crons !
870
-		include_spip('inc/genie');
871
-		genie_queue_watch_dist();
872
-	}
873
-
874
-	return ($GLOBALS['meta']['plugin'] != $actifs_avant);
768
+    // creer le repertoire cache/ si necessaire ! (installation notamment)
769
+    $cache = sous_repertoire(_DIR_CACHE, '', false, true);
770
+
771
+    // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
772
+    if (!$cache and !spip_connect()) {
773
+        return false;
774
+    }
775
+
776
+    if ($operation != 'raz') {
777
+        $plugin_valides = liste_chemin_plugin_actifs();
778
+        $plugin_valides = is_plugin_dir($plugin_valides);
779
+        if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
780
+            $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
781
+            $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
782
+            $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
783
+        }
784
+        // si des plugins sont en attentes (coches mais impossible a activer)
785
+        // on les reinjecte ici
786
+        if (isset($GLOBALS['meta']['plugin_attente'])
787
+            and $a = unserialize($GLOBALS['meta']['plugin_attente'])
788
+        ) {
789
+            $plugin_valides = $plugin_valides + liste_chemin_plugin($a);
790
+        }
791
+
792
+        if ($operation == 'ajoute') {
793
+            $plugin = array_merge($plugin_valides, $plugin);
794
+        } elseif ($operation == 'enleve') {
795
+            $plugin = array_diff($plugin_valides, $plugin);
796
+        } else {
797
+            $plugin = $plugin_valides;
798
+        }
799
+    }
800
+    $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
801
+
802
+    // si une fonction de gestion de dependances existe, l'appeler ici
803
+    if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) {
804
+        $plugin = $ajouter_dependances($plugin);
805
+    }
806
+
807
+    // recharger le xml des plugins a activer
808
+    // on force le reload ici, meme si le fichier xml n'a pas change
809
+    // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
810
+    // pourra etre evite quand on ne supportera plus les plugin.xml
811
+    // en deplacant la detection de ces fichiers dans la compilation ci dessous
812
+    list($infos, $liste) = liste_plugin_valides($plugin, true);
813
+    // trouver l'ordre d'activation
814
+    list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste);
815
+    if ($reste) {
816
+        plugins_erreurs($reste, $liste, $infos);
817
+    }
818
+
819
+    // Ignorer les plugins necessitant une lib absente
820
+    // et preparer la meta d'entete Http
821
+    $err = $msg = $header = array();
822
+    foreach ($plugin_valides as $p => $resume) {
823
+        // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
824
+        if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
825
+            $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
826
+        }
827
+        if ($resume['dir']) {
828
+            foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
829
+                if (!find_in_path($l['nom'], 'lib/')) {
830
+                    $err[$p] = $resume;
831
+                    $msg[$p][] = $l;
832
+                    unset($plugin_valides[$p]);
833
+                }
834
+            }
835
+        }
836
+    }
837
+    if ($err) {
838
+        plugins_erreurs($err, '', $infos, $msg);
839
+    }
840
+
841
+    if (isset($GLOBALS['meta']['message_crash_plugins'])) {
842
+        effacer_meta('message_crash_plugins');
843
+    }
844
+    ecrire_meta('plugin', serialize($plugin_valides));
845
+    $liste = array_diff_key($liste, $plugin_valides);
846
+    ecrire_meta('plugin_attente', serialize($liste));
847
+    $header = strtolower(implode(",", $header));
848
+    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
849
+        ecrire_fichier(_DIR_VAR . "config.txt",
850
+            (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
851
+    } else {
852
+        @unlink(_DIR_VAR . "config.txt");
853
+    }
854
+    // generer charger_plugins_chemin.php
855
+    plugins_precompile_chemin($plugin_valides, $ordre);
856
+    // generer les fichiers
857
+    // - charger_plugins_options.php
858
+    // - charger_plugins_fonctions.php
859
+    plugins_precompile_xxxtions($plugin_valides, $ordre);
860
+    // charger les chemins des plugins et les fichiers d'options 
861
+    // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
862
+    plugins_amorcer_plugins_actifs();
863
+    // mise a jour de la matrice des pipelines
864
+    $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
865
+    // generer le fichier _CACHE_PIPELINE
866
+    pipeline_precompile($prepend_code);
867
+
868
+    if (spip_connect()) {
869
+        // lancer et initialiser les nouveaux crons !
870
+        include_spip('inc/genie');
871
+        genie_queue_watch_dist();
872
+    }
873
+
874
+    return ($GLOBALS['meta']['plugin'] != $actifs_avant);
875 875
 }
876 876
 
877 877
 /**
@@ -890,56 +890,56 @@  discard block
 block discarded – undo
890 890
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
891 891
 **/
892 892
 function plugins_precompile_chemin($plugin_valides, $ordre) {
893
-	$chemins = array();
894
-	$contenu = "";
895
-	foreach ($ordre as $p => $info) {
896
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
897
-		if (isset($plugin_valides[$p])) {
898
-			$dir_type = $plugin_valides[$p]['dir_type'];
899
-			$plug = $plugin_valides[$p]['dir'];
900
-			// definir le plugin, donc le path avant l'include du fichier options
901
-			// permet de faire des include_spip pour attraper un inc_ du plugin
902
-
903
-			$dir = $dir_type . ".'" . $plug . "/'";
904
-
905
-			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
906
-			if (
907
-				$prefix !== "SPIP"
908
-				and strpos($dir, ":") === false // exclure le cas des procure:
909
-			) {
910
-				$contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
911
-				foreach ($info['chemin'] as $chemin) {
912
-					if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'],
913
-							$GLOBALS['spip_version_branche'], 'spip')
914
-					) {
915
-						$dir = $chemin['path'];
916
-						if (strlen($dir) and $dir{0} == "/") {
917
-							$dir = substr($dir, 1);
918
-						}
919
-						if (strlen($dir) and $dir == "./") {
920
-							$dir = '';
921
-						}
922
-						if (strlen($dir)) {
923
-							$dir = rtrim($dir, '/') . '/';
924
-						}
925
-						if (!isset($chemin['type']) or $chemin['type'] == 'public') {
926
-							$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
927
-						}
928
-						if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
929
-							$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
930
-						}
931
-					}
932
-				}
933
-			}
934
-		}
935
-	}
936
-	if (count($chemins)) {
937
-		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
938
-				array_reverse($chemins['public'])) . ")));\n"
939
-			. "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
940
-	}
941
-
942
-	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
893
+    $chemins = array();
894
+    $contenu = "";
895
+    foreach ($ordre as $p => $info) {
896
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
897
+        if (isset($plugin_valides[$p])) {
898
+            $dir_type = $plugin_valides[$p]['dir_type'];
899
+            $plug = $plugin_valides[$p]['dir'];
900
+            // definir le plugin, donc le path avant l'include du fichier options
901
+            // permet de faire des include_spip pour attraper un inc_ du plugin
902
+
903
+            $dir = $dir_type . ".'" . $plug . "/'";
904
+
905
+            $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
906
+            if (
907
+                $prefix !== "SPIP"
908
+                and strpos($dir, ":") === false // exclure le cas des procure:
909
+            ) {
910
+                $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
911
+                foreach ($info['chemin'] as $chemin) {
912
+                    if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'],
913
+                            $GLOBALS['spip_version_branche'], 'spip')
914
+                    ) {
915
+                        $dir = $chemin['path'];
916
+                        if (strlen($dir) and $dir{0} == "/") {
917
+                            $dir = substr($dir, 1);
918
+                        }
919
+                        if (strlen($dir) and $dir == "./") {
920
+                            $dir = '';
921
+                        }
922
+                        if (strlen($dir)) {
923
+                            $dir = rtrim($dir, '/') . '/';
924
+                        }
925
+                        if (!isset($chemin['type']) or $chemin['type'] == 'public') {
926
+                            $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
927
+                        }
928
+                        if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
929
+                            $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
930
+                        }
931
+                    }
932
+                }
933
+            }
934
+        }
935
+    }
936
+    if (count($chemins)) {
937
+        $contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
938
+                array_reverse($chemins['public'])) . ")));\n"
939
+            . "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
940
+    }
941
+
942
+    ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
943 943
 }
944 944
 
945 945
 /**
@@ -957,65 +957,65 @@  discard block
 block discarded – undo
957 957
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
958 958
 **/
959 959
 function plugins_precompile_xxxtions($plugin_valides, $ordre) {
960
-	$contenu = array('options' => '', 'fonctions' => '');
961
-	$boutons = array();
962
-	$onglets = array();
963
-	$sign = "";
964
-
965
-	foreach ($ordre as $p => $info) {
966
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
967
-		if (isset($plugin_valides[$p])) {
968
-			$dir_type = $plugin_valides[$p]['dir_type'];
969
-			$plug = $plugin_valides[$p]['dir'];
970
-			$dir = constant($dir_type);
971
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
972
-			if ($info['menu']) {
973
-				$boutons = array_merge($boutons, $info['menu']);
974
-			}
975
-			if ($info['onglet']) {
976
-				$onglets = array_merge($onglets, $info['onglet']);
977
-			}
978
-			foreach ($contenu as $charge => $v) {
979
-				// si pas declare/detecte a la lecture du paquet.xml,
980
-				// detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
981
-				// donc ni sa relecture, ni sa detection
982
-				if (!isset($info[$charge])
983
-					and $dir // exclure le cas du plugin "SPIP"
984
-					and strpos($dir, ":") === false // exclure le cas des procure:
985
-					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
986
-				) {
987
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
988
-						$info[$charge] = array($file);
989
-					}
990
-				}
991
-				if (isset($info[$charge])) {
992
-					$files = $info[$charge];
993
-					foreach ($files as $k => $file) {
994
-						// on genere un if file_exists devant chaque include
995
-						// pour pouvoir garder le meme niveau d'erreur general
996
-						$file = trim($file);
997
-						if (!is_readable("$dir$plug/$file")
998
-							// uniquement pour les paquet.xml
999
-							and file_exists("$dir$plug/paquet.xml")
1000
-						) {
1001
-							unset($info[$charge][$k]);
1002
-						} else {
1003
-							$_file = $root_dir_type . ".'$plug/$file'";
1004
-							$contenu[$charge] .= "include_once_check($_file);\n";
1005
-						}
1006
-					}
1007
-				}
1008
-			}
1009
-			$sign .= md5(serialize($info));
1010
-		}
1011
-	}
1012
-
1013
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1014
-	$contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1015
-		. plugin_ongletbouton("onglets_plugins", $onglets);
1016
-
1017
-	ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1018
-	ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
960
+    $contenu = array('options' => '', 'fonctions' => '');
961
+    $boutons = array();
962
+    $onglets = array();
963
+    $sign = "";
964
+
965
+    foreach ($ordre as $p => $info) {
966
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
967
+        if (isset($plugin_valides[$p])) {
968
+            $dir_type = $plugin_valides[$p]['dir_type'];
969
+            $plug = $plugin_valides[$p]['dir'];
970
+            $dir = constant($dir_type);
971
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
972
+            if ($info['menu']) {
973
+                $boutons = array_merge($boutons, $info['menu']);
974
+            }
975
+            if ($info['onglet']) {
976
+                $onglets = array_merge($onglets, $info['onglet']);
977
+            }
978
+            foreach ($contenu as $charge => $v) {
979
+                // si pas declare/detecte a la lecture du paquet.xml,
980
+                // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
981
+                // donc ni sa relecture, ni sa detection
982
+                if (!isset($info[$charge])
983
+                    and $dir // exclure le cas du plugin "SPIP"
984
+                    and strpos($dir, ":") === false // exclure le cas des procure:
985
+                    and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
986
+                ) {
987
+                    if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
988
+                        $info[$charge] = array($file);
989
+                    }
990
+                }
991
+                if (isset($info[$charge])) {
992
+                    $files = $info[$charge];
993
+                    foreach ($files as $k => $file) {
994
+                        // on genere un if file_exists devant chaque include
995
+                        // pour pouvoir garder le meme niveau d'erreur general
996
+                        $file = trim($file);
997
+                        if (!is_readable("$dir$plug/$file")
998
+                            // uniquement pour les paquet.xml
999
+                            and file_exists("$dir$plug/paquet.xml")
1000
+                        ) {
1001
+                            unset($info[$charge][$k]);
1002
+                        } else {
1003
+                            $_file = $root_dir_type . ".'$plug/$file'";
1004
+                            $contenu[$charge] .= "include_once_check($_file);\n";
1005
+                        }
1006
+                    }
1007
+                }
1008
+            }
1009
+            $sign .= md5(serialize($info));
1010
+        }
1011
+    }
1012
+
1013
+    $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1014
+    $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1015
+        . plugin_ongletbouton("onglets_plugins", $onglets);
1016
+
1017
+    ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1018
+    ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1019 1019
 }
1020 1020
 
1021 1021
 /**
@@ -1034,24 +1034,24 @@  discard block
 block discarded – undo
1034 1034
  * @return string Code php
1035 1035
  */
1036 1036
 function plugin_ongletbouton($nom, $val) {
1037
-	if (!$val) {
1038
-		$val = array();
1039
-	}
1040
-
1041
-	$val = serialize($val);
1042
-	$md5 = md5($val);
1043
-
1044
-	if (!defined("_UPDATED_$nom")) {
1045
-		define("_UPDATED_$nom", $val);
1046
-		define("_UPDATED_md5_$nom", $md5);
1047
-	}
1048
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1049
-
1050
-	return
1051
-		"if (!function_exists('$nom')) {\n"
1052
-		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1053
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1054
-		. "}\n";
1037
+    if (!$val) {
1038
+        $val = array();
1039
+    }
1040
+
1041
+    $val = serialize($val);
1042
+    $md5 = md5($val);
1043
+
1044
+    if (!defined("_UPDATED_$nom")) {
1045
+        define("_UPDATED_$nom", $val);
1046
+        define("_UPDATED_md5_$nom", $md5);
1047
+    }
1048
+    $val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1049
+
1050
+    return
1051
+        "if (!function_exists('$nom')) {\n"
1052
+        . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1053
+        . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1054
+        . "}\n";
1055 1055
 }
1056 1056
 
1057 1057
 /**
@@ -1066,15 +1066,15 @@  discard block
 block discarded – undo
1066 1066
 **/
1067 1067
 function plugins_amorcer_plugins_actifs() {
1068 1068
 
1069
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1070
-		include_once(_CACHE_PLUGINS_PATH);
1071
-	} 
1069
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1070
+        include_once(_CACHE_PLUGINS_PATH);
1071
+    } 
1072 1072
 
1073
-	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1074
-		include_once(_CACHE_PLUGINS_OPT);
1075
-	} else {
1076
-		spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1077
-	}
1073
+    if (@is_readable(_CACHE_PLUGINS_OPT)) {
1074
+        include_once(_CACHE_PLUGINS_OPT);
1075
+    } else {
1076
+        spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1077
+    }
1078 1078
 }
1079 1079
 
1080 1080
 /**
@@ -1097,136 +1097,136 @@  discard block
 block discarded – undo
1097 1097
  *     Couples (nom du pipeline => Code PHP à insérer au début du pipeline)
1098 1098
 **/
1099 1099
 function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) {
1100
-	static $liste_pipe_manquants = array();
1101
-	if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1102
-		$liste_pipe_manquants[] = $pipe_recherche;
1103
-	}
1104
-
1105
-	$prepend_code = array();
1106
-
1107
-	foreach ($ordre as $p => $info) {
1108
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1109
-		if (isset($plugin_valides[$p])) {
1110
-			$dir_type = $plugin_valides[$p]['dir_type'];
1111
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1112
-			$plug = $plugin_valides[$p]['dir'];
1113
-			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1114
-			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1115
-				foreach ($info['pipeline'] as $pipe) {
1116
-					$nom = $pipe['nom'];
1117
-					if (isset($pipe['action'])) {
1118
-						$action = $pipe['action'];
1119
-					} else {
1120
-						$action = $nom;
1121
-					}
1122
-					$nomlower = strtolower($nom);
1123
-					if ($nomlower != $nom
1124
-						and isset($GLOBALS['spip_pipeline'][$nom])
1125
-						and !isset($GLOBALS['spip_pipeline'][$nomlower])
1126
-					) {
1127
-						$GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1128
-						unset($GLOBALS['spip_pipeline'][$nom]);
1129
-					}
1130
-					$nom = $nomlower;
1131
-					// une action vide est une declaration qui ne doit pas etre compilee !
1132
-					if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1133
-					{
1134
-						$GLOBALS['spip_pipeline'][$nom] = "";
1135
-					}
1136
-					if ($action) {
1137
-						if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1138
-							$GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
1139
-								$GLOBALS['spip_pipeline'][$nom], 1);
1140
-						}
1141
-						if (isset($pipe['inclure'])) {
1142
-							$GLOBALS['spip_matrice']["$prefix$action"] =
1143
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1144
-						}
1145
-					}
1146
-				}
1147
-			}
1148
-			if (isset($info['genie']) and count($info['genie'])) {
1149
-				if (!isset($prepend_code['taches_generales_cron'])) {
1150
-					$prepend_code['taches_generales_cron'] = "";
1151
-				}
1152
-				foreach ($info['genie'] as $genie) {
1153
-					$nom = $prefix . $genie['nom'];
1154
-					$periode = max(60, intval($genie['periode']));
1155
-					if (charger_fonction($nom, "genie", true)) {
1156
-						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1157
-					} else {
1158
-						spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1159
-					}
1160
-				}
1161
-			}
1162
-			if (isset($info['style']) and count($info['style'])) {
1163
-				if (!isset($prepend_code['insert_head_css'])) {
1164
-					$prepend_code['insert_head_css'] = "";
1165
-				}
1166
-				if (!isset($prepend_code['header_prive_css'])) {
1167
-					$prepend_code['header_prive_css'] = "";
1168
-				}
1169
-				foreach ($info['style'] as $style) {
1170
-					if (isset($style['path']) and $style['path']) {
1171
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1172
-					} else {
1173
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1174
-					}
1175
-					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1176
-					if (isset($style['media']) and strlen($style['media'])) {
1177
-						$code .= " media=\"" . addslashes($style['media']) . "\"";
1178
-					}
1179
-					$code .= "/>';\n";
1180
-					if ($style['type'] != 'prive') {
1181
-						$prepend_code['insert_head_css'] .= $code;
1182
-					}
1183
-					if ($style['type'] != 'public') {
1184
-						$prepend_code['header_prive_css'] .= $code;
1185
-					}
1186
-				}
1187
-			}
1188
-			if (!isset($prepend_code['insert_head'])) {
1189
-				$prepend_code['insert_head'] = "";
1190
-			}
1191
-			if (!isset($prepend_code['header_prive'])) {
1192
-				$prepend_code['header_prive'] = "";
1193
-			}
1194
-			if (isset($info['script']) and count($info['script'])) {
1195
-				foreach ($info['script'] as $script) {
1196
-					if (isset($script['path']) and $script['path']) {
1197
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1198
-					} else {
1199
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1200
-					}
1201
-					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1202
-					if ($script['type'] != 'prive') {
1203
-						$prepend_code['insert_head'] .= $code;
1204
-					}
1205
-					if ($script['type'] != 'public') {
1206
-						$prepend_code['header_prive'] .= $code;
1207
-					}
1208
-				}
1209
-			}
1210
-		}
1211
-	}
1212
-
1213
-	$prepend_code['insert_head'] =
1214
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1215
-		. "\$val = minipipe('f_jQuery', \$val);\n"
1216
-		. $prepend_code['insert_head'];
1217
-	$prepend_code['header_prive'] =
1218
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1219
-		. "\$val = minipipe('f_jQuery_prive', \$val);\n"
1220
-		. $prepend_code['header_prive'];
1221
-
1222
-	// on ajoute les pipe qui ont ete recenses manquants
1223
-	foreach ($liste_pipe_manquants as $add_pipe) {
1224
-		if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1225
-			$GLOBALS['spip_pipeline'][$add_pipe] = '';
1226
-		}
1227
-	}
1228
-
1229
-	return $prepend_code;
1100
+    static $liste_pipe_manquants = array();
1101
+    if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1102
+        $liste_pipe_manquants[] = $pipe_recherche;
1103
+    }
1104
+
1105
+    $prepend_code = array();
1106
+
1107
+    foreach ($ordre as $p => $info) {
1108
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1109
+        if (isset($plugin_valides[$p])) {
1110
+            $dir_type = $plugin_valides[$p]['dir_type'];
1111
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1112
+            $plug = $plugin_valides[$p]['dir'];
1113
+            $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1114
+            if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1115
+                foreach ($info['pipeline'] as $pipe) {
1116
+                    $nom = $pipe['nom'];
1117
+                    if (isset($pipe['action'])) {
1118
+                        $action = $pipe['action'];
1119
+                    } else {
1120
+                        $action = $nom;
1121
+                    }
1122
+                    $nomlower = strtolower($nom);
1123
+                    if ($nomlower != $nom
1124
+                        and isset($GLOBALS['spip_pipeline'][$nom])
1125
+                        and !isset($GLOBALS['spip_pipeline'][$nomlower])
1126
+                    ) {
1127
+                        $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1128
+                        unset($GLOBALS['spip_pipeline'][$nom]);
1129
+                    }
1130
+                    $nom = $nomlower;
1131
+                    // une action vide est une declaration qui ne doit pas etre compilee !
1132
+                    if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1133
+                    {
1134
+                        $GLOBALS['spip_pipeline'][$nom] = "";
1135
+                    }
1136
+                    if ($action) {
1137
+                        if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1138
+                            $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
1139
+                                $GLOBALS['spip_pipeline'][$nom], 1);
1140
+                        }
1141
+                        if (isset($pipe['inclure'])) {
1142
+                            $GLOBALS['spip_matrice']["$prefix$action"] =
1143
+                                "$root_dir_type:$plug/" . $pipe['inclure'];
1144
+                        }
1145
+                    }
1146
+                }
1147
+            }
1148
+            if (isset($info['genie']) and count($info['genie'])) {
1149
+                if (!isset($prepend_code['taches_generales_cron'])) {
1150
+                    $prepend_code['taches_generales_cron'] = "";
1151
+                }
1152
+                foreach ($info['genie'] as $genie) {
1153
+                    $nom = $prefix . $genie['nom'];
1154
+                    $periode = max(60, intval($genie['periode']));
1155
+                    if (charger_fonction($nom, "genie", true)) {
1156
+                        $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1157
+                    } else {
1158
+                        spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1159
+                    }
1160
+                }
1161
+            }
1162
+            if (isset($info['style']) and count($info['style'])) {
1163
+                if (!isset($prepend_code['insert_head_css'])) {
1164
+                    $prepend_code['insert_head_css'] = "";
1165
+                }
1166
+                if (!isset($prepend_code['header_prive_css'])) {
1167
+                    $prepend_code['header_prive_css'] = "";
1168
+                }
1169
+                foreach ($info['style'] as $style) {
1170
+                    if (isset($style['path']) and $style['path']) {
1171
+                        $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1172
+                    } else {
1173
+                        $code = "if (\$f='" . addslashes($style['url']) . "') ";
1174
+                    }
1175
+                    $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1176
+                    if (isset($style['media']) and strlen($style['media'])) {
1177
+                        $code .= " media=\"" . addslashes($style['media']) . "\"";
1178
+                    }
1179
+                    $code .= "/>';\n";
1180
+                    if ($style['type'] != 'prive') {
1181
+                        $prepend_code['insert_head_css'] .= $code;
1182
+                    }
1183
+                    if ($style['type'] != 'public') {
1184
+                        $prepend_code['header_prive_css'] .= $code;
1185
+                    }
1186
+                }
1187
+            }
1188
+            if (!isset($prepend_code['insert_head'])) {
1189
+                $prepend_code['insert_head'] = "";
1190
+            }
1191
+            if (!isset($prepend_code['header_prive'])) {
1192
+                $prepend_code['header_prive'] = "";
1193
+            }
1194
+            if (isset($info['script']) and count($info['script'])) {
1195
+                foreach ($info['script'] as $script) {
1196
+                    if (isset($script['path']) and $script['path']) {
1197
+                        $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1198
+                    } else {
1199
+                        $code = "if (\$f='" . addslashes($script['url']) . "') ";
1200
+                    }
1201
+                    $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1202
+                    if ($script['type'] != 'prive') {
1203
+                        $prepend_code['insert_head'] .= $code;
1204
+                    }
1205
+                    if ($script['type'] != 'public') {
1206
+                        $prepend_code['header_prive'] .= $code;
1207
+                    }
1208
+                }
1209
+            }
1210
+        }
1211
+    }
1212
+
1213
+    $prepend_code['insert_head'] =
1214
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1215
+        . "\$val = minipipe('f_jQuery', \$val);\n"
1216
+        . $prepend_code['insert_head'];
1217
+    $prepend_code['header_prive'] =
1218
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1219
+        . "\$val = minipipe('f_jQuery_prive', \$val);\n"
1220
+        . $prepend_code['header_prive'];
1221
+
1222
+    // on ajoute les pipe qui ont ete recenses manquants
1223
+    foreach ($liste_pipe_manquants as $add_pipe) {
1224
+        if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1225
+            $GLOBALS['spip_pipeline'][$add_pipe] = '';
1226
+        }
1227
+    }
1228
+
1229
+    return $prepend_code;
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1253,44 +1253,44 @@  discard block
 block discarded – undo
1253 1253
 **/
1254 1254
 function pipeline_precompile($prepend_code = array()) {
1255 1255
 
1256
-	$content = "";
1257
-	foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1258
-		$s_inc = "";
1259
-		$s_call = "";
1260
-		$pipe = array_filter(explode('|', $pipeline));
1261
-		// Eclater le pipeline en filtres et appliquer chaque filtre
1262
-		foreach ($pipe as $fonc) {
1263
-			$fonc = trim($fonc);
1264
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1265
-			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1266
-				$file = $GLOBALS['spip_matrice'][$fonc];
1267
-				$file = "'$file'";
1268
-				// si un _DIR_XXX: est dans la chaine, on extrait la constante
1269
-				if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) {
1270
-					$dir = $regs[1];
1271
-					$root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1272
-					if (defined($root_dir)) {
1273
-						$dir = $root_dir;
1274
-					}
1275
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1276
-					$file = str_replace("''.", "", $file);
1277
-					$file = str_replace(constant($dir), '', $file);
1278
-				}
1279
-				$s_inc .= "include_once_check($file);\n";
1280
-			}
1281
-		}
1282
-		if (strlen($s_inc)) {
1283
-			$s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1284
-		}
1285
-		$content .= "// Pipeline $action \n"
1286
-			. "function execute_pipeline_$action(&\$val){\n"
1287
-			. $s_inc
1288
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1289
-			. $s_call
1290
-			. "return \$val;\n}\n";
1291
-	}
1292
-	ecrire_fichier_php(_CACHE_PIPELINES, $content);
1293
-	clear_path_cache();
1256
+    $content = "";
1257
+    foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1258
+        $s_inc = "";
1259
+        $s_call = "";
1260
+        $pipe = array_filter(explode('|', $pipeline));
1261
+        // Eclater le pipeline en filtres et appliquer chaque filtre
1262
+        foreach ($pipe as $fonc) {
1263
+            $fonc = trim($fonc);
1264
+            $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1265
+            if (isset($GLOBALS['spip_matrice'][$fonc])) {
1266
+                $file = $GLOBALS['spip_matrice'][$fonc];
1267
+                $file = "'$file'";
1268
+                // si un _DIR_XXX: est dans la chaine, on extrait la constante
1269
+                if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) {
1270
+                    $dir = $regs[1];
1271
+                    $root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1272
+                    if (defined($root_dir)) {
1273
+                        $dir = $root_dir;
1274
+                    }
1275
+                    $file = str_replace($regs[0], "'." . $dir . ".'", $file);
1276
+                    $file = str_replace("''.", "", $file);
1277
+                    $file = str_replace(constant($dir), '', $file);
1278
+                }
1279
+                $s_inc .= "include_once_check($file);\n";
1280
+            }
1281
+        }
1282
+        if (strlen($s_inc)) {
1283
+            $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1284
+        }
1285
+        $content .= "// Pipeline $action \n"
1286
+            . "function execute_pipeline_$action(&\$val){\n"
1287
+            . $s_inc
1288
+            . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1289
+            . $s_call
1290
+            . "return \$val;\n}\n";
1291
+    }
1292
+    ecrire_fichier_php(_CACHE_PIPELINES, $content);
1293
+    clear_path_cache();
1294 1294
 }
1295 1295
 
1296 1296
 
@@ -1303,12 +1303,12 @@  discard block
 block discarded – undo
1303 1303
  *     true si le plugin est actif, false sinon
1304 1304
 **/
1305 1305
 function plugin_est_installe($plug_path) {
1306
-	$plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array();
1307
-	if (!$plugin_installes) {
1308
-		return false;
1309
-	}
1306
+    $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array();
1307
+    if (!$plugin_installes) {
1308
+        return false;
1309
+    }
1310 1310
 
1311
-	return in_array($plug_path, $plugin_installes);
1311
+    return in_array($plug_path, $plugin_installes);
1312 1312
 }
1313 1313
 
1314 1314
 
@@ -1321,37 +1321,37 @@  discard block
 block discarded – undo
1321 1321
  * @uses plugins_installer_dist()
1322 1322
  **/
1323 1323
 function plugin_installes_meta() {
1324
-	if (isset($GLOBALS['fichier_php_compile_recent'])) {
1325
-		// attendre eventuellement l'invalidation du cache opcode
1326
-		spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1327
-	}
1328
-
1329
-	$installer_plugins = charger_fonction('installer', 'plugins');
1330
-	$meta_plug_installes = array();
1331
-	foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1332
-		if ($plug = $resume['dir']) {
1333
-			$infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1334
-			if ($infos) {
1335
-				if (!is_array($infos) or $infos['install_test'][0]) {
1336
-					$meta_plug_installes[] = $plug;
1337
-				}
1338
-				if (is_array($infos)) {
1339
-					list($ok, $trace) = $infos['install_test'];
1340
-					include_spip('inc/filtres_boites');
1341
-					echo "<div class='install-plugins svp_retour'>"
1342
-						. boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))),
1343
-							($ok ? 'success' : 'error'))
1344
-						. $trace
1345
-						. "<div class='result'>"
1346
-						. ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec"))
1347
-						. "</div>"
1348
-						. boite_fermer()
1349
-						. "</div>";
1350
-				}
1351
-			}
1352
-		}
1353
-	}
1354
-	ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1324
+    if (isset($GLOBALS['fichier_php_compile_recent'])) {
1325
+        // attendre eventuellement l'invalidation du cache opcode
1326
+        spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1327
+    }
1328
+
1329
+    $installer_plugins = charger_fonction('installer', 'plugins');
1330
+    $meta_plug_installes = array();
1331
+    foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1332
+        if ($plug = $resume['dir']) {
1333
+            $infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1334
+            if ($infos) {
1335
+                if (!is_array($infos) or $infos['install_test'][0]) {
1336
+                    $meta_plug_installes[] = $plug;
1337
+                }
1338
+                if (is_array($infos)) {
1339
+                    list($ok, $trace) = $infos['install_test'];
1340
+                    include_spip('inc/filtres_boites');
1341
+                    echo "<div class='install-plugins svp_retour'>"
1342
+                        . boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))),
1343
+                            ($ok ? 'success' : 'error'))
1344
+                        . $trace
1345
+                        . "<div class='result'>"
1346
+                        . ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec"))
1347
+                        . "</div>"
1348
+                        . boite_fermer()
1349
+                        . "</div>";
1350
+                }
1351
+            }
1352
+        }
1353
+    }
1354
+    ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1355 1355
 }
1356 1356
 
1357 1357
 /**
@@ -1365,29 +1365,29 @@  discard block
 block discarded – undo
1365 1365
  *     Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante
1366 1366
 **/
1367 1367
 function ecrire_fichier_php($nom, $contenu, $comment = '') {
1368
-	if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1369
-		$GLOBALS['fichier_php_compile_recent'] = 0;
1370
-	}
1371
-
1372
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1373
-	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1374
-	// si pas de modif on ne touche pas au fichier initial
1375
-	if (file_exists($nom)) {
1376
-		if (substr($nom, -4) == '.php') {
1377
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1378
-		}
1379
-		else {
1380
-			$fichier_tmp = $nom . '.tmp';
1381
-		}
1382
-		file_put_contents($fichier_tmp, $contenu);
1383
-		if(md5_file($nom) == md5_file($fichier_tmp)) {
1384
-			$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1385
-			@unlink($fichier_tmp);
1386
-			return;
1387
-		}
1388
-		@unlink($fichier_tmp);
1389
-	}
1390
-	ecrire_fichier($nom, $contenu);
1391
-	$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1392
-	spip_clear_opcode_cache(realpath($nom));
1368
+    if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1369
+        $GLOBALS['fichier_php_compile_recent'] = 0;
1370
+    }
1371
+
1372
+    $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1373
+    // si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1374
+    // si pas de modif on ne touche pas au fichier initial
1375
+    if (file_exists($nom)) {
1376
+        if (substr($nom, -4) == '.php') {
1377
+            $fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1378
+        }
1379
+        else {
1380
+            $fichier_tmp = $nom . '.tmp';
1381
+        }
1382
+        file_put_contents($fichier_tmp, $contenu);
1383
+        if(md5_file($nom) == md5_file($fichier_tmp)) {
1384
+            $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1385
+            @unlink($fichier_tmp);
1386
+            return;
1387
+        }
1388
+        @unlink($fichier_tmp);
1389
+    }
1390
+    ecrire_fichier($nom, $contenu);
1391
+    $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1392
+    spip_clear_opcode_cache(realpath($nom));
1393 1393
 }
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.
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 				if ($dir) {
354 354
 					$dir .= "/";
355 355
 				}
356
-				$dir .= "procure:" . $procure['nom'];
356
+				$dir .= "procure:".$procure['nom'];
357 357
 
358 358
 				$procure['etat'] = '?';
359 359
 				$procure['dir_type'] = $resume['dir_type'];
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 		$plug = $resume['dir'];
535 535
 		$k = $infos[$dir_type][$plug];
536 536
 
537
-		$plug = constant($dir_type) . $plug;
537
+		$plug = constant($dir_type).$plug;
538 538
 		if (!isset($msg[$p])) {
539 539
 			if (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
540 540
 				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
@@ -571,10 +571,10 @@  discard block
 block discarded – undo
571 571
 		$list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
572 572
 	} elseif (!$raw) {
573 573
 		foreach ($list as $plug => $msg) {
574
-			$list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
575
-				. "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
574
+			$list[$plug] = "<li>"._T('plugin_impossible_activer', array('plugin' => $plug))
575
+				. "<ul><li>".implode("</li><li>", $msg)."</li></ul></li>";
576 576
 		}
577
-		$list = "<ul>" . join("\n", $list) . "</ul>";
577
+		$list = "<ul>".join("\n", $list)."</ul>";
578 578
 	}
579 579
 	if ($raz) {
580 580
 		effacer_meta('plugin_erreur_activation');
@@ -683,13 +683,13 @@  discard block
 block discarded – undo
683 683
 			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
684 684
 				return _T("plugin_${balise}_${type}", array(
685 685
 					'plugin' => $nom,
686
-					'version' => ' &ge; ' . $minimum
686
+					'version' => ' &ge; '.$minimum
687 687
 				));
688 688
 			}
689 689
 			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
690 690
 				return _T("plugin_${balise}_${type}", array(
691 691
 					'plugin' => $nom,
692
-					'version' => ' &gt; ' . $minimum
692
+					'version' => ' &gt; '.$minimum
693 693
 				));
694 694
 			}
695 695
 		}
@@ -698,13 +698,13 @@  discard block
 block discarded – undo
698 698
 			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
699 699
 				return _T("plugin_${balise}_${type}", array(
700 700
 					'plugin' => $nom,
701
-					'version' => ' &le; ' . $maximum
701
+					'version' => ' &le; '.$maximum
702 702
 				));
703 703
 			}
704 704
 			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
705 705
 				return _T("plugin_${balise}_plugin", array(
706 706
 					'plugin' => $nom,
707
-					'version' => ' &lt; ' . $maximum
707
+					'version' => ' &lt; '.$maximum
708 708
 				));
709 709
 			}
710 710
 		}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 		include_spip('inc/charger_plugin');
724 724
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
725 725
 	}*/
726
-	return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
726
+	return _T('plugin_necessite_lib', array('lib' => $lib))." <a href='$url'>$url</a>";
727 727
 }
728 728
 
729 729
 
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
 	foreach ($plugin_valides as $p => $resume) {
823 823
 		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
824 824
 		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
825
-			$header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
825
+			$header[] = $p.($resume['version'] ? "(".$resume['version'].")" : "");
826 826
 		}
827 827
 		if ($resume['dir']) {
828 828
 			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
@@ -846,10 +846,10 @@  discard block
 block discarded – undo
846 846
 	ecrire_meta('plugin_attente', serialize($liste));
847 847
 	$header = strtolower(implode(",", $header));
848 848
 	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
849
-		ecrire_fichier(_DIR_VAR . "config.txt",
850
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
849
+		ecrire_fichier(_DIR_VAR."config.txt",
850
+			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP").' '.$GLOBALS['spip_version_affichee']." @ www.spip.net + ".$header);
851 851
 	} else {
852
-		@unlink(_DIR_VAR . "config.txt");
852
+		@unlink(_DIR_VAR."config.txt");
853 853
 	}
854 854
 	// generer charger_plugins_chemin.php
855 855
 	plugins_precompile_chemin($plugin_valides, $ordre);
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 			// definir le plugin, donc le path avant l'include du fichier options
901 901
 			// permet de faire des include_spip pour attraper un inc_ du plugin
902 902
 
903
-			$dir = $dir_type . ".'" . $plug . "/'";
903
+			$dir = $dir_type.".'".$plug."/'";
904 904
 
905 905
 			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
906 906
 			if (
@@ -920,13 +920,13 @@  discard block
 block discarded – undo
920 920
 							$dir = '';
921 921
 						}
922 922
 						if (strlen($dir)) {
923
-							$dir = rtrim($dir, '/') . '/';
923
+							$dir = rtrim($dir, '/').'/';
924 924
 						}
925 925
 						if (!isset($chemin['type']) or $chemin['type'] == 'public') {
926
-							$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
926
+							$chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : "");
927 927
 						}
928 928
 						if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
929
-							$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
929
+							$chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : "");
930 930
 						}
931 931
 					}
932 932
 				}
@@ -934,9 +934,9 @@  discard block
 block discarded – undo
934 934
 		}
935 935
 	}
936 936
 	if (count($chemins)) {
937
-		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
938
-				array_reverse($chemins['public'])) . ")));\n"
939
-			. "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
937
+		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(".implode(',',
938
+				array_reverse($chemins['public'])).")));\n"
939
+			. "else _chemin(implode(':',array(".implode(',', array_reverse($chemins['prive'])).")));\n";
940 940
 	}
941 941
 
942 942
 	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 					and strpos($dir, ":") === false // exclure le cas des procure:
985 985
 					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
986 986
 				) {
987
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
987
+					if (is_readable("$dir$plug/".($file = $info['prefix']."_".$charge.".php"))) {
988 988
 						$info[$charge] = array($file);
989 989
 					}
990 990
 				}
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 						) {
1001 1001
 							unset($info[$charge][$k]);
1002 1002
 						} else {
1003
-							$_file = $root_dir_type . ".'$plug/$file'";
1003
+							$_file = $root_dir_type.".'$plug/$file'";
1004 1004
 							$contenu[$charge] .= "include_once_check($_file);\n";
1005 1005
 						}
1006 1006
 					}
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 		}
1011 1011
 	}
1012 1012
 
1013
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1013
+	$contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options'];
1014 1014
 	$contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1015 1015
 		. plugin_ongletbouton("onglets_plugins", $onglets);
1016 1016
 
@@ -1045,12 +1045,12 @@  discard block
 block discarded – undo
1045 1045
 		define("_UPDATED_$nom", $val);
1046 1046
 		define("_UPDATED_md5_$nom", $md5);
1047 1047
 	}
1048
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1048
+	$val = "unserialize('".str_replace("'", "\'", $val)."')";
1049 1049
 
1050 1050
 	return
1051 1051
 		"if (!function_exists('$nom')) {\n"
1052 1052
 		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1053
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1053
+		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n"
1054 1054
 		. "}\n";
1055 1055
 }
1056 1056
 
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1074 1074
 		include_once(_CACHE_PLUGINS_OPT);
1075 1075
 	} else {
1076
-		spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1076
+		spip_log("pipelines desactives: impossible de produire "._CACHE_PLUGINS_OPT);
1077 1077
 	}
1078 1078
 }
1079 1079
 
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
 			$dir_type = $plugin_valides[$p]['dir_type'];
1111 1111
 			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1112 1112
 			$plug = $plugin_valides[$p]['dir'];
1113
-			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1113
+			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix']."_");
1114 1114
 			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1115 1115
 				foreach ($info['pipeline'] as $pipe) {
1116 1116
 					$nom = $pipe['nom'];
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 						}
1141 1141
 						if (isset($pipe['inclure'])) {
1142 1142
 							$GLOBALS['spip_matrice']["$prefix$action"] =
1143
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1143
+								"$root_dir_type:$plug/".$pipe['inclure'];
1144 1144
 						}
1145 1145
 					}
1146 1146
 				}
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 					$prepend_code['taches_generales_cron'] = "";
1151 1151
 				}
1152 1152
 				foreach ($info['genie'] as $genie) {
1153
-					$nom = $prefix . $genie['nom'];
1153
+					$nom = $prefix.$genie['nom'];
1154 1154
 					$periode = max(60, intval($genie['periode']));
1155 1155
 					if (charger_fonction($nom, "genie", true)) {
1156 1156
 						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
@@ -1168,13 +1168,13 @@  discard block
 block discarded – undo
1168 1168
 				}
1169 1169
 				foreach ($info['style'] as $style) {
1170 1170
 					if (isset($style['path']) and $style['path']) {
1171
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1171
+						$code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) ";
1172 1172
 					} else {
1173
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1173
+						$code = "if (\$f='".addslashes($style['url'])."') ";
1174 1174
 					}
1175 1175
 					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1176 1176
 					if (isset($style['media']) and strlen($style['media'])) {
1177
-						$code .= " media=\"" . addslashes($style['media']) . "\"";
1177
+						$code .= " media=\"".addslashes($style['media'])."\"";
1178 1178
 					}
1179 1179
 					$code .= "/>';\n";
1180 1180
 					if ($style['type'] != 'prive') {
@@ -1194,9 +1194,9 @@  discard block
 block discarded – undo
1194 1194
 			if (isset($info['script']) and count($info['script'])) {
1195 1195
 				foreach ($info['script'] as $script) {
1196 1196
 					if (isset($script['path']) and $script['path']) {
1197
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1197
+						$code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) ";
1198 1198
 					} else {
1199
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1199
+						$code = "if (\$f='".addslashes($script['url'])."') ";
1200 1200
 					}
1201 1201
 					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1202 1202
 					if ($script['type'] != 'prive') {
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
 		// Eclater le pipeline en filtres et appliquer chaque filtre
1262 1262
 		foreach ($pipe as $fonc) {
1263 1263
 			$fonc = trim($fonc);
1264
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1264
+			$s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n";
1265 1265
 			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1266 1266
 				$file = $GLOBALS['spip_matrice'][$fonc];
1267 1267
 				$file = "'$file'";
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 					if (defined($root_dir)) {
1273 1273
 						$dir = $root_dir;
1274 1274
 					}
1275
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1275
+					$file = str_replace($regs[0], "'.".$dir.".'", $file);
1276 1276
 					$file = str_replace("''.", "", $file);
1277 1277
 					$file = str_replace(constant($dir), '', $file);
1278 1278
 				}
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 		$content .= "// Pipeline $action \n"
1286 1286
 			. "function execute_pipeline_$action(&\$val){\n"
1287 1287
 			. $s_inc
1288
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1288
+			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '')
1289 1289
 			. $s_call
1290 1290
 			. "return \$val;\n}\n";
1291 1291
 	}
@@ -1369,18 +1369,18 @@  discard block
 block discarded – undo
1369 1369
 		$GLOBALS['fichier_php_compile_recent'] = 0;
1370 1370
 	}
1371 1371
 
1372
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1372
+	$contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>';
1373 1373
 	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1374 1374
 	// si pas de modif on ne touche pas au fichier initial
1375 1375
 	if (file_exists($nom)) {
1376 1376
 		if (substr($nom, -4) == '.php') {
1377
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1377
+			$fichier_tmp = substr($nom, 0, -4).'.tmp.php';
1378 1378
 		}
1379 1379
 		else {
1380
-			$fichier_tmp = $nom . '.tmp';
1380
+			$fichier_tmp = $nom.'.tmp';
1381 1381
 		}
1382 1382
 		file_put_contents($fichier_tmp, $contenu);
1383
-		if(md5_file($nom) == md5_file($fichier_tmp)) {
1383
+		if (md5_file($nom) == md5_file($fichier_tmp)) {
1384 1384
 			$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1385 1385
 			@unlink($fichier_tmp);
1386 1386
 			return;
Please login to merge, or discard this patch.