Completed
Push — master ( 4fa0dc...b74578 )
by cam
01:19
created
ecrire/plugins/afficher_repertoires.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -10,110 +10,110 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 function plugins_afficher_repertoires_dist($url_page, $liste_plugins, $liste_plugins_actifs) {
17
-	$ligne_plug = charger_fonction('afficher_plugin', 'plugins');
18
-	$racine = basename(_DIR_PLUGINS);
19
-	$init_dir = $current_dir = '';
20
-	// liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif
21
-	// des qu'un path est deja note deplie on s'arrete
22
-	$deplie = [$racine => true];
23
-	$fast_liste_plugins_actifs = [];
24
-	foreach ($liste_plugins_actifs as $key => $plug) {
25
-		$chemin_plug = chemin_plug($racine, $plug);
26
-		$fast_liste_plugins_actifs[$chemin_plug] = true;
27
-		$dir = dirname($chemin_plug);
28
-		$maxiter = 100;
29
-		while (strlen($dir) && !isset($deplie[$dir]) && $dir !== $racine && $maxiter-- > 0) {
30
-			$deplie[$dir] = true;
31
-			$dir = dirname($dir);
32
-		}
33
-	}
17
+    $ligne_plug = charger_fonction('afficher_plugin', 'plugins');
18
+    $racine = basename(_DIR_PLUGINS);
19
+    $init_dir = $current_dir = '';
20
+    // liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif
21
+    // des qu'un path est deja note deplie on s'arrete
22
+    $deplie = [$racine => true];
23
+    $fast_liste_plugins_actifs = [];
24
+    foreach ($liste_plugins_actifs as $key => $plug) {
25
+        $chemin_plug = chemin_plug($racine, $plug);
26
+        $fast_liste_plugins_actifs[$chemin_plug] = true;
27
+        $dir = dirname($chemin_plug);
28
+        $maxiter = 100;
29
+        while (strlen($dir) && !isset($deplie[$dir]) && $dir !== $racine && $maxiter-- > 0) {
30
+            $deplie[$dir] = true;
31
+            $dir = dirname($dir);
32
+        }
33
+    }
34 34
 
35
-	// index repertoires --> plugin
36
-	$dir_index = [];
37
-	foreach ($liste_plugins as $key => $plug) {
38
-		$liste_plugins[$key] = chemin_plug($racine, $plug);
39
-		$dir_index[dirname($liste_plugins[$key])][] = $key;
40
-	}
35
+    // index repertoires --> plugin
36
+    $dir_index = [];
37
+    foreach ($liste_plugins as $key => $plug) {
38
+        $liste_plugins[$key] = chemin_plug($racine, $plug);
39
+        $dir_index[dirname($liste_plugins[$key])][] = $key;
40
+    }
41 41
 
42
-	$visible = @isset($deplie[$current_dir]);
43
-	$maxiter = 1000;
42
+    $visible = @isset($deplie[$current_dir]);
43
+    $maxiter = 1000;
44 44
 
45
-	$res = '';
46
-	while ((is_countable($liste_plugins) ? count($liste_plugins) : 0) && $maxiter--) {
47
-		// le rep suivant
48
-		$dir = dirname(reset($liste_plugins));
49
-		if ($dir != $current_dir) {
50
-			$res .= tree_open_close_dir($current_dir, $dir, $deplie);
51
-		}
45
+    $res = '';
46
+    while ((is_countable($liste_plugins) ? count($liste_plugins) : 0) && $maxiter--) {
47
+        // le rep suivant
48
+        $dir = dirname(reset($liste_plugins));
49
+        if ($dir != $current_dir) {
50
+            $res .= tree_open_close_dir($current_dir, $dir, $deplie);
51
+        }
52 52
 
53
-		// d'abord tous les plugins du rep courant
54
-		if (isset($dir_index[$current_dir])) {
55
-			foreach ($dir_index[$current_dir] as $key) {
56
-				$plug = $liste_plugins[$key];
57
-				$actif = @isset($fast_liste_plugins_actifs[$plug]);
58
-				$id = substr(md5($plug), 0, 16);
59
-				$res .= $ligne_plug(
60
-					$url_page,
61
-					str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug),
62
-					$actif,
63
-					'menu-entree'
64
-				) . "\n";
65
-				unset($liste_plugins[$key]);
66
-			}
67
-		}
68
-	}
69
-	$res .= tree_open_close_dir($current_dir, $init_dir, true);
53
+        // d'abord tous les plugins du rep courant
54
+        if (isset($dir_index[$current_dir])) {
55
+            foreach ($dir_index[$current_dir] as $key) {
56
+                $plug = $liste_plugins[$key];
57
+                $actif = @isset($fast_liste_plugins_actifs[$plug]);
58
+                $id = substr(md5($plug), 0, 16);
59
+                $res .= $ligne_plug(
60
+                    $url_page,
61
+                    str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug),
62
+                    $actif,
63
+                    'menu-entree'
64
+                ) . "\n";
65
+                unset($liste_plugins[$key]);
66
+            }
67
+        }
68
+    }
69
+    $res .= tree_open_close_dir($current_dir, $init_dir, true);
70 70
 
71
-	return "<ul class='menu-liste plugins'>"
72
-	. $res
73
-	. '</ul>';
71
+    return "<ul class='menu-liste plugins'>"
72
+    . $res
73
+    . '</ul>';
74 74
 }
75 75
 
76 76
 
77 77
 // vraiment n'importe quoi la gestion des chemins des plugins
78 78
 // une fonction pour aider...
79 79
 function chemin_plug($racine, $plug) {
80
-	return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug");
80
+    return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug");
81 81
 }
82 82
 
83 83
 function tree_open_close_dir(&$current, $target, $deplie = []) {
84
-	if ($current == $target) {
85
-		return '';
86
-	}
87
-	$tcur = explode('/', $current);
88
-	$ttarg = explode('/', $target);
89
-	$tcom = [];
90
-	$output = '';
91
-	// la partie commune
92
-	while (reset($tcur) === reset($ttarg)) {
93
-		$tcom[] = array_shift($tcur);
94
-		array_shift($ttarg);
95
-	}
96
-	// fermer les repertoires courant jusqu'au point de fork
97
-	while ($close = array_pop($tcur)) {
98
-		$output .= "</ul>\n";
99
-		$output .= fin_block();
100
-		$output .= "</li>\n";
101
-	}
102
-	$chemin = '';
103
-	if ($tcom !== []) {
104
-		$chemin .= implode('/', $tcom) . '/';
105
-	}
106
-	// ouvrir les repertoires jusqu'a la cible
107
-	while ($open = array_shift($ttarg)) {
108
-		$visible = @isset($deplie[$chemin . $open]);
109
-		$chemin .= $open . '/';
110
-		$output .= '<li>';
111
-		$output .= bouton_block_depliable($chemin, $visible);
112
-		$output .= debut_block_depliable($visible);
84
+    if ($current == $target) {
85
+        return '';
86
+    }
87
+    $tcur = explode('/', $current);
88
+    $ttarg = explode('/', $target);
89
+    $tcom = [];
90
+    $output = '';
91
+    // la partie commune
92
+    while (reset($tcur) === reset($ttarg)) {
93
+        $tcom[] = array_shift($tcur);
94
+        array_shift($ttarg);
95
+    }
96
+    // fermer les repertoires courant jusqu'au point de fork
97
+    while ($close = array_pop($tcur)) {
98
+        $output .= "</ul>\n";
99
+        $output .= fin_block();
100
+        $output .= "</li>\n";
101
+    }
102
+    $chemin = '';
103
+    if ($tcom !== []) {
104
+        $chemin .= implode('/', $tcom) . '/';
105
+    }
106
+    // ouvrir les repertoires jusqu'a la cible
107
+    while ($open = array_shift($ttarg)) {
108
+        $visible = @isset($deplie[$chemin . $open]);
109
+        $chemin .= $open . '/';
110
+        $output .= '<li>';
111
+        $output .= bouton_block_depliable($chemin, $visible);
112
+        $output .= debut_block_depliable($visible);
113 113
 
114
-		$output .= "<ul>\n";
115
-	}
116
-	$current = $target;
114
+        $output .= "<ul>\n";
115
+    }
116
+    $current = $target;
117 117
 
118
-	return $output;
118
+    return $output;
119 119
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 				$id = substr(md5($plug), 0, 16);
59 59
 				$res .= $ligne_plug(
60 60
 					$url_page,
61
-					str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug),
61
+					str_replace(_DIR_PLUGINS, '', _DIR_RACINE.$plug),
62 62
 					$actif,
63 63
 					'menu-entree'
64
-				) . "\n";
64
+				)."\n";
65 65
 				unset($liste_plugins[$key]);
66 66
 			}
67 67
 		}
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 	$chemin = '';
103 103
 	if ($tcom !== []) {
104
-		$chemin .= implode('/', $tcom) . '/';
104
+		$chemin .= implode('/', $tcom).'/';
105 105
 	}
106 106
 	// ouvrir les repertoires jusqu'a la cible
107 107
 	while ($open = array_shift($ttarg)) {
108
-		$visible = @isset($deplie[$chemin . $open]);
109
-		$chemin .= $open . '/';
108
+		$visible = @isset($deplie[$chemin.$open]);
109
+		$chemin .= $open.'/';
110 110
 		$output .= '<li>';
111 111
 		$output .= bouton_block_depliable($chemin, $visible);
112 112
 		$output .= debut_block_depliable($visible);
Please login to merge, or discard this patch.
ecrire/plugins/get_infos.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -32,110 +32,110 @@  discard block
 block discarded – undo
32 32
  * @return array
33 33
  */
34 34
 function plugins_get_infos_dist($plug = false, $reload = false, $dir = _DIR_PLUGINS, $clean_old = false) {
35
-	$contenu = null;
36
-	$res = null;
37
-	static $cache = '';
38
-	static $filecache = '';
39
-
40
-	if ($cache === '') {
41
-		$filecache = _DIR_TMP . 'plugin_xml_cache.gz';
42
-		if (is_file($filecache)) {
43
-			lire_fichier($filecache, $contenu);
44
-			$cache = unserialize($contenu);
45
-		}
46
-		if (!is_array($cache)) {
47
-			$cache = [];
48
-		}
49
-	}
50
-
51
-	if (defined('_VAR_MODE') && _VAR_MODE == 'recalcul') {
52
-		$reload = true;
53
-	}
54
-
55
-	if ($plug === false) {
56
-		ecrire_fichier($filecache, serialize($cache));
57
-
58
-		return $cache;
59
-	} elseif (is_string($plug)) {
60
-		$res = plugins_get_infos_un($plug, $reload, $dir, $cache);
61
-	} elseif (is_array($plug)) {
62
-		$res = false;
63
-		if (!$reload) {
64
-			$reload = -1;
65
-		}
66
-		foreach ($plug as $nom) {
67
-			$res |= plugins_get_infos_un($nom, $reload, $dir, $cache);
68
-		}
69
-
70
-		// Nettoyer le cache des vieux plugins qui ne sont plus la
71
-		if ($clean_old && isset($cache[$dir]) && (is_countable($cache[$dir]) ? count($cache[$dir]) : 0)) {
72
-			foreach (array_keys($cache[$dir]) as $p) {
73
-				if (!in_array($p, $plug)) {
74
-					unset($cache[$dir][$p]);
75
-				}
76
-			}
77
-		}
78
-	}
79
-	if ($res) {
80
-		ecrire_fichier($filecache, serialize($cache));
81
-	}
82
-	if (!isset($cache[$dir])) {
83
-		return [];
84
-	}
85
-	if (is_string($plug)) {
86
-		return $cache[$dir][$plug] ?? [];
87
-	} else {
88
-		return $cache[$dir];
89
-	}
35
+    $contenu = null;
36
+    $res = null;
37
+    static $cache = '';
38
+    static $filecache = '';
39
+
40
+    if ($cache === '') {
41
+        $filecache = _DIR_TMP . 'plugin_xml_cache.gz';
42
+        if (is_file($filecache)) {
43
+            lire_fichier($filecache, $contenu);
44
+            $cache = unserialize($contenu);
45
+        }
46
+        if (!is_array($cache)) {
47
+            $cache = [];
48
+        }
49
+    }
50
+
51
+    if (defined('_VAR_MODE') && _VAR_MODE == 'recalcul') {
52
+        $reload = true;
53
+    }
54
+
55
+    if ($plug === false) {
56
+        ecrire_fichier($filecache, serialize($cache));
57
+
58
+        return $cache;
59
+    } elseif (is_string($plug)) {
60
+        $res = plugins_get_infos_un($plug, $reload, $dir, $cache);
61
+    } elseif (is_array($plug)) {
62
+        $res = false;
63
+        if (!$reload) {
64
+            $reload = -1;
65
+        }
66
+        foreach ($plug as $nom) {
67
+            $res |= plugins_get_infos_un($nom, $reload, $dir, $cache);
68
+        }
69
+
70
+        // Nettoyer le cache des vieux plugins qui ne sont plus la
71
+        if ($clean_old && isset($cache[$dir]) && (is_countable($cache[$dir]) ? count($cache[$dir]) : 0)) {
72
+            foreach (array_keys($cache[$dir]) as $p) {
73
+                if (!in_array($p, $plug)) {
74
+                    unset($cache[$dir][$p]);
75
+                }
76
+            }
77
+        }
78
+    }
79
+    if ($res) {
80
+        ecrire_fichier($filecache, serialize($cache));
81
+    }
82
+    if (!isset($cache[$dir])) {
83
+        return [];
84
+    }
85
+    if (is_string($plug)) {
86
+        return $cache[$dir][$plug] ?? [];
87
+    } else {
88
+        return $cache[$dir];
89
+    }
90 90
 }
91 91
 
92 92
 
93 93
 function plugins_get_infos_un($plug, $reload, $dir, &$cache) {
94
-	if (!is_readable($file = "$dir$plug/paquet.xml")) {
95
-		return false;
96
-	}
97
-	$time = (int) @filemtime($file);
98
-	if ($time < 0) {
99
-		return false;
100
-	}
101
-	$md5 = md5_file($file);
102
-
103
-	$pcache = $cache[$dir][$plug] ?? ['filemtime' => 0, 'md5_file' => ''];
104
-
105
-	// si le cache est valide
106
-	if (
107
-		(int) $reload <= 0
108
-		&& $time > 0
109
-		&& $time <= $pcache['filemtime']
110
-		&& $md5 == $pcache['md5_file']
111
-	) {
112
-		return false;
113
-	}
114
-
115
-	// si on arrive pas a lire le fichier, se contenter du cache
116
-	if (!($texte = spip_file_get_contents($file))) {
117
-		return false;
118
-	}
119
-
120
-	$f = charger_fonction('infos_paquet', 'plugins');
121
-	$ret = $f($texte, $plug, $dir);
122
-	$ret['filemtime'] = $time;
123
-	$ret['md5_file'] = $md5;
124
-	// Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent
125
-	// utiliser un necessite php. SPIP procure donc la version php courante du serveur.
126
-	// chaque librairie php est aussi procurée, par exemple 'php:curl'.
127
-	if (isset($ret['prefix']) && $ret['prefix'] == 'spip') {
128
-		$ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()];
129
-		foreach (get_loaded_extensions() as $ext) {
130
-			$ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)];
131
-		}
132
-	}
133
-	$diff = ($ret != $pcache);
134
-
135
-	if ($diff) {
136
-		$cache[$dir][$plug] = $ret;
94
+    if (!is_readable($file = "$dir$plug/paquet.xml")) {
95
+        return false;
96
+    }
97
+    $time = (int) @filemtime($file);
98
+    if ($time < 0) {
99
+        return false;
100
+    }
101
+    $md5 = md5_file($file);
102
+
103
+    $pcache = $cache[$dir][$plug] ?? ['filemtime' => 0, 'md5_file' => ''];
104
+
105
+    // si le cache est valide
106
+    if (
107
+        (int) $reload <= 0
108
+        && $time > 0
109
+        && $time <= $pcache['filemtime']
110
+        && $md5 == $pcache['md5_file']
111
+    ) {
112
+        return false;
113
+    }
114
+
115
+    // si on arrive pas a lire le fichier, se contenter du cache
116
+    if (!($texte = spip_file_get_contents($file))) {
117
+        return false;
118
+    }
119
+
120
+    $f = charger_fonction('infos_paquet', 'plugins');
121
+    $ret = $f($texte, $plug, $dir);
122
+    $ret['filemtime'] = $time;
123
+    $ret['md5_file'] = $md5;
124
+    // Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent
125
+    // utiliser un necessite php. SPIP procure donc la version php courante du serveur.
126
+    // chaque librairie php est aussi procurée, par exemple 'php:curl'.
127
+    if (isset($ret['prefix']) && $ret['prefix'] == 'spip') {
128
+        $ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()];
129
+        foreach (get_loaded_extensions() as $ext) {
130
+            $ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)];
131
+        }
132
+    }
133
+    $diff = ($ret != $pcache);
134
+
135
+    if ($diff) {
136
+        $cache[$dir][$plug] = $ret;
137 137
 #       echo count($cache[$dir]), $dir,$plug, " $reloadc<br>";
138
-	}
138
+    }
139 139
 
140
-	return $diff;
140
+    return $diff;
141 141
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	static $filecache = '';
39 39
 
40 40
 	if ($cache === '') {
41
-		$filecache = _DIR_TMP . 'plugin_xml_cache.gz';
41
+		$filecache = _DIR_TMP.'plugin_xml_cache.gz';
42 42
 		if (is_file($filecache)) {
43 43
 			lire_fichier($filecache, $contenu);
44 44
 			$cache = unserialize($contenu);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	if (isset($ret['prefix']) && $ret['prefix'] == 'spip') {
128 128
 		$ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()];
129 129
 		foreach (get_loaded_extensions() as $ext) {
130
-			$ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)];
130
+			$ret['procure']['php:'.$ext] = ['nom' => 'php:'.$ext, 'version' => phpversion($ext)];
131 131
 		}
132 132
 	}
133 133
 	$diff = ($ret != $pcache);
Please login to merge, or discard this patch.
ecrire/plugins/infos_paquet.php 1 patch
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 /**
@@ -24,64 +24,64 @@  discard block
 block discarded – undo
24 24
  * @return array
25 25
  */
26 26
 function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) {
27
-	static $process = [ // tableau constant
28
-		'debut' => 'paquet_debutElement',
29
-		'fin' => 'paquet_finElement',
30
-		'text' => 'paquet_textElement'
31
-	];
32
-
33
-	$valider_xml = charger_fonction('valider', 'xml');
34
-	$vxml = $valider_xml($desc, false, $process, 'paquet.dtd', 'utf-8');
35
-	if (!$vxml->err) {
36
-		// On veut toutes les variantes selon la version de SPIP
37
-		if (!$plug) {
38
-			return $vxml->versions;
39
-		}
40
-
41
-		// compatibilite avec l'existant:
42
-		$tree = $vxml->versions['0'];
43
-
44
-		// l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca.
45
-		if (isset($tree['']) && !strlen($tree[''])) {
46
-			unset($tree['']);
47
-		}
48
-
49
-		$tree['slogan'] = $tree['prefix'] . '_slogan';
50
-		$tree['description'] = $tree['prefix'] . '_description';
51
-		paquet_readable_files($tree, "$dir_plugins$plug/");
52
-		if (!$tree['chemin']) {
53
-			$tree['chemin'] = [];
54
-		}
55
-
56
-		// On verifie qu'il existe des balises spip qu'il faudrait rajouter dans
57
-		// la structure d'infos du paquet en fonction de la version spip courante
58
-		if ((is_countable($vxml->versions) ? count($vxml->versions) : 0) > 1) {
59
-			$vspip = $GLOBALS['spip_version_branche'];
60
-			foreach ($vxml->versions as $_compatibilite => $_version) {
61
-				if (
62
-					$_version['balise'] == 'spip'
63
-					&& plugin_version_compatible($_compatibilite, $vspip, 'spip')
64
-				) {
65
-					// on merge les sous-balises de la balise spip compatible avec celles de la
66
-					// balise paquet
67
-					foreach ($_version as $_index => $_balise) {
68
-						if ($_index && $_index != 'balise') {
69
-							$tree[$_index] = array_merge($tree[$_index], $_balise);
70
-						}
71
-					}
72
-				}
73
-			}
74
-		}
75
-
76
-		return $tree;
77
-	}
78
-
79
-	// Prendre les messages d'erreur sans les numeros de lignes
80
-	$msg = array_column($vxml->err, 0);
81
-	$t = _T('plugins_erreur', ['plugins' => $plug]);
82
-	array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>');
83
-
84
-	return ['erreur' => $msg];
27
+    static $process = [ // tableau constant
28
+        'debut' => 'paquet_debutElement',
29
+        'fin' => 'paquet_finElement',
30
+        'text' => 'paquet_textElement'
31
+    ];
32
+
33
+    $valider_xml = charger_fonction('valider', 'xml');
34
+    $vxml = $valider_xml($desc, false, $process, 'paquet.dtd', 'utf-8');
35
+    if (!$vxml->err) {
36
+        // On veut toutes les variantes selon la version de SPIP
37
+        if (!$plug) {
38
+            return $vxml->versions;
39
+        }
40
+
41
+        // compatibilite avec l'existant:
42
+        $tree = $vxml->versions['0'];
43
+
44
+        // l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca.
45
+        if (isset($tree['']) && !strlen($tree[''])) {
46
+            unset($tree['']);
47
+        }
48
+
49
+        $tree['slogan'] = $tree['prefix'] . '_slogan';
50
+        $tree['description'] = $tree['prefix'] . '_description';
51
+        paquet_readable_files($tree, "$dir_plugins$plug/");
52
+        if (!$tree['chemin']) {
53
+            $tree['chemin'] = [];
54
+        }
55
+
56
+        // On verifie qu'il existe des balises spip qu'il faudrait rajouter dans
57
+        // la structure d'infos du paquet en fonction de la version spip courante
58
+        if ((is_countable($vxml->versions) ? count($vxml->versions) : 0) > 1) {
59
+            $vspip = $GLOBALS['spip_version_branche'];
60
+            foreach ($vxml->versions as $_compatibilite => $_version) {
61
+                if (
62
+                    $_version['balise'] == 'spip'
63
+                    && plugin_version_compatible($_compatibilite, $vspip, 'spip')
64
+                ) {
65
+                    // on merge les sous-balises de la balise spip compatible avec celles de la
66
+                    // balise paquet
67
+                    foreach ($_version as $_index => $_balise) {
68
+                        if ($_index && $_index != 'balise') {
69
+                            $tree[$_index] = array_merge($tree[$_index], $_balise);
70
+                        }
71
+                    }
72
+                }
73
+            }
74
+        }
75
+
76
+        return $tree;
77
+    }
78
+
79
+    // Prendre les messages d'erreur sans les numeros de lignes
80
+    $msg = array_column($vxml->err, 0);
81
+    $t = _T('plugins_erreur', ['plugins' => $plug]);
82
+    array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>');
83
+
84
+    return ['erreur' => $msg];
85 85
 }
86 86
 
87 87
 /**
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
  * @return void
94 94
  */
95 95
 function paquet_readable_files(&$tree, $dir) {
96
-	$prefix = strtolower($tree['prefix']);
96
+    $prefix = strtolower($tree['prefix']);
97 97
 
98
-	$tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : [];
99
-	$tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : [];
100
-	$tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : [];
98
+    $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : [];
99
+    $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : [];
100
+    $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : [];
101 101
 }
102 102
 
103 103
 /**
@@ -114,35 +114,35 @@  discard block
 block discarded – undo
114 114
  * @param array $attrs
115 115
  */
116 116
 function paquet_debutElement($phraseur, $name, $attrs) {
117
-	xml_debutElement($phraseur, $name, $attrs);
118
-	if ($phraseur->err) {
119
-		return;
120
-	}
121
-	if ($name == 'paquet' || $name == 'spip') {
122
-		if ($name == 'spip') {
123
-			$n = $attrs['compatibilite'];
124
-			$attrs = [];
125
-		} else {
126
-			$n = '0';
127
-			$phraseur->contenu['paquet'] = $attrs;
128
-			$attrs['menu'] = [];
129
-			$attrs['chemin'] = [];
130
-			$attrs['necessite'] = [];
131
-			$attrs['lib'] = [];
132
-			$attrs['onglet'] = [];
133
-			$attrs['procure'] = [];
134
-			$attrs['pipeline'] = [];
135
-			$attrs['utilise'] = [];
136
-			$attrs['style'] = [];
137
-			$attrs['script'] = [];
138
-			$attrs['genie'] = [];
139
-		}
140
-		$phraseur->contenu['compatible'] = $n;
141
-		$phraseur->versions[$phraseur->contenu['compatible']] = $attrs;
142
-	} else {
143
-		$phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs;
144
-	}
145
-	$phraseur->versions[$phraseur->contenu['compatible']][''] = '';
117
+    xml_debutElement($phraseur, $name, $attrs);
118
+    if ($phraseur->err) {
119
+        return;
120
+    }
121
+    if ($name == 'paquet' || $name == 'spip') {
122
+        if ($name == 'spip') {
123
+            $n = $attrs['compatibilite'];
124
+            $attrs = [];
125
+        } else {
126
+            $n = '0';
127
+            $phraseur->contenu['paquet'] = $attrs;
128
+            $attrs['menu'] = [];
129
+            $attrs['chemin'] = [];
130
+            $attrs['necessite'] = [];
131
+            $attrs['lib'] = [];
132
+            $attrs['onglet'] = [];
133
+            $attrs['procure'] = [];
134
+            $attrs['pipeline'] = [];
135
+            $attrs['utilise'] = [];
136
+            $attrs['style'] = [];
137
+            $attrs['script'] = [];
138
+            $attrs['genie'] = [];
139
+        }
140
+        $phraseur->contenu['compatible'] = $n;
141
+        $phraseur->versions[$phraseur->contenu['compatible']] = $attrs;
142
+    } else {
143
+        $phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs;
144
+    }
145
+    $phraseur->versions[$phraseur->contenu['compatible']][''] = '';
146 146
 }
147 147
 
148 148
 /**
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
  * @param string $data
155 155
  */
156 156
 function paquet_textElement($phraseur, $data) {
157
-	xml_textElement($phraseur, $data);
158
-	if ($phraseur->err || !(trim($data))) {
159
-		return;
160
-	}
161
-	$phraseur->versions[$phraseur->contenu['compatible']][''] .= $data;
157
+    xml_textElement($phraseur, $data);
158
+    if ($phraseur->err || !(trim($data))) {
159
+        return;
160
+    }
161
+    $phraseur->versions[$phraseur->contenu['compatible']][''] .= $data;
162 162
 }
163 163
 
164 164
 /**
@@ -170,32 +170,32 @@  discard block
 block discarded – undo
170 170
  * @param string $name
171 171
  */
172 172
 function paquet_finElement($phraseur, $name) {
173
-	if ($phraseur->err) {
174
-		return;
175
-	}
176
-	$n = $phraseur->contenu['compatible'];
177
-
178
-	if (isset($phraseur->versions[$n][$name][0]) && is_array($phraseur->versions[$n][$name][0])) {
179
-		$attrs = $phraseur->versions[$n][$name][0];
180
-		unset($phraseur->versions[$n][$name][0]);
181
-	} else {
182
-		$attrs = [];
183
-	}
184
-
185
-	$texte = trim($phraseur->versions[$n]['']);
186
-	$phraseur->versions[$n][''] = '';
187
-
188
-	$f = 'info_paquet_' . $name;
189
-	if (function_exists($f)) {
190
-		$f($phraseur, $attrs, $texte);
191
-	} elseif (!$attrs) {
192
-		$phraseur->versions[$n][$name] = $texte;
193
-	} else {
194
-		// Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici
195
-		$phraseur->versions[$n][$name][$attrs['nom']] = $attrs;
196
-		#	  echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]);
197
-	}
198
-	xml_finElement($phraseur, $name, $attrs);
173
+    if ($phraseur->err) {
174
+        return;
175
+    }
176
+    $n = $phraseur->contenu['compatible'];
177
+
178
+    if (isset($phraseur->versions[$n][$name][0]) && is_array($phraseur->versions[$n][$name][0])) {
179
+        $attrs = $phraseur->versions[$n][$name][0];
180
+        unset($phraseur->versions[$n][$name][0]);
181
+    } else {
182
+        $attrs = [];
183
+    }
184
+
185
+    $texte = trim($phraseur->versions[$n]['']);
186
+    $phraseur->versions[$n][''] = '';
187
+
188
+    $f = 'info_paquet_' . $name;
189
+    if (function_exists($f)) {
190
+        $f($phraseur, $attrs, $texte);
191
+    } elseif (!$attrs) {
192
+        $phraseur->versions[$n][$name] = $texte;
193
+    } else {
194
+        // Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici
195
+        $phraseur->versions[$n][$name][$attrs['nom']] = $attrs;
196
+        #	  echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]);
197
+    }
198
+    xml_finElement($phraseur, $name, $attrs);
199 199
 }
200 200
 
201 201
 /**
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
  * @param string $texte
208 208
  */
209 209
 function info_paquet_licence($phraseur, $attrs, $texte) {
210
-	$lien = $attrs['lien'] ?? '';
211
-	$n = $phraseur->contenu['compatible'];
212
-	$phraseur->versions[$n]['licence'][] = ['nom' => $texte, 'url' => $lien];
210
+    $lien = $attrs['lien'] ?? '';
211
+    $n = $phraseur->contenu['compatible'];
212
+    $phraseur->versions[$n]['licence'][] = ['nom' => $texte, 'url' => $lien];
213 213
 }
214 214
 
215 215
 /**
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
  * @param string $texte
222 222
  */
223 223
 function info_paquet_chemin($phraseur, $attrs, $texte) {
224
-	$n = $phraseur->contenu['compatible'];
225
-	if (isset($attrs['path'])) {
226
-		if (isset($attrs['type'])) {
227
-			$phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path'], 'type' => $attrs['type']];
228
-		} else {
229
-			$phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path']];
230
-		}
231
-	}
224
+    $n = $phraseur->contenu['compatible'];
225
+    if (isset($attrs['path'])) {
226
+        if (isset($attrs['type'])) {
227
+            $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path'], 'type' => $attrs['type']];
228
+        } else {
229
+            $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path']];
230
+        }
231
+    }
232 232
 }
233 233
 
234 234
 
@@ -242,20 +242,20 @@  discard block
 block discarded – undo
242 242
  * @param string $texte
243 243
  */
244 244
 function info_paquet_auteur($phraseur, $attrs, $texte) {
245
-	#  echo 'auteur ', $texte;  var_dump($attrs);
246
-	if (isset($attrs['mail'])) {
247
-		if (strpos($attrs['mail'], '@')) {
248
-			$attrs['mail'] = str_replace('@', ' AT ', $attrs['mail']);
249
-		}
250
-		$mail = $attrs['mail'];
251
-	} else {
252
-		$mail = '';
253
-	}
254
-
255
-	$lien = $attrs['lien'] ?? '';
256
-
257
-	$n = $phraseur->contenu['compatible'];
258
-	$phraseur->versions[$n]['auteur'][] = ['nom' => $texte, 'url' => $lien, 'mail' => $mail];
245
+    #  echo 'auteur ', $texte;  var_dump($attrs);
246
+    if (isset($attrs['mail'])) {
247
+        if (strpos($attrs['mail'], '@')) {
248
+            $attrs['mail'] = str_replace('@', ' AT ', $attrs['mail']);
249
+        }
250
+        $mail = $attrs['mail'];
251
+    } else {
252
+        $mail = '';
253
+    }
254
+
255
+    $lien = $attrs['lien'] ?? '';
256
+
257
+    $n = $phraseur->contenu['compatible'];
258
+    $phraseur->versions[$n]['auteur'][] = ['nom' => $texte, 'url' => $lien, 'mail' => $mail];
259 259
 }
260 260
 
261 261
 /**
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
  */
269 269
 function info_paquet_credit($phraseur, $attrs, $texte) {
270 270
 
271
-	$lien = $attrs['lien'] ?? '';
271
+    $lien = $attrs['lien'] ?? '';
272 272
 
273
-	$n = $phraseur->contenu['compatible'];
274
-	$phraseur->versions[$n]['credit'][] = ['nom' => $texte, 'url' => $lien];
273
+    $n = $phraseur->contenu['compatible'];
274
+    $phraseur->versions[$n]['credit'][] = ['nom' => $texte, 'url' => $lien];
275 275
 }
276 276
 
277 277
 /**
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
  * @param string $texte
284 284
  */
285 285
 function info_paquet_copyright($phraseur, $attrs, $texte) {
286
-	$n = $phraseur->contenu['compatible'];
287
-	$phraseur->versions[$n]['copyright'][] = $texte;
286
+    $n = $phraseur->contenu['compatible'];
287
+    $phraseur->versions[$n]['copyright'][] = $texte;
288 288
 }
289 289
 
290 290
 /**
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
  * @param string $texte
297 297
  */
298 298
 function info_paquet_paquet($phraseur, $attrs, $texte) {
299
-	$n = 0;
300
-	$phraseur->versions[$n]['dtd'] = 'paquet';
301
-	$phraseur->versions[$n]['balise'] = 'paquet';
299
+    $n = 0;
300
+    $phraseur->versions[$n]['dtd'] = 'paquet';
301
+    $phraseur->versions[$n]['balise'] = 'paquet';
302 302
 }
303 303
 
304 304
 /**
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
  * @param string $texte
311 311
  **/
312 312
 function info_paquet_traduire($phraseur, $attrs, $texte) {
313
-	$n = $phraseur->contenu['compatible'];
314
-	$phraseur->versions[$n]['traduire'][] = $attrs;
313
+    $n = $phraseur->contenu['compatible'];
314
+    $phraseur->versions[$n]['traduire'][] = $attrs;
315 315
 }
316 316
 
317 317
 /**
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
  * @param string $texte
324 324
  */
325 325
 function info_paquet_spip($phraseur, $attrs, $texte) {
326
-	$n = $phraseur->contenu['compatible'];
327
-	$phraseur->versions[$n]['balise'] = 'spip';
326
+    $n = $phraseur->contenu['compatible'];
327
+    $phraseur->versions[$n]['balise'] = 'spip';
328 328
 }
329 329
 
330 330
 
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
  * @param string $texte
337 337
  */
338 338
 function info_paquet_pipeline($phraseur, $attrs, $texte) {
339
-	$n = $phraseur->contenu['compatible'];
340
-	$phraseur->versions[$n]['pipeline'][] = $attrs;
339
+    $n = $phraseur->contenu['compatible'];
340
+    $phraseur->versions[$n]['pipeline'][] = $attrs;
341 341
 }
342 342
 
343 343
 
@@ -350,23 +350,23 @@  discard block
 block discarded – undo
350 350
  * @param string $texte
351 351
  */
352 352
 function info_paquet_style($phraseur, $attrs, $texte) {
353
-	$lien = $chemin = $type = $media = '';
354
-
355
-	include_spip('inc/utils');
356
-	if (tester_url_absolue($attrs['source'])) {
357
-		$lien = $attrs['source'];
358
-	} else {
359
-		$chemin = $attrs['source'];
360
-	}
361
-	if (isset($attrs['type'])) {
362
-		$type = $attrs['type'];
363
-	}
364
-	if (isset($attrs['media'])) {
365
-		$media = $attrs['media'];
366
-	}
367
-
368
-	$n = $phraseur->contenu['compatible'];
369
-	$phraseur->versions[$n]['style'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media];
353
+    $lien = $chemin = $type = $media = '';
354
+
355
+    include_spip('inc/utils');
356
+    if (tester_url_absolue($attrs['source'])) {
357
+        $lien = $attrs['source'];
358
+    } else {
359
+        $chemin = $attrs['source'];
360
+    }
361
+    if (isset($attrs['type'])) {
362
+        $type = $attrs['type'];
363
+    }
364
+    if (isset($attrs['media'])) {
365
+        $media = $attrs['media'];
366
+    }
367
+
368
+    $n = $phraseur->contenu['compatible'];
369
+    $phraseur->versions[$n]['style'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media];
370 370
 }
371 371
 
372 372
 
@@ -379,20 +379,20 @@  discard block
 block discarded – undo
379 379
  * @param string $texte
380 380
  */
381 381
 function info_paquet_script($phraseur, $attrs, $texte) {
382
-	$lien = $chemin = $type = $media = '';
383
-
384
-	include_spip('inc/utils');
385
-	if (tester_url_absolue($attrs['source'])) {
386
-		$lien = $attrs['source'];
387
-	} else {
388
-		$chemin = $attrs['source'];
389
-	}
390
-	if (isset($attrs['type'])) {
391
-		$type = $attrs['type'];
392
-	}
393
-
394
-	$n = $phraseur->contenu['compatible'];
395
-	$phraseur->versions[$n]['script'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type];
382
+    $lien = $chemin = $type = $media = '';
383
+
384
+    include_spip('inc/utils');
385
+    if (tester_url_absolue($attrs['source'])) {
386
+        $lien = $attrs['source'];
387
+    } else {
388
+        $chemin = $attrs['source'];
389
+    }
390
+    if (isset($attrs['type'])) {
391
+        $type = $attrs['type'];
392
+    }
393
+
394
+    $n = $phraseur->contenu['compatible'];
395
+    $phraseur->versions[$n]['script'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type];
396 396
 }
397 397
 
398 398
 /**
@@ -403,6 +403,6 @@  discard block
 block discarded – undo
403 403
  * @param string $texte
404 404
  */
405 405
 function info_paquet_genie($phraseur, $attrs, $texte) {
406
-	$n = $phraseur->contenu['compatible'];
407
-	$phraseur->versions[$n]['genie'][] = $attrs;
406
+    $n = $phraseur->contenu['compatible'];
407
+    $phraseur->versions[$n]['genie'][] = $attrs;
408 408
 }
Please login to merge, or discard this patch.
ecrire/plugins/installer.php 2 patches
Indentation   +130 added lines, -130 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
 /**
@@ -53,92 +53,92 @@  discard block
 block discarded – undo
53 53
  */
54 54
 function plugins_installer_dist($plug, $action, $dir_type = '_DIR_PLUGINS') {
55 55
 
56
-	// Charger les informations du XML du plugin et vérification de l'existence d'une installation
57
-	$get_infos = charger_fonction('get_infos', 'plugins');
58
-	$infos = $get_infos($plug, false, constant($dir_type));
59
-	if (!isset($infos['install']) || !$infos['install']) {
60
-		return false;
61
-	}
62
-
63
-	// Passer en chemin absolu si possible, c'est plus efficace
64
-	$dir = str_replace('_DIR_', '_ROOT_', $dir_type);
65
-	if (!defined($dir)) {
66
-		$dir = $dir_type;
67
-	}
68
-	$dir = constant($dir);
69
-	foreach ($infos['install'] as $file) {
70
-		$file = $dir . $plug . '/' . trim($file);
71
-		if (file_exists($file)) {
72
-			include_once($file);
73
-		}
74
-	}
75
-
76
-	// Détermination de la table meta et du nom de la meta plugin
77
-	$table = 'meta';
78
-	if (isset($infos['meta']) && $infos['meta'] !== 'meta') {
79
-		$table = $infos['meta'];
80
-		// S'assurer que les metas de la table spécifique sont bien accessibles dans la globale
81
-		lire_metas($table);
82
-	}
83
-	$nom_meta = $infos['prefix'] . '_base_version';
84
-
85
-	// Détermination de la fonction à appeler et de ses arguments
86
-	$f = $infos['prefix'] . '_install';
87
-	if (!function_exists($f)) {
88
-		$f = isset($infos['schema']) ? 'spip_plugin_install' : '';
89
-		$arg = $infos;
90
-		// On passe la table et la meta pour éviter de les recalculer dans la fonction appelée
91
-		$arg['meta'] = $table;
92
-		$arg['nom_meta'] = $nom_meta;
93
-	} else {
94
-		// Ancienne méthode d'installation - TODO à supprimer à terme
95
-		// stupide: info deja dans le nom
96
-		$arg = $infos['prefix'];
97
-	}
98
-	$version = $infos['schema'] ?? '';
99
-
100
-	if (!$f) {
101
-		// installation sans operation particuliere
102
-		$infos['install_test'] = [true, ''];
103
-		return $infos;
104
-	}
105
-
106
-	// Tester si l'action demandée est nécessaire ou pas.
107
-	$test = $f('test', $arg, $version);
108
-	if ($action == 'uninstall') {
109
-		$test = !$test;
110
-	}
111
-	// Si deja fait, on ne fait rien et on ne dit rien
112
-	if ($test) {
113
-		return true;
114
-	}
115
-
116
-	// Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos
117
-	// pour renvoyer le bon message en retour de la fonction.
118
-	if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) {
119
-		$infos['upgrade'] = true;
120
-	}
121
-
122
-	// executer l'installation ou l'inverse
123
-	// et renvoyer la trace (mais il faudrait passer en AJAX plutot)
124
-	ob_start();
125
-	$f($action, $arg, $version);
126
-	$aff = ob_get_contents();
127
-	ob_end_clean();
128
-
129
-	// vider le cache des descriptions de tables a chaque (de)installation
130
-	$trouver_table = charger_fonction('trouver_table', 'base');
131
-	$trouver_table('');
132
-	$infos['install_test'] = [$f('test', $arg, $version), $aff];
133
-
134
-	// Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin
135
-	// on force la création du fichier cache à la date du moment.
136
-	// On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta.
137
-	if ($table !== 'meta' && $action == 'install' && empty($infos['upgrade'])) {
138
-		touch_meta(false, $table);
139
-	}
140
-
141
-	return $infos;
56
+    // Charger les informations du XML du plugin et vérification de l'existence d'une installation
57
+    $get_infos = charger_fonction('get_infos', 'plugins');
58
+    $infos = $get_infos($plug, false, constant($dir_type));
59
+    if (!isset($infos['install']) || !$infos['install']) {
60
+        return false;
61
+    }
62
+
63
+    // Passer en chemin absolu si possible, c'est plus efficace
64
+    $dir = str_replace('_DIR_', '_ROOT_', $dir_type);
65
+    if (!defined($dir)) {
66
+        $dir = $dir_type;
67
+    }
68
+    $dir = constant($dir);
69
+    foreach ($infos['install'] as $file) {
70
+        $file = $dir . $plug . '/' . trim($file);
71
+        if (file_exists($file)) {
72
+            include_once($file);
73
+        }
74
+    }
75
+
76
+    // Détermination de la table meta et du nom de la meta plugin
77
+    $table = 'meta';
78
+    if (isset($infos['meta']) && $infos['meta'] !== 'meta') {
79
+        $table = $infos['meta'];
80
+        // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale
81
+        lire_metas($table);
82
+    }
83
+    $nom_meta = $infos['prefix'] . '_base_version';
84
+
85
+    // Détermination de la fonction à appeler et de ses arguments
86
+    $f = $infos['prefix'] . '_install';
87
+    if (!function_exists($f)) {
88
+        $f = isset($infos['schema']) ? 'spip_plugin_install' : '';
89
+        $arg = $infos;
90
+        // On passe la table et la meta pour éviter de les recalculer dans la fonction appelée
91
+        $arg['meta'] = $table;
92
+        $arg['nom_meta'] = $nom_meta;
93
+    } else {
94
+        // Ancienne méthode d'installation - TODO à supprimer à terme
95
+        // stupide: info deja dans le nom
96
+        $arg = $infos['prefix'];
97
+    }
98
+    $version = $infos['schema'] ?? '';
99
+
100
+    if (!$f) {
101
+        // installation sans operation particuliere
102
+        $infos['install_test'] = [true, ''];
103
+        return $infos;
104
+    }
105
+
106
+    // Tester si l'action demandée est nécessaire ou pas.
107
+    $test = $f('test', $arg, $version);
108
+    if ($action == 'uninstall') {
109
+        $test = !$test;
110
+    }
111
+    // Si deja fait, on ne fait rien et on ne dit rien
112
+    if ($test) {
113
+        return true;
114
+    }
115
+
116
+    // Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos
117
+    // pour renvoyer le bon message en retour de la fonction.
118
+    if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) {
119
+        $infos['upgrade'] = true;
120
+    }
121
+
122
+    // executer l'installation ou l'inverse
123
+    // et renvoyer la trace (mais il faudrait passer en AJAX plutot)
124
+    ob_start();
125
+    $f($action, $arg, $version);
126
+    $aff = ob_get_contents();
127
+    ob_end_clean();
128
+
129
+    // vider le cache des descriptions de tables a chaque (de)installation
130
+    $trouver_table = charger_fonction('trouver_table', 'base');
131
+    $trouver_table('');
132
+    $infos['install_test'] = [$f('test', $arg, $version), $aff];
133
+
134
+    // Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin
135
+    // on force la création du fichier cache à la date du moment.
136
+    // On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta.
137
+    if ($table !== 'meta' && $action == 'install' && empty($infos['upgrade'])) {
138
+        touch_meta(false, $table);
139
+    }
140
+
141
+    return $infos;
142 142
 }
143 143
 
144 144
 /**
@@ -154,24 +154,24 @@  discard block
 block discarded – undo
154 154
  * @return bool|void
155 155
  */
156 156
 function spip_plugin_install($action, $infos, $version_cible) {
157
-	$nom_meta = $infos['nom_meta'];
158
-	$table = $infos['meta'];
159
-	switch ($action) {
160
-		case 'test':
161
-			return (isset($GLOBALS[$table])
162
-				&& isset($GLOBALS[$table][$nom_meta])
163
-				&& spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>='));
164
-		case 'install':
165
-			if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) {
166
-				$upgrade($nom_meta, $version_cible, $table);
167
-			}
168
-			break;
169
-		case 'uninstall':
170
-			if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) {
171
-				$vider_tables($nom_meta, $table);
172
-			}
173
-			break;
174
-	}
157
+    $nom_meta = $infos['nom_meta'];
158
+    $table = $infos['meta'];
159
+    switch ($action) {
160
+        case 'test':
161
+            return (isset($GLOBALS[$table])
162
+                && isset($GLOBALS[$table][$nom_meta])
163
+                && spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>='));
164
+        case 'install':
165
+            if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) {
166
+                $upgrade($nom_meta, $version_cible, $table);
167
+            }
168
+            break;
169
+        case 'uninstall':
170
+            if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) {
171
+                $vider_tables($nom_meta, $table);
172
+            }
173
+            break;
174
+    }
175 175
 }
176 176
 
177 177
 
@@ -190,29 +190,29 @@  discard block
 block discarded – undo
190 190
  * @return array Tableau des plugins actifs
191 191
  **/
192 192
 function liste_plugin_actifs() {
193
-	$liste = $GLOBALS['meta']['plugin'] ?? '';
194
-	if (!$liste) {
195
-		return [];
196
-	}
197
-	if (!is_array($liste = unserialize($liste))) {
198
-		// compatibilite pre 1.9.2, mettre a jour la meta
199
-		spip_log("MAJ meta plugin vieille version : $liste", 'plugin');
200
-		$new = true;
201
-		[, $liste] = liste_plugin_valides(explode(',', $liste));
202
-	} else {
203
-		$new = false;
204
-		// compat au moment d'une migration depuis version anterieure
205
-		// si pas de dir_type, alors c'est _DIR_PLUGINS
206
-		foreach ($liste as $prefix => $infos) {
207
-			if (!isset($infos['dir_type'])) {
208
-				$liste[$prefix]['dir_type'] = '_DIR_PLUGINS';
209
-				$new = true;
210
-			}
211
-		}
212
-	}
213
-	if ($new) {
214
-		ecrire_meta('plugin', serialize($liste));
215
-	}
216
-
217
-	return $liste;
193
+    $liste = $GLOBALS['meta']['plugin'] ?? '';
194
+    if (!$liste) {
195
+        return [];
196
+    }
197
+    if (!is_array($liste = unserialize($liste))) {
198
+        // compatibilite pre 1.9.2, mettre a jour la meta
199
+        spip_log("MAJ meta plugin vieille version : $liste", 'plugin');
200
+        $new = true;
201
+        [, $liste] = liste_plugin_valides(explode(',', $liste));
202
+    } else {
203
+        $new = false;
204
+        // compat au moment d'une migration depuis version anterieure
205
+        // si pas de dir_type, alors c'est _DIR_PLUGINS
206
+        foreach ($liste as $prefix => $infos) {
207
+            if (!isset($infos['dir_type'])) {
208
+                $liste[$prefix]['dir_type'] = '_DIR_PLUGINS';
209
+                $new = true;
210
+            }
211
+        }
212
+    }
213
+    if ($new) {
214
+        ecrire_meta('plugin', serialize($liste));
215
+    }
216
+
217
+    return $liste;
218 218
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	}
68 68
 	$dir = constant($dir);
69 69
 	foreach ($infos['install'] as $file) {
70
-		$file = $dir . $plug . '/' . trim($file);
70
+		$file = $dir.$plug.'/'.trim($file);
71 71
 		if (file_exists($file)) {
72 72
 			include_once($file);
73 73
 		}
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 		// S'assurer que les metas de la table spécifique sont bien accessibles dans la globale
81 81
 		lire_metas($table);
82 82
 	}
83
-	$nom_meta = $infos['prefix'] . '_base_version';
83
+	$nom_meta = $infos['prefix'].'_base_version';
84 84
 
85 85
 	// Détermination de la fonction à appeler et de ses arguments
86
-	$f = $infos['prefix'] . '_install';
86
+	$f = $infos['prefix'].'_install';
87 87
 	if (!function_exists($f)) {
88 88
 		$f = isset($infos['schema']) ? 'spip_plugin_install' : '';
89 89
 		$arg = $infos;
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
 				&& isset($GLOBALS[$table][$nom_meta])
163 163
 				&& spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>='));
164 164
 		case 'install':
165
-			if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) {
165
+			if (function_exists($upgrade = $infos['prefix'].'_upgrade')) {
166 166
 				$upgrade($nom_meta, $version_cible, $table);
167 167
 			}
168 168
 			break;
169 169
 		case 'uninstall':
170
-			if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) {
170
+			if (function_exists($vider_tables = $infos['prefix'].'_vider_tables')) {
171 171
 				$vider_tables($nom_meta, $table);
172 172
 			}
173 173
 			break;
Please login to merge, or discard this patch.
ecrire/plugins/afficher_liste.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 include_spip('inc/charsets');
16 16
 
@@ -26,90 +26,90 @@  discard block
 block discarded – undo
26 26
  * @return string
27 27
  */
28 28
 function plugins_afficher_liste_dist(
29
-	$url_page,
30
-	$liste_plugins,
31
-	$liste_plugins_checked,
32
-	$liste_plugins_actifs,
33
-	$dir_plugins = _DIR_PLUGINS,
34
-	$afficher_un = 'afficher_plugin'
29
+    $url_page,
30
+    $liste_plugins,
31
+    $liste_plugins_checked,
32
+    $liste_plugins_actifs,
33
+    $dir_plugins = _DIR_PLUGINS,
34
+    $afficher_un = 'afficher_plugin'
35 35
 ) {
36
-	$get_infos = charger_fonction('get_infos', 'plugins');
37
-	$ligne_plug = charger_fonction($afficher_un, 'plugins');
36
+    $get_infos = charger_fonction('get_infos', 'plugins');
37
+    $ligne_plug = charger_fonction($afficher_un, 'plugins');
38 38
 
39
-	$all_infos = $get_infos($liste_plugins, false, $dir_plugins);
39
+    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
40 40
 
41
-	$all_infos = pipeline(
42
-		'filtrer_liste_plugins',
43
-		[
44
-			'args' => [
45
-				'liste_plugins' => $liste_plugins,
46
-				'liste_plugins_checked' => $liste_plugins_checked,
47
-				'liste_plugins_actifs' => $liste_plugins_actifs,
48
-				'dir_plugins' => $dir_plugins
49
-			],
50
-			'data' => $all_infos
51
-		]
52
-	);
41
+    $all_infos = pipeline(
42
+        'filtrer_liste_plugins',
43
+        [
44
+            'args' => [
45
+                'liste_plugins' => $liste_plugins,
46
+                'liste_plugins_checked' => $liste_plugins_checked,
47
+                'liste_plugins_actifs' => $liste_plugins_actifs,
48
+                'dir_plugins' => $dir_plugins
49
+            ],
50
+            'data' => $all_infos
51
+        ]
52
+    );
53 53
 
54
-	$liste_plugins = array_flip($liste_plugins);
55
-	foreach (array_keys($liste_plugins) as $chemin) {
56
-		// des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
57
-		if (isset($all_infos[$chemin])) {
58
-			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
59
-		} else {
60
-			unset($liste_plugins[$chemin]);
61
-		}
62
-	}
63
-	asort($liste_plugins);
64
-	$exposed = urldecode(_request('plugin') ?? '');
54
+    $liste_plugins = array_flip($liste_plugins);
55
+    foreach (array_keys($liste_plugins) as $chemin) {
56
+        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
57
+        if (isset($all_infos[$chemin])) {
58
+            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
59
+        } else {
60
+            unset($liste_plugins[$chemin]);
61
+        }
62
+    }
63
+    asort($liste_plugins);
64
+    $exposed = urldecode(_request('plugin') ?? '');
65 65
 
66
-	$block_par_lettre = false;//count($liste_plugins)>10;
67
-	$fast_liste_plugins_actifs = [];
68
-	$fast_liste_plugins_checked = [];
69
-	if (is_array($liste_plugins_actifs)) {
70
-		$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
71
-	}
72
-	if (is_array($liste_plugins_checked)) {
73
-		$fast_liste_plugins_checked = array_flip($liste_plugins_checked);
74
-	}
66
+    $block_par_lettre = false;//count($liste_plugins)>10;
67
+    $fast_liste_plugins_actifs = [];
68
+    $fast_liste_plugins_checked = [];
69
+    if (is_array($liste_plugins_actifs)) {
70
+        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
71
+    }
72
+    if (is_array($liste_plugins_checked)) {
73
+        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
74
+    }
75 75
 
76
-	$res = '';
77
-	$block = '';
78
-	$initiale = '';
79
-	$block_actif = false;
80
-	foreach ($liste_plugins as $plug => $nom) {
81
-		if (($i = substr($nom, 0, 1)) !== $initiale) {
82
-			$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
83
-			$initiale = $i;
84
-			$block = '';
85
-			$block_actif = false;
86
-		}
87
-		// le rep suivant
88
-		$actif = isset($fast_liste_plugins_actifs[$plug]);
89
-		$checked = isset($fast_liste_plugins_checked[$plug]);
90
-		$block_actif |= $actif;
91
-		$expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins . $plug || $exposed === substr(
92
-			$dir_plugins,
93
-			strlen(_DIR_RACINE)
94
-		) . $plug));
95
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
96
-	}
97
-	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
98
-	$class = basename($dir_plugins);
76
+    $res = '';
77
+    $block = '';
78
+    $initiale = '';
79
+    $block_actif = false;
80
+    foreach ($liste_plugins as $plug => $nom) {
81
+        if (($i = substr($nom, 0, 1)) !== $initiale) {
82
+            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
83
+            $initiale = $i;
84
+            $block = '';
85
+            $block_actif = false;
86
+        }
87
+        // le rep suivant
88
+        $actif = isset($fast_liste_plugins_actifs[$plug]);
89
+        $checked = isset($fast_liste_plugins_checked[$plug]);
90
+        $block_actif |= $actif;
91
+        $expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins . $plug || $exposed === substr(
92
+            $dir_plugins,
93
+            strlen(_DIR_RACINE)
94
+        ) . $plug));
95
+        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
96
+    }
97
+    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
98
+    $class = basename($dir_plugins);
99 99
 
100
-	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
100
+    return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
101 101
 }
102 102
 
103 103
 
104 104
 function affiche_block_initiale($initiale, $block, $block_actif) {
105
-	if (strlen($block)) {
106
-		return "<li class='item'>"
107
-		. bouton_block_depliable($initiale, (bool) $block_actif)
108
-		. debut_block_depliable($block_actif)
109
-		. "<ul>$block</ul>"
110
-		. fin_block()
111
-		. '</li>';
112
-	}
105
+    if (strlen($block)) {
106
+        return "<li class='item'>"
107
+        . bouton_block_depliable($initiale, (bool) $block_actif)
108
+        . debut_block_depliable($block_actif)
109
+        . "<ul>$block</ul>"
110
+        . fin_block()
111
+        . '</li>';
112
+    }
113 113
 
114
-	return '';
114
+    return '';
115 115
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	asort($liste_plugins);
64 64
 	$exposed = urldecode(_request('plugin') ?? '');
65 65
 
66
-	$block_par_lettre = false;//count($liste_plugins)>10;
66
+	$block_par_lettre = false; //count($liste_plugins)>10;
67 67
 	$fast_liste_plugins_actifs = [];
68 68
 	$fast_liste_plugins_checked = [];
69 69
 	if (is_array($liste_plugins_actifs)) {
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 		$actif = isset($fast_liste_plugins_actifs[$plug]);
89 89
 		$checked = isset($fast_liste_plugins_checked[$plug]);
90 90
 		$block_actif |= $actif;
91
-		$expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins . $plug || $exposed === substr(
91
+		$expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins.$plug || $exposed === substr(
92 92
 			$dir_plugins,
93 93
 			strlen(_DIR_RACINE)
94
-		) . $plug));
95
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
94
+		).$plug));
95
+		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins)."\n";
96 96
 	}
97 97
 	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
98 98
 	$class = basename($dir_plugins);
Please login to merge, or discard this patch.
ecrire/plugins/verifie_conformite.php 2 patches
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -10,207 +10,207 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/xml');
17 17
 include_spip('inc/plugin');
18 18
 
19 19
 function plugins_verifie_conformite_dist($plug, &$arbre, $dir_plugins = _DIR_PLUGINS) {
20
-	$needs = null;
21
-	$compat_spip = null;
22
-	$uses = null;
23
-	$paths = null;
24
-	$trads = null;
25
-	static $etats = ['dev', 'experimental', 'test', 'stable'];
20
+    $needs = null;
21
+    $compat_spip = null;
22
+    $uses = null;
23
+    $paths = null;
24
+    $trads = null;
25
+    static $etats = ['dev', 'experimental', 'test', 'stable'];
26 26
 
27
-	$matches = [];
28
-	$silence = false;
29
-	$p = null;
30
-	// chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP
31
-	if ($n = spip_xml_match_nodes(',^plugin(\s|$),', $arbre, $matches)) {
32
-		// version de SPIP
33
-		$vspip = $GLOBALS['spip_version_branche'];
34
-		foreach ($matches as $tag => $sous) {
35
-			[$tagname, $atts] = spip_xml_decompose_tag($tag);
36
-			// On rajoute la condition sur $n :
37
-			// -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait
38
-			//    un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise
39
-			//    de la meme facon.
40
-			if (
41
-				$tagname == 'plugin'
42
-				&& is_array($sous)
43
-				&& (!isset($atts['spip']) || $n == 1 || plugin_version_compatible($atts['spip'], $vspip, 'spip'))
44
-			) {
45
-				// on prend la derniere declaration avec ce nom
46
-				$p = end($sous);
47
-				$compat_spip = $atts['spip'] ?? '';
48
-			}
49
-		}
50
-	}
51
-	if (is_null($p)) {
52
-		$arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]];
53
-		$silence = true;
54
-	} else {
55
-		$arbre = $p;
56
-	}
57
-	if (!is_array($arbre)) {
58
-		$arbre = [];
59
-	}
60
-	// verification de la conformite du plugin avec quelques
61
-	// precautions elementaires
62
-	if (!isset($arbre['nom'])) {
63
-		if (!$silence) {
64
-			$arbre['erreur'][] = _T('erreur_plugin_nom_manquant');
65
-		}
66
-		$arbre['nom'] = [''];
67
-	}
68
-	if (!isset($arbre['version'])) {
69
-		if (!$silence) {
70
-			$arbre['erreur'][] = _T('erreur_plugin_version_manquant');
71
-		}
72
-		$arbre['version'] = [''];
73
-	}
74
-	if (!isset($arbre['prefix'])) {
75
-		if (!$silence) {
76
-			$arbre['erreur'][] = _T('erreur_plugin_prefix_manquant');
77
-		}
78
-		$arbre['prefix'] = [''];
79
-	} else {
80
-		$prefix = trim(end($arbre['prefix']));
81
-		if (strtoupper($prefix) == 'SPIP' && $plug != './') {
82
-			$arbre['erreur'][] = _T('erreur_plugin_prefix_interdit');
83
-		}
84
-		if (isset($arbre['etat'])) {
85
-			$etat = trim(end($arbre['etat']));
86
-			if (!in_array($etat, $etats)) {
87
-				$arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'";
88
-			}
89
-		}
90
-		if (isset($arbre['options'])) {
91
-			foreach ($arbre['options'] as $optfile) {
92
-				$optfile = trim($optfile);
93
-				if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) {
94
-					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
95
-				}
96
-			}
97
-		}
98
-		if (isset($arbre['fonctions'])) {
99
-			foreach ($arbre['fonctions'] as $optfile) {
100
-				$optfile = trim($optfile);
101
-				if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) {
102
-					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
103
-				}
104
-			}
105
-		}
106
-		$fonctions = [];
107
-		if (isset($arbre['fonctions'])) {
108
-			$fonctions = $arbre['fonctions'];
109
-		}
110
-		$liste_methodes_reservees = [
111
-			'__construct',
112
-			'__destruct',
113
-			'plugin',
114
-			'install',
115
-			'uninstall',
116
-			strtolower($prefix)
117
-		];
27
+    $matches = [];
28
+    $silence = false;
29
+    $p = null;
30
+    // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP
31
+    if ($n = spip_xml_match_nodes(',^plugin(\s|$),', $arbre, $matches)) {
32
+        // version de SPIP
33
+        $vspip = $GLOBALS['spip_version_branche'];
34
+        foreach ($matches as $tag => $sous) {
35
+            [$tagname, $atts] = spip_xml_decompose_tag($tag);
36
+            // On rajoute la condition sur $n :
37
+            // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait
38
+            //    un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise
39
+            //    de la meme facon.
40
+            if (
41
+                $tagname == 'plugin'
42
+                && is_array($sous)
43
+                && (!isset($atts['spip']) || $n == 1 || plugin_version_compatible($atts['spip'], $vspip, 'spip'))
44
+            ) {
45
+                // on prend la derniere declaration avec ce nom
46
+                $p = end($sous);
47
+                $compat_spip = $atts['spip'] ?? '';
48
+            }
49
+        }
50
+    }
51
+    if (is_null($p)) {
52
+        $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]];
53
+        $silence = true;
54
+    } else {
55
+        $arbre = $p;
56
+    }
57
+    if (!is_array($arbre)) {
58
+        $arbre = [];
59
+    }
60
+    // verification de la conformite du plugin avec quelques
61
+    // precautions elementaires
62
+    if (!isset($arbre['nom'])) {
63
+        if (!$silence) {
64
+            $arbre['erreur'][] = _T('erreur_plugin_nom_manquant');
65
+        }
66
+        $arbre['nom'] = [''];
67
+    }
68
+    if (!isset($arbre['version'])) {
69
+        if (!$silence) {
70
+            $arbre['erreur'][] = _T('erreur_plugin_version_manquant');
71
+        }
72
+        $arbre['version'] = [''];
73
+    }
74
+    if (!isset($arbre['prefix'])) {
75
+        if (!$silence) {
76
+            $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant');
77
+        }
78
+        $arbre['prefix'] = [''];
79
+    } else {
80
+        $prefix = trim(end($arbre['prefix']));
81
+        if (strtoupper($prefix) == 'SPIP' && $plug != './') {
82
+            $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit');
83
+        }
84
+        if (isset($arbre['etat'])) {
85
+            $etat = trim(end($arbre['etat']));
86
+            if (!in_array($etat, $etats)) {
87
+                $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'";
88
+            }
89
+        }
90
+        if (isset($arbre['options'])) {
91
+            foreach ($arbre['options'] as $optfile) {
92
+                $optfile = trim($optfile);
93
+                if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) {
94
+                    $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
95
+                }
96
+            }
97
+        }
98
+        if (isset($arbre['fonctions'])) {
99
+            foreach ($arbre['fonctions'] as $optfile) {
100
+                $optfile = trim($optfile);
101
+                if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) {
102
+                    $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
103
+                }
104
+            }
105
+        }
106
+        $fonctions = [];
107
+        if (isset($arbre['fonctions'])) {
108
+            $fonctions = $arbre['fonctions'];
109
+        }
110
+        $liste_methodes_reservees = [
111
+            '__construct',
112
+            '__destruct',
113
+            'plugin',
114
+            'install',
115
+            'uninstall',
116
+            strtolower($prefix)
117
+        ];
118 118
 
119
-		$extraire_pipelines = charger_fonction('extraire_pipelines', 'plugins');
120
-		$arbre['pipeline'] = $extraire_pipelines($arbre);
121
-		foreach ($arbre['pipeline'] as $pipe) {
122
-			if (!isset($pipe['nom']) && !$silence) {
123
-				$arbre['erreur'][] = _T('erreur_plugin_nom_pipeline_non_defini');
124
-			}
125
-			$action = $pipe['action'] ?? $pipe['nom'];
126
-			// verif que la methode a un nom autorise
127
-			if (in_array(strtolower($action), $liste_methodes_reservees) && !$silence) {
128
-				$arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action";
129
-			}
130
-			if (isset($pipe['inclure'])) {
131
-				$inclure = $dir_plugins . "$plug/" . $pipe['inclure'];
132
-				if (!@is_readable($inclure) && !$silence) {
133
-					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure";
134
-				}
135
-			}
136
-		}
137
-		$necessite = [];
138
-		$spip_trouve = false;
139
-		if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) {
140
-			foreach (array_keys($needs) as $tag) {
141
-				[$tag, $att] = spip_xml_decompose_tag($tag);
142
-				if (!isset($att['id'])) {
143
-					if (!$silence) {
144
-						$arbre['erreur'][] = _T(
145
-							'erreur_plugin_attribut_balise_manquant',
146
-							['attribut' => 'id', 'balise' => $att]
147
-						);
148
-					}
149
-				} else {
150
-					$necessite[] = $att;
151
-				}
152
-				if (strtolower($att['id']) == 'spip') {
153
-					$spip_trouve = true;
154
-				}
155
-			}
156
-		}
157
-		if ($compat_spip && !$spip_trouve) {
158
-			$necessite[] = ['id' => 'spip', 'version' => $compat_spip];
159
-		}
160
-		$arbre['necessite'] = $necessite;
161
-		$utilise = [];
162
-		if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) {
163
-			foreach (array_keys($uses) as $tag) {
164
-				[$tag, $att] = spip_xml_decompose_tag($tag);
165
-				if (!isset($att['id'])) {
166
-					if (!$silence) {
167
-						$arbre['erreur'][] = _T(
168
-							'erreur_plugin_attribut_balise_manquant',
169
-							['attribut' => 'id', 'balise' => $att]
170
-						);
171
-					}
172
-				} else {
173
-					$utilise[] = $att;
174
-				}
175
-			}
176
-		}
177
-		$arbre['utilise'] = $utilise;
178
-		$procure = [];
179
-		if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) {
180
-			foreach (array_keys($uses) as $tag) {
181
-				[$tag, $att] = spip_xml_decompose_tag($tag);
182
-				$procure[] = $att;
183
-			}
184
-		}
185
-		$arbre['procure'] = $procure;
186
-		$path = [];
187
-		if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) {
188
-			foreach (array_keys($paths) as $tag) {
189
-				[$tag, $att] = spip_xml_decompose_tag($tag);
190
-				$att['path'] = $att['dir']; // ancienne syntaxe
191
-				$path[] = $att;
192
-			}
193
-		} else {
194
-			$path = [['dir' => '']];
195
-		} // initialiser par defaut
196
-		$arbre['path'] = $path;
197
-		// exposer les noisettes
198
-		if (isset($arbre['noisette'])) {
199
-			foreach ($arbre['noisette'] as $k => $nut) {
200
-				$nut = preg_replace(',[.]html$,uims', '', trim($nut));
201
-				$arbre['noisette'][$k] = $nut;
202
-				if (!@is_readable($dir_plugins . "$plug/$nut.html") && !$silence) {
203
-					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut";
204
-				}
205
-			}
206
-		}
207
-		$traduire = [];
208
-		if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) {
209
-			foreach (array_keys($trads) as $tag) {
210
-				[$tag, $att] = spip_xml_decompose_tag($tag);
211
-				$traduire[] = $att;
212
-			}
213
-		}
214
-		$arbre['traduire'] = $traduire;
215
-	}
119
+        $extraire_pipelines = charger_fonction('extraire_pipelines', 'plugins');
120
+        $arbre['pipeline'] = $extraire_pipelines($arbre);
121
+        foreach ($arbre['pipeline'] as $pipe) {
122
+            if (!isset($pipe['nom']) && !$silence) {
123
+                $arbre['erreur'][] = _T('erreur_plugin_nom_pipeline_non_defini');
124
+            }
125
+            $action = $pipe['action'] ?? $pipe['nom'];
126
+            // verif que la methode a un nom autorise
127
+            if (in_array(strtolower($action), $liste_methodes_reservees) && !$silence) {
128
+                $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action";
129
+            }
130
+            if (isset($pipe['inclure'])) {
131
+                $inclure = $dir_plugins . "$plug/" . $pipe['inclure'];
132
+                if (!@is_readable($inclure) && !$silence) {
133
+                    $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure";
134
+                }
135
+            }
136
+        }
137
+        $necessite = [];
138
+        $spip_trouve = false;
139
+        if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) {
140
+            foreach (array_keys($needs) as $tag) {
141
+                [$tag, $att] = spip_xml_decompose_tag($tag);
142
+                if (!isset($att['id'])) {
143
+                    if (!$silence) {
144
+                        $arbre['erreur'][] = _T(
145
+                            'erreur_plugin_attribut_balise_manquant',
146
+                            ['attribut' => 'id', 'balise' => $att]
147
+                        );
148
+                    }
149
+                } else {
150
+                    $necessite[] = $att;
151
+                }
152
+                if (strtolower($att['id']) == 'spip') {
153
+                    $spip_trouve = true;
154
+                }
155
+            }
156
+        }
157
+        if ($compat_spip && !$spip_trouve) {
158
+            $necessite[] = ['id' => 'spip', 'version' => $compat_spip];
159
+        }
160
+        $arbre['necessite'] = $necessite;
161
+        $utilise = [];
162
+        if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) {
163
+            foreach (array_keys($uses) as $tag) {
164
+                [$tag, $att] = spip_xml_decompose_tag($tag);
165
+                if (!isset($att['id'])) {
166
+                    if (!$silence) {
167
+                        $arbre['erreur'][] = _T(
168
+                            'erreur_plugin_attribut_balise_manquant',
169
+                            ['attribut' => 'id', 'balise' => $att]
170
+                        );
171
+                    }
172
+                } else {
173
+                    $utilise[] = $att;
174
+                }
175
+            }
176
+        }
177
+        $arbre['utilise'] = $utilise;
178
+        $procure = [];
179
+        if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) {
180
+            foreach (array_keys($uses) as $tag) {
181
+                [$tag, $att] = spip_xml_decompose_tag($tag);
182
+                $procure[] = $att;
183
+            }
184
+        }
185
+        $arbre['procure'] = $procure;
186
+        $path = [];
187
+        if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) {
188
+            foreach (array_keys($paths) as $tag) {
189
+                [$tag, $att] = spip_xml_decompose_tag($tag);
190
+                $att['path'] = $att['dir']; // ancienne syntaxe
191
+                $path[] = $att;
192
+            }
193
+        } else {
194
+            $path = [['dir' => '']];
195
+        } // initialiser par defaut
196
+        $arbre['path'] = $path;
197
+        // exposer les noisettes
198
+        if (isset($arbre['noisette'])) {
199
+            foreach ($arbre['noisette'] as $k => $nut) {
200
+                $nut = preg_replace(',[.]html$,uims', '', trim($nut));
201
+                $arbre['noisette'][$k] = $nut;
202
+                if (!@is_readable($dir_plugins . "$plug/$nut.html") && !$silence) {
203
+                    $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut";
204
+                }
205
+            }
206
+        }
207
+        $traduire = [];
208
+        if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) {
209
+            foreach (array_keys($trads) as $tag) {
210
+                [$tag, $att] = spip_xml_decompose_tag($tag);
211
+                $traduire[] = $att;
212
+            }
213
+        }
214
+        $arbre['traduire'] = $traduire;
215
+    }
216 216
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		}
50 50
 	}
51 51
 	if (is_null($p)) {
52
-		$arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]];
52
+		$arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent')." : $plug"]];
53 53
 		$silence = true;
54 54
 	} else {
55 55
 		$arbre = $p;
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 		if (isset($arbre['etat'])) {
85 85
 			$etat = trim(end($arbre['etat']));
86 86
 			if (!in_array($etat, $etats)) {
87
-				$arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'";
87
+				$arbre['erreur'][] = _T('erreur_plugin_etat_inconnu')." : '$etat'";
88 88
 			}
89 89
 		}
90 90
 		if (isset($arbre['options'])) {
91 91
 			foreach ($arbre['options'] as $optfile) {
92 92
 				$optfile = trim($optfile);
93
-				if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) {
94
-					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
93
+				if (!@is_readable($dir_plugins."$plug/$optfile") && !$silence) {
94
+					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile";
95 95
 				}
96 96
 			}
97 97
 		}
98 98
 		if (isset($arbre['fonctions'])) {
99 99
 			foreach ($arbre['fonctions'] as $optfile) {
100 100
 				$optfile = trim($optfile);
101
-				if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) {
102
-					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
101
+				if (!@is_readable($dir_plugins."$plug/$optfile") && !$silence) {
102
+					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile";
103 103
 				}
104 104
 			}
105 105
 		}
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 			$action = $pipe['action'] ?? $pipe['nom'];
126 126
 			// verif que la methode a un nom autorise
127 127
 			if (in_array(strtolower($action), $liste_methodes_reservees) && !$silence) {
128
-				$arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action";
128
+				$arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit')." : $action";
129 129
 			}
130 130
 			if (isset($pipe['inclure'])) {
131
-				$inclure = $dir_plugins . "$plug/" . $pipe['inclure'];
131
+				$inclure = $dir_plugins."$plug/".$pipe['inclure'];
132 132
 				if (!@is_readable($inclure) && !$silence) {
133
-					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure";
133
+					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $inclure";
134 134
 				}
135 135
 			}
136 136
 		}
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 			foreach ($arbre['noisette'] as $k => $nut) {
200 200
 				$nut = preg_replace(',[.]html$,uims', '', trim($nut));
201 201
 				$arbre['noisette'][$k] = $nut;
202
-				if (!@is_readable($dir_plugins . "$plug/$nut.html") && !$silence) {
203
-					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut";
202
+				if (!@is_readable($dir_plugins."$plug/$nut.html") && !$silence) {
203
+					$arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $nut";
204 204
 				}
205 205
 			}
206 206
 		}
Please login to merge, or discard this patch.
ecrire/plugins/afficher_nom_plugin.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -10,59 +10,59 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 include_spip('inc/charsets');
16 16
 include_spip('inc/texte');
17 17
 include_spip('plugins/afficher_plugin');
18 18
 
19 19
 function plugins_afficher_nom_plugin_dist(
20
-	$url_page,
21
-	$plug_file,
22
-	$checked,
23
-	$actif,
24
-	$expose = false,
25
-	$class_li = 'item',
26
-	$dir_plugins = _DIR_PLUGINS
20
+    $url_page,
21
+    $plug_file,
22
+    $checked,
23
+    $actif,
24
+    $expose = false,
25
+    $class_li = 'item',
26
+    $dir_plugins = _DIR_PLUGINS
27 27
 ) {
28
-	static $id_input = 0;
29
-	static $versions = [];
28
+    static $id_input = 0;
29
+    static $versions = [];
30 30
 
31
-	$erreur = false;
32
-	$s = '';
31
+    $erreur = false;
32
+    $s = '';
33 33
 
34
-	$get_infos = charger_fonction('get_infos', 'plugins');
35
-	$info = $get_infos($plug_file, false, $dir_plugins);
34
+    $get_infos = charger_fonction('get_infos', 'plugins');
35
+    $info = $get_infos($plug_file, false, $dir_plugins);
36 36
 
37
-	// numerotons les occurences d'un meme prefix
38
-	$versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
39
-	$id = $info['prefix'] . $versions[$info['prefix']];
37
+    // numerotons les occurences d'un meme prefix
38
+    $versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
39
+    $id = $info['prefix'] . $versions[$info['prefix']];
40 40
 
41
-	$class = $class_li;
42
-	$class .= $actif ? ' actif' : '';
43
-	$class .= $expose ? ' on' : '';
44
-	$erreur = isset($info['erreur']);
45
-	if ($erreur) {
46
-		$class .= ' error';
47
-	}
48
-	$s .= "<li id='$id' class='$class'>";
41
+    $class = $class_li;
42
+    $class .= $actif ? ' actif' : '';
43
+    $class .= $expose ? ' on' : '';
44
+    $erreur = isset($info['erreur']);
45
+    if ($erreur) {
46
+        $class .= ' error';
47
+    }
48
+    $s .= "<li id='$id' class='$class'>";
49 49
 
50
-	// Cartouche Resume
51
-	$s .= "<div class='resume'>";
50
+    // Cartouche Resume
51
+    $s .= "<div class='resume'>";
52 52
 
53
-	$prefix = $info['prefix'];
54
-	$dir = "$dir_plugins$plug_file/lang/$prefix";
55
-	$desc = plugin_propre($info['description'], $dir);
56
-	$url_stat = parametre_url($url_page, 'plugin', $dir_plugins . $plug_file);
53
+    $prefix = $info['prefix'];
54
+    $dir = "$dir_plugins$plug_file/lang/$prefix";
55
+    $desc = plugin_propre($info['description'], $dir);
56
+    $url_stat = parametre_url($url_page, 'plugin', $dir_plugins . $plug_file);
57 57
 
58
-	$s .= "<strong class='nom'>" . typo($info['nom']) . '</strong>';
59
-	$s .= " <span class='version'>" . $info['version'] . '</span>';
60
-	$s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . '</span>';
61
-	$s .= '</div>';
58
+    $s .= "<strong class='nom'>" . typo($info['nom']) . '</strong>';
59
+    $s .= " <span class='version'>" . $info['version'] . '</span>';
60
+    $s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . '</span>';
61
+    $s .= '</div>';
62 62
 
63
-	if ($erreur) {
64
-		$s .= "<div class='erreur'>" . implode('<br >', $info['erreur']) . '</div>';
65
-	}
63
+    if ($erreur) {
64
+        $s .= "<div class='erreur'>" . implode('<br >', $info['erreur']) . '</div>';
65
+    }
66 66
 
67
-	return $s . '</li>';
67
+    return $s . '</li>';
68 68
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
 	// numerotons les occurences d'un meme prefix
38 38
 	$versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
39
-	$id = $info['prefix'] . $versions[$info['prefix']];
39
+	$id = $info['prefix'].$versions[$info['prefix']];
40 40
 
41 41
 	$class = $class_li;
42 42
 	$class .= $actif ? ' actif' : '';
@@ -53,16 +53,16 @@  discard block
 block discarded – undo
53 53
 	$prefix = $info['prefix'];
54 54
 	$dir = "$dir_plugins$plug_file/lang/$prefix";
55 55
 	$desc = plugin_propre($info['description'], $dir);
56
-	$url_stat = parametre_url($url_page, 'plugin', $dir_plugins . $plug_file);
56
+	$url_stat = parametre_url($url_page, 'plugin', $dir_plugins.$plug_file);
57 57
 
58
-	$s .= "<strong class='nom'>" . typo($info['nom']) . '</strong>';
59
-	$s .= " <span class='version'>" . $info['version'] . '</span>';
60
-	$s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . '</span>';
58
+	$s .= "<strong class='nom'>".typo($info['nom']).'</strong>';
59
+	$s .= " <span class='version'>".$info['version'].'</span>';
60
+	$s .= " <span class='etat'> - ".plugin_etat_en_clair($info['etat']).'</span>';
61 61
 	$s .= '</div>';
62 62
 
63 63
 	if ($erreur) {
64
-		$s .= "<div class='erreur'>" . implode('<br >', $info['erreur']) . '</div>';
64
+		$s .= "<div class='erreur'>".implode('<br >', $info['erreur']).'</div>';
65 65
 	}
66 66
 
67
-	return $s . '</li>';
67
+	return $s.'</li>';
68 68
 }
Please login to merge, or discard this patch.