Completed
Push — master ( fb0017...92433c )
by cam
01:14
created
ecrire/genie/maintenance.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,8 +107,8 @@
 block discarded – undo
107 107
 function message_crash_tables() {
108 108
 	if ($crash = verifier_crash_tables()) {
109 109
 		return
110
-			'<strong>' . _T('texte_recuperer_base') . '</strong><br />'
111
-			. ' <tt>' . join(', ', $crash) . '</tt><br />'
110
+			'<strong>'._T('texte_recuperer_base').'</strong><br />'
111
+			. ' <tt>'.join(', ', $crash).'</tt><br />'
112 112
 			. generer_form_ecrire(
113 113
 				'base_repair',
114 114
 				_T('texte_crash_base'),
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 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
 /**
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function genie_maintenance_dist($t) {
37 37
 
38
-	// (re)mettre .htaccess avec deny from all
39
-	// dans les deux repertoires dits inaccessibles par http
40
-	include_spip('inc/acces');
41
-	verifier_htaccess(_DIR_ETC);
42
-	verifier_htaccess(_DIR_TMP);
43
-	verifier_htaccess(_DIR_VENDOR);
38
+    // (re)mettre .htaccess avec deny from all
39
+    // dans les deux repertoires dits inaccessibles par http
40
+    include_spip('inc/acces');
41
+    verifier_htaccess(_DIR_ETC);
42
+    verifier_htaccess(_DIR_TMP);
43
+    verifier_htaccess(_DIR_VENDOR);
44 44
 
45
-	// Verifier qu'aucune table n'est crashee
46
-	if (!_request('reinstall')) {
47
-		verifier_crash_tables();
48
-	}
45
+    // Verifier qu'aucune table n'est crashee
46
+    if (!_request('reinstall')) {
47
+        verifier_crash_tables();
48
+    }
49 49
 
50
-	return 1;
50
+    return 1;
51 51
 }
52 52
 
53 53
 
@@ -64,33 +64,33 @@  discard block
 block discarded – undo
64 64
  *     des tables qui ont crashé.
65 65
  */
66 66
 function verifier_crash_tables() {
67
-	if (spip_connect()) {
68
-		include_spip('base/serial');
69
-		include_spip('base/auxiliaires');
70
-		$crash = [];
71
-		foreach (['tables_principales', 'tables_auxiliaires'] as $com) {
72
-			foreach ($GLOBALS[$com] as $table => $desc) {
73
-				if (
74
-					!sql_select('*', $table, '', '', '', 1)
75
-					and !defined('spip_interdire_cache')
76
-				) { # cas "LOST CONNECTION"
77
-				$crash[] = $table;
78
-				}
79
-			}
80
-		}
81
-		#$crash[] = 'test';
82
-		if ($crash) {
83
-			ecrire_meta('message_crash_tables', serialize($crash));
84
-			spip_log('crash des tables', 'err');
85
-			spip_log($crash, 'err');
86
-		} else {
87
-			effacer_meta('message_crash_tables');
88
-		}
67
+    if (spip_connect()) {
68
+        include_spip('base/serial');
69
+        include_spip('base/auxiliaires');
70
+        $crash = [];
71
+        foreach (['tables_principales', 'tables_auxiliaires'] as $com) {
72
+            foreach ($GLOBALS[$com] as $table => $desc) {
73
+                if (
74
+                    !sql_select('*', $table, '', '', '', 1)
75
+                    and !defined('spip_interdire_cache')
76
+                ) { # cas "LOST CONNECTION"
77
+                $crash[] = $table;
78
+                }
79
+            }
80
+        }
81
+        #$crash[] = 'test';
82
+        if ($crash) {
83
+            ecrire_meta('message_crash_tables', serialize($crash));
84
+            spip_log('crash des tables', 'err');
85
+            spip_log($crash, 'err');
86
+        } else {
87
+            effacer_meta('message_crash_tables');
88
+        }
89 89
 
90
-		return $crash;
91
-	}
90
+        return $crash;
91
+    }
92 92
 
93
-	return false;
93
+    return false;
94 94
 }
95 95
 
96 96
 /**
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
  * @return string
107 107
  */
108 108
 function message_crash_tables() {
109
-	if ($crash = verifier_crash_tables()) {
110
-		return
111
-			'<strong>' . _T('texte_recuperer_base') . '</strong><br />'
112
-			. ' <tt>' . join(', ', $crash) . '</tt><br />'
113
-			. generer_form_ecrire(
114
-				'base_repair',
115
-				_T('texte_crash_base'),
116
-				'',
117
-				_T('bouton_tenter_recuperation')
118
-			);
119
-	}
120
-	return '';
109
+    if ($crash = verifier_crash_tables()) {
110
+        return
111
+            '<strong>' . _T('texte_recuperer_base') . '</strong><br />'
112
+            . ' <tt>' . join(', ', $crash) . '</tt><br />'
113
+            . generer_form_ecrire(
114
+                'base_repair',
115
+                _T('texte_crash_base'),
116
+                '',
117
+                _T('bouton_tenter_recuperation')
118
+            );
119
+    }
120
+    return '';
121 121
 }
Please login to merge, or discard this patch.
ecrire/inc/plugin.php 3 patches
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -561,11 +561,9 @@  discard block
 block discarded – undo
561 561
 		if (!isset($msg[$p])) {
562 562
 			if (isset($resume['erreur']) and $resume['erreur']) {
563 563
 				$msg[$p] = [$resume['erreur']];
564
-			}
565
-			elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
564
+			} elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
566 565
 				$msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')];
567
-			}
568
-			elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
566
+			} elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
569 567
 				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
570 568
 			}
571 569
 		} else {
@@ -954,8 +952,7 @@  discard block
 block discarded – undo
954 952
 					if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
955 953
 						$chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
956 954
 					}
957
-				}
958
-				else {
955
+				} else {
959 956
 					foreach ($info['chemin'] as $chemin) {
960 957
 						if (
961 958
 							!isset($chemin['version']) or plugin_version_compatible(
@@ -1425,8 +1422,7 @@  discard block
 block discarded – undo
1425 1422
 						echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1426 1423
 						  $trace,
1427 1424
 						  "\n";
1428
-					}
1429
-					else {
1425
+					} else {
1430 1426
 						include_spip('inc/filtres_boites');
1431 1427
 						echo "<div class='install-plugins svp_retour'>"
1432 1428
 							. boite_ouvrir($titre, ($ok ? 'success' : 'error'))
@@ -1463,8 +1459,7 @@  discard block
 block discarded – undo
1463 1459
 	if (file_exists($nom)) {
1464 1460
 		if (substr($nom, -4) == '.php') {
1465 1461
 			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1466
-		}
1467
-		else {
1462
+		} else {
1468 1463
 			$fichier_tmp = $nom . '.tmp';
1469 1464
 		}
1470 1465
 		file_put_contents($fichier_tmp, $contenu);
Please login to merge, or discard this patch.
Indentation   +984 added lines, -984 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /** l'adresse du repertoire de telechargement et de decompactage des plugins */
24 24
 if (!defined('_DIR_PLUGINS_AUTO')) {
25
-	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
25
+    define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
26 26
 }
27 27
 
28 28
 #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins.
@@ -47,27 +47,27 @@  discard block
 block discarded – undo
47 47
  * @return array
48 48
 **/
49 49
 function liste_plugin_files($dir_plugins = null) {
50
-	static $plugin_files = [];
51
-	if (is_null($dir_plugins)) {
52
-		$dir_plugins = _DIR_PLUGINS;
53
-	}
54
-	if (
55
-		!isset($plugin_files[$dir_plugins])
56
-		or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0
57
-	) {
58
-		$plugin_files[$dir_plugins] = [];
59
-		foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
60
-			$plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
61
-		}
62
-
63
-		sort($plugin_files[$dir_plugins]);
64
-		// et on lit le XML de tous les plugins pour le mettre en cache
65
-		// et en profiter pour nettoyer ceux qui n'existent plus du cache
66
-		$get_infos = charger_fonction('get_infos', 'plugins');
67
-		$get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
68
-	}
69
-
70
-	return $plugin_files[$dir_plugins];
50
+    static $plugin_files = [];
51
+    if (is_null($dir_plugins)) {
52
+        $dir_plugins = _DIR_PLUGINS;
53
+    }
54
+    if (
55
+        !isset($plugin_files[$dir_plugins])
56
+        or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0
57
+    ) {
58
+        $plugin_files[$dir_plugins] = [];
59
+        foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) {
60
+            $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins));
61
+        }
62
+
63
+        sort($plugin_files[$dir_plugins]);
64
+        // et on lit le XML de tous les plugins pour le mettre en cache
65
+        // et en profiter pour nettoyer ceux qui n'existent plus du cache
66
+        $get_infos = charger_fonction('get_infos', 'plugins');
67
+        $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true);
68
+    }
69
+
70
+    return $plugin_files[$dir_plugins];
71 71
 }
72 72
 
73 73
 /**
@@ -83,45 +83,45 @@  discard block
 block discarded – undo
83 83
  *     Liste complète des répeertoires
84 84
 **/
85 85
 function fast_find_plugin_dirs($dir, $max_prof = 100) {
86
-	$fichiers = [];
87
-	// revenir au repertoire racine si on a recu dossier/truc
88
-	// pour regarder dossier/truc/ ne pas oublier le / final
89
-	$dir = preg_replace(',/[^/]*$,', '', $dir);
90
-	if ($dir == '') {
91
-		$dir = '.';
92
-	}
93
-
94
-	if (!is_dir($dir)) {
95
-		return $fichiers;
96
-	}
97
-	if (is_plugin_dir($dir, '')) {
98
-		$fichiers[] = $dir;
99
-
100
-		return $fichiers;
101
-	}
102
-	if ($max_prof <= 0) {
103
-		return $fichiers;
104
-	}
105
-
106
-	$subdirs = [];
107
-	if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
108
-		while (($f = readdir($d)) !== false) {
109
-			if (
110
-				$f[0] != '.' # ignorer . .. .svn etc
111
-				and $f != 'CVS'
112
-				and is_dir($f = "$dir/$f")
113
-			) {
114
-				$subdirs[] = $f;
115
-			}
116
-		}
117
-		closedir($d);
118
-	}
119
-
120
-	foreach ($subdirs as $d) {
121
-		$fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
122
-	}
123
-
124
-	return $fichiers;
86
+    $fichiers = [];
87
+    // revenir au repertoire racine si on a recu dossier/truc
88
+    // pour regarder dossier/truc/ ne pas oublier le / final
89
+    $dir = preg_replace(',/[^/]*$,', '', $dir);
90
+    if ($dir == '') {
91
+        $dir = '.';
92
+    }
93
+
94
+    if (!is_dir($dir)) {
95
+        return $fichiers;
96
+    }
97
+    if (is_plugin_dir($dir, '')) {
98
+        $fichiers[] = $dir;
99
+
100
+        return $fichiers;
101
+    }
102
+    if ($max_prof <= 0) {
103
+        return $fichiers;
104
+    }
105
+
106
+    $subdirs = [];
107
+    if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) {
108
+        while (($f = readdir($d)) !== false) {
109
+            if (
110
+                $f[0] != '.' # ignorer . .. .svn etc
111
+                and $f != 'CVS'
112
+                and is_dir($f = "$dir/$f")
113
+            ) {
114
+                $subdirs[] = $f;
115
+            }
116
+        }
117
+        closedir($d);
118
+    }
119
+
120
+    foreach ($subdirs as $d) {
121
+        $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1));
122
+    }
123
+
124
+    return $fichiers;
125 125
 }
126 126
 
127 127
 /**
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 **/
143 143
 function is_plugin_dir($dir, $dir_plugins = null) {
144 144
 
145
-	if (is_array($dir)) {
146
-		foreach ($dir as $k => $d) {
147
-			if (!is_plugin_dir($d, $dir_plugins)) {
148
-				unset($dir[$k]);
149
-			}
150
-		}
151
-
152
-		return $dir;
153
-	}
154
-	if (is_null($dir_plugins)) {
155
-		$dir_plugins = _DIR_PLUGINS;
156
-	}
157
-	$search = ["$dir_plugins$dir/paquet.xml"];
158
-
159
-	foreach ($search as $s) {
160
-		if (file_exists($s)) {
161
-			return $dir;
162
-		}
163
-	}
164
-
165
-	return '';
145
+    if (is_array($dir)) {
146
+        foreach ($dir as $k => $d) {
147
+            if (!is_plugin_dir($d, $dir_plugins)) {
148
+                unset($dir[$k]);
149
+            }
150
+        }
151
+
152
+        return $dir;
153
+    }
154
+    if (is_null($dir_plugins)) {
155
+        $dir_plugins = _DIR_PLUGINS;
156
+    }
157
+    $search = ["$dir_plugins$dir/paquet.xml"];
158
+
159
+    foreach ($search as $s) {
160
+        if (file_exists($s)) {
161
+            return $dir;
162
+        }
163
+    }
164
+
165
+    return '';
166 166
 }
167 167
 
168 168
 /** Regexp d'extraction des informations d'un intervalle de compatibilité */
@@ -189,51 +189,51 @@  discard block
 block discarded – undo
189 189
  **/
190 190
 function plugin_version_compatible($intervalle, $version, $avec_quoi = '') {
191 191
 
192
-	if (!strlen($intervalle)) {
193
-		return true;
194
-	}
195
-	if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
196
-		return false;
197
-	}
198
-	// Extraction des bornes et traitement de * pour la borne sup :
199
-	// -- on autorise uniquement les ecritures 3.0.*, 3.*
200
-	$minimum = $regs[1];
201
-	$maximum = $regs[2];
202
-
203
-	//  si une version SPIP de compatibilité a été définie (dans
204
-	//  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
205
-	//  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
206
-	//  avec la version de SPIP (ne nuit donc pas aux tests de necessite
207
-	//  entre plugins)
208
-	if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
209
-		if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
210
-			return true;
211
-		}
212
-		// si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
213
-		// cas du plugin qui n'est compatible qu'avec cette nouvelle version
214
-	}
215
-
216
-	$minimum_inc = $intervalle[0] == '[';
217
-	$maximum_inc = substr($intervalle, -1) == ']';
218
-
219
-	if (strlen($minimum)) {
220
-		if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
221
-			return false;
222
-		}
223
-		if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
224
-			return false;
225
-		}
226
-	}
227
-	if (strlen($maximum)) {
228
-		if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
229
-			return false;
230
-		}
231
-		if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
232
-			return false;
233
-		}
234
-	}
235
-
236
-	return true;
192
+    if (!strlen($intervalle)) {
193
+        return true;
194
+    }
195
+    if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
196
+        return false;
197
+    }
198
+    // Extraction des bornes et traitement de * pour la borne sup :
199
+    // -- on autorise uniquement les ecritures 3.0.*, 3.*
200
+    $minimum = $regs[1];
201
+    $maximum = $regs[2];
202
+
203
+    //  si une version SPIP de compatibilité a été définie (dans
204
+    //  mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0');
205
+    //  on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison
206
+    //  avec la version de SPIP (ne nuit donc pas aux tests de necessite
207
+    //  entre plugins)
208
+    if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) {
209
+        if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) {
210
+            return true;
211
+        }
212
+        // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version
213
+        // cas du plugin qui n'est compatible qu'avec cette nouvelle version
214
+    }
215
+
216
+    $minimum_inc = $intervalle[0] == '[';
217
+    $maximum_inc = substr($intervalle, -1) == ']';
218
+
219
+    if (strlen($minimum)) {
220
+        if ($minimum_inc and spip_version_compare($version, $minimum, '<')) {
221
+            return false;
222
+        }
223
+        if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) {
224
+            return false;
225
+        }
226
+    }
227
+    if (strlen($maximum)) {
228
+        if ($maximum_inc and spip_version_compare($version, $maximum, '>')) {
229
+            return false;
230
+        }
231
+        if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) {
232
+            return false;
233
+        }
234
+    }
235
+
236
+    return true;
237 237
 }
238 238
 
239 239
 /**
@@ -250,62 +250,62 @@  discard block
 block discarded – undo
250 250
  * @return array
251 251
  */
252 252
 function liste_plugin_valides($liste_plug, $force = false) {
253
-	$liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
254
-	$get_infos = charger_fonction('get_infos', 'plugins');
255
-	$infos = [
256
-		// lister les extensions qui sont automatiquement actives
257
-		'_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
258
-		'_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
259
-	];
260
-
261
-	// creer une premiere liste non ordonnee mais qui ne retient
262
-	// que les plugins valides, et dans leur derniere version en cas de doublon
263
-	$infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
264
-	$infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
265
-	$infos['_DIR_RESTREINT']['SPIP']['chemin'] = [];
266
-	$liste_non_classee = [
267
-		'SPIP' => [
268
-			'nom' => 'SPIP',
269
-			'etat' => 'stable',
270
-			'version' => $GLOBALS['spip_version_branche'],
271
-			'dir_type' => '_DIR_RESTREINT',
272
-			'dir' => '',
273
-		]
274
-	];
275
-
276
-	$invalides = [];
277
-	foreach ($liste_ext as $plug) {
278
-		if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
279
-			plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
280
-		}
281
-	}
282
-	foreach ($liste_plug as $plug) {
283
-		if (isset($infos['_DIR_PLUGINS'][$plug])) {
284
-			$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
285
-			if (is_array($r)) {
286
-				$invalides = array_merge($invalides, $r);
287
-			}
288
-		}
289
-	}
290
-
291
-	if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
292
-		$infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
293
-		foreach ($liste_plug as $plug) {
294
-			if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
295
-				$r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
296
-				if (is_array($r)) {
297
-					$invalides = array_merge($invalides, $r);
298
-				}
299
-			}
300
-		}
301
-	}
302
-
303
-	plugin_fixer_procure($liste_non_classee, $infos);
304
-
305
-	// les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
306
-	$invalides = array_diff_key($invalides, $liste_non_classee);
307
-
308
-	return [$infos, $liste_non_classee, $invalides];
253
+    $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST);
254
+    $get_infos = charger_fonction('get_infos', 'plugins');
255
+    $infos = [
256
+        // lister les extensions qui sont automatiquement actives
257
+        '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST),
258
+        '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS)
259
+    ];
260
+
261
+    // creer une premiere liste non ordonnee mais qui ne retient
262
+    // que les plugins valides, et dans leur derniere version en cas de doublon
263
+    $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT);
264
+    $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche'];
265
+    $infos['_DIR_RESTREINT']['SPIP']['chemin'] = [];
266
+    $liste_non_classee = [
267
+        'SPIP' => [
268
+            'nom' => 'SPIP',
269
+            'etat' => 'stable',
270
+            'version' => $GLOBALS['spip_version_branche'],
271
+            'dir_type' => '_DIR_RESTREINT',
272
+            'dir' => '',
273
+        ]
274
+    ];
275
+
276
+    $invalides = [];
277
+    foreach ($liste_ext as $plug) {
278
+        if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) {
279
+            plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST');
280
+        }
281
+    }
282
+    foreach ($liste_plug as $plug) {
283
+        if (isset($infos['_DIR_PLUGINS'][$plug])) {
284
+            $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS');
285
+            if (is_array($r)) {
286
+                $invalides = array_merge($invalides, $r);
287
+            }
288
+        }
289
+    }
290
+
291
+    if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) {
292
+        $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL);
293
+        foreach ($liste_plug as $plug) {
294
+            if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) {
295
+                $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL');
296
+                if (is_array($r)) {
297
+                    $invalides = array_merge($invalides, $r);
298
+                }
299
+            }
300
+        }
301
+    }
302
+
303
+    plugin_fixer_procure($liste_non_classee, $infos);
304
+
305
+    // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide)
306
+    $invalides = array_diff_key($invalides, $liste_non_classee);
307
+
308
+    return [$infos, $liste_non_classee, $invalides];
309 309
 }
310 310
 
311 311
 /**
@@ -325,38 +325,38 @@  discard block
 block discarded – undo
325 325
  *   array description short si on ne le retient pas (pour memorisation dans une table des erreurs)
326 326
  */
327 327
 function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) {
328
-	$i = $infos[$dir_type][$plug];
329
-	// minimum syndical pour afficher si le xml avait des erreurs éventuelles
330
-	$short_desc = [
331
-		'dir' => $plug,
332
-		'dir_type' => $dir_type
333
-	];
334
-	if (empty($i['prefix'])) {
335
-		// erreur xml ? mais sans connaissance du prefix, on retourne le chemin…
336
-		$short_desc['erreur'] = $i['erreur'] ?? ['?'];
337
-		return [$plug => $short_desc];
338
-	}
339
-
340
-	$p = strtoupper($i['prefix']);
341
-	$short_desc['nom'] = $i['nom'];
342
-	$short_desc['etat'] = $i['etat'];
343
-	$short_desc['version'] = $i['version'];
344
-
345
-	if (isset($i['erreur']) and $i['erreur']) {
346
-		$short_desc['erreur'] = $i['erreur'];
347
-		return [$p => $short_desc];
348
-	}
349
-	if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
350
-		return [$p => $short_desc];
351
-	}
352
-	if (
353
-		!isset($liste[$p])
354
-		or spip_version_compare($i['version'], $liste[$p]['version'], '>')
355
-	) {
356
-		$liste[$p] = $short_desc;
357
-	}
358
-	// ok le plugin etait deja dans la liste ou on a choisi une version plus recente
359
-	return $p;
328
+    $i = $infos[$dir_type][$plug];
329
+    // minimum syndical pour afficher si le xml avait des erreurs éventuelles
330
+    $short_desc = [
331
+        'dir' => $plug,
332
+        'dir_type' => $dir_type
333
+    ];
334
+    if (empty($i['prefix'])) {
335
+        // erreur xml ? mais sans connaissance du prefix, on retourne le chemin…
336
+        $short_desc['erreur'] = $i['erreur'] ?? ['?'];
337
+        return [$plug => $short_desc];
338
+    }
339
+
340
+    $p = strtoupper($i['prefix']);
341
+    $short_desc['nom'] = $i['nom'];
342
+    $short_desc['etat'] = $i['etat'];
343
+    $short_desc['version'] = $i['version'];
344
+
345
+    if (isset($i['erreur']) and $i['erreur']) {
346
+        $short_desc['erreur'] = $i['erreur'];
347
+        return [$p => $short_desc];
348
+    }
349
+    if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
350
+        return [$p => $short_desc];
351
+    }
352
+    if (
353
+        !isset($liste[$p])
354
+        or spip_version_compare($i['version'], $liste[$p]['version'], '>')
355
+    ) {
356
+        $liste[$p] = $short_desc;
357
+    }
358
+    // ok le plugin etait deja dans la liste ou on a choisi une version plus recente
359
+    return $p;
360 360
 }
361 361
 
362 362
 /**
@@ -372,47 +372,47 @@  discard block
 block discarded – undo
372 372
  * @param array $infos
373 373
  */
374 374
 function plugin_fixer_procure(&$liste, &$infos) {
375
-	foreach ($liste as $p => $resume) {
376
-		$i = $infos[$resume['dir_type']][$resume['dir']];
377
-		if (isset($i['procure']) and $i['procure']) {
378
-			foreach ($i['procure'] as $procure) {
379
-				$p = strtoupper($procure['nom']);
380
-				$dir = $resume['dir'];
381
-				if ($dir) {
382
-					$dir .= '/';
383
-				}
384
-				$dir .= 'procure:' . $procure['nom'];
385
-
386
-				$procure['etat'] = '?';
387
-				$procure['dir_type'] = $resume['dir_type'];
388
-				$procure['dir'] = $dir;
389
-
390
-				// si ce plugin n'est pas deja procure, ou dans une version plus ancienne
391
-				// on ajoute cette version a la liste
392
-				if (
393
-					!isset($liste[$p])
394
-					or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
395
-				) {
396
-					$liste[$p] = $procure;
397
-
398
-					// on fournit une information minimale pour ne pas perturber la compilation
399
-					$infos[$resume['dir_type']][$dir] = [
400
-						'prefix' => $procure['nom'],
401
-						'nom' => $procure['nom'],
402
-						'etat' => $procure['etat'],
403
-						'version' => $procure['version'],
404
-						'chemin' => [],
405
-						'necessite' => [],
406
-						'utilise' => [],
407
-						'lib' => [],
408
-						'menu' => [],
409
-						'onglet' => [],
410
-						'procure' => [],
411
-					];
412
-				}
413
-			}
414
-		}
415
-	}
375
+    foreach ($liste as $p => $resume) {
376
+        $i = $infos[$resume['dir_type']][$resume['dir']];
377
+        if (isset($i['procure']) and $i['procure']) {
378
+            foreach ($i['procure'] as $procure) {
379
+                $p = strtoupper($procure['nom']);
380
+                $dir = $resume['dir'];
381
+                if ($dir) {
382
+                    $dir .= '/';
383
+                }
384
+                $dir .= 'procure:' . $procure['nom'];
385
+
386
+                $procure['etat'] = '?';
387
+                $procure['dir_type'] = $resume['dir_type'];
388
+                $procure['dir'] = $dir;
389
+
390
+                // si ce plugin n'est pas deja procure, ou dans une version plus ancienne
391
+                // on ajoute cette version a la liste
392
+                if (
393
+                    !isset($liste[$p])
394
+                    or spip_version_compare($procure['version'], $liste[$p]['version'], '>')
395
+                ) {
396
+                    $liste[$p] = $procure;
397
+
398
+                    // on fournit une information minimale pour ne pas perturber la compilation
399
+                    $infos[$resume['dir_type']][$dir] = [
400
+                        'prefix' => $procure['nom'],
401
+                        'nom' => $procure['nom'],
402
+                        'etat' => $procure['etat'],
403
+                        'version' => $procure['version'],
404
+                        'chemin' => [],
405
+                        'necessite' => [],
406
+                        'utilise' => [],
407
+                        'lib' => [],
408
+                        'menu' => [],
409
+                        'onglet' => [],
410
+                        'procure' => [],
411
+                    ];
412
+                }
413
+            }
414
+        }
415
+    }
416 416
 }
417 417
 
418 418
 /**
@@ -426,20 +426,20 @@  discard block
 block discarded – undo
426 426
  * @return array
427 427
  */
428 428
 function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) {
429
-	foreach ($liste as $prefix => $infos) {
430
-		if (
431
-			!$dir_plugins
432
-			or (
433
-				defined($infos['dir_type'])
434
-				and constant($infos['dir_type']) == $dir_plugins)
435
-		) {
436
-			$liste[$prefix] = $infos['dir'];
437
-		} else {
438
-			unset($liste[$prefix]);
439
-		}
440
-	}
441
-
442
-	return $liste;
429
+    foreach ($liste as $prefix => $infos) {
430
+        if (
431
+            !$dir_plugins
432
+            or (
433
+                defined($infos['dir_type'])
434
+                and constant($infos['dir_type']) == $dir_plugins)
435
+        ) {
436
+            $liste[$prefix] = $infos['dir'];
437
+        } else {
438
+            unset($liste[$prefix]);
439
+        }
440
+    }
441
+
442
+    return $liste;
443 443
 }
444 444
 
445 445
 /**
@@ -454,9 +454,9 @@  discard block
 block discarded – undo
454 454
  * @return array
455 455
  */
456 456
 function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) {
457
-	include_spip('plugins/installer');
457
+    include_spip('plugins/installer');
458 458
 
459
-	return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
459
+    return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins);
460 460
 }
461 461
 
462 462
 /**
@@ -487,54 +487,54 @@  discard block
 block discarded – undo
487 487
  *                qui n'ont pas satisfait leurs dépendances
488 488
 **/
489 489
 function plugin_trier($infos, $liste_non_classee) {
490
-	$toute_la_liste = $liste_non_classee;
491
-	$liste = $ordre = [];
492
-	$count = 0;
493
-
494
-	while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
495
-		#echo "tour::";var_dump($liste_non_classee);
496
-		$count = $c;
497
-		foreach ($liste_non_classee as $p => $resume) {
498
-			$plug = $resume['dir'];
499
-			$dir_type = $resume['dir_type'];
500
-			$info1 = $infos[$dir_type][$plug];
501
-			// si des plugins sont necessaires,
502
-			// on ne peut inserer qu'apres eux
503
-			foreach ($info1['necessite'] as $need) {
504
-				$nom = strtoupper($need['nom']);
505
-				$compat = $need['compatibilite'] ?? '';
506
-				if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
507
-					$info1 = false;
508
-					break;
509
-				}
510
-			}
511
-			if (!$info1) {
512
-				continue;
513
-			}
514
-			// idem si des plugins sont utiles,
515
-			// sauf si ils sont de toute facon absents de la liste
516
-			foreach ($info1['utilise'] as $need) {
517
-				$nom = strtoupper($need['nom']);
518
-				$compat = $need['compatibilite'] ?? '';
519
-				if (isset($toute_la_liste[$nom])) {
520
-					if (
521
-						!isset($liste[$nom]) or
522
-						!plugin_version_compatible($compat, $liste[$nom]['version'])
523
-					) {
524
-						$info1 = false;
525
-						break;
526
-					}
527
-				}
528
-			}
529
-			if ($info1) {
530
-				$ordre[$p] = $info1;
531
-				$liste[$p] = $liste_non_classee[$p];
532
-				unset($liste_non_classee[$p]);
533
-			}
534
-		}
535
-	}
536
-
537
-	return [$liste, $ordre, $liste_non_classee];
490
+    $toute_la_liste = $liste_non_classee;
491
+    $liste = $ordre = [];
492
+    $count = 0;
493
+
494
+    while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas
495
+        #echo "tour::";var_dump($liste_non_classee);
496
+        $count = $c;
497
+        foreach ($liste_non_classee as $p => $resume) {
498
+            $plug = $resume['dir'];
499
+            $dir_type = $resume['dir_type'];
500
+            $info1 = $infos[$dir_type][$plug];
501
+            // si des plugins sont necessaires,
502
+            // on ne peut inserer qu'apres eux
503
+            foreach ($info1['necessite'] as $need) {
504
+                $nom = strtoupper($need['nom']);
505
+                $compat = $need['compatibilite'] ?? '';
506
+                if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) {
507
+                    $info1 = false;
508
+                    break;
509
+                }
510
+            }
511
+            if (!$info1) {
512
+                continue;
513
+            }
514
+            // idem si des plugins sont utiles,
515
+            // sauf si ils sont de toute facon absents de la liste
516
+            foreach ($info1['utilise'] as $need) {
517
+                $nom = strtoupper($need['nom']);
518
+                $compat = $need['compatibilite'] ?? '';
519
+                if (isset($toute_la_liste[$nom])) {
520
+                    if (
521
+                        !isset($liste[$nom]) or
522
+                        !plugin_version_compatible($compat, $liste[$nom]['version'])
523
+                    ) {
524
+                        $info1 = false;
525
+                        break;
526
+                    }
527
+                }
528
+            }
529
+            if ($info1) {
530
+                $ordre[$p] = $info1;
531
+                $liste[$p] = $liste_non_classee[$p];
532
+                unset($liste_non_classee[$p]);
533
+            }
534
+        }
535
+    }
536
+
537
+    return [$liste, $ordre, $liste_non_classee];
538 538
 }
539 539
 
540 540
 /**
@@ -551,40 +551,40 @@  discard block
 block discarded – undo
551 551
  *     Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent
552 552
 **/
553 553
 function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = []) {
554
-	static $erreurs = [];
555
-
556
-	if (!is_array($liste)) {
557
-		$liste = [];
558
-	}
559
-
560
-	// les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
561
-	$liste = array_diff_key($liste, $liste_non_classee);
562
-
563
-	foreach ($liste_non_classee as $p => $resume) {
564
-		$dir_type = $resume['dir_type'];
565
-		$plug = $resume['dir'];
566
-		$k = $infos[$dir_type][$plug];
567
-
568
-		$plug = constant($dir_type) . $plug;
569
-		if (!isset($msg[$p])) {
570
-			if (isset($resume['erreur']) and $resume['erreur']) {
571
-				$msg[$p] = [$resume['erreur']];
572
-			}
573
-			elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
574
-				$msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')];
575
-			}
576
-			elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
577
-				$msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
578
-			}
579
-		} else {
580
-			foreach ($msg[$p] as $c => $l) {
581
-				$msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
582
-			}
583
-		}
584
-		$erreurs[$plug] = $msg[$p];
585
-	}
586
-
587
-	ecrire_meta('plugin_erreur_activation', serialize($erreurs));
554
+    static $erreurs = [];
555
+
556
+    if (!is_array($liste)) {
557
+        $liste = [];
558
+    }
559
+
560
+    // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste
561
+    $liste = array_diff_key($liste, $liste_non_classee);
562
+
563
+    foreach ($liste_non_classee as $p => $resume) {
564
+        $dir_type = $resume['dir_type'];
565
+        $plug = $resume['dir'];
566
+        $k = $infos[$dir_type][$plug];
567
+
568
+        $plug = constant($dir_type) . $plug;
569
+        if (!isset($msg[$p])) {
570
+            if (isset($resume['erreur']) and $resume['erreur']) {
571
+                $msg[$p] = [$resume['erreur']];
572
+            }
573
+            elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) {
574
+                $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')];
575
+            }
576
+            elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) {
577
+                $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise');
578
+            }
579
+        } else {
580
+            foreach ($msg[$p] as $c => $l) {
581
+                $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']);
582
+            }
583
+        }
584
+        $erreurs[$plug] = $msg[$p];
585
+    }
586
+
587
+    ecrire_meta('plugin_erreur_activation', serialize($erreurs));
588 588
 }
589 589
 
590 590
 /**
@@ -599,25 +599,25 @@  discard block
 block discarded – undo
599 599
  *     - Liste des erreurs ou code HTML des erreurs
600 600
 **/
601 601
 function plugin_donne_erreurs($raw = false, $raz = true) {
602
-	if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
603
-		return $raw ? [] : '';
604
-	}
605
-	$list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
606
-	// Compat ancienne version
607
-	if (!$list) {
608
-		$list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation'];
609
-	} elseif (!$raw) {
610
-		foreach ($list as $plug => $msg) {
611
-			$list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug])
612
-				. '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>';
613
-		}
614
-		$list = '<ul>' . join("\n", $list) . '</ul>';
615
-	}
616
-	if ($raz) {
617
-		effacer_meta('plugin_erreur_activation');
618
-	}
619
-
620
-	return $list;
602
+    if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) {
603
+        return $raw ? [] : '';
604
+    }
605
+    $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']);
606
+    // Compat ancienne version
607
+    if (!$list) {
608
+        $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation'];
609
+    } elseif (!$raw) {
610
+        foreach ($list as $plug => $msg) {
611
+            $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug])
612
+                . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>';
613
+        }
614
+        $list = '<ul>' . join("\n", $list) . '</ul>';
615
+    }
616
+    if ($raz) {
617
+        effacer_meta('plugin_erreur_activation');
618
+    }
619
+
620
+    return $list;
621 621
 }
622 622
 
623 623
 /**
@@ -637,21 +637,21 @@  discard block
 block discarded – undo
637 637
  *
638 638
  **/
639 639
 function plugin_necessite($n, $liste, $balise = 'necessite') {
640
-	$msg = [];
641
-	foreach ($n as $need) {
642
-		$id = strtoupper($need['nom']);
643
-		$r = plugin_controler_necessite(
644
-			$liste,
645
-			$id,
646
-			$need['compatibilite'] ?? '',
647
-			$balise
648
-		);
649
-		if ($r) {
650
-			$msg[] = $r;
651
-		}
652
-	}
653
-
654
-	return $msg;
640
+    $msg = [];
641
+    foreach ($n as $need) {
642
+        $id = strtoupper($need['nom']);
643
+        $r = plugin_controler_necessite(
644
+            $liste,
645
+            $id,
646
+            $need['compatibilite'] ?? '',
647
+            $balise
648
+        );
649
+        if ($r) {
650
+            $msg[] = $r;
651
+        }
652
+    }
653
+
654
+    return $msg;
655 655
 }
656 656
 
657 657
 /**
@@ -673,19 +673,19 @@  discard block
 block discarded – undo
673 673
  *    Message d'erreur lorsque la dépendance est absente.
674 674
  **/
675 675
 function plugin_controler_necessite($liste, $nom, $intervalle, $balise) {
676
-	if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
677
-		return '';
678
-	}
679
-	// Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur
680
-	if ($balise === 'utilise' and !isset($liste[$nom])) {
681
-		return '';
682
-	}
683
-	return plugin_message_incompatibilite(
684
-		$intervalle,
685
-		(isset($liste[$nom]) ? $liste[$nom]['version'] : ''),
686
-		$nom,
687
-		$balise
688
-	);
676
+    if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) {
677
+        return '';
678
+    }
679
+    // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur
680
+    if ($balise === 'utilise' and !isset($liste[$nom])) {
681
+        return '';
682
+    }
683
+    return plugin_message_incompatibilite(
684
+        $intervalle,
685
+        (isset($liste[$nom]) ? $liste[$nom]['version'] : ''),
686
+        $nom,
687
+        $balise
688
+    );
689 689
 }
690 690
 
691 691
 /**
@@ -702,70 +702,70 @@  discard block
 block discarded – undo
702 702
  */
703 703
 function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) {
704 704
 
705
-	// prendre en compte les erreurs de dépendances à PHP
706
-	// ou à une extension PHP avec des messages d'erreurs dédiés.
707
-	$type = 'plugin';
708
-	if ($nom === 'SPIP') {
709
-		$type = 'spip';
710
-	} elseif ($nom === 'PHP') {
711
-		$type = 'php';
712
-	} elseif (strncmp($nom, 'PHP:', 4) === 0) {
713
-		$type = 'extension_php';
714
-		[, $nom] = explode(':', $nom, 2);
715
-	}
716
-
717
-	if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
718
-		$minimum = $regs[1];
719
-		$maximum = $regs[2];
720
-
721
-		$minimum_inclus = $intervalle[0] == '[';
722
-		$maximum_inclus = substr($intervalle, -1) == ']';
723
-
724
-		if (strlen($minimum)) {
725
-			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
726
-				return _T("plugin_{$balise}_{$type}", [
727
-					'plugin' => $nom,
728
-					'version' => ' &ge; ' . $minimum
729
-				]);
730
-			}
731
-			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
732
-				return _T("plugin_{$balise}_{$type}", [
733
-					'plugin' => $nom,
734
-					'version' => ' &gt; ' . $minimum
735
-				]);
736
-			}
737
-		}
738
-
739
-		if (strlen($maximum)) {
740
-			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
741
-				return _T("plugin_{$balise}_{$type}", [
742
-					'plugin' => $nom,
743
-					'version' => ' &le; ' . $maximum
744
-				]);
745
-			}
746
-			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
747
-				return _T("plugin_{$balise}_plugin", [
748
-					'plugin' => $nom,
749
-					'version' => ' &lt; ' . $maximum
750
-				]);
751
-			}
752
-		}
753
-	}
754
-
755
-	// note : il ne peut pas y avoir d'erreur sur
756
-	// - un 'utilise' sans version.
757
-	// - un 'php' sans version.
758
-	return _T("plugin_necessite_{$type}_sans_version", ['plugin' => $nom]);
705
+    // prendre en compte les erreurs de dépendances à PHP
706
+    // ou à une extension PHP avec des messages d'erreurs dédiés.
707
+    $type = 'plugin';
708
+    if ($nom === 'SPIP') {
709
+        $type = 'spip';
710
+    } elseif ($nom === 'PHP') {
711
+        $type = 'php';
712
+    } elseif (strncmp($nom, 'PHP:', 4) === 0) {
713
+        $type = 'extension_php';
714
+        [, $nom] = explode(':', $nom, 2);
715
+    }
716
+
717
+    if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) {
718
+        $minimum = $regs[1];
719
+        $maximum = $regs[2];
720
+
721
+        $minimum_inclus = $intervalle[0] == '[';
722
+        $maximum_inclus = substr($intervalle, -1) == ']';
723
+
724
+        if (strlen($minimum)) {
725
+            if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
726
+                return _T("plugin_{$balise}_{$type}", [
727
+                    'plugin' => $nom,
728
+                    'version' => ' &ge; ' . $minimum
729
+                ]);
730
+            }
731
+            if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
732
+                return _T("plugin_{$balise}_{$type}", [
733
+                    'plugin' => $nom,
734
+                    'version' => ' &gt; ' . $minimum
735
+                ]);
736
+            }
737
+        }
738
+
739
+        if (strlen($maximum)) {
740
+            if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
741
+                return _T("plugin_{$balise}_{$type}", [
742
+                    'plugin' => $nom,
743
+                    'version' => ' &le; ' . $maximum
744
+                ]);
745
+            }
746
+            if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
747
+                return _T("plugin_{$balise}_plugin", [
748
+                    'plugin' => $nom,
749
+                    'version' => ' &lt; ' . $maximum
750
+                ]);
751
+            }
752
+        }
753
+    }
754
+
755
+    // note : il ne peut pas y avoir d'erreur sur
756
+    // - un 'utilise' sans version.
757
+    // - un 'php' sans version.
758
+    return _T("plugin_necessite_{$type}_sans_version", ['plugin' => $nom]);
759 759
 }
760 760
 
761 761
 
762 762
 function plugin_controler_lib($lib, $url) {
763
-	/* Feature sortie du core, voir STP
763
+    /* Feature sortie du core, voir STP
764 764
 	 * if ($url) {
765 765
 		include_spip('inc/charger_plugin');
766 766
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
767 767
 	}*/
768
-	return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>";
768
+    return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>";
769 769
 }
770 770
 
771 771
 
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
  *     true si il y a eu des modifications sur la liste des plugins actifs, false sinon
781 781
  **/
782 782
 function actualise_plugins_actifs($pipe_recherche = false) {
783
-	return ecrire_plugin_actifs('', $pipe_recherche, 'force');
783
+    return ecrire_plugin_actifs('', $pipe_recherche, 'force');
784 784
 }
785 785
 
786 786
 
@@ -807,116 +807,116 @@  discard block
 block discarded – undo
807 807
  **/
808 808
 function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') {
809 809
 
810
-	// creer le repertoire cache/ si necessaire ! (installation notamment)
811
-	$cache = sous_repertoire(_DIR_CACHE, '', false, true);
812
-
813
-	// Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
814
-	if (!$cache and !spip_connect()) {
815
-		return false;
816
-	}
817
-
818
-	if ($operation != 'raz') {
819
-		$plugin_valides = liste_chemin_plugin_actifs();
820
-		$plugin_valides = is_plugin_dir($plugin_valides);
821
-		if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
822
-			$plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
823
-			$plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
824
-			$plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
825
-		}
826
-		// si des plugins sont en attentes (coches mais impossible a activer)
827
-		// on les reinjecte ici
828
-		if (
829
-			isset($GLOBALS['meta']['plugin_attente'])
830
-			and $a = unserialize($GLOBALS['meta']['plugin_attente'])
831
-		) {
832
-			$plugin_valides = $plugin_valides + liste_chemin_plugin($a);
833
-		}
834
-
835
-		if ($operation == 'ajoute') {
836
-			$plugin = array_merge($plugin_valides, $plugin);
837
-		} elseif ($operation == 'enleve') {
838
-			$plugin = array_diff($plugin_valides, $plugin);
839
-		} else {
840
-			$plugin = $plugin_valides;
841
-		}
842
-	}
843
-	$actifs_avant = $GLOBALS['meta']['plugin'] ?? '';
844
-
845
-	// si une fonction de gestion de dependances existe, l'appeler ici
846
-	if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) {
847
-		$plugin = $ajouter_dependances($plugin);
848
-	}
849
-
850
-	// recharger le xml des plugins a activer
851
-	// on force le reload ici, meme si le fichier xml n'a pas change
852
-	// pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
853
-	// pourra etre evite quand on ne supportera plus les plugin.xml
854
-	// en deplacant la detection de ces fichiers dans la compilation ci dessous
855
-	[$infos, $liste, $invalides] = liste_plugin_valides($plugin, true);
856
-	// trouver l'ordre d'activation
857
-	[$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste);
858
-	if ($invalides or $reste) {
859
-		plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
860
-	}
861
-
862
-	// Ignorer les plugins necessitant une lib absente
863
-	// et preparer la meta d'entete Http
864
-	$err = $msg = $header = [];
865
-	foreach ($plugin_valides as $p => $resume) {
866
-		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
867
-		if (!str_starts_with($p, 'PHP:') and $p !== 'PHP') {
868
-			$header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : '');
869
-		}
870
-		if ($resume['dir']) {
871
-			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
872
-				if (!find_in_path($l['nom'], 'lib/')) {
873
-					$err[$p] = $resume;
874
-					$msg[$p][] = $l;
875
-					unset($plugin_valides[$p]);
876
-				}
877
-			}
878
-		}
879
-	}
880
-	if ($err) {
881
-		plugins_erreurs($err, '', $infos, $msg);
882
-	}
883
-
884
-	if (isset($GLOBALS['meta']['message_crash_plugins'])) {
885
-		effacer_meta('message_crash_plugins');
886
-	}
887
-	ecrire_meta('plugin', serialize($plugin_valides));
888
-	$liste = array_diff_key($liste, $plugin_valides);
889
-	ecrire_meta('plugin_attente', serialize($liste));
890
-	$header = strtolower(implode(',', $header));
891
-	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
892
-		ecrire_fichier(
893
-			_DIR_VAR . 'config.txt',
894
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header
895
-		);
896
-	} else {
897
-		@unlink(_DIR_VAR . 'config.txt');
898
-	}
899
-	// generer charger_plugins_chemin.php
900
-	plugins_precompile_chemin($plugin_valides, $ordre);
901
-	// generer les fichiers
902
-	// - charger_plugins_options.php
903
-	// - charger_plugins_fonctions.php
904
-	plugins_precompile_xxxtions($plugin_valides, $ordre);
905
-	// charger les chemins des plugins et les fichiers d'options
906
-	// (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
907
-	plugins_amorcer_plugins_actifs();
908
-	// mise a jour de la matrice des pipelines
909
-	$prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
910
-	// generer le fichier _CACHE_PIPELINE
911
-	pipeline_precompile($prepend_code);
912
-
913
-	if (spip_connect()) {
914
-		// lancer et initialiser les nouveaux crons !
915
-		include_spip('inc/genie');
916
-		genie_queue_watch_dist();
917
-	}
918
-
919
-	return ($GLOBALS['meta']['plugin'] != $actifs_avant);
810
+    // creer le repertoire cache/ si necessaire ! (installation notamment)
811
+    $cache = sous_repertoire(_DIR_CACHE, '', false, true);
812
+
813
+    // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore.
814
+    if (!$cache and !spip_connect()) {
815
+        return false;
816
+    }
817
+
818
+    if ($operation != 'raz') {
819
+        $plugin_valides = liste_chemin_plugin_actifs();
820
+        $plugin_valides = is_plugin_dir($plugin_valides);
821
+        if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
822
+            $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL);
823
+            $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL);
824
+            $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp);
825
+        }
826
+        // si des plugins sont en attentes (coches mais impossible a activer)
827
+        // on les reinjecte ici
828
+        if (
829
+            isset($GLOBALS['meta']['plugin_attente'])
830
+            and $a = unserialize($GLOBALS['meta']['plugin_attente'])
831
+        ) {
832
+            $plugin_valides = $plugin_valides + liste_chemin_plugin($a);
833
+        }
834
+
835
+        if ($operation == 'ajoute') {
836
+            $plugin = array_merge($plugin_valides, $plugin);
837
+        } elseif ($operation == 'enleve') {
838
+            $plugin = array_diff($plugin_valides, $plugin);
839
+        } else {
840
+            $plugin = $plugin_valides;
841
+        }
842
+    }
843
+    $actifs_avant = $GLOBALS['meta']['plugin'] ?? '';
844
+
845
+    // si une fonction de gestion de dependances existe, l'appeler ici
846
+    if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) {
847
+        $plugin = $ajouter_dependances($plugin);
848
+    }
849
+
850
+    // recharger le xml des plugins a activer
851
+    // on force le reload ici, meme si le fichier xml n'a pas change
852
+    // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations
853
+    // pourra etre evite quand on ne supportera plus les plugin.xml
854
+    // en deplacant la detection de ces fichiers dans la compilation ci dessous
855
+    [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true);
856
+    // trouver l'ordre d'activation
857
+    [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste);
858
+    if ($invalides or $reste) {
859
+        plugins_erreurs(array_merge($invalides, $reste), $liste, $infos);
860
+    }
861
+
862
+    // Ignorer les plugins necessitant une lib absente
863
+    // et preparer la meta d'entete Http
864
+    $err = $msg = $header = [];
865
+    foreach ($plugin_valides as $p => $resume) {
866
+        // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
867
+        if (!str_starts_with($p, 'PHP:') and $p !== 'PHP') {
868
+            $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : '');
869
+        }
870
+        if ($resume['dir']) {
871
+            foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
872
+                if (!find_in_path($l['nom'], 'lib/')) {
873
+                    $err[$p] = $resume;
874
+                    $msg[$p][] = $l;
875
+                    unset($plugin_valides[$p]);
876
+                }
877
+            }
878
+        }
879
+    }
880
+    if ($err) {
881
+        plugins_erreurs($err, '', $infos, $msg);
882
+    }
883
+
884
+    if (isset($GLOBALS['meta']['message_crash_plugins'])) {
885
+        effacer_meta('message_crash_plugins');
886
+    }
887
+    ecrire_meta('plugin', serialize($plugin_valides));
888
+    $liste = array_diff_key($liste, $plugin_valides);
889
+    ecrire_meta('plugin_attente', serialize($liste));
890
+    $header = strtolower(implode(',', $header));
891
+    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
892
+        ecrire_fichier(
893
+            _DIR_VAR . 'config.txt',
894
+            (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header
895
+        );
896
+    } else {
897
+        @unlink(_DIR_VAR . 'config.txt');
898
+    }
899
+    // generer charger_plugins_chemin.php
900
+    plugins_precompile_chemin($plugin_valides, $ordre);
901
+    // generer les fichiers
902
+    // - charger_plugins_options.php
903
+    // - charger_plugins_fonctions.php
904
+    plugins_precompile_xxxtions($plugin_valides, $ordre);
905
+    // charger les chemins des plugins et les fichiers d'options
906
+    // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins)
907
+    plugins_amorcer_plugins_actifs();
908
+    // mise a jour de la matrice des pipelines
909
+    $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche);
910
+    // generer le fichier _CACHE_PIPELINE
911
+    pipeline_precompile($prepend_code);
912
+
913
+    if (spip_connect()) {
914
+        // lancer et initialiser les nouveaux crons !
915
+        include_spip('inc/genie');
916
+        genie_queue_watch_dist();
917
+    }
918
+
919
+    return ($GLOBALS['meta']['plugin'] != $actifs_avant);
920 920
 }
921 921
 
922 922
 /**
@@ -935,74 +935,74 @@  discard block
 block discarded – undo
935 935
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
936 936
 **/
937 937
 function plugins_precompile_chemin($plugin_valides, $ordre) {
938
-	$chemins = [
939
-		'public' => [],
940
-		'prive' => []
941
-	];
942
-	$contenu = '';
943
-	foreach ($ordre as $p => $info) {
944
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
945
-		if (isset($plugin_valides[$p])) {
946
-			$dir_type = $plugin_valides[$p]['dir_type'];
947
-			$plug = $plugin_valides[$p]['dir'];
948
-			// definir le plugin, donc le path avant l'include du fichier options
949
-			// permet de faire des include_spip pour attraper un inc_ du plugin
950
-
951
-			$dir = $dir_type . ".'" . $plug . "/'";
952
-
953
-			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
954
-			if (
955
-				$prefix !== 'SPIP'
956
-				and !str_contains($dir, ':') // exclure le cas des procure:
957
-			) {
958
-				$contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
959
-				if (!$info['chemin']) {
960
-					$chemins['public'][] = "_DIR_PLUGIN_$prefix";
961
-					$chemins['prive'][] = "_DIR_PLUGIN_$prefix";
962
-					if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
963
-						$chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
964
-					}
965
-				}
966
-				else {
967
-					foreach ($info['chemin'] as $chemin) {
968
-						if (
969
-							!isset($chemin['version']) or plugin_version_compatible(
970
-								$chemin['version'],
971
-								$GLOBALS['spip_version_branche'],
972
-								'spip'
973
-							)
974
-						) {
975
-							$dir = $chemin['path'];
976
-							if (strlen($dir) and $dir[0] == '/') {
977
-								$dir = substr($dir, 1);
978
-							}
979
-							if (strlen($dir) and $dir == './') {
980
-								$dir = '';
981
-							}
982
-							if (strlen($dir)) {
983
-								$dir = rtrim($dir, '/') . '/';
984
-							}
985
-							if (!isset($chemin['type']) or $chemin['type'] == 'public') {
986
-								$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
987
-							}
988
-							if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
989
-								$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
990
-							}
991
-						}
992
-					}
993
-				}
994
-			}
995
-		}
996
-	}
997
-	if (count($chemins['public']) or count($chemins['prive'])) {
998
-		$contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode(
999
-			',',
1000
-			array_reverse($chemins['public'])
1001
-		) . "]);\n"
1002
-			. 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n";
1003
-	}
1004
-
1005
-	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
938
+    $chemins = [
939
+        'public' => [],
940
+        'prive' => []
941
+    ];
942
+    $contenu = '';
943
+    foreach ($ordre as $p => $info) {
944
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
945
+        if (isset($plugin_valides[$p])) {
946
+            $dir_type = $plugin_valides[$p]['dir_type'];
947
+            $plug = $plugin_valides[$p]['dir'];
948
+            // definir le plugin, donc le path avant l'include du fichier options
949
+            // permet de faire des include_spip pour attraper un inc_ du plugin
950
+
951
+            $dir = $dir_type . ".'" . $plug . "/'";
952
+
953
+            $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
954
+            if (
955
+                $prefix !== 'SPIP'
956
+                and !str_contains($dir, ':') // exclure le cas des procure:
957
+            ) {
958
+                $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n";
959
+                if (!$info['chemin']) {
960
+                    $chemins['public'][] = "_DIR_PLUGIN_$prefix";
961
+                    $chemins['prive'][] = "_DIR_PLUGIN_$prefix";
962
+                    if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
963
+                        $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
964
+                    }
965
+                }
966
+                else {
967
+                    foreach ($info['chemin'] as $chemin) {
968
+                        if (
969
+                            !isset($chemin['version']) or plugin_version_compatible(
970
+                                $chemin['version'],
971
+                                $GLOBALS['spip_version_branche'],
972
+                                'spip'
973
+                            )
974
+                        ) {
975
+                            $dir = $chemin['path'];
976
+                            if (strlen($dir) and $dir[0] == '/') {
977
+                                $dir = substr($dir, 1);
978
+                            }
979
+                            if (strlen($dir) and $dir == './') {
980
+                                $dir = '';
981
+                            }
982
+                            if (strlen($dir)) {
983
+                                $dir = rtrim($dir, '/') . '/';
984
+                            }
985
+                            if (!isset($chemin['type']) or $chemin['type'] == 'public') {
986
+                                $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
987
+                            }
988
+                            if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
989
+                                $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
990
+                            }
991
+                        }
992
+                    }
993
+                }
994
+            }
995
+        }
996
+    }
997
+    if (count($chemins['public']) or count($chemins['prive'])) {
998
+        $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode(
999
+            ',',
1000
+            array_reverse($chemins['public'])
1001
+        ) . "]);\n"
1002
+            . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n";
1003
+    }
1004
+
1005
+    ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
1006 1006
 }
1007 1007
 
1008 1008
 /**
@@ -1020,67 +1020,67 @@  discard block
 block discarded – undo
1020 1020
  *     Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances
1021 1021
 **/
1022 1022
 function plugins_precompile_xxxtions($plugin_valides, $ordre) {
1023
-	$contenu = ['options' => '', 'fonctions' => ''];
1024
-	$boutons = [];
1025
-	$onglets = [];
1026
-	$sign = '';
1027
-
1028
-	foreach ($ordre as $p => $info) {
1029
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1030
-		if (isset($plugin_valides[$p])) {
1031
-			$dir_type = $plugin_valides[$p]['dir_type'];
1032
-			$plug = $plugin_valides[$p]['dir'];
1033
-			$dir = constant($dir_type);
1034
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1035
-			if ($info['menu']) {
1036
-				$boutons = array_merge($boutons, $info['menu']);
1037
-			}
1038
-			if ($info['onglet']) {
1039
-				$onglets = array_merge($onglets, $info['onglet']);
1040
-			}
1041
-			foreach ($contenu as $charge => $v) {
1042
-				// si pas declare/detecte a la lecture du paquet.xml,
1043
-				// detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1044
-				// donc ni sa relecture, ni sa detection
1045
-				if (
1046
-					!isset($info[$charge])
1047
-					and $dir // exclure le cas du plugin "SPIP"
1048
-					and !str_contains($dir, ':') // exclure le cas des procure:
1049
-					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1050
-				) {
1051
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) {
1052
-						$info[$charge] = [$file];
1053
-					}
1054
-				}
1055
-				if (isset($info[$charge])) {
1056
-					$files = $info[$charge];
1057
-					foreach ($files as $k => $file) {
1058
-						// on genere un if file_exists devant chaque include
1059
-						// pour pouvoir garder le meme niveau d'erreur general
1060
-						$file = trim($file);
1061
-						if (
1062
-							!is_readable("$dir$plug/$file")
1063
-							// uniquement pour les paquet.xml
1064
-							and file_exists("$dir$plug/paquet.xml")
1065
-						) {
1066
-							unset($info[$charge][$k]);
1067
-						} else {
1068
-							$_file = $root_dir_type . ".'$plug/$file'";
1069
-							$contenu[$charge] .= "include_once_check($_file);\n";
1070
-						}
1071
-					}
1072
-				}
1073
-			}
1074
-			$sign .= md5(serialize($info));
1075
-		}
1076
-	}
1077
-
1078
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1079
-	$contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons)
1080
-		. plugin_ongletbouton('onglets_plugins', $onglets);
1081
-
1082
-	ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1083
-	ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1023
+    $contenu = ['options' => '', 'fonctions' => ''];
1024
+    $boutons = [];
1025
+    $onglets = [];
1026
+    $sign = '';
1027
+
1028
+    foreach ($ordre as $p => $info) {
1029
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1030
+        if (isset($plugin_valides[$p])) {
1031
+            $dir_type = $plugin_valides[$p]['dir_type'];
1032
+            $plug = $plugin_valides[$p]['dir'];
1033
+            $dir = constant($dir_type);
1034
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1035
+            if ($info['menu']) {
1036
+                $boutons = array_merge($boutons, $info['menu']);
1037
+            }
1038
+            if ($info['onglet']) {
1039
+                $onglets = array_merge($onglets, $info['onglet']);
1040
+            }
1041
+            foreach ($contenu as $charge => $v) {
1042
+                // si pas declare/detecte a la lecture du paquet.xml,
1043
+                // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml
1044
+                // donc ni sa relecture, ni sa detection
1045
+                if (
1046
+                    !isset($info[$charge])
1047
+                    and $dir // exclure le cas du plugin "SPIP"
1048
+                    and !str_contains($dir, ':') // exclure le cas des procure:
1049
+                    and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1050
+                ) {
1051
+                    if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) {
1052
+                        $info[$charge] = [$file];
1053
+                    }
1054
+                }
1055
+                if (isset($info[$charge])) {
1056
+                    $files = $info[$charge];
1057
+                    foreach ($files as $k => $file) {
1058
+                        // on genere un if file_exists devant chaque include
1059
+                        // pour pouvoir garder le meme niveau d'erreur general
1060
+                        $file = trim($file);
1061
+                        if (
1062
+                            !is_readable("$dir$plug/$file")
1063
+                            // uniquement pour les paquet.xml
1064
+                            and file_exists("$dir$plug/paquet.xml")
1065
+                        ) {
1066
+                            unset($info[$charge][$k]);
1067
+                        } else {
1068
+                            $_file = $root_dir_type . ".'$plug/$file'";
1069
+                            $contenu[$charge] .= "include_once_check($_file);\n";
1070
+                        }
1071
+                    }
1072
+                }
1073
+            }
1074
+            $sign .= md5(serialize($info));
1075
+        }
1076
+    }
1077
+
1078
+    $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1079
+    $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons)
1080
+        . plugin_ongletbouton('onglets_plugins', $onglets);
1081
+
1082
+    ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']);
1083
+    ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']);
1084 1084
 }
1085 1085
 
1086 1086
 /**
@@ -1099,24 +1099,24 @@  discard block
 block discarded – undo
1099 1099
  * @return string Code php
1100 1100
  */
1101 1101
 function plugin_ongletbouton($nom, $val) {
1102
-	if (!$val) {
1103
-		$val = [];
1104
-	}
1105
-
1106
-	$val = serialize($val);
1107
-	$md5 = md5($val);
1108
-
1109
-	if (!defined("_UPDATED_$nom")) {
1110
-		define("_UPDATED_$nom", $val);
1111
-		define("_UPDATED_md5_$nom", $md5);
1112
-	}
1113
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1114
-
1115
-	return
1116
-		"if (!function_exists('$nom')) {\n"
1117
-		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1118
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1119
-		. "}\n";
1102
+    if (!$val) {
1103
+        $val = [];
1104
+    }
1105
+
1106
+    $val = serialize($val);
1107
+    $md5 = md5($val);
1108
+
1109
+    if (!defined("_UPDATED_$nom")) {
1110
+        define("_UPDATED_$nom", $val);
1111
+        define("_UPDATED_md5_$nom", $md5);
1112
+    }
1113
+    $val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1114
+
1115
+    return
1116
+        "if (!function_exists('$nom')) {\n"
1117
+        . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1118
+        . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1119
+        . "}\n";
1120 1120
 }
1121 1121
 
1122 1122
 /**
@@ -1131,15 +1131,15 @@  discard block
 block discarded – undo
1131 1131
 **/
1132 1132
 function plugins_amorcer_plugins_actifs() {
1133 1133
 
1134
-	if (@is_readable(_CACHE_PLUGINS_PATH)) {
1135
-		include_once(_CACHE_PLUGINS_PATH);
1136
-	}
1134
+    if (@is_readable(_CACHE_PLUGINS_PATH)) {
1135
+        include_once(_CACHE_PLUGINS_PATH);
1136
+    }
1137 1137
 
1138
-	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1139
-		include_once(_CACHE_PLUGINS_OPT);
1140
-	} else {
1141
-		spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT);
1142
-	}
1138
+    if (@is_readable(_CACHE_PLUGINS_OPT)) {
1139
+        include_once(_CACHE_PLUGINS_OPT);
1140
+    } else {
1141
+        spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT);
1142
+    }
1143 1143
 }
1144 1144
 
1145 1145
 /**
@@ -1162,140 +1162,140 @@  discard block
 block discarded – undo
1162 1162
  *     Couples (nom du pipeline => Code PHP à insérer au début du pipeline)
1163 1163
 **/
1164 1164
 function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) {
1165
-	static $liste_pipe_manquants = [];
1166
-	if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1167
-		$liste_pipe_manquants[] = $pipe_recherche;
1168
-	}
1169
-
1170
-	$prepend_code = [];
1171
-
1172
-	foreach ($ordre as $p => $info) {
1173
-		// $ordre peur contenir des plugins en attente et non valides pour ce hit
1174
-		if (isset($plugin_valides[$p])) {
1175
-			$dir_type = $plugin_valides[$p]['dir_type'];
1176
-			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1177
-			$plug = $plugin_valides[$p]['dir'];
1178
-			$prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_');
1179
-			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1180
-				foreach ($info['pipeline'] as $pipe) {
1181
-					$nom = $pipe['nom'];
1182
-					if (isset($pipe['action'])) {
1183
-						$action = $pipe['action'];
1184
-					} else {
1185
-						$action = $nom;
1186
-					}
1187
-					$nomlower = strtolower($nom);
1188
-					if (
1189
-						$nomlower != $nom
1190
-						and isset($GLOBALS['spip_pipeline'][$nom])
1191
-						and !isset($GLOBALS['spip_pipeline'][$nomlower])
1192
-					) {
1193
-						$GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1194
-						unset($GLOBALS['spip_pipeline'][$nom]);
1195
-					}
1196
-					$nom = $nomlower;
1197
-					// une action vide est une declaration qui ne doit pas etre compilee !
1198
-					if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel
1199
-					$GLOBALS['spip_pipeline'][$nom] = '';
1200
-					}
1201
-					if ($action) {
1202
-						if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) {
1203
-							$GLOBALS['spip_pipeline'][$nom] = preg_replace(
1204
-								',(\|\||$),',
1205
-								"|$prefix$action\\1",
1206
-								$GLOBALS['spip_pipeline'][$nom],
1207
-								1
1208
-							);
1209
-						}
1210
-						if (isset($pipe['inclure'])) {
1211
-							$GLOBALS['spip_matrice']["$prefix$action"] =
1212
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1213
-						}
1214
-					}
1215
-				}
1216
-			}
1217
-			if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) {
1218
-				if (!isset($prepend_code['taches_generales_cron'])) {
1219
-					$prepend_code['taches_generales_cron'] = '';
1220
-				}
1221
-				foreach ($info['genie'] as $genie) {
1222
-					$nom = $prefix . $genie['nom'];
1223
-					$periode = max(60, intval($genie['periode']));
1224
-					if (charger_fonction($nom, 'genie', true)) {
1225
-						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1226
-					} else {
1227
-						spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1228
-					}
1229
-				}
1230
-			}
1231
-			if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) {
1232
-				if (!isset($prepend_code['insert_head_css'])) {
1233
-					$prepend_code['insert_head_css'] = '';
1234
-				}
1235
-				if (!isset($prepend_code['header_prive_css'])) {
1236
-					$prepend_code['header_prive_css'] = '';
1237
-				}
1238
-				foreach ($info['style'] as $style) {
1239
-					if (isset($style['path']) and $style['path']) {
1240
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1241
-					} else {
1242
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1243
-					}
1244
-					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1245
-					if (isset($style['media']) and strlen($style['media'])) {
1246
-						$code .= ' media="' . addslashes($style['media']) . '"';
1247
-					}
1248
-					$code .= "/>';\n";
1249
-					if ($style['type'] != 'prive') {
1250
-						$prepend_code['insert_head_css'] .= $code;
1251
-					}
1252
-					if ($style['type'] != 'public') {
1253
-						$prepend_code['header_prive_css'] .= $code;
1254
-					}
1255
-				}
1256
-			}
1257
-			if (!isset($prepend_code['insert_head'])) {
1258
-				$prepend_code['insert_head'] = '';
1259
-			}
1260
-			if (!isset($prepend_code['header_prive'])) {
1261
-				$prepend_code['header_prive'] = '';
1262
-			}
1263
-			if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) {
1264
-				foreach ($info['script'] as $script) {
1265
-					if (isset($script['path']) and $script['path']) {
1266
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1267
-					} else {
1268
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1269
-					}
1270
-					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1271
-					if ($script['type'] != 'prive') {
1272
-						$prepend_code['insert_head'] .= $code;
1273
-					}
1274
-					if ($script['type'] != 'public') {
1275
-						$prepend_code['header_prive'] .= $code;
1276
-					}
1277
-				}
1278
-			}
1279
-		}
1280
-	}
1281
-
1282
-	$prepend_code['insert_head'] =
1283
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1284
-		. "\$val = minipipe('f_jQuery', \$val);\n"
1285
-		. $prepend_code['insert_head'];
1286
-	$prepend_code['header_prive'] =
1287
-		"include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1288
-		. "\$val = minipipe('f_jQuery_prive', \$val);\n"
1289
-		. $prepend_code['header_prive'];
1290
-
1291
-	// on ajoute les pipe qui ont ete recenses manquants
1292
-	foreach ($liste_pipe_manquants as $add_pipe) {
1293
-		if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1294
-			$GLOBALS['spip_pipeline'][$add_pipe] = '';
1295
-		}
1296
-	}
1297
-
1298
-	return $prepend_code;
1165
+    static $liste_pipe_manquants = [];
1166
+    if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) {
1167
+        $liste_pipe_manquants[] = $pipe_recherche;
1168
+    }
1169
+
1170
+    $prepend_code = [];
1171
+
1172
+    foreach ($ordre as $p => $info) {
1173
+        // $ordre peur contenir des plugins en attente et non valides pour ce hit
1174
+        if (isset($plugin_valides[$p])) {
1175
+            $dir_type = $plugin_valides[$p]['dir_type'];
1176
+            $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1177
+            $plug = $plugin_valides[$p]['dir'];
1178
+            $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_');
1179
+            if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1180
+                foreach ($info['pipeline'] as $pipe) {
1181
+                    $nom = $pipe['nom'];
1182
+                    if (isset($pipe['action'])) {
1183
+                        $action = $pipe['action'];
1184
+                    } else {
1185
+                        $action = $nom;
1186
+                    }
1187
+                    $nomlower = strtolower($nom);
1188
+                    if (
1189
+                        $nomlower != $nom
1190
+                        and isset($GLOBALS['spip_pipeline'][$nom])
1191
+                        and !isset($GLOBALS['spip_pipeline'][$nomlower])
1192
+                    ) {
1193
+                        $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom];
1194
+                        unset($GLOBALS['spip_pipeline'][$nom]);
1195
+                    }
1196
+                    $nom = $nomlower;
1197
+                    // une action vide est une declaration qui ne doit pas etre compilee !
1198
+                    if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel
1199
+                    $GLOBALS['spip_pipeline'][$nom] = '';
1200
+                    }
1201
+                    if ($action) {
1202
+                        if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) {
1203
+                            $GLOBALS['spip_pipeline'][$nom] = preg_replace(
1204
+                                ',(\|\||$),',
1205
+                                "|$prefix$action\\1",
1206
+                                $GLOBALS['spip_pipeline'][$nom],
1207
+                                1
1208
+                            );
1209
+                        }
1210
+                        if (isset($pipe['inclure'])) {
1211
+                            $GLOBALS['spip_matrice']["$prefix$action"] =
1212
+                                "$root_dir_type:$plug/" . $pipe['inclure'];
1213
+                        }
1214
+                    }
1215
+                }
1216
+            }
1217
+            if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) {
1218
+                if (!isset($prepend_code['taches_generales_cron'])) {
1219
+                    $prepend_code['taches_generales_cron'] = '';
1220
+                }
1221
+                foreach ($info['genie'] as $genie) {
1222
+                    $nom = $prefix . $genie['nom'];
1223
+                    $periode = max(60, intval($genie['periode']));
1224
+                    if (charger_fonction($nom, 'genie', true)) {
1225
+                        $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
1226
+                    } else {
1227
+                        spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR);
1228
+                    }
1229
+                }
1230
+            }
1231
+            if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) {
1232
+                if (!isset($prepend_code['insert_head_css'])) {
1233
+                    $prepend_code['insert_head_css'] = '';
1234
+                }
1235
+                if (!isset($prepend_code['header_prive_css'])) {
1236
+                    $prepend_code['header_prive_css'] = '';
1237
+                }
1238
+                foreach ($info['style'] as $style) {
1239
+                    if (isset($style['path']) and $style['path']) {
1240
+                        $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1241
+                    } else {
1242
+                        $code = "if (\$f='" . addslashes($style['url']) . "') ";
1243
+                    }
1244
+                    $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1245
+                    if (isset($style['media']) and strlen($style['media'])) {
1246
+                        $code .= ' media="' . addslashes($style['media']) . '"';
1247
+                    }
1248
+                    $code .= "/>';\n";
1249
+                    if ($style['type'] != 'prive') {
1250
+                        $prepend_code['insert_head_css'] .= $code;
1251
+                    }
1252
+                    if ($style['type'] != 'public') {
1253
+                        $prepend_code['header_prive_css'] .= $code;
1254
+                    }
1255
+                }
1256
+            }
1257
+            if (!isset($prepend_code['insert_head'])) {
1258
+                $prepend_code['insert_head'] = '';
1259
+            }
1260
+            if (!isset($prepend_code['header_prive'])) {
1261
+                $prepend_code['header_prive'] = '';
1262
+            }
1263
+            if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) {
1264
+                foreach ($info['script'] as $script) {
1265
+                    if (isset($script['path']) and $script['path']) {
1266
+                        $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1267
+                    } else {
1268
+                        $code = "if (\$f='" . addslashes($script['url']) . "') ";
1269
+                    }
1270
+                    $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1271
+                    if ($script['type'] != 'prive') {
1272
+                        $prepend_code['insert_head'] .= $code;
1273
+                    }
1274
+                    if ($script['type'] != 'public') {
1275
+                        $prepend_code['header_prive'] .= $code;
1276
+                    }
1277
+                }
1278
+            }
1279
+        }
1280
+    }
1281
+
1282
+    $prepend_code['insert_head'] =
1283
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n"
1284
+        . "\$val = minipipe('f_jQuery', \$val);\n"
1285
+        . $prepend_code['insert_head'];
1286
+    $prepend_code['header_prive'] =
1287
+        "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n"
1288
+        . "\$val = minipipe('f_jQuery_prive', \$val);\n"
1289
+        . $prepend_code['header_prive'];
1290
+
1291
+    // on ajoute les pipe qui ont ete recenses manquants
1292
+    foreach ($liste_pipe_manquants as $add_pipe) {
1293
+        if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) {
1294
+            $GLOBALS['spip_pipeline'][$add_pipe] = '';
1295
+        }
1296
+    }
1297
+
1298
+    return $prepend_code;
1299 1299
 }
1300 1300
 
1301 1301
 /**
@@ -1322,62 +1322,62 @@  discard block
 block discarded – undo
1322 1322
 **/
1323 1323
 function pipeline_precompile($prepend_code = []) {
1324 1324
 
1325
-	$all_pipes = $all_pipes_end = '';
1326
-	if (!empty($GLOBALS['spip_pipeline']['all'])) {
1327
-		$a = explode('||', $GLOBALS['spip_pipeline']['all'], 2);
1328
-		unset($GLOBALS['spip_pipeline']['all']);
1329
-		$all_pipes = trim(array_shift($a));
1330
-		if ($all_pipes) {
1331
-			$all_pipes = '|' . ltrim($all_pipes, '|');
1332
-		}
1333
-		if (count($a)) {
1334
-			$all_pipes_end = '||' . array_shift($a);
1335
-		}
1336
-	}
1337
-	$content = '';
1338
-	foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1339
-		$s_inc = '';
1340
-		$s_call = '';
1341
-		if ($all_pipes) {
1342
-			$pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1);
1343
-		}
1344
-		if ($all_pipes_end) {
1345
-			$pipeline .= $all_pipes_end;
1346
-		}
1347
-		$pipe = array_filter(explode('|', $pipeline));
1348
-		// Eclater le pipeline en filtres et appliquer chaque filtre
1349
-		foreach ($pipe as $fonc) {
1350
-			$fonc = trim($fonc);
1351
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1352
-			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1353
-				$file = $GLOBALS['spip_matrice'][$fonc];
1354
-				$file = "'$file'";
1355
-				// si un _DIR_XXX: est dans la chaine, on extrait la constante
1356
-				if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) {
1357
-					$dir = $regs[1];
1358
-					$root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1359
-					if (defined($root_dir)) {
1360
-						$dir = $root_dir;
1361
-					}
1362
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1363
-					$file = str_replace("''.", '', $file);
1364
-					$file = str_replace(constant($dir), '', $file);
1365
-				}
1366
-				$s_inc .= "include_once_check($file);\n";
1367
-			}
1368
-		}
1369
-		if (strlen($s_inc)) {
1370
-			$s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1371
-		}
1372
-		$content .= "// Pipeline $action \n"
1373
-			. "function execute_pipeline_$action(&\$val){\n"
1374
-			. $s_inc
1375
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1376
-			. $s_call
1377
-			. "return \$val;\n}\n";
1378
-	}
1379
-	ecrire_fichier_php(_CACHE_PIPELINES, $content);
1380
-	clear_path_cache();
1325
+    $all_pipes = $all_pipes_end = '';
1326
+    if (!empty($GLOBALS['spip_pipeline']['all'])) {
1327
+        $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2);
1328
+        unset($GLOBALS['spip_pipeline']['all']);
1329
+        $all_pipes = trim(array_shift($a));
1330
+        if ($all_pipes) {
1331
+            $all_pipes = '|' . ltrim($all_pipes, '|');
1332
+        }
1333
+        if (count($a)) {
1334
+            $all_pipes_end = '||' . array_shift($a);
1335
+        }
1336
+    }
1337
+    $content = '';
1338
+    foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) {
1339
+        $s_inc = '';
1340
+        $s_call = '';
1341
+        if ($all_pipes) {
1342
+            $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1);
1343
+        }
1344
+        if ($all_pipes_end) {
1345
+            $pipeline .= $all_pipes_end;
1346
+        }
1347
+        $pipe = array_filter(explode('|', $pipeline));
1348
+        // Eclater le pipeline en filtres et appliquer chaque filtre
1349
+        foreach ($pipe as $fonc) {
1350
+            $fonc = trim($fonc);
1351
+            $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1352
+            if (isset($GLOBALS['spip_matrice'][$fonc])) {
1353
+                $file = $GLOBALS['spip_matrice'][$fonc];
1354
+                $file = "'$file'";
1355
+                // si un _DIR_XXX: est dans la chaine, on extrait la constante
1356
+                if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) {
1357
+                    $dir = $regs[1];
1358
+                    $root_dir = str_replace('_DIR_', '_ROOT_', $dir);
1359
+                    if (defined($root_dir)) {
1360
+                        $dir = $root_dir;
1361
+                    }
1362
+                    $file = str_replace($regs[0], "'." . $dir . ".'", $file);
1363
+                    $file = str_replace("''.", '', $file);
1364
+                    $file = str_replace(constant($dir), '', $file);
1365
+                }
1366
+                $s_inc .= "include_once_check($file);\n";
1367
+            }
1368
+        }
1369
+        if (strlen($s_inc)) {
1370
+            $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n";
1371
+        }
1372
+        $content .= "// Pipeline $action \n"
1373
+            . "function execute_pipeline_$action(&\$val){\n"
1374
+            . $s_inc
1375
+            . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1376
+            . $s_call
1377
+            . "return \$val;\n}\n";
1378
+    }
1379
+    ecrire_fichier_php(_CACHE_PIPELINES, $content);
1380
+    clear_path_cache();
1381 1381
 }
1382 1382
 
1383 1383
 
@@ -1390,12 +1390,12 @@  discard block
 block discarded – undo
1390 1390
  *     true si le plugin est actif, false sinon
1391 1391
 **/
1392 1392
 function plugin_est_installe($plug_path) {
1393
-	$plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : [];
1394
-	if (!$plugin_installes) {
1395
-		return false;
1396
-	}
1393
+    $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : [];
1394
+    if (!$plugin_installes) {
1395
+        return false;
1396
+    }
1397 1397
 
1398
-	return in_array($plug_path, $plugin_installes);
1398
+    return in_array($plug_path, $plugin_installes);
1399 1399
 }
1400 1400
 
1401 1401
 
@@ -1408,46 +1408,46 @@  discard block
 block discarded – undo
1408 1408
  * @uses plugins_installer_dist()
1409 1409
  **/
1410 1410
 function plugin_installes_meta() {
1411
-	if (isset($GLOBALS['fichier_php_compile_recent'])) {
1412
-		// attendre eventuellement l'invalidation du cache opcode
1413
-		spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1414
-	}
1415
-
1416
-	$installer_plugins = charger_fonction('installer', 'plugins');
1417
-	$meta_plug_installes = [];
1418
-	foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1419
-		if ($plug = $resume['dir']) {
1420
-			$infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1421
-			if ($infos) {
1422
-				if (!is_array($infos) or $infos['install_test'][0]) {
1423
-					$meta_plug_installes[] = $plug;
1424
-				}
1425
-				if (is_array($infos)) {
1426
-					[$ok, $trace] = $infos['install_test'];
1427
-					$titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]);
1428
-					$result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec'));
1429
-					if (_IS_CLI) {
1430
-						include_spip('inc/filtres');
1431
-						$trace = ltrim(textebrut($trace) . "\n" . $result);
1432
-						$trace = '    ' . str_replace("\n", "\n    ", $trace);
1433
-						echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1434
-						  $trace,
1435
-						  "\n";
1436
-					}
1437
-					else {
1438
-						include_spip('inc/filtres_boites');
1439
-						echo "<div class='install-plugins svp_retour'>"
1440
-							. boite_ouvrir($titre, ($ok ? 'success' : 'error'))
1441
-							. $trace
1442
-							. "<div class='result'>$result</div>"
1443
-							. boite_fermer()
1444
-							. '</div>';
1445
-					}
1446
-				}
1447
-			}
1448
-		}
1449
-	}
1450
-	ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1411
+    if (isset($GLOBALS['fichier_php_compile_recent'])) {
1412
+        // attendre eventuellement l'invalidation du cache opcode
1413
+        spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
1414
+    }
1415
+
1416
+    $installer_plugins = charger_fonction('installer', 'plugins');
1417
+    $meta_plug_installes = [];
1418
+    foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) {
1419
+        if ($plug = $resume['dir']) {
1420
+            $infos = $installer_plugins($plug, 'install', $resume['dir_type']);
1421
+            if ($infos) {
1422
+                if (!is_array($infos) or $infos['install_test'][0]) {
1423
+                    $meta_plug_installes[] = $plug;
1424
+                }
1425
+                if (is_array($infos)) {
1426
+                    [$ok, $trace] = $infos['install_test'];
1427
+                    $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]);
1428
+                    $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec'));
1429
+                    if (_IS_CLI) {
1430
+                        include_spip('inc/filtres');
1431
+                        $trace = ltrim(textebrut($trace) . "\n" . $result);
1432
+                        $trace = '    ' . str_replace("\n", "\n    ", $trace);
1433
+                        echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1434
+                            $trace,
1435
+                            "\n";
1436
+                    }
1437
+                    else {
1438
+                        include_spip('inc/filtres_boites');
1439
+                        echo "<div class='install-plugins svp_retour'>"
1440
+                            . boite_ouvrir($titre, ($ok ? 'success' : 'error'))
1441
+                            . $trace
1442
+                            . "<div class='result'>$result</div>"
1443
+                            . boite_fermer()
1444
+                            . '</div>';
1445
+                    }
1446
+                }
1447
+            }
1448
+        }
1449
+    }
1450
+    ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non');
1451 1451
 }
1452 1452
 
1453 1453
 /**
@@ -1461,29 +1461,29 @@  discard block
 block discarded – undo
1461 1461
  *     Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante
1462 1462
 **/
1463 1463
 function ecrire_fichier_php($nom, $contenu, $comment = '') {
1464
-	if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1465
-		$GLOBALS['fichier_php_compile_recent'] = 0;
1466
-	}
1467
-
1468
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1469
-	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1470
-	// si pas de modif on ne touche pas au fichier initial
1471
-	if (file_exists($nom)) {
1472
-		if (substr($nom, -4) == '.php') {
1473
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1474
-		}
1475
-		else {
1476
-			$fichier_tmp = $nom . '.tmp';
1477
-		}
1478
-		file_put_contents($fichier_tmp, $contenu);
1479
-		if (md5_file($nom) == md5_file($fichier_tmp)) {
1480
-			$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1481
-			@unlink($fichier_tmp);
1482
-			return;
1483
-		}
1484
-		@unlink($fichier_tmp);
1485
-	}
1486
-	ecrire_fichier($nom, $contenu);
1487
-	$GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1488
-	spip_clear_opcode_cache(realpath($nom));
1464
+    if (!isset($GLOBALS['fichier_php_compile_recent'])) {
1465
+        $GLOBALS['fichier_php_compile_recent'] = 0;
1466
+    }
1467
+
1468
+    $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1469
+    // si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1470
+    // si pas de modif on ne touche pas au fichier initial
1471
+    if (file_exists($nom)) {
1472
+        if (substr($nom, -4) == '.php') {
1473
+            $fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1474
+        }
1475
+        else {
1476
+            $fichier_tmp = $nom . '.tmp';
1477
+        }
1478
+        file_put_contents($fichier_tmp, $contenu);
1479
+        if (md5_file($nom) == md5_file($fichier_tmp)) {
1480
+            $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1481
+            @unlink($fichier_tmp);
1482
+            return;
1483
+        }
1484
+        @unlink($fichier_tmp);
1485
+    }
1486
+    ecrire_fichier($nom, $contenu);
1487
+    $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom));
1488
+    spip_clear_opcode_cache(realpath($nom));
1489 1489
 }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 /** l'adresse du repertoire de telechargement et de decompactage des plugins */
24 24
 if (!defined('_DIR_PLUGINS_AUTO')) {
25
-	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/');
25
+	define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/');
26 26
 }
27 27
 
28 28
 #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins.
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 				if ($dir) {
382 382
 					$dir .= '/';
383 383
 				}
384
-				$dir .= 'procure:' . $procure['nom'];
384
+				$dir .= 'procure:'.$procure['nom'];
385 385
 
386 386
 				$procure['etat'] = '?';
387 387
 				$procure['dir_type'] = $resume['dir_type'];
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		$plug = $resume['dir'];
566 566
 		$k = $infos[$dir_type][$plug];
567 567
 
568
-		$plug = constant($dir_type) . $plug;
568
+		$plug = constant($dir_type).$plug;
569 569
 		if (!isset($msg[$p])) {
570 570
 			if (isset($resume['erreur']) and $resume['erreur']) {
571 571
 				$msg[$p] = [$resume['erreur']];
@@ -608,10 +608,10 @@  discard block
 block discarded – undo
608 608
 		$list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation'];
609 609
 	} elseif (!$raw) {
610 610
 		foreach ($list as $plug => $msg) {
611
-			$list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug])
612
-				. '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>';
611
+			$list[$plug] = '<li>'._T('plugin_impossible_activer', ['plugin' => $plug])
612
+				. '<ul><li>'.implode('</li><li>', $msg).'</li></ul></li>';
613 613
 		}
614
-		$list = '<ul>' . join("\n", $list) . '</ul>';
614
+		$list = '<ul>'.join("\n", $list).'</ul>';
615 615
 	}
616 616
 	if ($raz) {
617 617
 		effacer_meta('plugin_erreur_activation');
@@ -725,13 +725,13 @@  discard block
 block discarded – undo
725 725
 			if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) {
726 726
 				return _T("plugin_{$balise}_{$type}", [
727 727
 					'plugin' => $nom,
728
-					'version' => ' &ge; ' . $minimum
728
+					'version' => ' &ge; '.$minimum
729 729
 				]);
730 730
 			}
731 731
 			if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) {
732 732
 				return _T("plugin_{$balise}_{$type}", [
733 733
 					'plugin' => $nom,
734
-					'version' => ' &gt; ' . $minimum
734
+					'version' => ' &gt; '.$minimum
735 735
 				]);
736 736
 			}
737 737
 		}
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
 			if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) {
741 741
 				return _T("plugin_{$balise}_{$type}", [
742 742
 					'plugin' => $nom,
743
-					'version' => ' &le; ' . $maximum
743
+					'version' => ' &le; '.$maximum
744 744
 				]);
745 745
 			}
746 746
 			if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) {
747 747
 				return _T("plugin_{$balise}_plugin", [
748 748
 					'plugin' => $nom,
749
-					'version' => ' &lt; ' . $maximum
749
+					'version' => ' &lt; '.$maximum
750 750
 				]);
751 751
 			}
752 752
 		}
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 		include_spip('inc/charger_plugin');
766 766
 		$url = '<br />'	. bouton_telechargement_plugin($url, 'lib');
767 767
 	}*/
768
-	return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>";
768
+	return _T('plugin_necessite_lib', ['lib' => $lib])." <a href='$url'>$url</a>";
769 769
 }
770 770
 
771 771
 
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 	foreach ($plugin_valides as $p => $resume) {
866 866
 		// Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP
867 867
 		if (!str_starts_with($p, 'PHP:') and $p !== 'PHP') {
868
-			$header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : '');
868
+			$header[] = $p.($resume['version'] ? '('.$resume['version'].')' : '');
869 869
 		}
870 870
 		if ($resume['dir']) {
871 871
 			foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) {
@@ -890,11 +890,11 @@  discard block
 block discarded – undo
890 890
 	$header = strtolower(implode(',', $header));
891 891
 	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
892 892
 		ecrire_fichier(
893
-			_DIR_VAR . 'config.txt',
894
-			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header
893
+			_DIR_VAR.'config.txt',
894
+			(defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP').' '.$GLOBALS['spip_version_affichee'].' @ www.spip.net + '.$header
895 895
 		);
896 896
 	} else {
897
-		@unlink(_DIR_VAR . 'config.txt');
897
+		@unlink(_DIR_VAR.'config.txt');
898 898
 	}
899 899
 	// generer charger_plugins_chemin.php
900 900
 	plugins_precompile_chemin($plugin_valides, $ordre);
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 			// definir le plugin, donc le path avant l'include du fichier options
949 949
 			// permet de faire des include_spip pour attraper un inc_ du plugin
950 950
 
951
-			$dir = $dir_type . ".'" . $plug . "/'";
951
+			$dir = $dir_type.".'".$plug."/'";
952 952
 
953 953
 			$prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix']));
954 954
 			if (
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 				if (!$info['chemin']) {
960 960
 					$chemins['public'][] = "_DIR_PLUGIN_$prefix";
961 961
 					$chemins['prive'][] = "_DIR_PLUGIN_$prefix";
962
-					if (is_dir(constant($dir_type) . $plug . '/squelettes/')) {
962
+					if (is_dir(constant($dir_type).$plug.'/squelettes/')) {
963 963
 						$chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'";
964 964
 					}
965 965
 				}
@@ -980,13 +980,13 @@  discard block
 block discarded – undo
980 980
 								$dir = '';
981 981
 							}
982 982
 							if (strlen($dir)) {
983
-								$dir = rtrim($dir, '/') . '/';
983
+								$dir = rtrim($dir, '/').'/';
984 984
 							}
985 985
 							if (!isset($chemin['type']) or $chemin['type'] == 'public') {
986
-								$chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
986
+								$chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : '');
987 987
 							}
988 988
 							if (!isset($chemin['type']) or $chemin['type'] == 'prive') {
989
-								$chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : '');
989
+								$chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : '');
990 990
 							}
991 991
 						}
992 992
 					}
@@ -995,11 +995,11 @@  discard block
 block discarded – undo
995 995
 		}
996 996
 	}
997 997
 	if (count($chemins['public']) or count($chemins['prive'])) {
998
-		$contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode(
998
+		$contenu .= 'if (_DIR_RESTREINT) _chemin(['.implode(
999 999
 			',',
1000 1000
 			array_reverse($chemins['public'])
1001
-		) . "]);\n"
1002
-			. 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n";
1001
+		)."]);\n"
1002
+			. 'else _chemin(['.implode(',', array_reverse($chemins['prive']))."]);\n";
1003 1003
 	}
1004 1004
 
1005 1005
 	ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu);
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 					and !str_contains($dir, ':') // exclure le cas des procure:
1049 1049
 					and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml
1050 1050
 				) {
1051
-					if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) {
1051
+					if (is_readable("$dir$plug/".($file = $info['prefix'].'_'.$charge.'.php'))) {
1052 1052
 						$info[$charge] = [$file];
1053 1053
 					}
1054 1054
 				}
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 						) {
1066 1066
 							unset($info[$charge][$k]);
1067 1067
 						} else {
1068
-							$_file = $root_dir_type . ".'$plug/$file'";
1068
+							$_file = $root_dir_type.".'$plug/$file'";
1069 1069
 							$contenu[$charge] .= "include_once_check($_file);\n";
1070 1070
 						}
1071 1071
 					}
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
 		}
1076 1076
 	}
1077 1077
 
1078
-	$contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options'];
1078
+	$contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options'];
1079 1079
 	$contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons)
1080 1080
 		. plugin_ongletbouton('onglets_plugins', $onglets);
1081 1081
 
@@ -1110,12 +1110,12 @@  discard block
 block discarded – undo
1110 1110
 		define("_UPDATED_$nom", $val);
1111 1111
 		define("_UPDATED_md5_$nom", $md5);
1112 1112
 	}
1113
-	$val = "unserialize('" . str_replace("'", "\'", $val) . "')";
1113
+	$val = "unserialize('".str_replace("'", "\'", $val)."')";
1114 1114
 
1115 1115
 	return
1116 1116
 		"if (!function_exists('$nom')) {\n"
1117 1117
 		. "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n"
1118
-		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n"
1118
+		. "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n"
1119 1119
 		. "}\n";
1120 1120
 }
1121 1121
 
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 	if (@is_readable(_CACHE_PLUGINS_OPT)) {
1139 1139
 		include_once(_CACHE_PLUGINS_OPT);
1140 1140
 	} else {
1141
-		spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT);
1141
+		spip_log('pipelines desactives: impossible de produire '._CACHE_PLUGINS_OPT);
1142 1142
 	}
1143 1143
 }
1144 1144
 
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 			$dir_type = $plugin_valides[$p]['dir_type'];
1176 1176
 			$root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type);
1177 1177
 			$plug = $plugin_valides[$p]['dir'];
1178
-			$prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_');
1178
+			$prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'].'_');
1179 1179
 			if (isset($info['pipeline']) and is_array($info['pipeline'])) {
1180 1180
 				foreach ($info['pipeline'] as $pipe) {
1181 1181
 					$nom = $pipe['nom'];
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
 						}
1210 1210
 						if (isset($pipe['inclure'])) {
1211 1211
 							$GLOBALS['spip_matrice']["$prefix$action"] =
1212
-								"$root_dir_type:$plug/" . $pipe['inclure'];
1212
+								"$root_dir_type:$plug/".$pipe['inclure'];
1213 1213
 						}
1214 1214
 					}
1215 1215
 				}
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
 					$prepend_code['taches_generales_cron'] = '';
1220 1220
 				}
1221 1221
 				foreach ($info['genie'] as $genie) {
1222
-					$nom = $prefix . $genie['nom'];
1222
+					$nom = $prefix.$genie['nom'];
1223 1223
 					$periode = max(60, intval($genie['periode']));
1224 1224
 					if (charger_fonction($nom, 'genie', true)) {
1225 1225
 						$prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n";
@@ -1237,13 +1237,13 @@  discard block
 block discarded – undo
1237 1237
 				}
1238 1238
 				foreach ($info['style'] as $style) {
1239 1239
 					if (isset($style['path']) and $style['path']) {
1240
-						$code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) ";
1240
+						$code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) ";
1241 1241
 					} else {
1242
-						$code = "if (\$f='" . addslashes($style['url']) . "') ";
1242
+						$code = "if (\$f='".addslashes($style['url'])."') ";
1243 1243
 					}
1244 1244
 					$code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\"";
1245 1245
 					if (isset($style['media']) and strlen($style['media'])) {
1246
-						$code .= ' media="' . addslashes($style['media']) . '"';
1246
+						$code .= ' media="'.addslashes($style['media']).'"';
1247 1247
 					}
1248 1248
 					$code .= "/>';\n";
1249 1249
 					if ($style['type'] != 'prive') {
@@ -1263,9 +1263,9 @@  discard block
 block discarded – undo
1263 1263
 			if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) {
1264 1264
 				foreach ($info['script'] as $script) {
1265 1265
 					if (isset($script['path']) and $script['path']) {
1266
-						$code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) ";
1266
+						$code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) ";
1267 1267
 					} else {
1268
-						$code = "if (\$f='" . addslashes($script['url']) . "') ";
1268
+						$code = "if (\$f='".addslashes($script['url'])."') ";
1269 1269
 					}
1270 1270
 					$code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n";
1271 1271
 					if ($script['type'] != 'prive') {
@@ -1328,10 +1328,10 @@  discard block
 block discarded – undo
1328 1328
 		unset($GLOBALS['spip_pipeline']['all']);
1329 1329
 		$all_pipes = trim(array_shift($a));
1330 1330
 		if ($all_pipes) {
1331
-			$all_pipes = '|' . ltrim($all_pipes, '|');
1331
+			$all_pipes = '|'.ltrim($all_pipes, '|');
1332 1332
 		}
1333 1333
 		if (count($a)) {
1334
-			$all_pipes_end = '||' . array_shift($a);
1334
+			$all_pipes_end = '||'.array_shift($a);
1335 1335
 		}
1336 1336
 	}
1337 1337
 	$content = '';
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
 		// Eclater le pipeline en filtres et appliquer chaque filtre
1349 1349
 		foreach ($pipe as $fonc) {
1350 1350
 			$fonc = trim($fonc);
1351
-			$s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n";
1351
+			$s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n";
1352 1352
 			if (isset($GLOBALS['spip_matrice'][$fonc])) {
1353 1353
 				$file = $GLOBALS['spip_matrice'][$fonc];
1354 1354
 				$file = "'$file'";
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
 					if (defined($root_dir)) {
1360 1360
 						$dir = $root_dir;
1361 1361
 					}
1362
-					$file = str_replace($regs[0], "'." . $dir . ".'", $file);
1362
+					$file = str_replace($regs[0], "'.".$dir.".'", $file);
1363 1363
 					$file = str_replace("''.", '', $file);
1364 1364
 					$file = str_replace(constant($dir), '', $file);
1365 1365
 				}
@@ -1372,7 +1372,7 @@  discard block
 block discarded – undo
1372 1372
 		$content .= "// Pipeline $action \n"
1373 1373
 			. "function execute_pipeline_$action(&\$val){\n"
1374 1374
 			. $s_inc
1375
-			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '')
1375
+			. ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '')
1376 1376
 			. $s_call
1377 1377
 			. "return \$val;\n}\n";
1378 1378
 	}
@@ -1428,9 +1428,9 @@  discard block
 block discarded – undo
1428 1428
 					$result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec'));
1429 1429
 					if (_IS_CLI) {
1430 1430
 						include_spip('inc/filtres');
1431
-						$trace = ltrim(textebrut($trace) . "\n" . $result);
1432
-						$trace = '    ' . str_replace("\n", "\n    ", $trace);
1433
-						echo "\n" . ($ok ? 'OK  ' : '/!\ ') . textebrut($titre) . "\n",
1431
+						$trace = ltrim(textebrut($trace)."\n".$result);
1432
+						$trace = '    '.str_replace("\n", "\n    ", $trace);
1433
+						echo "\n".($ok ? 'OK  ' : '/!\ ').textebrut($titre)."\n",
1434 1434
 						  $trace,
1435 1435
 						  "\n";
1436 1436
 					}
@@ -1465,15 +1465,15 @@  discard block
 block discarded – undo
1465 1465
 		$GLOBALS['fichier_php_compile_recent'] = 0;
1466 1466
 	}
1467 1467
 
1468
-	$contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>';
1468
+	$contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>';
1469 1469
 	// si un fichier existe deja on verifie que son contenu change avant de l'ecraser
1470 1470
 	// si pas de modif on ne touche pas au fichier initial
1471 1471
 	if (file_exists($nom)) {
1472 1472
 		if (substr($nom, -4) == '.php') {
1473
-			$fichier_tmp = substr($nom, 0, -4) . '.tmp.php';
1473
+			$fichier_tmp = substr($nom, 0, -4).'.tmp.php';
1474 1474
 		}
1475 1475
 		else {
1476
-			$fichier_tmp = $nom . '.tmp';
1476
+			$fichier_tmp = $nom.'.tmp';
1477 1477
 		}
1478 1478
 		file_put_contents($fichier_tmp, $contenu);
1479 1479
 		if (md5_file($nom) == md5_file($fichier_tmp)) {
Please login to merge, or discard this patch.
ecrire/inc/definir_menus_favoris.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,21 +20,21 @@
 block discarded – undo
20 20
  * Retourne la liste des menus favoris par défaut ainsi que leur rang
21 21
  */
22 22
 function inc_definir_menus_favoris_dist() {
23
-	$liste = [
23
+    $liste = [
24 24
 
25
-		// Menu Édition,
26
-		'auteurs' => 1,
27
-		'rubriques' => 2,
28
-		'articles' => 3,
25
+        // Menu Édition,
26
+        'auteurs' => 1,
27
+        'rubriques' => 2,
28
+        'articles' => 3,
29 29
 
30
-		// Menu Maintenance
31
-		'admin_vider' => 1,
30
+        // Menu Maintenance
31
+        'admin_vider' => 1,
32 32
 
33
-		// Menu Configurations
34
-		'configurer_identite' => 1,
35
-		'admin_plugin' => 2,
33
+        // Menu Configurations
34
+        'configurer_identite' => 1,
35
+        'admin_plugin' => 2,
36 36
 
37
-	];
37
+    ];
38 38
 
39
-	return $liste;
39
+    return $liste;
40 40
 }
Please login to merge, or discard this patch.
ecrire/inc/puce_statut.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -416,7 +416,7 @@
 block discarded – undo
416 416
 	$h = generer_action_auteur('instituer_objet', "$type-$id-$statut");
417 417
 	$t = supprimer_tags($titre);
418 418
 
419
-	return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>';
419
+	return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>".http_img_pack($img, $t).'</a>';
420 420
 }
421 421
 
422 422
 // compat
Please login to merge, or discard this patch.
Indentation   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 if (!defined('_ACTIVER_PUCE_RAPIDE')) {
25
-	/**
26
-	 * Activer le changement rapide de statut sur les listes d'objets ?
27
-	 *
28
-	 * Peut ralentir un site sur des listes très longues.
29
-	 *
30
-	 * @var bool
31
-	 **/
32
-	define('_ACTIVER_PUCE_RAPIDE', true);
25
+    /**
26
+     * Activer le changement rapide de statut sur les listes d'objets ?
27
+     *
28
+     * Peut ralentir un site sur des listes très longues.
29
+     *
30
+     * @var bool
31
+     **/
32
+    define('_ACTIVER_PUCE_RAPIDE', true);
33 33
 }
34 34
 
35 35
 /**
@@ -57,31 +57,31 @@  discard block
 block discarded – undo
57 57
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
58 58
  */
59 59
 function inc_puce_statut_dist(
60
-	$id_objet,
61
-	$statut,
62
-	$id_parent,
63
-	$type,
64
-	$ajax = false,
65
-	$menu_rapide = _ACTIVER_PUCE_RAPIDE
60
+    $id_objet,
61
+    $statut,
62
+    $id_parent,
63
+    $type,
64
+    $ajax = false,
65
+    $menu_rapide = _ACTIVER_PUCE_RAPIDE
66 66
 ) {
67
-	static $f_puce_statut = [];
68
-	$type = objet_type($type);
69
-	// cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques
70
-	if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) {
71
-		$f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true);
72
-	}
73
-	if ($f_puce_statut[$type]) {
74
-		return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide);
75
-	}
76
-
77
-	// si statut_image trouve quelque chose (et '' est quelque chose)
78
-	// composer une puce, avec si possible changement rapide
79
-	elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) {
80
-		return $puce;
81
-	} // sinon fausse puce avec le type de l'image
82
-	else {
83
-		return http_img_pack("$type-16.png", '');
84
-	}
67
+    static $f_puce_statut = [];
68
+    $type = objet_type($type);
69
+    // cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques
70
+    if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) {
71
+        $f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true);
72
+    }
73
+    if ($f_puce_statut[$type]) {
74
+        return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide);
75
+    }
76
+
77
+    // si statut_image trouve quelque chose (et '' est quelque chose)
78
+    // composer une puce, avec si possible changement rapide
79
+    elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) {
80
+        return $puce;
81
+    } // sinon fausse puce avec le type de l'image
82
+    else {
83
+        return http_img_pack("$type-16.png", '');
84
+    }
85 85
 }
86 86
 
87 87
 /**
@@ -110,41 +110,41 @@  discard block
 block discarded – undo
110 110
  *   null si pas capable de déterminer l'image
111 111
  */
112 112
 function statut_image($objet, $statut) {
113
-	$src = null;
114
-	$table = table_objet_sql($objet);
115
-	$desc = lister_tables_objets_sql($table);
116
-	if (isset($desc['statut_images'])) {
117
-		// si une declaration statut_images
118
-		// mais rien pour le statut demande, ne rien afficher
119
-		$src = '';
120
-		if (isset($desc['statut_images'][$statut])) {
121
-			$src = $desc['statut_images'][$statut];
122
-		} // sinon image par defaut ?
123
-		elseif (isset($desc['statut_images'][0])) {
124
-			$src = $desc['statut_images'][0];
125
-		}
126
-	} else {
127
-		switch ($statut) {
128
-			case 'prepa':
129
-				$src = 'puce-preparer-xx.svg?12px';
130
-				break;
131
-			case 'prop':
132
-				$src = 'puce-proposer-xx.svg?12px';
133
-				break;
134
-			case 'publie':
135
-				$src = 'puce-publier-xx.svg?12px';
136
-				break;
137
-			case 'refuse':
138
-				$src = 'puce-refuser-xx.svg?12px';
139
-				break;
140
-			case 'poubelle':
141
-			case 'poub':
142
-				$src = 'puce-supprimer-xx.svg?12px';
143
-				break;
144
-		}
145
-	}
146
-
147
-	return $src;
113
+    $src = null;
114
+    $table = table_objet_sql($objet);
115
+    $desc = lister_tables_objets_sql($table);
116
+    if (isset($desc['statut_images'])) {
117
+        // si une declaration statut_images
118
+        // mais rien pour le statut demande, ne rien afficher
119
+        $src = '';
120
+        if (isset($desc['statut_images'][$statut])) {
121
+            $src = $desc['statut_images'][$statut];
122
+        } // sinon image par defaut ?
123
+        elseif (isset($desc['statut_images'][0])) {
124
+            $src = $desc['statut_images'][0];
125
+        }
126
+    } else {
127
+        switch ($statut) {
128
+            case 'prepa':
129
+                $src = 'puce-preparer-xx.svg?12px';
130
+                break;
131
+            case 'prop':
132
+                $src = 'puce-proposer-xx.svg?12px';
133
+                break;
134
+            case 'publie':
135
+                $src = 'puce-publier-xx.svg?12px';
136
+                break;
137
+            case 'refuse':
138
+                $src = 'puce-refuser-xx.svg?12px';
139
+                break;
140
+            case 'poubelle':
141
+            case 'poub':
142
+                $src = 'puce-supprimer-xx.svg?12px';
143
+                break;
144
+        }
145
+    }
146
+
147
+    return $src;
148 148
 }
149 149
 
150 150
 /**
@@ -172,40 +172,40 @@  discard block
 block discarded – undo
172 172
  * @return string
173 173
  */
174 174
 function statut_titre($objet, $statut) {
175
-	$titre = '';
176
-	$table = table_objet_sql($objet);
177
-	$desc = lister_tables_objets_sql($table);
178
-	if (isset($desc['statut_titres'])) {
179
-		// si une declaration statut_titres
180
-		// mais rien pour le statut demande, ne rien afficher
181
-		if (isset($desc['statut_titres'][$statut])) {
182
-			$titre = $desc['statut_titres'][$statut];
183
-		} // sinon image par defaut ?
184
-		elseif (isset($desc['statut_titres'][0])) {
185
-			$titre = $desc['statut_titres'][0];
186
-		}
187
-	} else {
188
-		switch ($statut) {
189
-			case 'prepa':
190
-				$titre = 'texte_statut_en_cours_redaction';
191
-				break;
192
-			case 'prop':
193
-				$titre = 'texte_statut_propose_evaluation';
194
-				break;
195
-			case 'publie':
196
-				$titre = 'texte_statut_publie';
197
-				break;
198
-			case 'refuse':
199
-				$titre = 'texte_statut_refuse';
200
-				break;
201
-			case 'poubelle':
202
-			case 'poub':
203
-				$titre = 'texte_statut_poubelle';
204
-				break;
205
-		}
206
-	}
207
-
208
-	return $titre ? _T($titre) : '';
175
+    $titre = '';
176
+    $table = table_objet_sql($objet);
177
+    $desc = lister_tables_objets_sql($table);
178
+    if (isset($desc['statut_titres'])) {
179
+        // si une declaration statut_titres
180
+        // mais rien pour le statut demande, ne rien afficher
181
+        if (isset($desc['statut_titres'][$statut])) {
182
+            $titre = $desc['statut_titres'][$statut];
183
+        } // sinon image par defaut ?
184
+        elseif (isset($desc['statut_titres'][0])) {
185
+            $titre = $desc['statut_titres'][0];
186
+        }
187
+    } else {
188
+        switch ($statut) {
189
+            case 'prepa':
190
+                $titre = 'texte_statut_en_cours_redaction';
191
+                break;
192
+            case 'prop':
193
+                $titre = 'texte_statut_propose_evaluation';
194
+                break;
195
+            case 'publie':
196
+                $titre = 'texte_statut_publie';
197
+                break;
198
+            case 'refuse':
199
+                $titre = 'texte_statut_refuse';
200
+                break;
201
+            case 'poubelle':
202
+            case 'poub':
203
+                $titre = 'texte_statut_poubelle';
204
+                break;
205
+        }
206
+    }
207
+
208
+    return $titre ? _T($titre) : '';
209 209
 }
210 210
 
211 211
 
@@ -225,37 +225,37 @@  discard block
 block discarded – undo
225 225
  * @return string
226 226
  */
227 227
 function statut_texte_instituer($objet, $statut) {
228
-	$texte = '';
229
-	$table = table_objet_sql($objet);
230
-	$desc = lister_tables_objets_sql($table);
231
-	if (isset($desc['statut_textes_instituer'])) {
232
-		// si une declaration statut_titres
233
-		// mais rien pour le statut demande, ne rien afficher
234
-		if (isset($desc['statut_textes_instituer'][$statut])) {
235
-			$texte = $desc['statut_textes_instituer'][$statut];
236
-		}
237
-	} else {
238
-		switch ($statut) {
239
-			case 'prepa':
240
-				$texte = 'texte_statut_en_cours_redaction';
241
-				break;
242
-			case 'prop':
243
-				$texte = 'texte_statut_propose_evaluation';
244
-				break;
245
-			case 'publie':
246
-				$texte = 'texte_statut_publie';
247
-				break;
248
-			case 'refuse':
249
-				$texte = 'texte_statut_refuse';
250
-				break;
251
-			case 'poubelle':
252
-			case 'poub':
253
-				$texte = 'texte_statut_poubelle';
254
-				break;
255
-		}
256
-	}
257
-
258
-	return $texte ? _T($texte) : '';
228
+    $texte = '';
229
+    $table = table_objet_sql($objet);
230
+    $desc = lister_tables_objets_sql($table);
231
+    if (isset($desc['statut_textes_instituer'])) {
232
+        // si une declaration statut_titres
233
+        // mais rien pour le statut demande, ne rien afficher
234
+        if (isset($desc['statut_textes_instituer'][$statut])) {
235
+            $texte = $desc['statut_textes_instituer'][$statut];
236
+        }
237
+    } else {
238
+        switch ($statut) {
239
+            case 'prepa':
240
+                $texte = 'texte_statut_en_cours_redaction';
241
+                break;
242
+            case 'prop':
243
+                $texte = 'texte_statut_propose_evaluation';
244
+                break;
245
+            case 'publie':
246
+                $texte = 'texte_statut_publie';
247
+                break;
248
+            case 'refuse':
249
+                $texte = 'texte_statut_refuse';
250
+                break;
251
+            case 'poubelle':
252
+            case 'poub':
253
+                $texte = 'texte_statut_poubelle';
254
+                break;
255
+        }
256
+    }
257
+
258
+    return $texte ? _T($texte) : '';
259 259
 }
260 260
 
261 261
 
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
  * @return string
276 276
  */
277 277
 function puce_statut_auteur_dist($id, $statut, $id_parent, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) {
278
-	$img = statut_image('auteur', $statut);
279
-	if (!$img) {
280
-		return '';
281
-	}
282
-	$alt = statut_titre('auteur', $statut);
278
+    $img = statut_image('auteur', $statut);
279
+    if (!$img) {
280
+        return '';
281
+    }
282
+    $alt = statut_titre('auteur', $statut);
283 283
 
284
-	$fond = '';
285
-	$titre = '';
284
+    $fond = '';
285
+    $titre = '';
286 286
 
287
-	/*
287
+    /*
288 288
 	if ($type != 'auteur') {
289 289
 	  $img2 = chemin_image('del-16.png');
290 290
 	  $titre = _T('titre_image_redacteur');
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 	}
295 295
 	*/
296 296
 
297
-	return http_img_pack($img, $alt, $fond, $alt);
297
+    return http_img_pack($img, $alt, $fond, $alt);
298 298
 }
299 299
 
300 300
 
301 301
 function puce_statut_rubrique_dist($id, $statut, $id_rubrique, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) {
302
-	return http_img_pack('rubrique-16.png', '');
302
+    return http_img_pack('rubrique-16.png', '');
303 303
 }
304 304
 
305 305
 /**
@@ -323,110 +323,110 @@  discard block
 block discarded – undo
323 323
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
324 324
  **/
325 325
 function puce_statut_changement_rapide(
326
-	$id,
327
-	$statut,
328
-	$id_rubrique,
329
-	$type = 'article',
330
-	$ajax = false,
331
-	$menu_rapide = _ACTIVER_PUCE_RAPIDE
326
+    $id,
327
+    $statut,
328
+    $id_rubrique,
329
+    $type = 'article',
330
+    $ajax = false,
331
+    $menu_rapide = _ACTIVER_PUCE_RAPIDE
332 332
 ) {
333
-	$src = statut_image($type, $statut);
334
-	if (!$src) {
335
-		return $src;
336
-	}
337
-
338
-	if (
339
-		!$id
340
-		or !_SPIP_AJAX
341
-		or !$menu_rapide
342
-	) {
343
-		$ajax_node = '';
344
-	} else {
345
-		$ajax_node = " class='imgstatut$type$id'";
346
-	}
347
-
348
-
349
-	$t = statut_titre($type, $statut);
350
-	$inser_puce = http_img_pack($src, $t, $ajax_node, $t);
351
-
352
-	if (!$ajax_node) {
353
-		return $inser_puce;
354
-	}
355
-
356
-	$table = table_objet_sql($type);
357
-	$desc = lister_tables_objets_sql($table);
358
-	if (!isset($desc['statut_textes_instituer'])) {
359
-		return $inser_puce;
360
-	}
361
-
362
-	if (!function_exists('autoriser')) {
363
-		include_spip('inc/autoriser');
364
-	}
365
-
366
-	// cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique)
367
-	if ($id_rubrique) {
368
-		if (!autoriser('publierdans', 'rubrique', $id_rubrique)) {
369
-			return $inser_puce;
370
-		}
371
-	} // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie
372
-	else {
373
-		if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) {
374
-			return $inser_puce;
375
-		}
376
-	}
377
-
378
-	$coord = array_flip(array_keys($desc['statut_textes_instituer']));
379
-	if (!isset($coord[$statut])) {
380
-		return $inser_puce;
381
-	}
382
-
383
-	$unit = 18/*widh de img*/ + 0/*padding*/
384
-	;
385
-	$margin = 0; /* marge a gauche + droite */
386
-	$zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/
387
-	;
388
-	$clip = $zero + ($unit * $coord[$statut]);
389
-
390
-	if ($ajax) {
391
-		$width = $unit * (is_countable($desc['statut_textes_instituer']) ? count($desc['statut_textes_instituer']) : 0) + $margin;
392
-		$out = "<span class='puce_objet_fixe $type'>"
393
-			. $inser_puce
394
-			. '</span>'
395
-			. "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
396
-		$i = 0;
397
-		foreach ($desc['statut_textes_instituer'] as $s => $t) {
398
-			$out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t));
399
-		}
400
-		$out .= '</span>';
401
-
402
-		return $out;
403
-	} else {
404
-		$nom = 'puce_statut_';
405
-		$action = generer_url_ecrire('puce_statut', '', true);
406
-		$lang_dir = lang_dir(lang_typo());
407
-
408
-		return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>"
409
-		. $inser_puce
410
-		. '</span>';
411
-	}
333
+    $src = statut_image($type, $statut);
334
+    if (!$src) {
335
+        return $src;
336
+    }
337
+
338
+    if (
339
+        !$id
340
+        or !_SPIP_AJAX
341
+        or !$menu_rapide
342
+    ) {
343
+        $ajax_node = '';
344
+    } else {
345
+        $ajax_node = " class='imgstatut$type$id'";
346
+    }
347
+
348
+
349
+    $t = statut_titre($type, $statut);
350
+    $inser_puce = http_img_pack($src, $t, $ajax_node, $t);
351
+
352
+    if (!$ajax_node) {
353
+        return $inser_puce;
354
+    }
355
+
356
+    $table = table_objet_sql($type);
357
+    $desc = lister_tables_objets_sql($table);
358
+    if (!isset($desc['statut_textes_instituer'])) {
359
+        return $inser_puce;
360
+    }
361
+
362
+    if (!function_exists('autoriser')) {
363
+        include_spip('inc/autoriser');
364
+    }
365
+
366
+    // cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique)
367
+    if ($id_rubrique) {
368
+        if (!autoriser('publierdans', 'rubrique', $id_rubrique)) {
369
+            return $inser_puce;
370
+        }
371
+    } // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie
372
+    else {
373
+        if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) {
374
+            return $inser_puce;
375
+        }
376
+    }
377
+
378
+    $coord = array_flip(array_keys($desc['statut_textes_instituer']));
379
+    if (!isset($coord[$statut])) {
380
+        return $inser_puce;
381
+    }
382
+
383
+    $unit = 18/*widh de img*/ + 0/*padding*/
384
+    ;
385
+    $margin = 0; /* marge a gauche + droite */
386
+    $zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/
387
+    ;
388
+    $clip = $zero + ($unit * $coord[$statut]);
389
+
390
+    if ($ajax) {
391
+        $width = $unit * (is_countable($desc['statut_textes_instituer']) ? count($desc['statut_textes_instituer']) : 0) + $margin;
392
+        $out = "<span class='puce_objet_fixe $type'>"
393
+            . $inser_puce
394
+            . '</span>'
395
+            . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>";
396
+        $i = 0;
397
+        foreach ($desc['statut_textes_instituer'] as $s => $t) {
398
+            $out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t));
399
+        }
400
+        $out .= '</span>';
401
+
402
+        return $out;
403
+    } else {
404
+        $nom = 'puce_statut_';
405
+        $action = generer_url_ecrire('puce_statut', '', true);
406
+        $lang_dir = lang_dir(lang_typo());
407
+
408
+        return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>"
409
+        . $inser_puce
410
+        . '</span>';
411
+    }
412 412
 }
413 413
 
414 414
 
415 415
 function afficher_script_statut($id, $type, $n, $img, $statut, $titre, $act = '') {
416
-	$h = generer_action_auteur('instituer_objet', "$type-$id-$statut");
417
-	$t = supprimer_tags($titre);
416
+    $h = generer_action_auteur('instituer_objet', "$type-$id-$statut");
417
+    $t = supprimer_tags($titre);
418 418
 
419
-	return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>';
419
+    return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>';
420 420
 }
421 421
 
422 422
 // compat
423 423
 // La couleur du statut
424 424
 
425 425
 function puce_statut($statut, $atts = '') {
426
-	$src = statut_image('article', $statut);
427
-	if (!$src) {
428
-		return '';
429
-	}
426
+    $src = statut_image('article', $statut);
427
+    if (!$src) {
428
+        return '';
429
+    }
430 430
 
431
-	return http_img_pack($src, statut_titre('article', $statut), $atts);
431
+    return http_img_pack($src, statut_titre('article', $statut), $atts);
432 432
 }
Please login to merge, or discard this patch.
ecrire/inc/boutons.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 			&& autoriser('onglet', "_$id")
103 103
 		) {
104 104
 			$onglets[$id] = new Bouton(
105
-				isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
106
-				$infos['titre'],  // titre
105
+				isset($infos['icone']) ? find_in_theme($infos['icone']) : '', // icone
106
+				$infos['titre'], // titre
107 107
 				(isset($infos['action']) and $infos['action'])
108 108
 					? generer_url_ecrire(
109 109
 						$infos['action'],
@@ -142,5 +142,5 @@  discard block
 block discarded – undo
142 142
 		$res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
143 143
 	}
144 144
 
145
-	return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
145
+	return !$res ? '' : (debut_onglet($class).$res.fin_onglet());
146 146
 }
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  */
20 20
 
21 21
 if (!defined('_ECRIRE_INC_VERSION')) {
22
-	return;
22
+    return;
23 23
 }
24 24
 
25 25
 /**
@@ -35,35 +35,35 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function definir_barre_onglets($script) {
37 37
 
38
-	$onglets = [];
39
-	$liste_onglets = [];
38
+    $onglets = [];
39
+    $liste_onglets = [];
40 40
 
41
-	// ajouter les onglets issus des plugin via paquet.xml
42
-	if (function_exists('onglets_plugins')) {
43
-		$liste_onglets = onglets_plugins();
44
-	}
41
+    // ajouter les onglets issus des plugin via paquet.xml
42
+    if (function_exists('onglets_plugins')) {
43
+        $liste_onglets = onglets_plugins();
44
+    }
45 45
 
46 46
 
47
-	foreach ($liste_onglets as $id => $infos) {
48
-		if (
49
-			($parent = $infos['parent'])
50
-			&& $parent == $script
51
-			&& autoriser('onglet', "_$id")
52
-		) {
53
-			$onglets[$id] = new Bouton(
54
-				isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
55
-				$infos['titre'],  // titre
56
-				(isset($infos['action']) and $infos['action'])
57
-					? generer_url_ecrire(
58
-						$infos['action'],
59
-						(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : ''
60
-					)
61
-					: null
62
-			);
63
-		}
64
-	}
47
+    foreach ($liste_onglets as $id => $infos) {
48
+        if (
49
+            ($parent = $infos['parent'])
50
+            && $parent == $script
51
+            && autoriser('onglet', "_$id")
52
+        ) {
53
+            $onglets[$id] = new Bouton(
54
+                isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
55
+                $infos['titre'],  // titre
56
+                (isset($infos['action']) and $infos['action'])
57
+                    ? generer_url_ecrire(
58
+                        $infos['action'],
59
+                        (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : ''
60
+                    )
61
+                    : null
62
+            );
63
+        }
64
+    }
65 65
 
66
-	return pipeline('ajouter_onglets', ['data' => $onglets, 'args' => $script]);
66
+    return pipeline('ajouter_onglets', ['data' => $onglets, 'args' => $script]);
67 67
 }
68 68
 
69 69
 /**
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
  * @return string
82 82
  */
83 83
 function barre_onglets($rubrique, $ongletCourant, $class = 'barre_onglet') {
84
-	include_spip('inc/presentation');
84
+    include_spip('inc/presentation');
85 85
 
86
-	$res = '';
86
+    $res = '';
87 87
 
88
-	foreach (definir_barre_onglets($rubrique) as $exec => $onglet) {
89
-		$url = $onglet->url ?: generer_url_ecrire($exec);
90
-		$res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
91
-	}
88
+    foreach (definir_barre_onglets($rubrique) as $exec => $onglet) {
89
+        $url = $onglet->url ?: generer_url_ecrire($exec);
90
+        $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
91
+    }
92 92
 
93
-	return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
93
+    return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
94 94
 }
Please login to merge, or discard this patch.
ecrire/inc/recherche_to_array.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		$_id_table = reset($_id_table);
68 68
 	}
69 69
 
70
-	$requete['SELECT'][] = 't.' . $_id_table;
70
+	$requete['SELECT'][] = 't.'.$_id_table;
71 71
 	$a = [];
72 72
 	// Recherche fulltext
73 73
 	foreach ($champs as $champ => $poids) {
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 				$champ = "t.$champ";
79 79
 			}
80 80
 			$requete['SELECT'][] = $champ;
81
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
81
+			$a[] = $champ.' '.$methode.' '.$q;
82 82
 		}
83 83
 	}
84 84
 	if ($a) {
85 85
 		$requete['WHERE'][] = join(' OR ', $a);
86 86
 	}
87
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
87
+	$requete['FROM'][] = table_objet_sql($table).' AS t';
88 88
 
89 89
 	$results = [];
90 90
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 					);
253 253
 				} // cas table de liaison generique spip_xxx_yyy
254 254
 				elseif (
255
-					$t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
-					or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
255
+					$t = $trouver_table($table_arrivee.'_'.$table_depart, $serveur)
256
+					or $t = $trouver_table($table_depart.'_'.$table_arrivee, $serveur)
257 257
 				) {
258 258
 					$s = sql_select(
259 259
 						"$cle_depart,$cle_arrivee",
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
 				}
293 293
 				if (isset($joint['champs']) and $joint['champs']) {
294 294
 					foreach ($joint['champs'] as $c => $val) {
295
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
295
+						$results[$id]['champs'][$table_liee.'.'.$c] = $val;
296 296
 					}
297 297
 				}
298 298
 				if (isset($joint['matches']) and $joint['matches']) {
299 299
 					foreach ($joint['matches'] as $c => $val) {
300
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
300
+						$results[$id]['matches'][$table_liee.'.'.$c] = $val;
301 301
 					}
302 302
 				}
303 303
 			}
Please login to merge, or discard this patch.
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -11,298 +11,298 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 
18 18
 // methodes sql
19 19
 function inc_recherche_to_array_dist($recherche, $options = []) {
20 20
 
21
-	// options par defaut
22
-	$options = array_merge(
23
-		[
24
-			'score' => true,
25
-			'champs' => false,
26
-			'toutvoir' => false,
27
-			'matches' => false,
28
-			'jointures' => false
29
-		],
30
-		$options
31
-	);
21
+    // options par defaut
22
+    $options = array_merge(
23
+        [
24
+            'score' => true,
25
+            'champs' => false,
26
+            'toutvoir' => false,
27
+            'matches' => false,
28
+            'jointures' => false
29
+        ],
30
+        $options
31
+    );
32 32
 
33
-	include_spip('inc/rechercher');
34
-	include_spip('inc/autoriser');
33
+    include_spip('inc/rechercher');
34
+    include_spip('inc/autoriser');
35 35
 
36
-	$requete = [
37
-		'SELECT' => [],
38
-		'FROM' => [],
39
-		'WHERE' => [],
40
-		'GROUPBY' => [],
41
-		'ORDERBY' => [],
42
-		'LIMIT' => '',
43
-		'HAVING' => []
44
-	];
36
+    $requete = [
37
+        'SELECT' => [],
38
+        'FROM' => [],
39
+        'WHERE' => [],
40
+        'GROUPBY' => [],
41
+        'ORDERBY' => [],
42
+        'LIMIT' => '',
43
+        'HAVING' => []
44
+    ];
45 45
 
46
-	$table = sinon($options['table'], 'article');
47
-	if ($options['champs']) {
48
-		$champs = $options['champs'];
49
-	} else {
50
-		$l = liste_des_champs();
51
-		$champs = $l['article'];
52
-	}
53
-	$serveur = $options['serveur'];
46
+    $table = sinon($options['table'], 'article');
47
+    if ($options['champs']) {
48
+        $champs = $options['champs'];
49
+    } else {
50
+        $l = liste_des_champs();
51
+        $champs = $l['article'];
52
+    }
53
+    $serveur = $options['serveur'];
54 54
 
55
-	[$methode, $q, $preg] = expression_recherche($recherche, $options);
55
+    [$methode, $q, $preg] = expression_recherche($recherche, $options);
56 56
 
57
-	$jointures = $options['jointures']
58
-		? liste_des_jointures()
59
-		: [];
57
+    $jointures = $options['jointures']
58
+        ? liste_des_jointures()
59
+        : [];
60 60
 
61
-	$_id_table = id_table_objet($table);
61
+    $_id_table = id_table_objet($table);
62 62
 
63
-	// c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
64
-	// (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
65
-	if (strpos($_id_table, ',') !== false) {
66
-		$_id_table = explode(',', $_id_table);
67
-		$_id_table = reset($_id_table);
68
-	}
63
+    // c'est un pis-aller : ca a peu de chance de marcher, mais mieux quand meme que en conservant la ','
64
+    // (aka ca marche au moins dans certains cas comme avec spip_formulaires_reponses_champs)
65
+    if (strpos($_id_table, ',') !== false) {
66
+        $_id_table = explode(',', $_id_table);
67
+        $_id_table = reset($_id_table);
68
+    }
69 69
 
70
-	$requete['SELECT'][] = 't.' . $_id_table;
71
-	$a = [];
72
-	// Recherche fulltext
73
-	foreach ($champs as $champ => $poids) {
74
-		if (is_array($champ)) {
75
-			spip_log('requetes imbriquees interdites');
76
-		} else {
77
-			if (strpos($champ, '.') === false) {
78
-				$champ = "t.$champ";
79
-			}
80
-			$requete['SELECT'][] = $champ;
81
-			$a[] = $champ . ' ' . $methode . ' ' . $q;
82
-		}
83
-	}
84
-	if ($a) {
85
-		$requete['WHERE'][] = join(' OR ', $a);
86
-	}
87
-	$requete['FROM'][] = table_objet_sql($table) . ' AS t';
70
+    $requete['SELECT'][] = 't.' . $_id_table;
71
+    $a = [];
72
+    // Recherche fulltext
73
+    foreach ($champs as $champ => $poids) {
74
+        if (is_array($champ)) {
75
+            spip_log('requetes imbriquees interdites');
76
+        } else {
77
+            if (strpos($champ, '.') === false) {
78
+                $champ = "t.$champ";
79
+            }
80
+            $requete['SELECT'][] = $champ;
81
+            $a[] = $champ . ' ' . $methode . ' ' . $q;
82
+        }
83
+    }
84
+    if ($a) {
85
+        $requete['WHERE'][] = join(' OR ', $a);
86
+    }
87
+    $requete['FROM'][] = table_objet_sql($table) . ' AS t';
88 88
 
89
-	$results = [];
89
+    $results = [];
90 90
 
91
-	$s = sql_select(
92
-		$requete['SELECT'],
93
-		$requete['FROM'],
94
-		$requete['WHERE'],
95
-		implode(' ', $requete['GROUPBY']),
96
-		$requete['ORDERBY'],
97
-		$requete['LIMIT'],
98
-		$requete['HAVING'],
99
-		$serveur
100
-	);
91
+    $s = sql_select(
92
+        $requete['SELECT'],
93
+        $requete['FROM'],
94
+        $requete['WHERE'],
95
+        implode(' ', $requete['GROUPBY']),
96
+        $requete['ORDERBY'],
97
+        $requete['LIMIT'],
98
+        $requete['HAVING'],
99
+        $serveur
100
+    );
101 101
 
102
-	while (
103
-		$t = sql_fetch($s, $serveur)
104
-		and (!isset($t['score']) or $t['score'] > 0)
105
-	) {
106
-		$id = intval($t[$_id_table]);
102
+    while (
103
+        $t = sql_fetch($s, $serveur)
104
+        and (!isset($t['score']) or $t['score'] > 0)
105
+    ) {
106
+        $id = intval($t[$_id_table]);
107 107
 
108
-		if (
109
-			$options['toutvoir']
110
-			or autoriser('voir', $table, $id)
111
-		) {
112
-			// indiquer les champs concernes
113
-			$champs_vus = [];
114
-			$score = 0;
115
-			$matches = [];
108
+        if (
109
+            $options['toutvoir']
110
+            or autoriser('voir', $table, $id)
111
+        ) {
112
+            // indiquer les champs concernes
113
+            $champs_vus = [];
114
+            $score = 0;
115
+            $matches = [];
116 116
 
117
-			$vu = false;
118
-			foreach ($champs as $champ => $poids) {
119
-				$champ = explode('.', $champ);
120
-				$champ = end($champ);
121
-				// translitteration_rapide uniquement si on est deja en utf-8
122
-				$value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
123
-				if (
124
-					$n =
125
-					($options['score'] || $options['matches'])
126
-						? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
127
-						: preg_match($preg, $value)
128
-				) {
129
-					$vu = true;
117
+            $vu = false;
118
+            foreach ($champs as $champ => $poids) {
119
+                $champ = explode('.', $champ);
120
+                $champ = end($champ);
121
+                // translitteration_rapide uniquement si on est deja en utf-8
122
+                $value = ($GLOBALS['meta']['charset'] == 'utf-8' ? translitteration_rapide($t[$champ]) : translitteration($t[$champ]));
123
+                if (
124
+                    $n =
125
+                    ($options['score'] || $options['matches'])
126
+                        ? preg_match_all($preg, $value, $regs, PREG_SET_ORDER)
127
+                        : preg_match($preg, $value)
128
+                ) {
129
+                    $vu = true;
130 130
 
131
-					if ($options['champs']) {
132
-						$champs_vus[$champ] = $t[$champ];
133
-					}
134
-					if ($options['score']) {
135
-						// compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
136
-						$score += $poids * strlen(implode('', array_column($regs, 0)));
137
-					}
131
+                    if ($options['champs']) {
132
+                        $champs_vus[$champ] = $t[$champ];
133
+                    }
134
+                    if ($options['score']) {
135
+                        // compter les points avec un peu de discernement : on pondere par la longueur du match compte en chars
136
+                        $score += $poids * strlen(implode('', array_column($regs, 0)));
137
+                    }
138 138
 
139
-					if ($options['matches']) {
140
-						$matches[$champ] = $regs;
141
-					}
139
+                    if ($options['matches']) {
140
+                        $matches[$champ] = $regs;
141
+                    }
142 142
 
143
-					if (
144
-						!$options['champs']
145
-						and !$options['score']
146
-						and !$options['matches']
147
-					) {
148
-						break;
149
-					}
150
-				}
151
-			}
143
+                    if (
144
+                        !$options['champs']
145
+                        and !$options['score']
146
+                        and !$options['matches']
147
+                    ) {
148
+                        break;
149
+                    }
150
+                }
151
+            }
152 152
 
153
-			if ($vu) {
154
-				if (!isset($results)) {
155
-					$results = [];
156
-				}
157
-				$results[$id] = [];
158
-				if ($champs_vus) {
159
-					$results[$id]['champs'] = $champs_vus;
160
-				}
161
-				if ($score) {
162
-					$results[$id]['score'] = $score;
163
-				}
164
-				if ($matches) {
165
-					$results[$id]['matches'] = $matches;
166
-				}
167
-			}
168
-		}
169
-	}
153
+            if ($vu) {
154
+                if (!isset($results)) {
155
+                    $results = [];
156
+                }
157
+                $results[$id] = [];
158
+                if ($champs_vus) {
159
+                    $results[$id]['champs'] = $champs_vus;
160
+                }
161
+                if ($score) {
162
+                    $results[$id]['score'] = $score;
163
+                }
164
+                if ($matches) {
165
+                    $results[$id]['matches'] = $matches;
166
+                }
167
+            }
168
+        }
169
+    }
170 170
 
171 171
 
172
-	// Gerer les donnees associees
173
-	// ici on est un peu naze : pas capables de reconstruire une jointure complexe
174
-	// on ne sait passer que par table de laison en 1 coup
175
-	if (
176
-		isset($jointures[$table])
177
-		and $joints = recherche_en_base(
178
-			$recherche,
179
-			$jointures[$table],
180
-			array_merge($options, ['jointures' => false])
181
-		)
182
-	) {
183
-		include_spip('action/editer_liens');
184
-		$trouver_table = charger_fonction('trouver_table', 'base');
185
-		$cle_depart = id_table_objet($table);
186
-		$table_depart = table_objet($table, $serveur);
187
-		$desc_depart = $trouver_table($table_depart, $serveur);
188
-		$depart_associable = objet_associable($table);
189
-		foreach ($joints as $table_liee => $ids_trouves) {
190
-			// on peut definir une fonction de recherche jointe pour regler les cas particuliers
191
-			if (
192
-				!(
193
-				$rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true)
194
-				or $rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true)
195
-				or $rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true)
196
-				)
197
-			) {
198
-				$cle_arrivee = id_table_objet($table_liee);
199
-				$table_arrivee = table_objet($table_liee, $serveur);
200
-				$desc_arrivee = $trouver_table($table_arrivee, $serveur);
201
-				// cas simple : $cle_depart dans la table_liee
202
-				if (isset($desc_arrivee['field'][$cle_depart])) {
203
-					$s = sql_select(
204
-						"$cle_depart, $cle_arrivee",
205
-						$desc_arrivee['table_sql'],
206
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
207
-						'',
208
-						'',
209
-						'',
210
-						'',
211
-						$serveur
212
-					);
213
-				} // cas simple : $cle_arrivee dans la table
214
-				elseif (isset($desc_depart['field'][$cle_arrivee])) {
215
-					$s = sql_select(
216
-						"$cle_depart, $cle_arrivee",
217
-						$desc_depart['table_sql'],
218
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
219
-						'',
220
-						'',
221
-						'',
222
-						'',
223
-						$serveur
224
-					);
225
-				}
226
-				// sinon cherchons une table de liaison
227
-				// cas recherche principale article, objet lie document : passer par spip_documents_liens
228
-				elseif ($l = objet_associable($table_liee)) {
229
-					[$primary, $table_liens] = $l;
230
-					$s = sql_select(
231
-						"id_objet as $cle_depart, $primary as $cle_arrivee",
232
-						$table_liens,
233
-						["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
234
-						'',
235
-						'',
236
-						'',
237
-						'',
238
-						$serveur
239
-					);
240
-				} // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
241
-				elseif ($l = $depart_associable) {
242
-					[$primary, $table_liens] = $l;
243
-					$s = sql_select(
244
-						"$primary as $cle_depart, id_objet as $cle_arrivee",
245
-						$table_liens,
246
-						["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
247
-						'',
248
-						'',
249
-						'',
250
-						'',
251
-						$serveur
252
-					);
253
-				} // cas table de liaison generique spip_xxx_yyy
254
-				elseif (
255
-					$t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
-					or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
257
-				) {
258
-					$s = sql_select(
259
-						"$cle_depart,$cle_arrivee",
260
-						$t['table_sql'],
261
-						sql_in($cle_arrivee, array_keys($ids_trouves)),
262
-						'',
263
-						'',
264
-						'',
265
-						'',
266
-						$serveur
267
-					);
268
-				}
269
-			} else {
270
-				[$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
271
-					$table,
272
-					$table_liee,
273
-					array_keys($ids_trouves),
274
-					$serveur
275
-				);
276
-			}
172
+    // Gerer les donnees associees
173
+    // ici on est un peu naze : pas capables de reconstruire une jointure complexe
174
+    // on ne sait passer que par table de laison en 1 coup
175
+    if (
176
+        isset($jointures[$table])
177
+        and $joints = recherche_en_base(
178
+            $recherche,
179
+            $jointures[$table],
180
+            array_merge($options, ['jointures' => false])
181
+        )
182
+    ) {
183
+        include_spip('action/editer_liens');
184
+        $trouver_table = charger_fonction('trouver_table', 'base');
185
+        $cle_depart = id_table_objet($table);
186
+        $table_depart = table_objet($table, $serveur);
187
+        $desc_depart = $trouver_table($table_depart, $serveur);
188
+        $depart_associable = objet_associable($table);
189
+        foreach ($joints as $table_liee => $ids_trouves) {
190
+            // on peut definir une fonction de recherche jointe pour regler les cas particuliers
191
+            if (
192
+                !(
193
+                $rechercher_joints = charger_fonction("rechercher_joints_{$table}_{$table_liee}", 'inc', true)
194
+                or $rechercher_joints = charger_fonction("rechercher_joints_objet_{$table_liee}", 'inc', true)
195
+                or $rechercher_joints = charger_fonction("rechercher_joints_{$table}_objet_lie", 'inc', true)
196
+                )
197
+            ) {
198
+                $cle_arrivee = id_table_objet($table_liee);
199
+                $table_arrivee = table_objet($table_liee, $serveur);
200
+                $desc_arrivee = $trouver_table($table_arrivee, $serveur);
201
+                // cas simple : $cle_depart dans la table_liee
202
+                if (isset($desc_arrivee['field'][$cle_depart])) {
203
+                    $s = sql_select(
204
+                        "$cle_depart, $cle_arrivee",
205
+                        $desc_arrivee['table_sql'],
206
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
207
+                        '',
208
+                        '',
209
+                        '',
210
+                        '',
211
+                        $serveur
212
+                    );
213
+                } // cas simple : $cle_arrivee dans la table
214
+                elseif (isset($desc_depart['field'][$cle_arrivee])) {
215
+                    $s = sql_select(
216
+                        "$cle_depart, $cle_arrivee",
217
+                        $desc_depart['table_sql'],
218
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
219
+                        '',
220
+                        '',
221
+                        '',
222
+                        '',
223
+                        $serveur
224
+                    );
225
+                }
226
+                // sinon cherchons une table de liaison
227
+                // cas recherche principale article, objet lie document : passer par spip_documents_liens
228
+                elseif ($l = objet_associable($table_liee)) {
229
+                    [$primary, $table_liens] = $l;
230
+                    $s = sql_select(
231
+                        "id_objet as $cle_depart, $primary as $cle_arrivee",
232
+                        $table_liens,
233
+                        ["objet='$table'", sql_in($primary, array_keys($ids_trouves))],
234
+                        '',
235
+                        '',
236
+                        '',
237
+                        '',
238
+                        $serveur
239
+                    );
240
+                } // cas recherche principale auteur, objet lie article: passer par spip_auteurs_liens
241
+                elseif ($l = $depart_associable) {
242
+                    [$primary, $table_liens] = $l;
243
+                    $s = sql_select(
244
+                        "$primary as $cle_depart, id_objet as $cle_arrivee",
245
+                        $table_liens,
246
+                        ["objet='$table_liee'", sql_in('id_objet', array_keys($ids_trouves))],
247
+                        '',
248
+                        '',
249
+                        '',
250
+                        '',
251
+                        $serveur
252
+                    );
253
+                } // cas table de liaison generique spip_xxx_yyy
254
+                elseif (
255
+                    $t = $trouver_table($table_arrivee . '_' . $table_depart, $serveur)
256
+                    or $t = $trouver_table($table_depart . '_' . $table_arrivee, $serveur)
257
+                ) {
258
+                    $s = sql_select(
259
+                        "$cle_depart,$cle_arrivee",
260
+                        $t['table_sql'],
261
+                        sql_in($cle_arrivee, array_keys($ids_trouves)),
262
+                        '',
263
+                        '',
264
+                        '',
265
+                        '',
266
+                        $serveur
267
+                    );
268
+                }
269
+            } else {
270
+                [$cle_depart, $cle_arrivee, $s] = $rechercher_joints(
271
+                    $table,
272
+                    $table_liee,
273
+                    array_keys($ids_trouves),
274
+                    $serveur
275
+                );
276
+            }
277 277
 
278
-			while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
279
-				$id = $t[$cle_depart];
280
-				$joint = $ids_trouves[$t[$cle_arrivee]];
281
-				if (!isset($results)) {
282
-					$results = [];
283
-				}
284
-				if (!isset($results[$id])) {
285
-					$results[$id] = [];
286
-				}
287
-				if (isset($joint['score']) and $joint['score']) {
288
-					if (!isset($results[$id]['score'])) {
289
-						$results[$id]['score'] = 0;
290
-					}
291
-					$results[$id]['score'] += $joint['score'];
292
-				}
293
-				if (isset($joint['champs']) and $joint['champs']) {
294
-					foreach ($joint['champs'] as $c => $val) {
295
-						$results[$id]['champs'][$table_liee . '.' . $c] = $val;
296
-					}
297
-				}
298
-				if (isset($joint['matches']) and $joint['matches']) {
299
-					foreach ($joint['matches'] as $c => $val) {
300
-						$results[$id]['matches'][$table_liee . '.' . $c] = $val;
301
-					}
302
-				}
303
-			}
304
-		}
305
-	}
278
+            while ($t = is_array($s) ? array_shift($s) : sql_fetch($s)) {
279
+                $id = $t[$cle_depart];
280
+                $joint = $ids_trouves[$t[$cle_arrivee]];
281
+                if (!isset($results)) {
282
+                    $results = [];
283
+                }
284
+                if (!isset($results[$id])) {
285
+                    $results[$id] = [];
286
+                }
287
+                if (isset($joint['score']) and $joint['score']) {
288
+                    if (!isset($results[$id]['score'])) {
289
+                        $results[$id]['score'] = 0;
290
+                    }
291
+                    $results[$id]['score'] += $joint['score'];
292
+                }
293
+                if (isset($joint['champs']) and $joint['champs']) {
294
+                    foreach ($joint['champs'] as $c => $val) {
295
+                        $results[$id]['champs'][$table_liee . '.' . $c] = $val;
296
+                    }
297
+                }
298
+                if (isset($joint['matches']) and $joint['matches']) {
299
+                    foreach ($joint['matches'] as $c => $val) {
300
+                        $results[$id]['matches'][$table_liee . '.' . $c] = $val;
301
+                    }
302
+                }
303
+            }
304
+        }
305
+    }
306 306
 
307
-	return $results;
307
+    return $results;
308 308
 }
Please login to merge, or discard this patch.
ecrire/inc/icone_renommer.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -11,71 +11,71 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/boutons');
18 18
 include_spip('base/objets');
19 19
 
20 20
 function inc_icone_renommer_dist($fond, $fonction) {
21
-	$size = 24;
22
-	if (
23
-		preg_match('/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
24
-		and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1]))
25
-	) {
26
-		if (isset($match[1]) and $match[1]) {
27
-			$size = $match[1];
28
-		}
29
-		$type = substr($fond, 0, -strlen($match[0]));
30
-		if (!isset($match[2]) or !$match[2]) {
31
-			$fond .= '.png';
32
-		}
33
-	} else {
34
-		$type = $fond;
35
-		$fond .= '.png';
36
-	}
21
+    $size = 24;
22
+    if (
23
+        preg_match('/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i', $fond, $match)
24
+        and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1]))
25
+    ) {
26
+        if (isset($match[1]) and $match[1]) {
27
+            $size = $match[1];
28
+        }
29
+        $type = substr($fond, 0, -strlen($match[0]));
30
+        if (!isset($match[2]) or !$match[2]) {
31
+            $fond .= '.png';
32
+        }
33
+    } else {
34
+        $type = $fond;
35
+        $fond .= '.png';
36
+    }
37 37
 
38
-	$rtl = false;
39
-	if (preg_match(',[-_]rtl$,i', $type, $match)) {
40
-		$rtl = true;
41
-		$type = substr($type, 0, -strlen($match[0]));
42
-	}
38
+    $rtl = false;
39
+    if (preg_match(',[-_]rtl$,i', $type, $match)) {
40
+        $rtl = true;
41
+        $type = substr($type, 0, -strlen($match[0]));
42
+    }
43 43
 
44
-	// objet_type garde invariant tout ce qui ne commence par par id_, spip_
45
-	// et ne finit pas par un s, sauf si c'est une exception declaree
46
-	$type = objet_type($type, false);
44
+    // objet_type garde invariant tout ce qui ne commence par par id_, spip_
45
+    // et ne finit pas par un s, sauf si c'est une exception declaree
46
+    $type = objet_type($type, false);
47 47
 
48
-	$dir = 'images/';
49
-	$f = "$type-$size.png";
50
-	if ($icone = find_in_theme($dir . $f)) {
51
-		$dir = dirname($icone);
52
-		$fond = $icone;
48
+    $dir = 'images/';
49
+    $f = "$type-$size.png";
50
+    if ($icone = find_in_theme($dir . $f)) {
51
+        $dir = dirname($icone);
52
+        $fond = $icone;
53 53
 
54
-		if (
55
-			$rtl
56
-			and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
57
-			and file_exists($fr)
58
-		) {
59
-			$fond = $fr;
60
-		}
54
+        if (
55
+            $rtl
56
+            and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
57
+            and file_exists($fr)
58
+        ) {
59
+            $fond = $fr;
60
+        }
61 61
 
62
-		$action = $fonction;
63
-		if ($action == 'supprimer.gif') {
64
-			$action = 'del';
65
-		} elseif ($action == 'creer.gif') {
66
-			$action = 'new';
67
-		} elseif ($action == 'edit.gif') {
68
-			$action = 'edit';
69
-		}
62
+        $action = $fonction;
63
+        if ($action == 'supprimer.gif') {
64
+            $action = 'del';
65
+        } elseif ($action == 'creer.gif') {
66
+            $action = 'new';
67
+        } elseif ($action == 'edit.gif') {
68
+            $action = 'edit';
69
+        }
70 70
 
71
-		$fonction = '';
72
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
73
-			$fonction = $action;
74
-		}
71
+        $fonction = '';
72
+        if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
73
+            $fonction = $action;
74
+        }
75 75
 
76
-		// c'est bon !
77
-		return [$fond, $fonction];
78
-	}
76
+        // c'est bon !
77
+        return [$fond, $fonction];
78
+    }
79 79
 
80
-	return [$fond, $fonction];
80
+    return [$fond, $fonction];
81 81
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 
48 48
 	$dir = 'images/';
49 49
 	$f = "$type-$size.png";
50
-	if ($icone = find_in_theme($dir . $f)) {
50
+	if ($icone = find_in_theme($dir.$f)) {
51 51
 		$dir = dirname($icone);
52 52
 		$fond = $icone;
53 53
 
54 54
 		if (
55 55
 			$rtl
56
-			and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone))
56
+			and $fr = $dir.'/'.str_replace("$type-", "$type-rtl-", basename($icone))
57 57
 			and file_exists($fr)
58 58
 		) {
59 59
 			$fond = $fr;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		}
70 70
 
71 71
 		$fonction = '';
72
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
+		if (in_array($action, ['add', 'del', 'new', 'edit', 'config'])) {
73 73
 			$fonction = $action;
74 74
 		}
75 75
 
Please login to merge, or discard this patch.
ecrire/inc/prepare_recherche.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 	$where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND');
83 83
 	if (!isset($cache[$serveur][$table][$recherche])) {
84 84
 		$hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : '');
85
-		$hash = substr(md5($recherche . $table), 0, 16);
86
-		$where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')";
85
+		$hash = substr(md5($recherche.$table), 0, 16);
86
+		$where = "(resultats.recherche='$hash' AND resultats.table_objet=".sql_quote($table)." AND resultats.serveur='$hash_serv')";
87 87
 		$row = sql_fetsel(
88 88
 			'recherche',
89 89
 			'spip_resultats AS resultats',
90
-			$where . " AND $where_resultat_recent",
90
+			$where." AND $where_resultat_recent",
91 91
 			'',
92 92
 			'',
93 93
 			'0,1'
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		}
197 197
 
198 198
 		foreach ($listes_ids as $p => $ids) {
199
-			$select .= "+$p*(" .
199
+			$select .= "+$p*(".
200 200
 				sql_in("$table.$primary", $ids, '', $serveur)
201 201
 				. ') ';
202 202
 		}
Please login to merge, or discard this patch.
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/rechercher');
24 24
 if (!defined('_DELAI_CACHE_resultats')) {
25
-	define('_DELAI_CACHE_resultats', 600);
25
+    define('_DELAI_CACHE_resultats', 600);
26 26
 }
27 27
 
28 28
 /**
@@ -49,129 +49,129 @@  discard block
 block discarded – undo
49 49
  * @return array
50 50
  */
51 51
 function inc_prepare_recherche_dist(
52
-	$recherche,
53
-	$table = 'articles',
54
-	$cond = false,
55
-	$serveur = '',
56
-	$modificateurs = [],
57
-	$primary = ''
52
+    $recherche,
53
+    $table = 'articles',
54
+    $cond = false,
55
+    $serveur = '',
56
+    $modificateurs = [],
57
+    $primary = ''
58 58
 ) {
59
-	$where = null;
60
-	$rows = null;
61
-	static $cache = [];
62
-	$delai_fraicheur = min(
63
-		\_DELAI_CACHE_resultats,
64
-		time() - ($GLOBALS['meta']['derniere_modif'] ?? 0)
65
-	);
66
-
67
-	// si recherche n'est pas dans le contexte, on va prendre en globals
68
-	// ca permet de faire des inclure simple.
69
-	if (!isset($recherche) and isset($GLOBALS['recherche'])) {
70
-		$recherche = $GLOBALS['recherche'];
71
-	}
72
-
73
-	// traiter le cas {recherche?}
74
-	if ($cond and !strlen($recherche)) {
75
-		return [
76
-			'0 as points' /* as points */, /* where */
77
-			''
78
-		];
79
-	}
80
-
81
-
82
-	$rechercher = false;
83
-
84
-	$where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND');
85
-	if (!isset($cache[$serveur][$table][$recherche])) {
86
-		$hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : '');
87
-		$hash = substr(md5($recherche . $table), 0, 16);
88
-		$where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')";
89
-		$row = sql_fetsel(
90
-			'recherche',
91
-			'spip_resultats AS resultats',
92
-			$where . " AND $where_resultat_recent",
93
-			'',
94
-			'',
95
-			'0,1'
96
-		);
97
-		if (
98
-			!$row
99
-			or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
100
-		) {
101
-			$rechercher = true;
102
-		}
103
-	}
104
-
105
-	// si on n'a pas encore traite les donnees dans une boucle precedente
106
-	if ($rechercher) {
107
-		//$tables = liste_des_champs();
108
-		$x = objet_type($table);
109
-		$points = recherche_en_base(
110
-			$recherche,
111
-			$x,
112
-			[
113
-				'score' => true,
114
-				'toutvoir' => true,
115
-				'jointures' => true
116
-			],
117
-			$serveur
118
-		);
119
-		// pas de résultat, pas de point
120
-		$points = $points[$x] ?? [];
121
-
122
-		// permettre aux plugins de modifier le resultat
123
-		$points = pipeline('prepare_recherche', [
124
-			'args' => [
125
-				'type' => $x,
126
-				'recherche' => $recherche,
127
-				'serveur' => $serveur,
128
-				'modificateurs' => $modificateurs
129
-			],
130
-			'data' => $points
131
-		]);
132
-
133
-		// supprimer les anciens resultats de cette recherche
134
-		// et les resultats trop vieux avec une marge
135
-		// pas de AS resultats dans un delete (mysql)
136
-		$whered = str_replace(
137
-			['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'],
138
-			['recherche', 'table_objet', 'serveur'],
139
-			$where
140
-		);
141
-
142
-		sql_delete(
143
-			'spip_resultats',
144
-			"NOT($where_resultat_recent) OR ($whered)"
145
-		);
146
-
147
-		// inserer les resultats dans la table de cache des resultats
148
-		if (is_countable($points) ? count($points) : 0) {
149
-			$tab_couples = [];
150
-			foreach ($points as $id => $p) {
151
-				$tab_couples[] = [
152
-					'recherche' => $hash,
153
-					'id' => $id,
154
-					'points' => $p['score'],
155
-					'table_objet' => $table,
156
-					'serveur' => $hash_serv,
157
-				];
158
-			}
159
-			sql_insertq_multi('spip_resultats', $tab_couples, []);
160
-		}
161
-	}
162
-
163
-	if (!isset($cache[$serveur][$table][$recherche])) {
164
-		if (!$serveur) {
165
-			$cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where];
166
-		} else {
167
-			if (sql_countsel('spip_resultats as resultats', $where)) {
168
-				$rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where);
169
-			}
170
-			$cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur);
171
-		}
172
-	}
173
-
174
-	return $cache[$serveur][$table][$recherche];
59
+    $where = null;
60
+    $rows = null;
61
+    static $cache = [];
62
+    $delai_fraicheur = min(
63
+        \_DELAI_CACHE_resultats,
64
+        time() - ($GLOBALS['meta']['derniere_modif'] ?? 0)
65
+    );
66
+
67
+    // si recherche n'est pas dans le contexte, on va prendre en globals
68
+    // ca permet de faire des inclure simple.
69
+    if (!isset($recherche) and isset($GLOBALS['recherche'])) {
70
+        $recherche = $GLOBALS['recherche'];
71
+    }
72
+
73
+    // traiter le cas {recherche?}
74
+    if ($cond and !strlen($recherche)) {
75
+        return [
76
+            '0 as points' /* as points */, /* where */
77
+            ''
78
+        ];
79
+    }
80
+
81
+
82
+    $rechercher = false;
83
+
84
+    $where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND');
85
+    if (!isset($cache[$serveur][$table][$recherche])) {
86
+        $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : '');
87
+        $hash = substr(md5($recherche . $table), 0, 16);
88
+        $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')";
89
+        $row = sql_fetsel(
90
+            'recherche',
91
+            'spip_resultats AS resultats',
92
+            $where . " AND $where_resultat_recent",
93
+            '',
94
+            '',
95
+            '0,1'
96
+        );
97
+        if (
98
+            !$row
99
+            or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
100
+        ) {
101
+            $rechercher = true;
102
+        }
103
+    }
104
+
105
+    // si on n'a pas encore traite les donnees dans une boucle precedente
106
+    if ($rechercher) {
107
+        //$tables = liste_des_champs();
108
+        $x = objet_type($table);
109
+        $points = recherche_en_base(
110
+            $recherche,
111
+            $x,
112
+            [
113
+                'score' => true,
114
+                'toutvoir' => true,
115
+                'jointures' => true
116
+            ],
117
+            $serveur
118
+        );
119
+        // pas de résultat, pas de point
120
+        $points = $points[$x] ?? [];
121
+
122
+        // permettre aux plugins de modifier le resultat
123
+        $points = pipeline('prepare_recherche', [
124
+            'args' => [
125
+                'type' => $x,
126
+                'recherche' => $recherche,
127
+                'serveur' => $serveur,
128
+                'modificateurs' => $modificateurs
129
+            ],
130
+            'data' => $points
131
+        ]);
132
+
133
+        // supprimer les anciens resultats de cette recherche
134
+        // et les resultats trop vieux avec une marge
135
+        // pas de AS resultats dans un delete (mysql)
136
+        $whered = str_replace(
137
+            ['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'],
138
+            ['recherche', 'table_objet', 'serveur'],
139
+            $where
140
+        );
141
+
142
+        sql_delete(
143
+            'spip_resultats',
144
+            "NOT($where_resultat_recent) OR ($whered)"
145
+        );
146
+
147
+        // inserer les resultats dans la table de cache des resultats
148
+        if (is_countable($points) ? count($points) : 0) {
149
+            $tab_couples = [];
150
+            foreach ($points as $id => $p) {
151
+                $tab_couples[] = [
152
+                    'recherche' => $hash,
153
+                    'id' => $id,
154
+                    'points' => $p['score'],
155
+                    'table_objet' => $table,
156
+                    'serveur' => $hash_serv,
157
+                ];
158
+            }
159
+            sql_insertq_multi('spip_resultats', $tab_couples, []);
160
+        }
161
+    }
162
+
163
+    if (!isset($cache[$serveur][$table][$recherche])) {
164
+        if (!$serveur) {
165
+            $cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where];
166
+        } else {
167
+            if (sql_countsel('spip_resultats as resultats', $where)) {
168
+                $rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where);
169
+            }
170
+            $cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur);
171
+        }
172
+    }
173
+
174
+    return $cache[$serveur][$table][$recherche];
175 175
 }
176 176
 
177 177
 
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
  * @return array
188 188
  */
189 189
 function generer_select_where_explicites($table, $primary, $rows, $serveur) {
190
-	# calculer le {id_article IN()} et le {... as points}
191
-	if (!count($rows)) {
192
-		return ["''", '0=1'];
193
-	} else {
194
-		$listes_ids = [];
195
-		$select = '0';
196
-		foreach ($rows as $r) {
197
-			$listes_ids[$r['points']][] = $r['id'];
198
-		}
199
-
200
-		foreach ($listes_ids as $p => $ids) {
201
-			$select .= "+$p*(" .
202
-				sql_in("$table.$primary", $ids, '', $serveur)
203
-				. ') ';
204
-		}
205
-
206
-		return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)];
207
-	}
190
+    # calculer le {id_article IN()} et le {... as points}
191
+    if (!count($rows)) {
192
+        return ["''", '0=1'];
193
+    } else {
194
+        $listes_ids = [];
195
+        $select = '0';
196
+        foreach ($rows as $r) {
197
+            $listes_ids[$r['points']][] = $r['id'];
198
+        }
199
+
200
+        foreach ($listes_ids as $p => $ids) {
201
+            $select .= "+$p*(" .
202
+                sql_in("$table.$primary", $ids, '', $serveur)
203
+                . ') ';
204
+        }
205
+
206
+        return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)];
207
+    }
208 208
 }
Please login to merge, or discard this patch.
ecrire/inc/lister_objets.php 2 patches
Indentation   +21 added lines, -21 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
 
@@ -40,29 +40,29 @@  discard block
 block discarded – undo
40 40
  *     Code HTML de la liste
41 41
  */
42 42
 function inc_lister_objets_dist($vue, $contexte = [], $force = false) {
43
-	$res = ''; // debug
44
-	if (!is_array($contexte)) {
45
-		return _L('$contexte doit etre un tableau dans inc/lister_objets');
46
-	}
43
+    $res = ''; // debug
44
+    if (!is_array($contexte)) {
45
+        return _L('$contexte doit etre un tableau dans inc/lister_objets');
46
+    }
47 47
 
48
-	$fond = "prive/objets/liste/$vue";
49
-	if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
50
-		// traiter les cas particuliers
51
-		include_spip('base/connect_sql');
52
-		$vue = table_objet($vue);
53
-		$fond = "prive/objets/liste/$vue";
54
-		if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
55
-			return _L("vue $vue introuvable pour lister les objets");
56
-		}
57
-	}
48
+    $fond = "prive/objets/liste/$vue";
49
+    if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
50
+        // traiter les cas particuliers
51
+        include_spip('base/connect_sql');
52
+        $vue = table_objet($vue);
53
+        $fond = "prive/objets/liste/$vue";
54
+        if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
55
+            return _L("vue $vue introuvable pour lister les objets");
56
+        }
57
+    }
58 58
 
59 59
 
60
-	$contexte['sinon'] = ($force ? $contexte['titre'] : '');
60
+    $contexte['sinon'] = ($force ? $contexte['titre'] : '');
61 61
 
62
-	$res = recuperer_fond($fond, $contexte, ['ajax' => true]);
63
-	if (_request('var_liste')) {
64
-		echo var_export($contexte, true);
65
-	}
62
+    $res = recuperer_fond($fond, $contexte, ['ajax' => true]);
63
+    if (_request('var_liste')) {
64
+        echo var_export($contexte, true);
65
+    }
66 66
 
67
-	return $res;
67
+    return $res;
68 68
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@
 block discarded – undo
46 46
 	}
47 47
 
48 48
 	$fond = "prive/objets/liste/$vue";
49
-	if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
49
+	if (!find_in_path($fond.'.'._EXTENSION_SQUELETTES)) {
50 50
 		// traiter les cas particuliers
51 51
 		include_spip('base/connect_sql');
52 52
 		$vue = table_objet($vue);
53 53
 		$fond = "prive/objets/liste/$vue";
54
-		if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) {
54
+		if (!find_in_path($fond.'.'._EXTENSION_SQUELETTES)) {
55 55
 			return _L("vue $vue introuvable pour lister les objets");
56 56
 		}
57 57
 	}
Please login to merge, or discard this patch.