Completed
Push — master ( 95390d...9ad9dd )
by cam
09:15
created
ecrire/inc/plugin.php 2 patches
Indentation   +865 added lines, -865 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /** l'adresse du repertoire de telechargement et de decompactage des plugins */
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
  * @return array
46 46
 **/
47 47
 function liste_plugin_files($dir_plugins = null) {
48
-	static $plugin_files = array();
49
-	if (is_null($dir_plugins)) {
50
-		$dir_plugins = _DIR_PLUGINS;
51
-	}
52
-	if (!isset($plugin_files[$dir_plugins])
53
-		or count($plugin_files[$dir_plugins]) == 0
54
-	) {
55
-		$plugin_files[$dir_plugins] = array();
56
-		foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
57
-			$plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
58
-		}
59
-
60
-		sort($plugin_files[$dir_plugins]);
61
-		// et on lit le XML de tous les plugins pour le mettre en cache
62
-		// et en profiter pour nettoyer ceux qui n'existent plus du cache
63
-		$get_infos = charger_fonction('get_infos', 'plugins');
64
-		$get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
65
-	}
66
-
67
-	return $plugin_files[$dir_plugins];
48
+    static $plugin_files = array();
49
+    if (is_null($dir_plugins)) {
50
+        $dir_plugins = _DIR_PLUGINS;
51
+    }
52
+    if (!isset($plugin_files[$dir_plugins])
53
+        or count($plugin_files[$dir_plugins]) == 0
54
+    ) {
55
+        $plugin_files[$dir_plugins] = array();
56
+        foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
57
+            $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
58
+        }
59
+
60
+        sort($plugin_files[$dir_plugins]);
61
+        // et on lit le XML de tous les plugins pour le mettre en cache
62
+        // et en profiter pour nettoyer ceux qui n'existent plus du cache
63
+        $get_infos = charger_fonction('get_infos', 'plugins');
64
+        $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
65
+    }
66
+
67
+    return $plugin_files[$dir_plugins];
68 68
 }
69 69
 
70 70
 /**
@@ -80,44 +80,44 @@  discard block
 block discarded – undo
80 80
  *     Liste complète des répeertoires
81 81
 **/
82 82
 function fast_find_plugin_dirs($dir, $max_prof = 100) {
83
-	$fichiers = array();
84
-	// revenir au repertoire racine si on a recu dossier/truc
85
-	// pour regarder dossier/truc/ ne pas oublier le / final
86
-	$dir = preg_replace(',/[^/]*$,', '', $dir);
87
-	if ($dir == '') {
88
-		$dir = '.';
89
-	}
90
-
91
-	if (!is_dir($dir)) {
92
-		return $fichiers;
93
-	}
94
-	if (is_plugin_dir($dir, '')) {
95
-		$fichiers[] = $dir;
96
-
97
-		return $fichiers;
98
-	}
99
-	if ($max_prof <= 0) {
100
-		return $fichiers;
101
-	}
102
-
103
-	$subdirs = array();
104
-	if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
105
-		while (($f = readdir($d)) !== false) {
106
-			if ($f[0] != '.' # ignorer . .. .svn etc
107
-				and $f != 'CVS'
108
-				and is_dir($f = "$dir/$f")
109
-			) {
110
-				$subdirs[] = $f;
111
-			}
112
-		}
113
-		closedir($d);
114
-	}
115
-
116
-	foreach ($subdirs as $d) {
117
-		$fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
118
-	}
119
-
120
-	return $fichiers;
83
+    $fichiers = array();
84
+    // revenir au repertoire racine si on a recu dossier/truc
85
+    // pour regarder dossier/truc/ ne pas oublier le / final
86
+    $dir = preg_replace(',/[^/]*$,', '', $dir);
87
+    if ($dir == '') {
88
+        $dir = '.';
89
+    }
90
+
91
+    if (!is_dir($dir)) {
92
+        return $fichiers;
93
+    }
94
+    if (is_plugin_dir($dir, '')) {
95
+        $fichiers[] = $dir;
96
+
97
+        return $fichiers;
98
+    }
99
+    if ($max_prof <= 0) {
100
+        return $fichiers;
101
+    }
102
+
103
+    $subdirs = array();
104
+    if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
105
+        while (($f = readdir($d)) !== false) {
106
+            if ($f[0] != '.' # ignorer . .. .svn etc
107
+                and $f != 'CVS'
108
+                and is_dir($f = "$dir/$f")
109
+            ) {
110
+                $subdirs[] = $f;
111
+            }
112
+        }
113
+        closedir($d);
114
+    }
115
+
116
+    foreach ($subdirs as $d) {
117
+        $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
118
+    }
119
+
120
+    return $fichiers;
121 121
 }
122 122
 
123 123
 /**
@@ -138,27 +138,27 @@  discard block
 block discarded – undo
138 138
 **/
139 139
 function is_plugin_dir($dir, $dir_plugins = null) {
140 140
 
141
-	if (is_array($dir)) {
142
-		foreach ($dir as $k => $d) {
143
-			if (!is_plugin_dir($d, $dir_plugins)) {
144
-				unset($dir[$k]);
145
-			}
146
-		}
147
-
148
-		return $dir;
149
-	}
150
-	if (is_null($dir_plugins)) {
151
-		$dir_plugins = _DIR_PLUGINS;
152
-	}
153
-	$search = array("$dir_plugins$dir/plugin.xml", "$dir_plugins$dir/paquet.xml");
154
-
155
-	foreach ($search as $s) {
156
-		if (file_exists($s)) {
157
-			return $dir;
158
-		}
159
-	}
160
-
161
-	return '';
141
+    if (is_array($dir)) {
142
+        foreach ($dir as $k => $d) {
143
+            if (!is_plugin_dir($d, $dir_plugins)) {
144
+                unset($dir[$k]);
145
+            }
146
+        }
147
+
148
+        return $dir;
149
+    }
150
+    if (is_null($dir_plugins)) {
151
+        $dir_plugins = _DIR_PLUGINS;
152
+    }
153
+    $search = array("$dir_plugins$dir/plugin.xml", "$dir_plugins$dir/paquet.xml");
154
+
155
+    foreach ($search as $s) {
156
+        if (file_exists($s)) {
157
+            return $dir;
158
+        }
159
+    }
160
+
161
+    return '';
162 162
 }
163 163
 
164 164
 /** Regexp d'extraction des informations d'un intervalle de compatibilité */
@@ -185,51 +185,51 @@  discard block
 block discarded – undo
185 185
  **/
186 186
 function plugin_version_compatible($intervalle, $version, $avec_quoi = '') {
187 187
 
188
-	if (!strlen($intervalle)) {
189
-		return true;
190
-	}
191
-	if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
192
-		return false;
193
-	}
194
-	// Extraction des bornes et traitement de * pour la borne sup :
195
-	// -- on autorise uniquement les ecritures 3.0.*, 3.*
196
-	$minimum = $regs[1];
197
-	$maximum = $regs[2];
198
-
199
-	//  si une version SPIP de compatibilité a été définie (dans
200
-	//  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
201
-	//  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
202
-	//  avec la version de SPIP (ne nuit donc pas aux tests de necessite
203
-	//  entre plugins)
204
-	if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
205
-		if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
206
-			return true;
207
-		}
208
-		// si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
209
-		// cas du plugin qui n'est compatible qu'avec cette nouvelle version
210
-	}
211
-
212
-	$minimum_inc = $intervalle{0} == "[";
213
-	$maximum_inc = substr($intervalle, -1) == "]";
214
-
215
-	if (strlen($minimum)) {
216
-		if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
217
-			return false;
218
-		}
219
-		if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
220
-			return false;
221
-		}
222
-	}
223
-	if (strlen($maximum)) {
224
-		if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
225
-			return false;
226
-		}
227
-		if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
228
-			return false;
229
-		}
230
-	}
231
-
232
-	return true;
188
+    if (!strlen($intervalle)) {
189
+        return true;
190
+    }
191
+    if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
192
+        return false;
193
+    }
194
+    // Extraction des bornes et traitement de * pour la borne sup :
195
+    // -- on autorise uniquement les ecritures 3.0.*, 3.*
196
+    $minimum = $regs[1];
197
+    $maximum = $regs[2];
198
+
199
+    //  si une version SPIP de compatibilité a été définie (dans
200
+    //  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
201
+    //  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
202
+    //  avec la version de SPIP (ne nuit donc pas aux tests de necessite
203
+    //  entre plugins)
204
+    if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
205
+        if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
206
+            return true;
207
+        }
208
+        // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
209
+        // cas du plugin qui n'est compatible qu'avec cette nouvelle version
210
+    }
211
+
212
+    $minimum_inc = $intervalle{0} == "[";
213
+    $maximum_inc = substr($intervalle, -1) == "]";
214
+
215
+    if (strlen($minimum)) {
216
+        if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
217
+            return false;
218
+        }
219
+        if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
220
+            return false;
221
+        }
222
+    }
223
+    if (strlen($maximum)) {
224
+        if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
225
+            return false;
226
+        }
227
+        if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
228
+            return false;
229
+        }
230
+    }
231
+
232
+    return true;
233 233
 }
234 234
 
235 235
 /**
@@ -246,52 +246,52 @@  discard block
 block discarded – undo
246 246
  * @return array
247 247
  */
248 248
 function liste_plugin_valides($liste_plug, $force = false) {
249
-	$liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
250
-	$get_infos = charger_fonction('get_infos', 'plugins');
251
-	$infos = array(
252
-		// lister les extensions qui sont automatiquement actives
253
-		'_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
254
-		'_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
255
-	);
256
-
257
-	// creer une premiere liste non ordonnee mais qui ne retient
258
-	// que les plugins valides, et dans leur derniere version en cas de doublon
259
-	$infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
260
-	$infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
261
-	$infos['_DIR_RESTREINT']['SPIP']['chemin'] = array();
262
-	$liste_non_classee = array(
263
-		'SPIP' => array(
264
-			'nom' => 'SPIP',
265
-			'etat' => 'stable',
266
-			'version' => $GLOBALS['spip_version_branche'],
267
-			'dir_type' => '_DIR_RESTREINT',
268
-			'dir' => '',
269
-		)
270
-	);
271
-
272
-	foreach ($liste_ext as $plug) {
273
-		if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
274
-			plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
275
-		}
276
-	}
277
-	foreach ($liste_plug as $plug) {
278
-		if (isset($infos['_DIR_PLUGINS'][$plug])) {
279
-			plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
280
-		}
281
-	}
282
-
283
-	if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
284
-		$infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
285
-		foreach ($liste_plug as $plug) {
286
-			if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
287
-				plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
288
-			}
289
-		}
290
-	}
291
-
292
-	plugin_fixer_procure($liste_non_classee, $infos);
293
-
294
-	return array($infos, $liste_non_classee);
249
+    $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
250
+    $get_infos = charger_fonction('get_infos', 'plugins');
251
+    $infos = array(
252
+        // lister les extensions qui sont automatiquement actives
253
+        '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
254
+        '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
255
+    );
256
+
257
+    // creer une premiere liste non ordonnee mais qui ne retient
258
+    // que les plugins valides, et dans leur derniere version en cas de doublon
259
+    $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
260
+    $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
261
+    $infos['_DIR_RESTREINT']['SPIP']['chemin'] = array();
262
+    $liste_non_classee = array(
263
+        'SPIP' => array(
264
+            'nom' => 'SPIP',
265
+            'etat' => 'stable',
266
+            'version' => $GLOBALS['spip_version_branche'],
267
+            'dir_type' => '_DIR_RESTREINT',
268
+            'dir' => '',
269
+        )
270
+    );
271
+
272
+    foreach ($liste_ext as $plug) {
273
+        if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
274
+            plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
275
+        }
276
+    }
277
+    foreach ($liste_plug as $plug) {
278
+        if (isset($infos['_DIR_PLUGINS'][$plug])) {
279
+            plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
280
+        }
281
+    }
282
+
283
+    if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
284
+        $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
285
+        foreach ($liste_plug as $plug) {
286
+            if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
287
+                plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
288
+            }
289
+        }
290
+    }
291
+
292
+    plugin_fixer_procure($liste_non_classee, $infos);
293
+
294
+    return array($infos, $liste_non_classee);
295 295
 }
296 296
 
297 297
 /**
@@ -308,25 +308,25 @@  discard block
 block discarded – undo
308 308
  * @param string $dir_type
309 309
  */
310 310
 function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) {
311
-	$i = $infos[$dir_type][$plug];
312
-	if (isset($i['erreur']) and $i['erreur']) {
313
-		return;
314
-	}
315
-	if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
316
-		return;
317
-	}
318
-	$p = strtoupper($i['prefix']);
319
-	if (!isset($liste[$p])
320
-		or spip_version_compare($i['version'], $liste[$p]['version'], '>')
321
-	) {
322
-		$liste[$p] = array(
323
-			'nom' => $i['nom'],
324
-			'etat' => $i['etat'],
325
-			'version' => $i['version'],
326
-			'dir' => $plug,
327
-			'dir_type' => $dir_type
328
-		);
329
-	}
311
+    $i = $infos[$dir_type][$plug];
312
+    if (isset($i['erreur']) and $i['erreur']) {
313
+        return;
314
+    }
315
+    if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
316
+        return;
317
+    }
318
+    $p = strtoupper($i['prefix']);
319
+    if (!isset($liste[$p])
320
+        or spip_version_compare($i['version'], $liste[$p]['version'], '>')
321
+    ) {
322
+        $liste[$p] = array(
323
+            'nom' => $i['nom'],
324
+            'etat' => $i['etat'],
325
+            'version' => $i['version'],
326
+            'dir' => $plug,
327
+            'dir_type' => $dir_type
328
+        );
329
+    }
330 330
 }
331 331
 
332 332
 /**
@@ -342,46 +342,46 @@  discard block
 block discarded – undo
342 342
  * @param array $infos
343 343
  */
344 344
 function plugin_fixer_procure(&$liste, &$infos) {
345
-	foreach ($liste as $p => $resume) {
346
-		$i = $infos[$resume['dir_type']][$resume['dir']];
347
-		if (isset($i['procure']) and $i['procure']) {
348
-			foreach ($i['procure'] as $procure) {
349
-				$p = strtoupper($procure['nom']);
350
-				$dir = $resume['dir'];
351
-				if ($dir) {
352
-					$dir .= "/";
353
-				}
354
-				$dir .= "procure:" . $procure['nom'];
355
-
356
-				$procure['etat'] = '?';
357
-				$procure['dir_type'] = $resume['dir_type'];
358
-				$procure['dir'] = $dir;
359
-
360
-				// si ce plugin n'est pas deja procure, ou dans une version plus ancienne
361
-				// on ajoute cette version a la liste
362
-				if (!isset($liste[$p])
363
-					or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
364
-				) {
365
-					$liste[$p] = $procure;
366
-
367
-					// on fournit une information minimale pour ne pas perturber la compilation
368
-					$infos[$resume['dir_type']][$dir] = array(
369
-						'prefix' => $procure['nom'],
370
-						'nom' => $procure['nom'],
371
-						'etat' => $procure['etat'],
372
-						'version' => $procure['version'],
373
-						'chemin' => array(),
374
-						'necessite' => array(),
375
-						'utilise' => array(),
376
-						'lib' => array(),
377
-						'menu' => array(),
378
-						'onglet' => array(),
379
-						'procure' => array(),
380
-					);
381
-				}
382
-			}
383
-		}
384
-	}
345
+    foreach ($liste as $p => $resume) {
346
+        $i = $infos[$resume['dir_type']][$resume['dir']];
347
+        if (isset($i['procure']) and $i['procure']) {
348
+            foreach ($i['procure'] as $procure) {
349
+                $p = strtoupper($procure['nom']);
350
+                $dir = $resume['dir'];
351
+                if ($dir) {
352
+                    $dir .= "/";
353
+                }
354
+                $dir .= "procure:" . $procure['nom'];
355
+
356
+                $procure['etat'] = '?';
357
+                $procure['dir_type'] = $resume['dir_type'];
358
+                $procure['dir'] = $dir;
359
+
360
+                // si ce plugin n'est pas deja procure, ou dans une version plus ancienne
361
+                // on ajoute cette version a la liste
362
+                if (!isset($liste[$p])
363
+                    or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
364
+                ) {
365
+                    $liste[$p] = $procure;
366
+
367
+                    // on fournit une information minimale pour ne pas perturber la compilation
368
+                    $infos[$resume['dir_type']][$dir] = array(
369
+                        'prefix' => $procure['nom'],
370
+                        'nom' => $procure['nom'],
371
+                        'etat' => $procure['etat'],
372
+                        'version' => $procure['version'],
373
+                        'chemin' => array(),
374
+                        'necessite' => array(),
375
+                        'utilise' => array(),
376
+                        'lib' => array(),
377
+                        'menu' => array(),
378
+                        'onglet' => array(),
379
+                        'procure' => array(),
380
+                    );
381
+                }
382
+            }
383
+        }
384
+    }
385 385
 }
386 386
 
387 387
 /**
@@ -395,19 +395,19 @@  discard block
 block discarded – undo
395 395
  * @return array
396 396
  */
397 397
 function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) {
398
-	foreach ($liste as $prefix => $infos) {
399
-		if (!$dir_plugins
400
-			or (
401
-				defined($infos['dir_type'])
402
-				and constant($infos['dir_type']) == $dir_plugins)
403
-		) {
404
-			$liste[$prefix] = $infos['dir'];
405
-		} else {
406
-			unset($liste[$prefix]);
407
-		}
408
-	}
409
-
410
-	return $liste;
398
+    foreach ($liste as $prefix => $infos) {
399
+        if (!$dir_plugins
400
+            or (
401
+                defined($infos['dir_type'])
402
+                and constant($infos['dir_type']) == $dir_plugins)
403
+        ) {
404
+            $liste[$prefix] = $infos['dir'];
405
+        } else {
406
+            unset($liste[$prefix]);
407
+        }
408
+    }
409
+
410
+    return $liste;
411 411
 }
412 412
 
413 413
 /**
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
  * @return array
423 423
  */
424 424
 function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) {
425
-	include_spip('plugins/installer');
425
+    include_spip('plugins/installer');
426 426
 
427
-	return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
427
+    return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
428 428
 }
429 429
 
430 430
 /**
@@ -455,53 +455,53 @@  discard block
 block discarded – undo
455 455
  *                qui n'ont pas satisfait leurs dépendances
456 456
 **/
457 457
 function plugin_trier($infos, $liste_non_classee) {
458
-	$toute_la_liste = $liste_non_classee;
459
-	$liste = $ordre = array();
460
-	$count = 0;
461
-
462
-	while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
463
-		#echo "tour::";var_dump($liste_non_classee);
464
-		$count = $c;
465
-		foreach ($liste_non_classee as $p => $resume) {
466
-			$plug = $resume['dir'];
467
-			$dir_type = $resume['dir_type'];
468
-			$info1 = $infos[$dir_type][$plug];
469
-			// si des plugins sont necessaires,
470
-			// on ne peut inserer qu'apres eux
471
-			foreach ($info1['necessite'] as $need) {
472
-				$nom = strtoupper($need['nom']);
473
-				$compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
474
-				if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
475
-					$info1 = false;
476
-					break;
477
-				}
478
-			}
479
-			if (!$info1) {
480
-				continue;
481
-			}
482
-			// idem si des plugins sont utiles,
483
-			// sauf si ils sont de toute facon absents de la liste
484
-			foreach ($info1['utilise'] as $need) {
485
-				$nom = strtoupper($need['nom']);
486
-				$compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
487
-				if (isset($toute_la_liste[$nom])) {
488
-					if (!isset($liste[$nom]) or
489
-						!plugin_version_compatible($compat, $liste[$nom]['version'])
490
-					) {
491
-						$info1 = false;
492
-						break;
493
-					}
494
-				}
495
-			}
496
-			if ($info1) {
497
-				$ordre[$p] = $info1;
498
-				$liste[$p] = $liste_non_classee[$p];
499
-				unset($liste_non_classee[$p]);
500
-			}
501
-		}
502
-	}
503
-
504
-	return array($liste, $ordre, $liste_non_classee);
458
+    $toute_la_liste = $liste_non_classee;
459
+    $liste = $ordre = array();
460
+    $count = 0;
461
+
462
+    while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
463
+        #echo "tour::";var_dump($liste_non_classee);
464
+        $count = $c;
465
+        foreach ($liste_non_classee as $p => $resume) {
466
+            $plug = $resume['dir'];
467
+            $dir_type = $resume['dir_type'];
468
+            $info1 = $infos[$dir_type][$plug];
469
+            // si des plugins sont necessaires,
470
+            // on ne peut inserer qu'apres eux
471
+            foreach ($info1['necessite'] as $need) {
472
+                $nom = strtoupper($need['nom']);
473
+                $compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
474
+                if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
475
+                    $info1 = false;
476
+                    break;
477
+                }
478
+            }
479
+            if (!$info1) {
480
+                continue;
481
+            }
482
+            // idem si des plugins sont utiles,
483
+            // sauf si ils sont de toute facon absents de la liste
484
+            foreach ($info1['utilise'] as $need) {
485
+                $nom = strtoupper($need['nom']);
486
+                $compat = isset($need['compatibilite']) ? $need['compatibilite'] : '';
487
+                if (isset($toute_la_liste[$nom])) {
488
+                    if (!isset($liste[$nom]) or
489
+                        !plugin_version_compatible($compat, $liste[$nom]['version'])
490
+                    ) {
491
+                        $info1 = false;
492
+                        break;
493
+                    }
494
+                }
495
+            }
496
+            if ($info1) {
497
+                $ordre[$p] = $info1;
498
+                $liste[$p] = $liste_non_classee[$p];
499
+                unset($liste_non_classee[$p]);
500
+            }
501
+        }
502
+    }
503
+
504
+    return array($liste, $ordre, $liste_non_classee);
505 505
 }
506 506
 
507 507
 /**
@@ -518,34 +518,34 @@  discard block
 block discarded – undo
518 518
  *     Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent
519 519
 **/
520 520
 function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = array()) {
521
-	static $erreurs = array();
522
-
523
-	if (!is_array($liste)) {
524
-		$liste = array();
525
-	}
526
-
527
-	// les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
528
-	$liste = array_diff_key($liste, $liste_non_classee);
529
-
530
-	foreach ($liste_non_classee as $p => $resume) {
531
-		$dir_type = $resume['dir_type'];
532
-		$plug = $resume['dir'];
533
-		$k = $infos[$dir_type][$plug];
534
-
535
-		$plug = constant($dir_type) . $plug;
536
-		if (!isset($msg[$p])) {
537
-			if (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
538
-				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
539
-			}
540
-		} else {
541
-			foreach ($msg[$p] as $c => $l) {
542
-				$msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
543
-			}
544
-		}
545
-		$erreurs[$plug] = $msg[$p];
546
-	}
547
-
548
-	ecrire_meta('plugin_erreur_activation', serialize($erreurs));
521
+    static $erreurs = array();
522
+
523
+    if (!is_array($liste)) {
524
+        $liste = array();
525
+    }
526
+
527
+    // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
528
+    $liste = array_diff_key($liste, $liste_non_classee);
529
+
530
+    foreach ($liste_non_classee as $p => $resume) {
531
+        $dir_type = $resume['dir_type'];
532
+        $plug = $resume['dir'];
533
+        $k = $infos[$dir_type][$plug];
534
+
535
+        $plug = constant($dir_type) . $plug;
536
+        if (!isset($msg[$p])) {
537
+            if (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
538
+                $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
539
+            }
540
+        } else {
541
+            foreach ($msg[$p] as $c => $l) {
542
+                $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
543
+            }
544
+        }
545
+        $erreurs[$plug] = $msg[$p];
546
+    }
547
+
548
+    ecrire_meta('plugin_erreur_activation', serialize($erreurs));
549 549
 }
550 550
 
551 551
 /**
@@ -560,25 +560,25 @@  discard block
 block discarded – undo
560 560
  *     - Liste des erreurs ou code HTML des erreurs
561 561
 **/
562 562
 function plugin_donne_erreurs($raw = false, $raz = true) {
563
-	if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
564
-		return $raw ? array() : '';
565
-	}
566
-	$list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
567
-	// Compat ancienne version
568
-	if (!$list) {
569
-		$list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
570
-	} elseif (!$raw) {
571
-		foreach ($list as $plug => $msg) {
572
-			$list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
573
-				. "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
574
-		}
575
-		$list = "<ul>" . join("\n", $list) . "</ul>";
576
-	}
577
-	if ($raz) {
578
-		effacer_meta('plugin_erreur_activation');
579
-	}
580
-
581
-	return $list;
563
+    if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
564
+        return $raw ? array() : '';
565
+    }
566
+    $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
567
+    // Compat ancienne version
568
+    if (!$list) {
569
+        $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
570
+    } elseif (!$raw) {
571
+        foreach ($list as $plug => $msg) {
572
+            $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
573
+                . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
574
+        }
575
+        $list = "<ul>" . join("\n", $list) . "</ul>";
576
+    }
577
+    if ($raz) {
578
+        effacer_meta('plugin_erreur_activation');
579
+    }
580
+
581
+    return $list;
582 582
 }
583 583
 
584 584
 /**
@@ -598,21 +598,21 @@  discard block
 block discarded – undo
598 598
  *
599 599
  **/
600 600
 function plugin_necessite($n, $liste, $balise = 'necessite') {
601
-	$msg = array();
602
-	foreach ($n as $need) {
603
-		$id = strtoupper($need['nom']);
604
-		$r = plugin_controler_necessite(
605
-			$liste, 
606
-			$id, 
607
-			isset($need['compatibilite']) ? $need['compatibilite'] : '', 
608
-			$balise
609
-		);
610
-		if ($r) {
611
-			$msg[] = $r;
612
-		}
613
-	}
614
-
615
-	return $msg;
601
+    $msg = array();
602
+    foreach ($n as $need) {
603
+        $id = strtoupper($need['nom']);
604
+        $r = plugin_controler_necessite(
605
+            $liste, 
606
+            $id, 
607
+            isset($need['compatibilite']) ? $need['compatibilite'] : '', 
608
+            $balise
609
+        );
610
+        if ($r) {
611
+            $msg[] = $r;
612
+        }
613
+    }
614
+
615
+    return $msg;
616 616
 }
617 617
 
618 618
 /**
@@ -634,16 +634,16 @@  discard block
 block discarded – undo
634 634
  *    Message d'erreur lorsque la dépendance est absente.
635 635
  **/
636 636
 function plugin_controler_necessite($liste, $nom, $intervalle, $balise) {
637
-	if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
638
-		return '';
639
-	}
640
-
641
-	return plugin_message_incompatibilite(
642
-		$intervalle, 
643
-		(isset($liste[$nom]) ? $liste[$nom]['version'] : ""), 
644
-		$nom, 
645
-		$balise
646
-	);
637
+    if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
638
+        return '';
639
+    }
640
+
641
+    return plugin_message_incompatibilite(
642
+        $intervalle, 
643
+        (isset($liste[$nom]) ? $liste[$nom]['version'] : ""), 
644
+        $nom, 
645
+        $balise
646
+    );
647 647
 }
648 648
 
649 649
 /**
@@ -660,68 +660,68 @@  discard block
 block discarded – undo
660 660
  */
661 661
 function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) {
662 662
 
663
-	// prendre en compte les erreurs de dépendances à PHP
664
-	// ou à une extension PHP avec des messages d'erreurs dédiés.
665
-	$type = 'plugin';
666
-	if ($nom === 'PHP') {
667
-		$type = 'php';
668
-	} elseif (strncmp($nom, 'PHP:', 4) === 0) {
669
-		$type = 'extension_php';
670
-		list(,$nom) = explode(':', $nom, 2);
671
-	}
672
-
673
-	if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
674
-		$minimum = $regs[1];
675
-		$maximum = $regs[2];
676
-
677
-		$minimum_inclus = $intervalle{0} == "[";
678
-		$maximum_inclus = substr($intervalle, -1) == "]";
679
-
680
-		if (strlen($minimum)) {
681
-			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
682
-				return _T("plugin_${balise}_${type}", array(
683
-					'plugin' => $nom,
684
-					'version' => ' &ge; ' . $minimum
685
-				));
686
-			}
687
-			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
688
-				return _T("plugin_${balise}_${type}", array(
689
-					'plugin' => $nom,
690
-					'version' => ' &gt; ' . $minimum
691
-				));
692
-			}
693
-		}
694
-
695
-		if (strlen($maximum)) {
696
-			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
697
-				return _T("plugin_${balise}_${type}", array(
698
-					'plugin' => $nom,
699
-					'version' => ' &le; ' . $maximum
700
-				));
701
-			}
702
-			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
703
-				return _T("plugin_${balise}_plugin", array(
704
-					'plugin' => $nom,
705
-					'version' => ' &lt; ' . $maximum
706
-				));
707
-			}
708
-		}
709
-	}
710
-
711
-	// note : il ne peut pas y avoir d'erreur sur
712
-	// - un 'utilise' sans version.
713
-	// - un 'php' sans version.
714
-	return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom));
663
+    // prendre en compte les erreurs de dépendances à PHP
664
+    // ou à une extension PHP avec des messages d'erreurs dédiés.
665
+    $type = 'plugin';
666
+    if ($nom === 'PHP') {
667
+        $type = 'php';
668
+    } elseif (strncmp($nom, 'PHP:', 4) === 0) {
669
+        $type = 'extension_php';
670
+        list(,$nom) = explode(':', $nom, 2);
671
+    }
672
+
673
+    if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
674
+        $minimum = $regs[1];
675
+        $maximum = $regs[2];
676
+
677
+        $minimum_inclus = $intervalle{0} == "[";
678
+        $maximum_inclus = substr($intervalle, -1) == "]";
679
+
680
+        if (strlen($minimum)) {
681
+            if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
682
+                return _T("plugin_${balise}_${type}", array(
683
+                    'plugin' => $nom,
684
+                    'version' => ' &ge; ' . $minimum
685
+                ));
686
+            }
687
+            if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
688
+                return _T("plugin_${balise}_${type}", array(
689
+                    'plugin' => $nom,
690
+                    'version' => ' &gt; ' . $minimum
691
+                ));
692
+            }
693
+        }
694
+
695
+        if (strlen($maximum)) {
696
+            if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
697
+                return _T("plugin_${balise}_${type}", array(
698
+                    'plugin' => $nom,
699
+                    'version' => ' &le; ' . $maximum
700
+                ));
701
+            }
702
+            if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
703
+                return _T("plugin_${balise}_plugin", array(
704
+                    'plugin' => $nom,
705
+                    'version' => ' &lt; ' . $maximum
706
+                ));
707
+            }
708
+        }
709
+    }
710
+
711
+    // note : il ne peut pas y avoir d'erreur sur
712
+    // - un 'utilise' sans version.
713
+    // - un 'php' sans version.
714
+    return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom));
715 715
 }
716 716
 
717 717
 
718 718
 function plugin_controler_lib($lib, $url) {
719
-	/* Feature sortie du core, voir STP
719
+    /* Feature sortie du core, voir STP
720 720
 	 * if ($url) {
721 721
 		include_spip('inc/charger_plugin');
722 722
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
723 723
 	}*/
724
-	return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
724
+    return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
725 725
 }
726 726
 
727 727
 
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
  *     true si il y a eu des modifications sur la liste des plugins actifs, false sinon
737 737
  **/
738 738
 function actualise_plugins_actifs($pipe_recherche = false) {
739
-	return ecrire_plugin_actifs('', $pipe_recherche, 'force');
739
+    return ecrire_plugin_actifs('', $pipe_recherche, 'force');
740 740
 }
741 741
 
742 742
 
@@ -763,116 +763,116 @@  discard block
 block discarded – undo
763 763
  **/
764 764
 function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') {
765 765
 
766
-	// creer le repertoire cache/ si necessaire ! (installation notamment)
767
-	$cache = sous_repertoire(_DIR_CACHE, '', false, true);
768
-
769
-	// Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
770
-	if (!$cache and !spip_connect()) {
771
-		return false;
772
-	}
773
-
774
-	if ($operation != 'raz') {
775
-		$plugin_valides = liste_chemin_plugin_actifs();
776
-		$plugin_valides = is_plugin_dir($plugin_valides);
777
-		if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
778
-			$plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
779
-			$plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
780
-			$plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
781
-		}
782
-		// si des plugins sont en attentes (coches mais impossible a activer)
783
-		// on les reinjecte ici
784
-		if (isset($GLOBALS['meta']['plugin_attente'])
785
-			and $a = unserialize($GLOBALS['meta']['plugin_attente'])
786
-		) {
787
-			$plugin_valides = $plugin_valides + liste_chemin_plugin($a);
788
-		}
789
-
790
-		if ($operation == 'ajoute') {
791
-			$plugin = array_merge($plugin_valides, $plugin);
792
-		} elseif ($operation == 'enleve') {
793
-			$plugin = array_diff($plugin_valides, $plugin);
794
-		} else {
795
-			$plugin = $plugin_valides;
796
-		}
797
-	}
798
-	$actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
799
-
800
-	// si une fonction de gestion de dependances existe, l'appeler ici
801
-	if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) {
802
-		$plugin = $ajouter_dependances($plugin);
803
-	}
804
-
805
-	// recharger le xml des plugins a activer
806
-	// on force le reload ici, meme si le fichier xml n'a pas change
807
-	// pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
808
-	// pourra etre evite quand on ne supportera plus les plugin.xml
809
-	// en deplacant la detection de ces fichiers dans la compilation ci dessous
810
-	list($infos, $liste) = liste_plugin_valides($plugin, true);
811
-	// trouver l'ordre d'activation
812
-	list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste);
813
-	if ($reste) {
814
-		plugins_erreurs($reste, $liste, $infos);
815
-	}
816
-
817
-	// Ignorer les plugins necessitant une lib absente
818
-	// et preparer la meta d'entete Http
819
-	$err = $msg = $header = array();
820
-	foreach ($plugin_valides as $p => $resume) {
821
-		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
822
-		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
823
-			$header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
824
-		}
825
-		if ($resume['dir']) {
826
-			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
827
-				if (!find_in_path($l['nom'], 'lib/')) {
828
-					$err[$p] = $resume;
829
-					$msg[$p][] = $l;
830
-					unset($plugin_valides[$p]);
831
-				}
832
-			}
833
-		}
834
-	}
835
-	if ($err) {
836
-		plugins_erreurs($err, '', $infos, $msg);
837
-	}
838
-
839
-	if (isset($GLOBALS['meta']['message_crash_plugins'])) {
840
-		effacer_meta('message_crash_plugins');
841
-	}
842
-	ecrire_meta('plugin', serialize($plugin_valides));
843
-	$liste = array_diff_key($liste, $plugin_valides);
844
-	ecrire_meta('plugin_attente', serialize($liste));
845
-	$header = strtolower(implode(",", $header));
846
-	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
847
-		ecrire_fichier(_DIR_VAR . "config.txt",
848
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
849
-	} else {
850
-		@unlink(_DIR_VAR . "config.txt");
851
-	}
852
-	// generer charger_plugins_chemin.php
853
-	plugins_precompile_chemin($plugin_valides, $ordre);
854
-	// generer les fichiers
855
-	// - charger_plugins_options.php
856
-	// - charger_plugins_fonctions.php
857
-	plugins_precompile_xxxtions($plugin_valides, $ordre);
858
-	// charger les chemins des plugins et les fichiers d'options 
859
-	// (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
860
-	plugins_amorcer_plugins_actifs();
861
-	// mise a jour de la matrice des pipelines
862
-	$prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
863
-	// generer le fichier _CACHE_PIPELINE
864
-	pipeline_precompile($prepend_code);
865
-
866
-	// attendre eventuellement l'invalidation du cache opcode
867
-	#spip_attend_invalidation_opcode_cache();
868
-
869
-	if (spip_connect()) {
870
-		// lancer et initialiser les nouveaux crons !
871
-		include_spip('inc/genie');
872
-		genie_queue_watch_dist();
873
-	}
874
-
875
-	return ($GLOBALS['meta']['plugin'] != $actifs_avant);
766
+    // creer le repertoire cache/ si necessaire ! (installation notamment)
767
+    $cache = sous_repertoire(_DIR_CACHE, '', false, true);
768
+
769
+    // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
770
+    if (!$cache and !spip_connect()) {
771
+        return false;
772
+    }
773
+
774
+    if ($operation != 'raz') {
775
+        $plugin_valides = liste_chemin_plugin_actifs();
776
+        $plugin_valides = is_plugin_dir($plugin_valides);
777
+        if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
778
+            $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
779
+            $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
780
+            $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
781
+        }
782
+        // si des plugins sont en attentes (coches mais impossible a activer)
783
+        // on les reinjecte ici
784
+        if (isset($GLOBALS['meta']['plugin_attente'])
785
+            and $a = unserialize($GLOBALS['meta']['plugin_attente'])
786
+        ) {
787
+            $plugin_valides = $plugin_valides + liste_chemin_plugin($a);
788
+        }
789
+
790
+        if ($operation == 'ajoute') {
791
+            $plugin = array_merge($plugin_valides, $plugin);
792
+        } elseif ($operation == 'enleve') {
793
+            $plugin = array_diff($plugin_valides, $plugin);
794
+        } else {
795
+            $plugin = $plugin_valides;
796
+        }
797
+    }
798
+    $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
799
+
800
+    // si une fonction de gestion de dependances existe, l'appeler ici
801
+    if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) {
802
+        $plugin = $ajouter_dependances($plugin);
803
+    }
804
+
805
+    // recharger le xml des plugins a activer
806
+    // on force le reload ici, meme si le fichier xml n'a pas change
807
+    // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
808
+    // pourra etre evite quand on ne supportera plus les plugin.xml
809
+    // en deplacant la detection de ces fichiers dans la compilation ci dessous
810
+    list($infos, $liste) = liste_plugin_valides($plugin, true);
811
+    // trouver l'ordre d'activation
812
+    list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste);
813
+    if ($reste) {
814
+        plugins_erreurs($reste, $liste, $infos);
815
+    }
816
+
817
+    // Ignorer les plugins necessitant une lib absente
818
+    // et preparer la meta d'entete Http
819
+    $err = $msg = $header = array();
820
+    foreach ($plugin_valides as $p => $resume) {
821
+        // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
822
+        if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
823
+            $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
824
+        }
825
+        if ($resume['dir']) {
826
+            foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
827
+                if (!find_in_path($l['nom'], 'lib/')) {
828
+                    $err[$p] = $resume;
829
+                    $msg[$p][] = $l;
830
+                    unset($plugin_valides[$p]);
831
+                }
832
+            }
833
+        }
834
+    }
835
+    if ($err) {
836
+        plugins_erreurs($err, '', $infos, $msg);
837
+    }
838
+
839
+    if (isset($GLOBALS['meta']['message_crash_plugins'])) {
840
+        effacer_meta('message_crash_plugins');
841
+    }
842
+    ecrire_meta('plugin', serialize($plugin_valides));
843
+    $liste = array_diff_key($liste, $plugin_valides);
844
+    ecrire_meta('plugin_attente', serialize($liste));
845
+    $header = strtolower(implode(",", $header));
846
+    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
847
+        ecrire_fichier(_DIR_VAR . "config.txt",
848
+            (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
849
+    } else {
850
+        @unlink(_DIR_VAR . "config.txt");
851
+    }
852
+    // generer charger_plugins_chemin.php
853
+    plugins_precompile_chemin($plugin_valides, $ordre);
854
+    // generer les fichiers
855
+    // - charger_plugins_options.php
856
+    // - charger_plugins_fonctions.php
857
+    plugins_precompile_xxxtions($plugin_valides, $ordre);
858
+    // charger les chemins des plugins et les fichiers d'options 
859
+    // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
860
+    plugins_amorcer_plugins_actifs();
861
+    // mise a jour de la matrice des pipelines
862
+    $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
863
+    // generer le fichier _CACHE_PIPELINE
864
+    pipeline_precompile($prepend_code);
865
+
866
+    // attendre eventuellement l'invalidation du cache opcode
867
+    #spip_attend_invalidation_opcode_cache();
868
+
869
+    if (spip_connect()) {
870
+        // lancer et initialiser les nouveaux crons !
871
+        include_spip('inc/genie');
872
+        genie_queue_watch_dist();
873
+    }
874
+
875
+    return ($GLOBALS['meta']['plugin'] != $actifs_avant);
876 876
 }
877 877
 
878 878
 /**
@@ -891,56 +891,56 @@  discard block
 block discarded – undo
891 891
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
892 892
 **/
893 893
 function plugins_precompile_chemin($plugin_valides, $ordre) {
894
-	$chemins = array();
895
-	$contenu = "";
896
-	foreach ($ordre as $p => $info) {
897
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
898
-		if (isset($plugin_valides[$p])) {
899
-			$dir_type = $plugin_valides[$p]['dir_type'];
900
-			$plug = $plugin_valides[$p]['dir'];
901
-			// definir le plugin, donc le path avant l'include du fichier options
902
-			// permet de faire des include_spip pour attraper un inc_ du plugin
903
-
904
-			$dir = $dir_type . ".'" . $plug . "/'";
905
-
906
-			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
907
-			if (
908
-				$prefix !== "SPIP"
909
-				and strpos($dir, ":") === false // exclure le cas des procure:
910
-			) {
911
-				$contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
912
-				foreach ($info['chemin'] as $chemin) {
913
-					if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'],
914
-							$GLOBALS['spip_version_branche'], 'spip')
915
-					) {
916
-						$dir = $chemin['path'];
917
-						if (strlen($dir) and $dir{0} == "/") {
918
-							$dir = substr($dir, 1);
919
-						}
920
-						if (strlen($dir) and $dir == "./") {
921
-							$dir = '';
922
-						}
923
-						if (strlen($dir)) {
924
-							$dir = rtrim($dir, '/') . '/';
925
-						}
926
-						if (!isset($chemin['type']) or $chemin['type'] == 'public') {
927
-							$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
928
-						}
929
-						if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
930
-							$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
931
-						}
932
-					}
933
-				}
934
-			}
935
-		}
936
-	}
937
-	if (count($chemins)) {
938
-		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
939
-				array_reverse($chemins['public'])) . ")));\n"
940
-			. "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
941
-	}
942
-
943
-	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
894
+    $chemins = array();
895
+    $contenu = "";
896
+    foreach ($ordre as $p => $info) {
897
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
898
+        if (isset($plugin_valides[$p])) {
899
+            $dir_type = $plugin_valides[$p]['dir_type'];
900
+            $plug = $plugin_valides[$p]['dir'];
901
+            // definir le plugin, donc le path avant l'include du fichier options
902
+            // permet de faire des include_spip pour attraper un inc_ du plugin
903
+
904
+            $dir = $dir_type . ".'" . $plug . "/'";
905
+
906
+            $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
907
+            if (
908
+                $prefix !== "SPIP"
909
+                and strpos($dir, ":") === false // exclure le cas des procure:
910
+            ) {
911
+                $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
912
+                foreach ($info['chemin'] as $chemin) {
913
+                    if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'],
914
+                            $GLOBALS['spip_version_branche'], 'spip')
915
+                    ) {
916
+                        $dir = $chemin['path'];
917
+                        if (strlen($dir) and $dir{0} == "/") {
918
+                            $dir = substr($dir, 1);
919
+                        }
920
+                        if (strlen($dir) and $dir == "./") {
921
+                            $dir = '';
922
+                        }
923
+                        if (strlen($dir)) {
924
+                            $dir = rtrim($dir, '/') . '/';
925
+                        }
926
+                        if (!isset($chemin['type']) or $chemin['type'] == 'public') {
927
+                            $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
928
+                        }
929
+                        if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
930
+                            $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
931
+                        }
932
+                    }
933
+                }
934
+            }
935
+        }
936
+    }
937
+    if (count($chemins)) {
938
+        $contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
939
+                array_reverse($chemins['public'])) . ")));\n"
940
+            . "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
941
+    }
942
+
943
+    ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
944 944
 }
945 945
 
946 946
 /**
@@ -958,65 +958,65 @@  discard block
 block discarded – undo
958 958
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
959 959
 **/
960 960
 function plugins_precompile_xxxtions($plugin_valides, $ordre) {
961
-	$contenu = array('options' => '', 'fonctions' => '');
962
-	$boutons = array();
963
-	$onglets = array();
964
-	$sign = "";
965
-
966
-	foreach ($ordre as $p => $info) {
967
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
968
-		if (isset($plugin_valides[$p])) {
969
-			$dir_type = $plugin_valides[$p]['dir_type'];
970
-			$plug = $plugin_valides[$p]['dir'];
971
-			$dir = constant($dir_type);
972
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
973
-			if ($info['menu']) {
974
-				$boutons = array_merge($boutons, $info['menu']);
975
-			}
976
-			if ($info['onglet']) {
977
-				$onglets = array_merge($onglets, $info['onglet']);
978
-			}
979
-			foreach ($contenu as $charge => $v) {
980
-				// si pas declare/detecte a la lecture du paquet.xml,
981
-				// detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
982
-				// donc ni sa relecture, ni sa detection
983
-				if (!isset($info[$charge])
984
-					and $dir // exclure le cas du plugin "SPIP"
985
-					and strpos($dir, ":") === false // exclure le cas des procure:
986
-					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
987
-				) {
988
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
989
-						$info[$charge] = array($file);
990
-					}
991
-				}
992
-				if (isset($info[$charge])) {
993
-					$files = $info[$charge];
994
-					foreach ($files as $k => $file) {
995
-						// on genere un if file_exists devant chaque include
996
-						// pour pouvoir garder le meme niveau d'erreur general
997
-						$file = trim($file);
998
-						if (!is_readable("$dir$plug/$file")
999
-							// uniquement pour les paquet.xml
1000
-							and file_exists("$dir$plug/paquet.xml")
1001
-						) {
1002
-							unset($info[$charge][$k]);
1003
-						} else {
1004
-							$_file = $root_dir_type . ".'$plug/$file'";
1005
-							$contenu[$charge] .= "include_once_check($_file);\n";
1006
-						}
1007
-					}
1008
-				}
1009
-			}
1010
-			$sign .= md5(serialize($info));
1011
-		}
1012
-	}
1013
-
1014
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1015
-	$contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1016
-		. plugin_ongletbouton("onglets_plugins", $onglets);
1017
-
1018
-	ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1019
-	ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
961
+    $contenu = array('options' => '', 'fonctions' => '');
962
+    $boutons = array();
963
+    $onglets = array();
964
+    $sign = "";
965
+
966
+    foreach ($ordre as $p => $info) {
967
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
968
+        if (isset($plugin_valides[$p])) {
969
+            $dir_type = $plugin_valides[$p]['dir_type'];
970
+            $plug = $plugin_valides[$p]['dir'];
971
+            $dir = constant($dir_type);
972
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
973
+            if ($info['menu']) {
974
+                $boutons = array_merge($boutons, $info['menu']);
975
+            }
976
+            if ($info['onglet']) {
977
+                $onglets = array_merge($onglets, $info['onglet']);
978
+            }
979
+            foreach ($contenu as $charge => $v) {
980
+                // si pas declare/detecte a la lecture du paquet.xml,
981
+                // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
982
+                // donc ni sa relecture, ni sa detection
983
+                if (!isset($info[$charge])
984
+                    and $dir // exclure le cas du plugin "SPIP"
985
+                    and strpos($dir, ":") === false // exclure le cas des procure:
986
+                    and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
987
+                ) {
988
+                    if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
989
+                        $info[$charge] = array($file);
990
+                    }
991
+                }
992
+                if (isset($info[$charge])) {
993
+                    $files = $info[$charge];
994
+                    foreach ($files as $k => $file) {
995
+                        // on genere un if file_exists devant chaque include
996
+                        // pour pouvoir garder le meme niveau d'erreur general
997
+                        $file = trim($file);
998
+                        if (!is_readable("$dir$plug/$file")
999
+                            // uniquement pour les paquet.xml
1000
+                            and file_exists("$dir$plug/paquet.xml")
1001
+                        ) {
1002
+                            unset($info[$charge][$k]);
1003
+                        } else {
1004
+                            $_file = $root_dir_type . ".'$plug/$file'";
1005
+                            $contenu[$charge] .= "include_once_check($_file);\n";
1006
+                        }
1007
+                    }
1008
+                }
1009
+            }
1010
+            $sign .= md5(serialize($info));
1011
+        }
1012
+    }
1013
+
1014
+    $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1015
+    $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1016
+        . plugin_ongletbouton("onglets_plugins", $onglets);
1017
+
1018
+    ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1019
+    ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1020 1020
 }
1021 1021
 
1022 1022
 /**
@@ -1035,24 +1035,24 @@  discard block
 block discarded – undo
1035 1035
  * @return string Code php
1036 1036
  */
1037 1037
 function plugin_ongletbouton($nom, $val) {
1038
-	if (!$val) {
1039
-		$val = array();
1040
-	}
1041
-
1042
-	$val = serialize($val);
1043
-	$md5 = md5($val);
1044
-
1045
-	if (!defined("_UPDATED_$nom")) {
1046
-		define("_UPDATED_$nom", $val);
1047
-		define("_UPDATED_md5_$nom", $md5);
1048
-	}
1049
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1050
-
1051
-	return
1052
-		"if (!function_exists('$nom')) {\n"
1053
-		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1054
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1055
-		. "}\n";
1038
+    if (!$val) {
1039
+        $val = array();
1040
+    }
1041
+
1042
+    $val = serialize($val);
1043
+    $md5 = md5($val);
1044
+
1045
+    if (!defined("_UPDATED_$nom")) {
1046
+        define("_UPDATED_$nom", $val);
1047
+        define("_UPDATED_md5_$nom", $md5);
1048
+    }
1049
+    $val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1050
+
1051
+    return
1052
+        "if (!function_exists('$nom')) {\n"
1053
+        . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1054
+        . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1055
+        . "}\n";
1056 1056
 }
1057 1057
 
1058 1058
 /**
@@ -1067,15 +1067,15 @@  discard block
 block discarded – undo
1067 1067
 **/
1068 1068
 function plugins_amorcer_plugins_actifs() {
1069 1069
 
1070
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1071
-		include_once(_CACHE_PLUGINS_PATH);
1072
-	} 
1070
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1071
+        include_once(_CACHE_PLUGINS_PATH);
1072
+    } 
1073 1073
 
1074
-	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1075
-		include_once(_CACHE_PLUGINS_OPT);
1076
-	} else {
1077
-		spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1078
-	}
1074
+    if (@is_readable(_CACHE_PLUGINS_OPT)) {
1075
+        include_once(_CACHE_PLUGINS_OPT);
1076
+    } else {
1077
+        spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1078
+    }
1079 1079
 }
1080 1080
 
1081 1081
 /**
@@ -1098,136 +1098,136 @@  discard block
 block discarded – undo
1098 1098
  *     Couples (nom du pipeline => Code PHP à insérer au début du pipeline)
1099 1099
 **/
1100 1100
 function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) {
1101
-	static $liste_pipe_manquants = array();
1102
-	if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1103
-		$liste_pipe_manquants[] = $pipe_recherche;
1104
-	}
1105
-
1106
-	$prepend_code = array();
1107
-
1108
-	foreach ($ordre as $p => $info) {
1109
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1110
-		if (isset($plugin_valides[$p])) {
1111
-			$dir_type = $plugin_valides[$p]['dir_type'];
1112
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1113
-			$plug = $plugin_valides[$p]['dir'];
1114
-			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1115
-			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1116
-				foreach ($info['pipeline'] as $pipe) {
1117
-					$nom = $pipe['nom'];
1118
-					if (isset($pipe['action'])) {
1119
-						$action = $pipe['action'];
1120
-					} else {
1121
-						$action = $nom;
1122
-					}
1123
-					$nomlower = strtolower($nom);
1124
-					if ($nomlower != $nom
1125
-						and isset($GLOBALS['spip_pipeline'][$nom])
1126
-						and !isset($GLOBALS['spip_pipeline'][$nomlower])
1127
-					) {
1128
-						$GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1129
-						unset($GLOBALS['spip_pipeline'][$nom]);
1130
-					}
1131
-					$nom = $nomlower;
1132
-					// une action vide est une declaration qui ne doit pas etre compilee !
1133
-					if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1134
-					{
1135
-						$GLOBALS['spip_pipeline'][$nom] = "";
1136
-					}
1137
-					if ($action) {
1138
-						if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1139
-							$GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
1140
-								$GLOBALS['spip_pipeline'][$nom], 1);
1141
-						}
1142
-						if (isset($pipe['inclure'])) {
1143
-							$GLOBALS['spip_matrice']["$prefix$action"] =
1144
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1145
-						}
1146
-					}
1147
-				}
1148
-			}
1149
-			if (isset($info['genie']) and count($info['genie'])) {
1150
-				if (!isset($prepend_code['taches_generales_cron'])) {
1151
-					$prepend_code['taches_generales_cron'] = "";
1152
-				}
1153
-				foreach ($info['genie'] as $genie) {
1154
-					$nom = $prefix . $genie['nom'];
1155
-					$periode = max(60, intval($genie['periode']));
1156
-					if (charger_fonction($nom, "genie", true)) {
1157
-						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1158
-					} else {
1159
-						spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1160
-					}
1161
-				}
1162
-			}
1163
-			if (isset($info['style']) and count($info['style'])) {
1164
-				if (!isset($prepend_code['insert_head_css'])) {
1165
-					$prepend_code['insert_head_css'] = "";
1166
-				}
1167
-				if (!isset($prepend_code['header_prive_css'])) {
1168
-					$prepend_code['header_prive_css'] = "";
1169
-				}
1170
-				foreach ($info['style'] as $style) {
1171
-					if (isset($style['path']) and $style['path']) {
1172
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1173
-					} else {
1174
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1175
-					}
1176
-					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1177
-					if (isset($style['media']) and strlen($style['media'])) {
1178
-						$code .= " media=\"" . addslashes($style['media']) . "\"";
1179
-					}
1180
-					$code .= "/>';\n";
1181
-					if ($style['type'] != 'prive') {
1182
-						$prepend_code['insert_head_css'] .= $code;
1183
-					}
1184
-					if ($style['type'] != 'public') {
1185
-						$prepend_code['header_prive_css'] .= $code;
1186
-					}
1187
-				}
1188
-			}
1189
-			if (!isset($prepend_code['insert_head'])) {
1190
-				$prepend_code['insert_head'] = "";
1191
-			}
1192
-			if (!isset($prepend_code['header_prive'])) {
1193
-				$prepend_code['header_prive'] = "";
1194
-			}
1195
-			if (isset($info['script']) and count($info['script'])) {
1196
-				foreach ($info['script'] as $script) {
1197
-					if (isset($script['path']) and $script['path']) {
1198
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1199
-					} else {
1200
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1201
-					}
1202
-					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1203
-					if ($script['type'] != 'prive') {
1204
-						$prepend_code['insert_head'] .= $code;
1205
-					}
1206
-					if ($script['type'] != 'public') {
1207
-						$prepend_code['header_prive'] .= $code;
1208
-					}
1209
-				}
1210
-			}
1211
-		}
1212
-	}
1213
-
1214
-	$prepend_code['insert_head'] =
1215
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1216
-		. "\$val = minipipe('f_jQuery', \$val);\n"
1217
-		. $prepend_code['insert_head'];
1218
-	$prepend_code['header_prive'] =
1219
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1220
-		. "\$val = minipipe('f_jQuery_prive', \$val);\n"
1221
-		. $prepend_code['header_prive'];
1222
-
1223
-	// on ajoute les pipe qui ont ete recenses manquants
1224
-	foreach ($liste_pipe_manquants as $add_pipe) {
1225
-		if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1226
-			$GLOBALS['spip_pipeline'][$add_pipe] = '';
1227
-		}
1228
-	}
1229
-
1230
-	return $prepend_code;
1101
+    static $liste_pipe_manquants = array();
1102
+    if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1103
+        $liste_pipe_manquants[] = $pipe_recherche;
1104
+    }
1105
+
1106
+    $prepend_code = array();
1107
+
1108
+    foreach ($ordre as $p => $info) {
1109
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1110
+        if (isset($plugin_valides[$p])) {
1111
+            $dir_type = $plugin_valides[$p]['dir_type'];
1112
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1113
+            $plug = $plugin_valides[$p]['dir'];
1114
+            $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1115
+            if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1116
+                foreach ($info['pipeline'] as $pipe) {
1117
+                    $nom = $pipe['nom'];
1118
+                    if (isset($pipe['action'])) {
1119
+                        $action = $pipe['action'];
1120
+                    } else {
1121
+                        $action = $nom;
1122
+                    }
1123
+                    $nomlower = strtolower($nom);
1124
+                    if ($nomlower != $nom
1125
+                        and isset($GLOBALS['spip_pipeline'][$nom])
1126
+                        and !isset($GLOBALS['spip_pipeline'][$nomlower])
1127
+                    ) {
1128
+                        $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1129
+                        unset($GLOBALS['spip_pipeline'][$nom]);
1130
+                    }
1131
+                    $nom = $nomlower;
1132
+                    // une action vide est une declaration qui ne doit pas etre compilee !
1133
+                    if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel
1134
+                    {
1135
+                        $GLOBALS['spip_pipeline'][$nom] = "";
1136
+                    }
1137
+                    if ($action) {
1138
+                        if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) {
1139
+                            $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1",
1140
+                                $GLOBALS['spip_pipeline'][$nom], 1);
1141
+                        }
1142
+                        if (isset($pipe['inclure'])) {
1143
+                            $GLOBALS['spip_matrice']["$prefix$action"] =
1144
+                                "$root_dir_type:$plug/" . $pipe['inclure'];
1145
+                        }
1146
+                    }
1147
+                }
1148
+            }
1149
+            if (isset($info['genie']) and count($info['genie'])) {
1150
+                if (!isset($prepend_code['taches_generales_cron'])) {
1151
+                    $prepend_code['taches_generales_cron'] = "";
1152
+                }
1153
+                foreach ($info['genie'] as $genie) {
1154
+                    $nom = $prefix . $genie['nom'];
1155
+                    $periode = max(60, intval($genie['periode']));
1156
+                    if (charger_fonction($nom, "genie", true)) {
1157
+                        $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1158
+                    } else {
1159
+                        spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1160
+                    }
1161
+                }
1162
+            }
1163
+            if (isset($info['style']) and count($info['style'])) {
1164
+                if (!isset($prepend_code['insert_head_css'])) {
1165
+                    $prepend_code['insert_head_css'] = "";
1166
+                }
1167
+                if (!isset($prepend_code['header_prive_css'])) {
1168
+                    $prepend_code['header_prive_css'] = "";
1169
+                }
1170
+                foreach ($info['style'] as $style) {
1171
+                    if (isset($style['path']) and $style['path']) {
1172
+                        $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1173
+                    } else {
1174
+                        $code = "if (\$f='" . addslashes($style['url']) . "') ";
1175
+                    }
1176
+                    $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1177
+                    if (isset($style['media']) and strlen($style['media'])) {
1178
+                        $code .= " media=\"" . addslashes($style['media']) . "\"";
1179
+                    }
1180
+                    $code .= "/>';\n";
1181
+                    if ($style['type'] != 'prive') {
1182
+                        $prepend_code['insert_head_css'] .= $code;
1183
+                    }
1184
+                    if ($style['type'] != 'public') {
1185
+                        $prepend_code['header_prive_css'] .= $code;
1186
+                    }
1187
+                }
1188
+            }
1189
+            if (!isset($prepend_code['insert_head'])) {
1190
+                $prepend_code['insert_head'] = "";
1191
+            }
1192
+            if (!isset($prepend_code['header_prive'])) {
1193
+                $prepend_code['header_prive'] = "";
1194
+            }
1195
+            if (isset($info['script']) and count($info['script'])) {
1196
+                foreach ($info['script'] as $script) {
1197
+                    if (isset($script['path']) and $script['path']) {
1198
+                        $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1199
+                    } else {
1200
+                        $code = "if (\$f='" . addslashes($script['url']) . "') ";
1201
+                    }
1202
+                    $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1203
+                    if ($script['type'] != 'prive') {
1204
+                        $prepend_code['insert_head'] .= $code;
1205
+                    }
1206
+                    if ($script['type'] != 'public') {
1207
+                        $prepend_code['header_prive'] .= $code;
1208
+                    }
1209
+                }
1210
+            }
1211
+        }
1212
+    }
1213
+
1214
+    $prepend_code['insert_head'] =
1215
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1216
+        . "\$val = minipipe('f_jQuery', \$val);\n"
1217
+        . $prepend_code['insert_head'];
1218
+    $prepend_code['header_prive'] =
1219
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1220
+        . "\$val = minipipe('f_jQuery_prive', \$val);\n"
1221
+        . $prepend_code['header_prive'];
1222
+
1223
+    // on ajoute les pipe qui ont ete recenses manquants
1224
+    foreach ($liste_pipe_manquants as $add_pipe) {
1225
+        if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1226
+            $GLOBALS['spip_pipeline'][$add_pipe] = '';
1227
+        }
1228
+    }
1229
+
1230
+    return $prepend_code;
1231 1231
 }
1232 1232
 
1233 1233
 /**
@@ -1254,44 +1254,44 @@  discard block
 block discarded – undo
1254 1254
 **/
1255 1255
 function pipeline_precompile($prepend_code = array()) {
1256 1256
 
1257
-	$content = "";
1258
-	foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1259
-		$s_inc = "";
1260
-		$s_call = "";
1261
-		$pipe = array_filter(explode('|', $pipeline));
1262
-		// Eclater le pipeline en filtres et appliquer chaque filtre
1263
-		foreach ($pipe as $fonc) {
1264
-			$fonc = trim($fonc);
1265
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1266
-			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1267
-				$file = $GLOBALS['spip_matrice'][$fonc];
1268
-				$file = "'$file'";
1269
-				// si un _DIR_XXX: est dans la chaine, on extrait la constante
1270
-				if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) {
1271
-					$dir = $regs[1];
1272
-					$root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1273
-					if (defined($root_dir)) {
1274
-						$dir = $root_dir;
1275
-					}
1276
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1277
-					$file = str_replace("''.", "", $file);
1278
-					$file = str_replace(constant($dir), '', $file);
1279
-				}
1280
-				$s_inc .= "include_once_check($file);\n";
1281
-			}
1282
-		}
1283
-		if (strlen($s_inc)) {
1284
-			$s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1285
-		}
1286
-		$content .= "// Pipeline $action \n"
1287
-			. "function execute_pipeline_$action(&\$val){\n"
1288
-			. $s_inc
1289
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1290
-			. $s_call
1291
-			. "return \$val;\n}\n";
1292
-	}
1293
-	ecrire_fichier_php(_CACHE_PIPELINES, $content);
1294
-	clear_path_cache();
1257
+    $content = "";
1258
+    foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1259
+        $s_inc = "";
1260
+        $s_call = "";
1261
+        $pipe = array_filter(explode('|', $pipeline));
1262
+        // Eclater le pipeline en filtres et appliquer chaque filtre
1263
+        foreach ($pipe as $fonc) {
1264
+            $fonc = trim($fonc);
1265
+            $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1266
+            if (isset($GLOBALS['spip_matrice'][$fonc])) {
1267
+                $file = $GLOBALS['spip_matrice'][$fonc];
1268
+                $file = "'$file'";
1269
+                // si un _DIR_XXX: est dans la chaine, on extrait la constante
1270
+                if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) {
1271
+                    $dir = $regs[1];
1272
+                    $root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1273
+                    if (defined($root_dir)) {
1274
+                        $dir = $root_dir;
1275
+                    }
1276
+                    $file = str_replace($regs[0], "'." . $dir . ".'", $file);
1277
+                    $file = str_replace("''.", "", $file);
1278
+                    $file = str_replace(constant($dir), '', $file);
1279
+                }
1280
+                $s_inc .= "include_once_check($file);\n";
1281
+            }
1282
+        }
1283
+        if (strlen($s_inc)) {
1284
+            $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1285
+        }
1286
+        $content .= "// Pipeline $action \n"
1287
+            . "function execute_pipeline_$action(&\$val){\n"
1288
+            . $s_inc
1289
+            . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1290
+            . $s_call
1291
+            . "return \$val;\n}\n";
1292
+    }
1293
+    ecrire_fichier_php(_CACHE_PIPELINES, $content);
1294
+    clear_path_cache();
1295 1295
 }
1296 1296
 
1297 1297
 
@@ -1304,12 +1304,12 @@  discard block
 block discarded – undo
1304 1304
  *     true si le plugin est actif, false sinon
1305 1305
 **/
1306 1306
 function plugin_est_installe($plug_path) {
1307
-	$plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array();
1308
-	if (!$plugin_installes) {
1309
-		return false;
1310
-	}
1307
+    $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array();
1308
+    if (!$plugin_installes) {
1309
+        return false;
1310
+    }
1311 1311
 
1312
-	return in_array($plug_path, $plugin_installes);
1312
+    return in_array($plug_path, $plugin_installes);
1313 1313
 }
1314 1314
 
1315 1315
 
@@ -1322,32 +1322,32 @@  discard block
 block discarded – undo
1322 1322
  * @uses plugins_installer_dist()
1323 1323
  **/
1324 1324
 function plugin_installes_meta() {
1325
-	$installer_plugins = charger_fonction('installer', 'plugins');
1326
-	$meta_plug_installes = array();
1327
-	foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1328
-		if ($plug = $resume['dir']) {
1329
-			$infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1330
-			if ($infos) {
1331
-				if (!is_array($infos) or $infos['install_test'][0]) {
1332
-					$meta_plug_installes[] = $plug;
1333
-				}
1334
-				if (is_array($infos)) {
1335
-					list($ok, $trace) = $infos['install_test'];
1336
-					include_spip('inc/filtres_boites');
1337
-					echo "<div class='install-plugins svp_retour'>"
1338
-						. boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))),
1339
-							($ok ? 'success' : 'error'))
1340
-						. $trace
1341
-						. "<div class='result'>"
1342
-						. ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec"))
1343
-						. "</div>"
1344
-						. boite_fermer()
1345
-						. "</div>";
1346
-				}
1347
-			}
1348
-		}
1349
-	}
1350
-	ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1325
+    $installer_plugins = charger_fonction('installer', 'plugins');
1326
+    $meta_plug_installes = array();
1327
+    foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1328
+        if ($plug = $resume['dir']) {
1329
+            $infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1330
+            if ($infos) {
1331
+                if (!is_array($infos) or $infos['install_test'][0]) {
1332
+                    $meta_plug_installes[] = $plug;
1333
+                }
1334
+                if (is_array($infos)) {
1335
+                    list($ok, $trace) = $infos['install_test'];
1336
+                    include_spip('inc/filtres_boites');
1337
+                    echo "<div class='install-plugins svp_retour'>"
1338
+                        . boite_ouvrir(_T('plugin_titre_installation', array('plugin' => typo($infos['nom']))),
1339
+                            ($ok ? 'success' : 'error'))
1340
+                        . $trace
1341
+                        . "<div class='result'>"
1342
+                        . ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec"))
1343
+                        . "</div>"
1344
+                        . boite_fermer()
1345
+                        . "</div>";
1346
+                }
1347
+            }
1348
+        }
1349
+    }
1350
+    ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1351 1351
 }
1352 1352
 
1353 1353
 /**
@@ -1361,6 +1361,6 @@  discard block
 block discarded – undo
1361 1361
  *     Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante
1362 1362
 **/
1363 1363
 function ecrire_fichier_php($nom, $contenu, $comment = '') {
1364
-	ecrire_fichier($nom,
1365
-		'<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>');
1364
+    ecrire_fichier($nom,
1365
+        '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>');
1366 1366
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 }
22 22
 
23 23
 /** l'adresse du repertoire de telechargement et de decompactage des plugins */
24
-define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
24
+define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/');
25 25
 
26 26
 #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins.
27 27
 include_spip('plugins/installer');
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 				if ($dir) {
352 352
 					$dir .= "/";
353 353
 				}
354
-				$dir .= "procure:" . $procure['nom'];
354
+				$dir .= "procure:".$procure['nom'];
355 355
 
356 356
 				$procure['etat'] = '?';
357 357
 				$procure['dir_type'] = $resume['dir_type'];
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 		$plug = $resume['dir'];
533 533
 		$k = $infos[$dir_type][$plug];
534 534
 
535
-		$plug = constant($dir_type) . $plug;
535
+		$plug = constant($dir_type).$plug;
536 536
 		if (!isset($msg[$p])) {
537 537
 			if (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
538 538
 				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
 		$list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation'];
570 570
 	} elseif (!$raw) {
571 571
 		foreach ($list as $plug => $msg) {
572
-			$list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug))
573
-				. "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>";
572
+			$list[$plug] = "<li>"._T('plugin_impossible_activer', array('plugin' => $plug))
573
+				. "<ul><li>".implode("</li><li>", $msg)."</li></ul></li>";
574 574
 		}
575
-		$list = "<ul>" . join("\n", $list) . "</ul>";
575
+		$list = "<ul>".join("\n", $list)."</ul>";
576 576
 	}
577 577
 	if ($raz) {
578 578
 		effacer_meta('plugin_erreur_activation');
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
 			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
682 682
 				return _T("plugin_${balise}_${type}", array(
683 683
 					'plugin' => $nom,
684
-					'version' => ' &ge; ' . $minimum
684
+					'version' => ' &ge; '.$minimum
685 685
 				));
686 686
 			}
687 687
 			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
688 688
 				return _T("plugin_${balise}_${type}", array(
689 689
 					'plugin' => $nom,
690
-					'version' => ' &gt; ' . $minimum
690
+					'version' => ' &gt; '.$minimum
691 691
 				));
692 692
 			}
693 693
 		}
@@ -696,13 +696,13 @@  discard block
 block discarded – undo
696 696
 			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
697 697
 				return _T("plugin_${balise}_${type}", array(
698 698
 					'plugin' => $nom,
699
-					'version' => ' &le; ' . $maximum
699
+					'version' => ' &le; '.$maximum
700 700
 				));
701 701
 			}
702 702
 			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
703 703
 				return _T("plugin_${balise}_plugin", array(
704 704
 					'plugin' => $nom,
705
-					'version' => ' &lt; ' . $maximum
705
+					'version' => ' &lt; '.$maximum
706 706
 				));
707 707
 			}
708 708
 		}
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 		include_spip('inc/charger_plugin');
722 722
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
723 723
 	}*/
724
-	return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>";
724
+	return _T('plugin_necessite_lib', array('lib' => $lib))." <a href='$url'>$url</a>";
725 725
 }
726 726
 
727 727
 
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 	foreach ($plugin_valides as $p => $resume) {
821 821
 		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
822 822
 		if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') {
823
-			$header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : "");
823
+			$header[] = $p.($resume['version'] ? "(".$resume['version'].")" : "");
824 824
 		}
825 825
 		if ($resume['dir']) {
826 826
 			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
@@ -844,10 +844,10 @@  discard block
 block discarded – undo
844 844
 	ecrire_meta('plugin_attente', serialize($liste));
845 845
 	$header = strtolower(implode(",", $header));
846 846
 	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
847
-		ecrire_fichier(_DIR_VAR . "config.txt",
848
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header);
847
+		ecrire_fichier(_DIR_VAR."config.txt",
848
+			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP").' '.$GLOBALS['spip_version_affichee']." @ www.spip.net + ".$header);
849 849
 	} else {
850
-		@unlink(_DIR_VAR . "config.txt");
850
+		@unlink(_DIR_VAR."config.txt");
851 851
 	}
852 852
 	// generer charger_plugins_chemin.php
853 853
 	plugins_precompile_chemin($plugin_valides, $ordre);
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 			// definir le plugin, donc le path avant l'include du fichier options
902 902
 			// permet de faire des include_spip pour attraper un inc_ du plugin
903 903
 
904
-			$dir = $dir_type . ".'" . $plug . "/'";
904
+			$dir = $dir_type.".'".$plug."/'";
905 905
 
906 906
 			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
907 907
 			if (
@@ -921,13 +921,13 @@  discard block
 block discarded – undo
921 921
 							$dir = '';
922 922
 						}
923 923
 						if (strlen($dir)) {
924
-							$dir = rtrim($dir, '/') . '/';
924
+							$dir = rtrim($dir, '/').'/';
925 925
 						}
926 926
 						if (!isset($chemin['type']) or $chemin['type'] == 'public') {
927
-							$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
927
+							$chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : "");
928 928
 						}
929 929
 						if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
930
-							$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : "");
930
+							$chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : "");
931 931
 						}
932 932
 					}
933 933
 				}
@@ -935,9 +935,9 @@  discard block
 block discarded – undo
935 935
 		}
936 936
 	}
937 937
 	if (count($chemins)) {
938
-		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(" . implode(',',
939
-				array_reverse($chemins['public'])) . ")));\n"
940
-			. "else _chemin(implode(':',array(" . implode(',', array_reverse($chemins['prive'])) . ")));\n";
938
+		$contenu .= "if (_DIR_RESTREINT) _chemin(implode(':',array(".implode(',',
939
+				array_reverse($chemins['public'])).")));\n"
940
+			. "else _chemin(implode(':',array(".implode(',', array_reverse($chemins['prive'])).")));\n";
941 941
 	}
942 942
 
943 943
 	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 					and strpos($dir, ":") === false // exclure le cas des procure:
986 986
 					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
987 987
 				) {
988
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) {
988
+					if (is_readable("$dir$plug/".($file = $info['prefix']."_".$charge.".php"))) {
989 989
 						$info[$charge] = array($file);
990 990
 					}
991 991
 				}
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 						) {
1002 1002
 							unset($info[$charge][$k]);
1003 1003
 						} else {
1004
-							$_file = $root_dir_type . ".'$plug/$file'";
1004
+							$_file = $root_dir_type.".'$plug/$file'";
1005 1005
 							$contenu[$charge] .= "include_once_check($_file);\n";
1006 1006
 						}
1007 1007
 					}
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 		}
1012 1012
 	}
1013 1013
 
1014
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1014
+	$contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options'];
1015 1015
 	$contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons)
1016 1016
 		. plugin_ongletbouton("onglets_plugins", $onglets);
1017 1017
 
@@ -1046,12 +1046,12 @@  discard block
 block discarded – undo
1046 1046
 		define("_UPDATED_$nom", $val);
1047 1047
 		define("_UPDATED_md5_$nom", $md5);
1048 1048
 	}
1049
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1049
+	$val = "unserialize('".str_replace("'", "\'", $val)."')";
1050 1050
 
1051 1051
 	return
1052 1052
 		"if (!function_exists('$nom')) {\n"
1053 1053
 		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1054
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1054
+		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n"
1055 1055
 		. "}\n";
1056 1056
 }
1057 1057
 
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1075 1075
 		include_once(_CACHE_PLUGINS_OPT);
1076 1076
 	} else {
1077
-		spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT);
1077
+		spip_log("pipelines desactives: impossible de produire "._CACHE_PLUGINS_OPT);
1078 1078
 	}
1079 1079
 }
1080 1080
 
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 			$dir_type = $plugin_valides[$p]['dir_type'];
1112 1112
 			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1113 1113
 			$plug = $plugin_valides[$p]['dir'];
1114
-			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_");
1114
+			$prefix = (($info['prefix'] == "spip") ? "" : $info['prefix']."_");
1115 1115
 			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1116 1116
 				foreach ($info['pipeline'] as $pipe) {
1117 1117
 					$nom = $pipe['nom'];
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 						}
1142 1142
 						if (isset($pipe['inclure'])) {
1143 1143
 							$GLOBALS['spip_matrice']["$prefix$action"] =
1144
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1144
+								"$root_dir_type:$plug/".$pipe['inclure'];
1145 1145
 						}
1146 1146
 					}
1147 1147
 				}
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 					$prepend_code['taches_generales_cron'] = "";
1152 1152
 				}
1153 1153
 				foreach ($info['genie'] as $genie) {
1154
-					$nom = $prefix . $genie['nom'];
1154
+					$nom = $prefix.$genie['nom'];
1155 1155
 					$periode = max(60, intval($genie['periode']));
1156 1156
 					if (charger_fonction($nom, "genie", true)) {
1157 1157
 						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
@@ -1169,13 +1169,13 @@  discard block
 block discarded – undo
1169 1169
 				}
1170 1170
 				foreach ($info['style'] as $style) {
1171 1171
 					if (isset($style['path']) and $style['path']) {
1172
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1172
+						$code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) ";
1173 1173
 					} else {
1174
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1174
+						$code = "if (\$f='".addslashes($style['url'])."') ";
1175 1175
 					}
1176 1176
 					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1177 1177
 					if (isset($style['media']) and strlen($style['media'])) {
1178
-						$code .= " media=\"" . addslashes($style['media']) . "\"";
1178
+						$code .= " media=\"".addslashes($style['media'])."\"";
1179 1179
 					}
1180 1180
 					$code .= "/>';\n";
1181 1181
 					if ($style['type'] != 'prive') {
@@ -1195,9 +1195,9 @@  discard block
 block discarded – undo
1195 1195
 			if (isset($info['script']) and count($info['script'])) {
1196 1196
 				foreach ($info['script'] as $script) {
1197 1197
 					if (isset($script['path']) and $script['path']) {
1198
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1198
+						$code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) ";
1199 1199
 					} else {
1200
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1200
+						$code = "if (\$f='".addslashes($script['url'])."') ";
1201 1201
 					}
1202 1202
 					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1203 1203
 					if ($script['type'] != 'prive') {
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 		// Eclater le pipeline en filtres et appliquer chaque filtre
1263 1263
 		foreach ($pipe as $fonc) {
1264 1264
 			$fonc = trim($fonc);
1265
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1265
+			$s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n";
1266 1266
 			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1267 1267
 				$file = $GLOBALS['spip_matrice'][$fonc];
1268 1268
 				$file = "'$file'";
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 					if (defined($root_dir)) {
1274 1274
 						$dir = $root_dir;
1275 1275
 					}
1276
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1276
+					$file = str_replace($regs[0], "'.".$dir.".'", $file);
1277 1277
 					$file = str_replace("''.", "", $file);
1278 1278
 					$file = str_replace(constant($dir), '', $file);
1279 1279
 				}
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 		$content .= "// Pipeline $action \n"
1287 1287
 			. "function execute_pipeline_$action(&\$val){\n"
1288 1288
 			. $s_inc
1289
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1289
+			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '')
1290 1290
 			. $s_call
1291 1291
 			. "return \$val;\n}\n";
1292 1292
 	}
@@ -1362,5 +1362,5 @@  discard block
 block discarded – undo
1362 1362
 **/
1363 1363
 function ecrire_fichier_php($nom, $contenu, $comment = '') {
1364 1364
 	ecrire_fichier($nom,
1365
-		'<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>');
1365
+		'<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>');
1366 1366
 }
Please login to merge, or discard this patch.