Completed
Pull Request — master (#32)
by
unknown
05:47
created
ecrire/notifications/instituerarticle.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -8,53 +8,53 @@
 block discarded – undo
8 8
 
9 9
 
10 10
 if (!defined('_ECRIRE_INC_VERSION')) {
11
-	return;
11
+    return;
12 12
 }
13 13
 
14 14
 // Fonction appelee par divers pipelines
15 15
 // http://code.spip.net/@notifications_instituerarticle_dist
16 16
 function notifications_instituerarticle_dist($quoi, $id_article, $options) {
17 17
 
18
-	// ne devrait jamais se produire
19
-	if ($options['statut'] == $options['statut_ancien']) {
20
-		spip_log('statut inchange', 'notifications');
21
-
22
-		return;
23
-	}
24
-
25
-	include_spip('inc/texte');
26
-
27
-	$modele = '';
28
-	if ($options['statut'] == 'publie') {
29
-		if ($GLOBALS['meta']['post_dates'] == 'non'
30
-			and strtotime($options['date']) > time()
31
-		) {
32
-			$modele = 'notifications/article_valide';
33
-		} else {
34
-			$modele = 'notifications/article_publie';
35
-		}
36
-	}
37
-
38
-	if ($options['statut'] == 'prop' and $options['statut_ancien'] != 'publie') {
39
-		$modele = 'notifications/article_propose';
40
-	}
41
-
42
-	if ($modele) {
43
-		$destinataires = array();
44
-		if ($GLOBALS['meta']['suivi_edito'] == 'oui') {
45
-			$destinataires = explode(',', $GLOBALS['meta']['adresse_suivi']);
46
-		}
47
-
48
-
49
-		$destinataires = pipeline(
50
-			'notifications_destinataires',
51
-			array(
52
-				'args' => array('quoi' => $quoi, 'id' => $id_article, 'options' => $options),
53
-				'data' => $destinataires
54
-			)
55
-		);
56
-
57
-		$texte = email_notification_article($id_article, $modele);
58
-		notifications_envoyer_mails($destinataires, $texte);
59
-	}
18
+    // ne devrait jamais se produire
19
+    if ($options['statut'] == $options['statut_ancien']) {
20
+        spip_log('statut inchange', 'notifications');
21
+
22
+        return;
23
+    }
24
+
25
+    include_spip('inc/texte');
26
+
27
+    $modele = '';
28
+    if ($options['statut'] == 'publie') {
29
+        if ($GLOBALS['meta']['post_dates'] == 'non'
30
+            and strtotime($options['date']) > time()
31
+        ) {
32
+            $modele = 'notifications/article_valide';
33
+        } else {
34
+            $modele = 'notifications/article_publie';
35
+        }
36
+    }
37
+
38
+    if ($options['statut'] == 'prop' and $options['statut_ancien'] != 'publie') {
39
+        $modele = 'notifications/article_propose';
40
+    }
41
+
42
+    if ($modele) {
43
+        $destinataires = array();
44
+        if ($GLOBALS['meta']['suivi_edito'] == 'oui') {
45
+            $destinataires = explode(',', $GLOBALS['meta']['adresse_suivi']);
46
+        }
47
+
48
+
49
+        $destinataires = pipeline(
50
+            'notifications_destinataires',
51
+            array(
52
+                'args' => array('quoi' => $quoi, 'id' => $id_article, 'options' => $options),
53
+                'data' => $destinataires
54
+            )
55
+        );
56
+
57
+        $texte = email_notification_article($id_article, $modele);
58
+        notifications_envoyer_mails($destinataires, $texte);
59
+    }
60 60
 }
Please login to merge, or discard this patch.
ecrire/prive.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@
 block discarded – undo
20 20
 $var_auth = $auth();
21 21
 
22 22
 if ($var_auth !== '') {
23
-	if (!is_int($var_auth)) {
24
-		// si l'authentifie' n'a pas acces a l'espace de redac
25
-		// c'est qu'on voulait forcer sa reconnaissance en tant que visiteur.
26
-		// On reexecute pour deboucher sur le include public.
27
-		// autrement on insiste
28
-		if (is_array($var_auth)) {
29
-			$var_auth = '../?' . $_SERVER['QUERY_STRING'];
30
-			spip_setcookie('spip_session', $_COOKIE['spip_session'], time() + 3600 * 24 * 14);
31
-		}
32
-		include_spip('inc/headers');
33
-		redirige_formulaire($var_auth);
34
-	}
23
+    if (!is_int($var_auth)) {
24
+        // si l'authentifie' n'a pas acces a l'espace de redac
25
+        // c'est qu'on voulait forcer sa reconnaissance en tant que visiteur.
26
+        // On reexecute pour deboucher sur le include public.
27
+        // autrement on insiste
28
+        if (is_array($var_auth)) {
29
+            $var_auth = '../?' . $_SERVER['QUERY_STRING'];
30
+            spip_setcookie('spip_session', $_COOKIE['spip_session'], time() + 3600 * 24 * 14);
31
+        }
32
+        include_spip('inc/headers');
33
+        redirige_formulaire($var_auth);
34
+    }
35 35
 }
36 36
 
37 37
 // En somme, est prive' ce qui est publiquement nomme'...
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 		// On reexecute pour deboucher sur le include public.
27 27
 		// autrement on insiste
28 28
 		if (is_array($var_auth)) {
29
-			$var_auth = '../?' . $_SERVER['QUERY_STRING'];
29
+			$var_auth = '../?'.$_SERVER['QUERY_STRING'];
30 30
 			spip_setcookie('spip_session', $_COOKIE['spip_session'], time() + 3600 * 24 * 14);
31 31
 		}
32 32
 		include_spip('inc/headers');
Please login to merge, or discard this patch.
ecrire/plugins/afficher_nom_plugin.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/charsets');
17 17
 include_spip('inc/texte');
@@ -19,54 +19,54 @@  discard block
 block discarded – undo
19 19
 
20 20
 // http://code.spip.net/@ligne_plug
21 21
 function plugins_afficher_nom_plugin_dist(
22
-	$url_page,
23
-	$plug_file,
24
-	$checked,
25
-	$actif,
26
-	$expose = false,
27
-	$class_li = "item",
28
-	$dir_plugins = _DIR_PLUGINS
22
+    $url_page,
23
+    $plug_file,
24
+    $checked,
25
+    $actif,
26
+    $expose = false,
27
+    $class_li = "item",
28
+    $dir_plugins = _DIR_PLUGINS
29 29
 ) {
30
-	static $id_input = 0;
31
-	static $versions = array();
30
+    static $id_input = 0;
31
+    static $versions = array();
32 32
 
33
-	$erreur = false;
34
-	$s = "";
33
+    $erreur = false;
34
+    $s = "";
35 35
 
36
-	$get_infos = charger_fonction('get_infos', 'plugins');
37
-	$info = $get_infos($plug_file, false, $dir_plugins);
36
+    $get_infos = charger_fonction('get_infos', 'plugins');
37
+    $info = $get_infos($plug_file, false, $dir_plugins);
38 38
 
39
-	// numerotons les occurences d'un meme prefix
40
-	$versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
41
-	$id = $info['prefix'] . $versions[$info['prefix']];
39
+    // numerotons les occurences d'un meme prefix
40
+    $versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
41
+    $id = $info['prefix'] . $versions[$info['prefix']];
42 42
 
43
-	$class = $class_li;
44
-	$class .= $actif ? " actif" : "";
45
-	$class .= $expose ? " on" : "";
46
-	$erreur = isset($info['erreur']);
47
-	if ($erreur) {
48
-		$class .= " error";
49
-	}
50
-	$s .= "<li id='$id' class='$class'>";
43
+    $class = $class_li;
44
+    $class .= $actif ? " actif" : "";
45
+    $class .= $expose ? " on" : "";
46
+    $erreur = isset($info['erreur']);
47
+    if ($erreur) {
48
+        $class .= " error";
49
+    }
50
+    $s .= "<li id='$id' class='$class'>";
51 51
 
52
-	// Cartouche Resume
53
-	$s .= "<div class='resume'>";
52
+    // Cartouche Resume
53
+    $s .= "<div class='resume'>";
54 54
 
55
-	$prefix = $info['prefix'];
56
-	$dir = "$dir_plugins$plug_file/lang/$prefix";
57
-	$desc = plugin_propre($info['description'], $dir);
58
-	$url_stat = parametre_url($url_page, "plugin", $dir_plugins . $plug_file);
55
+    $prefix = $info['prefix'];
56
+    $dir = "$dir_plugins$plug_file/lang/$prefix";
57
+    $desc = plugin_propre($info['description'], $dir);
58
+    $url_stat = parametre_url($url_page, "plugin", $dir_plugins . $plug_file);
59 59
 
60
-	$s .= "<strong class='nom'>" . typo($info['nom']) . "</strong>";
61
-	$s .= " <span class='version'>" . $info['version'] . "</span>";
62
-	$s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . "</span>";
63
-	$s .= "</div>";
60
+    $s .= "<strong class='nom'>" . typo($info['nom']) . "</strong>";
61
+    $s .= " <span class='version'>" . $info['version'] . "</span>";
62
+    $s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . "</span>";
63
+    $s .= "</div>";
64 64
 
65
-	if ($erreur) {
66
-		$s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>";
67
-	}
65
+    if ($erreur) {
66
+        $s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>";
67
+    }
68 68
 
69
-	$s .= "</li>";
69
+    $s .= "</li>";
70 70
 
71
-	return $s;
71
+    return $s;
72 72
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 	// numerotons les occurences d'un meme prefix
40 40
 	$versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
41
-	$id = $info['prefix'] . $versions[$info['prefix']];
41
+	$id = $info['prefix'].$versions[$info['prefix']];
42 42
 
43 43
 	$class = $class_li;
44 44
 	$class .= $actif ? " actif" : "";
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
 	$prefix = $info['prefix'];
56 56
 	$dir = "$dir_plugins$plug_file/lang/$prefix";
57 57
 	$desc = plugin_propre($info['description'], $dir);
58
-	$url_stat = parametre_url($url_page, "plugin", $dir_plugins . $plug_file);
58
+	$url_stat = parametre_url($url_page, "plugin", $dir_plugins.$plug_file);
59 59
 
60
-	$s .= "<strong class='nom'>" . typo($info['nom']) . "</strong>";
61
-	$s .= " <span class='version'>" . $info['version'] . "</span>";
62
-	$s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . "</span>";
60
+	$s .= "<strong class='nom'>".typo($info['nom'])."</strong>";
61
+	$s .= " <span class='version'>".$info['version']."</span>";
62
+	$s .= " <span class='etat'> - ".plugin_etat_en_clair($info['etat'])."</span>";
63 63
 	$s .= "</div>";
64 64
 
65 65
 	if ($erreur) {
66
-		$s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>";
66
+		$s .= "<div class='erreur'>".join('<br >', $info['erreur'])."</div>";
67 67
 	}
68 68
 
69 69
 	$s .= "</li>";
Please login to merge, or discard this patch.
ecrire/plugins/installer.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	}
66 66
 	$dir = constant($dir);
67 67
 	foreach ($infos['install'] as $file) {
68
-		$file = $dir . $plug . "/" . trim($file);
68
+		$file = $dir.$plug."/".trim($file);
69 69
 		if (file_exists($file)) {
70 70
 			include_once($file);
71 71
 		}
72 72
 	}
73 73
 	$version = isset($infos['schema']) ? $infos['schema'] : '';
74 74
 	$arg = $infos;
75
-	$f = $infos['prefix'] . "_install";
75
+	$f = $infos['prefix']."_install";
76 76
 	if (!function_exists($f)) {
77 77
 		$f = isset($infos['schema']) ? 'spip_plugin_install' : '';
78 78
 	} else {
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		return true;
95 95
 	}
96 96
 	// Si install et que l'on a la meta d'installation, c'est un upgrade
97
-	if ($action == 'install' && !is_null(lire_meta($infos['prefix'] . '_base_version'))) {
97
+	if ($action == 'install' && !is_null(lire_meta($infos['prefix'].'_base_version'))) {
98 98
 		$infos['upgrade'] = true;
99 99
 	}
100 100
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	if (isset($infos['meta']) and (($table = $infos['meta']) !== 'meta')) {
121 121
 		$nom_meta = "base_version";
122 122
 	} else {
123
-		$nom_meta = $prefix . "_base_version";
123
+		$nom_meta = $prefix."_base_version";
124 124
 		$table = 'meta';
125 125
 	}
126 126
 	switch ($action) {
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
 				and spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>='));
131 131
 			break;
132 132
 		case 'install':
133
-			if (function_exists($upgrade = $prefix . "_upgrade")) {
133
+			if (function_exists($upgrade = $prefix."_upgrade")) {
134 134
 				$upgrade($nom_meta, $version_cible, $table);
135 135
 			}
136 136
 			break;
137 137
 		case 'uninstall':
138
-			if (function_exists($vider_tables = $prefix . "_vider_tables")) {
138
+			if (function_exists($vider_tables = $prefix."_vider_tables")) {
139 139
 				$vider_tables($nom_meta, $table);
140 140
 			}
141 141
 			break;
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  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
 /**
@@ -53,93 +53,93 @@  discard block
 block discarded – undo
53 53
  *     - le tableau de get_infos sinon
54 54
  */
55 55
 function plugins_installer_dist($plug, $action, $dir_type = '_DIR_PLUGINS') {
56
-	$get_infos = charger_fonction('get_infos', 'plugins');
57
-	$infos = $get_infos($plug, false, constant($dir_type));
58
-	if (!isset($infos['install']) or !$infos['install']) {
59
-		return false;
60
-	}
61
-	// passer en chemin absolu si possible, c'est plus efficace
62
-	$dir = str_replace('_DIR_', '_ROOT_', $dir_type);
63
-	if (!defined($dir)) {
64
-		$dir = $dir_type;
65
-	}
66
-	$dir = constant($dir);
67
-	foreach ($infos['install'] as $file) {
68
-		$file = $dir . $plug . "/" . trim($file);
69
-		if (file_exists($file)) {
70
-			include_once($file);
71
-		}
72
-	}
73
-	$version = isset($infos['schema']) ? $infos['schema'] : '';
74
-	$arg = $infos;
75
-	$f = $infos['prefix'] . "_install";
76
-	if (!function_exists($f)) {
77
-		$f = isset($infos['schema']) ? 'spip_plugin_install' : '';
78
-	} else {
79
-		$arg = $infos['prefix'];
80
-	} // stupide: info deja dans le nom
81
-
82
-	if (!$f) {
83
-		// installation sans operation particuliere
84
-		$infos['install_test'] = array(true, '');
85
-
86
-		return $infos;
87
-	}
88
-	$test = $f('test', $arg, $version);
89
-	if ($action == 'uninstall') {
90
-		$test = !$test;
91
-	}
92
-	// Si deja fait, on ne dit rien
93
-	if ($test) {
94
-		return true;
95
-	}
96
-	// Si install et que l'on a la meta d'installation, c'est un upgrade
97
-	if ($action == 'install' && !is_null(lire_meta($infos['prefix'] . '_base_version'))) {
98
-		$infos['upgrade'] = true;
99
-	}
100
-
101
-	// executer l'installation ou l'inverse
102
-	// et renvoyer la trace (mais il faudrait passer en AJAX plutot)
103
-	ob_start();
104
-	$f($action, $arg, $version);
105
-	$aff = ob_get_contents();
106
-	ob_end_clean();
107
-	// vider le cache des descriptions de tables a chaque (de)installation
108
-	$trouver_table = charger_fonction('trouver_table', 'base');
109
-	$trouver_table('');
110
-	$infos['install_test'] = array($f('test', $arg, $version), $aff);
111
-
112
-	return $infos;
56
+    $get_infos = charger_fonction('get_infos', 'plugins');
57
+    $infos = $get_infos($plug, false, constant($dir_type));
58
+    if (!isset($infos['install']) or !$infos['install']) {
59
+        return false;
60
+    }
61
+    // passer en chemin absolu si possible, c'est plus efficace
62
+    $dir = str_replace('_DIR_', '_ROOT_', $dir_type);
63
+    if (!defined($dir)) {
64
+        $dir = $dir_type;
65
+    }
66
+    $dir = constant($dir);
67
+    foreach ($infos['install'] as $file) {
68
+        $file = $dir . $plug . "/" . trim($file);
69
+        if (file_exists($file)) {
70
+            include_once($file);
71
+        }
72
+    }
73
+    $version = isset($infos['schema']) ? $infos['schema'] : '';
74
+    $arg = $infos;
75
+    $f = $infos['prefix'] . "_install";
76
+    if (!function_exists($f)) {
77
+        $f = isset($infos['schema']) ? 'spip_plugin_install' : '';
78
+    } else {
79
+        $arg = $infos['prefix'];
80
+    } // stupide: info deja dans le nom
81
+
82
+    if (!$f) {
83
+        // installation sans operation particuliere
84
+        $infos['install_test'] = array(true, '');
85
+
86
+        return $infos;
87
+    }
88
+    $test = $f('test', $arg, $version);
89
+    if ($action == 'uninstall') {
90
+        $test = !$test;
91
+    }
92
+    // Si deja fait, on ne dit rien
93
+    if ($test) {
94
+        return true;
95
+    }
96
+    // Si install et que l'on a la meta d'installation, c'est un upgrade
97
+    if ($action == 'install' && !is_null(lire_meta($infos['prefix'] . '_base_version'))) {
98
+        $infos['upgrade'] = true;
99
+    }
100
+
101
+    // executer l'installation ou l'inverse
102
+    // et renvoyer la trace (mais il faudrait passer en AJAX plutot)
103
+    ob_start();
104
+    $f($action, $arg, $version);
105
+    $aff = ob_get_contents();
106
+    ob_end_clean();
107
+    // vider le cache des descriptions de tables a chaque (de)installation
108
+    $trouver_table = charger_fonction('trouver_table', 'base');
109
+    $trouver_table('');
110
+    $infos['install_test'] = array($f('test', $arg, $version), $aff);
111
+
112
+    return $infos;
113 113
 }
114 114
 
115 115
 // Fonction par defaut pour install/desinstall
116 116
 
117 117
 // http://code.spip.net/@spip_plugin_install
118 118
 function spip_plugin_install($action, $infos, $version_cible) {
119
-	$prefix = $infos['prefix'];
120
-	if (isset($infos['meta']) and (($table = $infos['meta']) !== 'meta')) {
121
-		$nom_meta = "base_version";
122
-	} else {
123
-		$nom_meta = $prefix . "_base_version";
124
-		$table = 'meta';
125
-	}
126
-	switch ($action) {
127
-		case 'test':
128
-			return (isset($GLOBALS[$table])
129
-				and isset($GLOBALS[$table][$nom_meta])
130
-				and spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>='));
131
-			break;
132
-		case 'install':
133
-			if (function_exists($upgrade = $prefix . "_upgrade")) {
134
-				$upgrade($nom_meta, $version_cible, $table);
135
-			}
136
-			break;
137
-		case 'uninstall':
138
-			if (function_exists($vider_tables = $prefix . "_vider_tables")) {
139
-				$vider_tables($nom_meta, $table);
140
-			}
141
-			break;
142
-	}
119
+    $prefix = $infos['prefix'];
120
+    if (isset($infos['meta']) and (($table = $infos['meta']) !== 'meta')) {
121
+        $nom_meta = "base_version";
122
+    } else {
123
+        $nom_meta = $prefix . "_base_version";
124
+        $table = 'meta';
125
+    }
126
+    switch ($action) {
127
+        case 'test':
128
+            return (isset($GLOBALS[$table])
129
+                and isset($GLOBALS[$table][$nom_meta])
130
+                and spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>='));
131
+            break;
132
+        case 'install':
133
+            if (function_exists($upgrade = $prefix . "_upgrade")) {
134
+                $upgrade($nom_meta, $version_cible, $table);
135
+            }
136
+            break;
137
+        case 'uninstall':
138
+            if (function_exists($vider_tables = $prefix . "_vider_tables")) {
139
+                $vider_tables($nom_meta, $table);
140
+            }
141
+            break;
142
+    }
143 143
 }
144 144
 
145 145
 
@@ -164,34 +164,34 @@  discard block
 block discarded – undo
164 164
  *    Avec operateur : bool.
165 165
  **/
166 166
 function spip_version_compare($v1, $v2, $op = null) {
167
-	$v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
168
-	$v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
169
-	$v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
170
-	$v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
171
-
172
-	$v1 = explode('.', $v1);
173
-	$v2 = explode('.', $v2);
174
-	// $v1 est toujours une version, donc sans etoile
175
-	while (count($v1) < count($v2)) {
176
-		$v1[] = '0';
177
-	}
178
-
179
-	// $v2 peut etre une borne, donc accepte l'etoile
180
-	$etoile = false;
181
-	foreach ($v1 as $k => $v) {
182
-		if (!isset($v2[$k])) {
183
-			$v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
184
-		} else {
185
-			if ($v2[$k] == '*') {
186
-				$etoile = true;
187
-				$v2[$k] = $v;
188
-			}
189
-		}
190
-	}
191
-	$v1 = implode('.', $v1);
192
-	$v2 = implode('.', $v2);
193
-
194
-	return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
167
+    $v1 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v1));
168
+    $v2 = strtolower(preg_replace(',([0-9])[\s.-]?(dev|alpha|a|beta|b|rc|pl|p),i', '\\1.\\2', $v2));
169
+    $v1 = str_replace('rc', 'RC', $v1); // certaines versions de PHP ne comprennent RC qu'en majuscule
170
+    $v2 = str_replace('rc', 'RC', $v2); // certaines versions de PHP ne comprennent RC qu'en majuscule
171
+
172
+    $v1 = explode('.', $v1);
173
+    $v2 = explode('.', $v2);
174
+    // $v1 est toujours une version, donc sans etoile
175
+    while (count($v1) < count($v2)) {
176
+        $v1[] = '0';
177
+    }
178
+
179
+    // $v2 peut etre une borne, donc accepte l'etoile
180
+    $etoile = false;
181
+    foreach ($v1 as $k => $v) {
182
+        if (!isset($v2[$k])) {
183
+            $v2[] = ($etoile and (is_numeric($v) or $v == 'pl' or $v == 'p')) ? $v : '0';
184
+        } else {
185
+            if ($v2[$k] == '*') {
186
+                $etoile = true;
187
+                $v2[$k] = $v;
188
+            }
189
+        }
190
+    }
191
+    $v1 = implode('.', $v1);
192
+    $v2 = implode('.', $v2);
193
+
194
+    return $op ? version_compare($v1, $v2, $op) : version_compare($v1, $v2);
195 195
 }
196 196
 
197 197
 
@@ -209,29 +209,29 @@  discard block
 block discarded – undo
209 209
  * @return array Tableau des plugins actifs
210 210
  **/
211 211
 function liste_plugin_actifs() {
212
-	$liste = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
213
-	if (!$liste) {
214
-		return array();
215
-	}
216
-	if (!is_array($liste = unserialize($liste))) {
217
-		// compatibilite pre 1.9.2, mettre a jour la meta
218
-		spip_log("MAJ meta plugin vieille version : $liste", "plugin");
219
-		$new = true;
220
-		list(, $liste) = liste_plugin_valides(explode(",", $liste));
221
-	} else {
222
-		$new = false;
223
-		// compat au moment d'une migration depuis version anterieure
224
-		// si pas de dir_type, alors c'est _DIR_PLUGINS
225
-		foreach ($liste as $prefix => $infos) {
226
-			if (!isset($infos['dir_type'])) {
227
-				$liste[$prefix]['dir_type'] = "_DIR_PLUGINS";
228
-				$new = true;
229
-			}
230
-		}
231
-	}
232
-	if ($new) {
233
-		ecrire_meta('plugin', serialize($liste));
234
-	}
235
-
236
-	return $liste;
212
+    $liste = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : '';
213
+    if (!$liste) {
214
+        return array();
215
+    }
216
+    if (!is_array($liste = unserialize($liste))) {
217
+        // compatibilite pre 1.9.2, mettre a jour la meta
218
+        spip_log("MAJ meta plugin vieille version : $liste", "plugin");
219
+        $new = true;
220
+        list(, $liste) = liste_plugin_valides(explode(",", $liste));
221
+    } else {
222
+        $new = false;
223
+        // compat au moment d'une migration depuis version anterieure
224
+        // si pas de dir_type, alors c'est _DIR_PLUGINS
225
+        foreach ($liste as $prefix => $infos) {
226
+            if (!isset($infos['dir_type'])) {
227
+                $liste[$prefix]['dir_type'] = "_DIR_PLUGINS";
228
+                $new = true;
229
+            }
230
+        }
231
+    }
232
+    if ($new) {
233
+        ecrire_meta('plugin', serialize($liste));
234
+    }
235
+
236
+    return $liste;
237 237
 }
Please login to merge, or discard this patch.
ecrire/plugins/infos_plugin.php 2 patches
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -17,116 +17,116 @@  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
 // lecture d'un texte ecrit en pseudo-xml issu d'un fichier plugin.xml
24 24
 // et conversion approximative en tableau PHP.
25 25
 function plugins_infos_plugin($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) {
26
-	include_spip('inc/xml');
27
-	$arbre = spip_xml_parse($desc);
28
-
29
-	$verifie_conformite = charger_fonction('verifie_conformite', 'plugins');
30
-	$verifie_conformite($plug, $arbre, $dir_plugins);
31
-
32
-	include_spip('inc/charsets');
33
-
34
-	// On renvoie la DTD utilisee
35
-	$ret['dtd'] = "plugin";
36
-
37
-	if (isset($arbre['categorie'])) {
38
-		$ret['categorie'] = trim(spip_xml_aplatit($arbre['categorie']));
39
-	}
40
-	if (isset($arbre['nom'])) {
41
-		$ret['nom'] = charset2unicode(spip_xml_aplatit($arbre['nom']));
42
-	}
43
-	if (isset($arbre['icon'])) {
44
-		$ret['logo'] = trim(spip_xml_aplatit($arbre['icon']));
45
-	}
46
-	if (isset($arbre['auteur'])) {
47
-		$ret['auteur'][] = trim(spip_xml_aplatit($arbre['auteur']));
48
-	} // garder le 1er niveau en tableau mais traiter le multi possible
49
-	if (isset($arbre['licence'])) {
50
-		$ret['licence'][] = trim(spip_xml_aplatit($arbre['licence']));
51
-	}
52
-	if (isset($arbre['version'])) {
53
-		$ret['version'] = trim(spip_xml_aplatit($arbre['version']));
54
-	}
55
-	if (isset($arbre['version_base'])) {
56
-		$ret['schema'] = trim(spip_xml_aplatit($arbre['version_base']));
57
-	}
58
-	if (isset($arbre['etat'])) {
59
-		$ret['etat'] = trim(spip_xml_aplatit($arbre['etat']));
60
-	}
61
-
62
-	$ret['description'] = $ret['slogan'] = "";
63
-	if (isset($arbre['slogan'])) {
64
-		$ret['slogan'] = trim(spip_xml_aplatit($arbre['slogan']));
65
-	}
66
-	if (isset($arbre['description'])) {
67
-		$ret['description'] = trim(spip_xml_aplatit($arbre['description']));
68
-	}
69
-
70
-	if (isset($arbre['lien'])) {
71
-		$ret['documentation'] = trim(join(' ', $arbre['lien']));
72
-		if ($ret['documentation']) {
73
-			// le lien de doc doit etre une url et c'est tout
74
-			if (!tester_url_absolue($ret['documentation'])) {
75
-				$ret['documentation'] = "";
76
-			}
77
-		}
78
-	}
79
-
80
-	if (isset($arbre['options'])) {
81
-		$ret['options'] = $arbre['options'];
82
-	}
83
-	if (isset($arbre['fonctions'])) {
84
-		$ret['fonctions'] = $arbre['fonctions'];
85
-	}
86
-	if (isset($arbre['prefix'][0])) {
87
-		$ret['prefix'] = trim(array_pop($arbre['prefix']));
88
-	}
89
-	if (isset($arbre['install'])) {
90
-		$ret['install'] = $arbre['install'];
91
-	}
92
-	if (isset($arbre['meta'])) {
93
-		$ret['meta'] = trim(spip_xml_aplatit($arbre['meta']));
94
-	}
95
-
96
-	$necessite = info_plugin_normalise_necessite(isset($arbre['necessite']) ? $arbre['necessite'] : '');
97
-	$ret['compatibilite'] = isset($necessite['compatible']) ? $necessite['compatible'] : '';
98
-	$ret['necessite'] = $necessite['necessite'];
99
-	$ret['lib'] = $necessite['lib'];
100
-	$ret['utilise'] = info_plugin_normalise_utilise(isset($arbre['utilise']) ? $arbre['utilise'] : '');
101
-	$ret['procure'] = info_plugin_normalise_procure(isset($arbre['procure']) ? $arbre['procure'] : '');
102
-	$ret['chemin'] = info_plugin_normalise_chemin(isset($arbre['path']) ? $arbre['path'] : '');
103
-
104
-	if (isset($arbre['pipeline'])) {
105
-		$ret['pipeline'] = $arbre['pipeline'];
106
-	}
107
-
108
-	$extraire_boutons = charger_fonction('extraire_boutons', 'plugins');
109
-	$les_boutons = $extraire_boutons($arbre);
110
-	$ret['menu'] = $les_boutons['bouton'];
111
-	$ret['onglet'] = $les_boutons['onglet'];
112
-
113
-	$ret['traduire'] = isset($arbre['traduire']) ? $arbre['traduire'] : '';
114
-
115
-	if (isset($arbre['config'])) {
116
-		$ret['config'] = spip_xml_aplatit($arbre['config']);
117
-	}
118
-	if (isset($arbre['noisette'])) {
119
-		$ret['noisette'] = $arbre['noisette'];
120
-	}
121
-
122
-	if (isset($arbre['erreur'])) {
123
-		$ret['erreur'] = $arbre['erreur'];
124
-		if ($plug) {
125
-			spip_log("infos_plugin $plug " . @join(' ', $arbre['erreur']));
126
-		}
127
-	}
128
-
129
-	return $ret;
26
+    include_spip('inc/xml');
27
+    $arbre = spip_xml_parse($desc);
28
+
29
+    $verifie_conformite = charger_fonction('verifie_conformite', 'plugins');
30
+    $verifie_conformite($plug, $arbre, $dir_plugins);
31
+
32
+    include_spip('inc/charsets');
33
+
34
+    // On renvoie la DTD utilisee
35
+    $ret['dtd'] = "plugin";
36
+
37
+    if (isset($arbre['categorie'])) {
38
+        $ret['categorie'] = trim(spip_xml_aplatit($arbre['categorie']));
39
+    }
40
+    if (isset($arbre['nom'])) {
41
+        $ret['nom'] = charset2unicode(spip_xml_aplatit($arbre['nom']));
42
+    }
43
+    if (isset($arbre['icon'])) {
44
+        $ret['logo'] = trim(spip_xml_aplatit($arbre['icon']));
45
+    }
46
+    if (isset($arbre['auteur'])) {
47
+        $ret['auteur'][] = trim(spip_xml_aplatit($arbre['auteur']));
48
+    } // garder le 1er niveau en tableau mais traiter le multi possible
49
+    if (isset($arbre['licence'])) {
50
+        $ret['licence'][] = trim(spip_xml_aplatit($arbre['licence']));
51
+    }
52
+    if (isset($arbre['version'])) {
53
+        $ret['version'] = trim(spip_xml_aplatit($arbre['version']));
54
+    }
55
+    if (isset($arbre['version_base'])) {
56
+        $ret['schema'] = trim(spip_xml_aplatit($arbre['version_base']));
57
+    }
58
+    if (isset($arbre['etat'])) {
59
+        $ret['etat'] = trim(spip_xml_aplatit($arbre['etat']));
60
+    }
61
+
62
+    $ret['description'] = $ret['slogan'] = "";
63
+    if (isset($arbre['slogan'])) {
64
+        $ret['slogan'] = trim(spip_xml_aplatit($arbre['slogan']));
65
+    }
66
+    if (isset($arbre['description'])) {
67
+        $ret['description'] = trim(spip_xml_aplatit($arbre['description']));
68
+    }
69
+
70
+    if (isset($arbre['lien'])) {
71
+        $ret['documentation'] = trim(join(' ', $arbre['lien']));
72
+        if ($ret['documentation']) {
73
+            // le lien de doc doit etre une url et c'est tout
74
+            if (!tester_url_absolue($ret['documentation'])) {
75
+                $ret['documentation'] = "";
76
+            }
77
+        }
78
+    }
79
+
80
+    if (isset($arbre['options'])) {
81
+        $ret['options'] = $arbre['options'];
82
+    }
83
+    if (isset($arbre['fonctions'])) {
84
+        $ret['fonctions'] = $arbre['fonctions'];
85
+    }
86
+    if (isset($arbre['prefix'][0])) {
87
+        $ret['prefix'] = trim(array_pop($arbre['prefix']));
88
+    }
89
+    if (isset($arbre['install'])) {
90
+        $ret['install'] = $arbre['install'];
91
+    }
92
+    if (isset($arbre['meta'])) {
93
+        $ret['meta'] = trim(spip_xml_aplatit($arbre['meta']));
94
+    }
95
+
96
+    $necessite = info_plugin_normalise_necessite(isset($arbre['necessite']) ? $arbre['necessite'] : '');
97
+    $ret['compatibilite'] = isset($necessite['compatible']) ? $necessite['compatible'] : '';
98
+    $ret['necessite'] = $necessite['necessite'];
99
+    $ret['lib'] = $necessite['lib'];
100
+    $ret['utilise'] = info_plugin_normalise_utilise(isset($arbre['utilise']) ? $arbre['utilise'] : '');
101
+    $ret['procure'] = info_plugin_normalise_procure(isset($arbre['procure']) ? $arbre['procure'] : '');
102
+    $ret['chemin'] = info_plugin_normalise_chemin(isset($arbre['path']) ? $arbre['path'] : '');
103
+
104
+    if (isset($arbre['pipeline'])) {
105
+        $ret['pipeline'] = $arbre['pipeline'];
106
+    }
107
+
108
+    $extraire_boutons = charger_fonction('extraire_boutons', 'plugins');
109
+    $les_boutons = $extraire_boutons($arbre);
110
+    $ret['menu'] = $les_boutons['bouton'];
111
+    $ret['onglet'] = $les_boutons['onglet'];
112
+
113
+    $ret['traduire'] = isset($arbre['traduire']) ? $arbre['traduire'] : '';
114
+
115
+    if (isset($arbre['config'])) {
116
+        $ret['config'] = spip_xml_aplatit($arbre['config']);
117
+    }
118
+    if (isset($arbre['noisette'])) {
119
+        $ret['noisette'] = $arbre['noisette'];
120
+    }
121
+
122
+    if (isset($arbre['erreur'])) {
123
+        $ret['erreur'] = $arbre['erreur'];
124
+        if ($plug) {
125
+            spip_log("infos_plugin $plug " . @join(' ', $arbre['erreur']));
126
+        }
127
+    }
128
+
129
+    return $ret;
130 130
 }
131 131
 
132 132
 
@@ -153,27 +153,27 @@  discard block
 block discarded – undo
153 153
  *     Liste des necessite modifiés.
154 154
  */
155 155
 function info_plugin_normalise_necessite($necessite) {
156
-	$res = array('necessite' => array(), 'lib' => array());
157
-
158
-	if (is_array($necessite)) {
159
-		foreach ($necessite as $need) {
160
-			$id = $need['id'];
161
-			$v = isset($need['version']) ? $need['version'] : '';
162
-
163
-			// Necessite SPIP version x ?
164
-			if (strtoupper($id) == 'SPIP') {
165
-				$res['compatible'] = $v;
166
-			} else {
167
-				if (preg_match(',^lib:\s*([^\s]*),i', $id, $r)) {
168
-					$res['lib'][] = array('nom' => $r[1], 'id' => $r[1], 'lien' => $need['src']);
169
-				} else {
170
-					$res['necessite'][] = array('id' => $id, 'nom' => $id, 'version' => $v, 'compatibilite' => $v);
171
-				}
172
-			}
173
-		}
174
-	}
175
-
176
-	return $res;
156
+    $res = array('necessite' => array(), 'lib' => array());
157
+
158
+    if (is_array($necessite)) {
159
+        foreach ($necessite as $need) {
160
+            $id = $need['id'];
161
+            $v = isset($need['version']) ? $need['version'] : '';
162
+
163
+            // Necessite SPIP version x ?
164
+            if (strtoupper($id) == 'SPIP') {
165
+                $res['compatible'] = $v;
166
+            } else {
167
+                if (preg_match(',^lib:\s*([^\s]*),i', $id, $r)) {
168
+                    $res['lib'][] = array('nom' => $r[1], 'id' => $r[1], 'lien' => $need['src']);
169
+                } else {
170
+                    $res['necessite'][] = array('id' => $id, 'nom' => $id, 'version' => $v, 'compatibilite' => $v);
171
+                }
172
+            }
173
+        }
174
+    }
175
+
176
+    return $res;
177 177
 }
178 178
 
179 179
 /**
@@ -189,17 +189,17 @@  discard block
 block discarded – undo
189 189
  *    Liste des utilise modifiés.
190 190
  */
191 191
 function info_plugin_normalise_utilise($utilise) {
192
-	$res = array();
192
+    $res = array();
193 193
 
194
-	if (is_array($utilise)) {
195
-		foreach ($utilise as $need) {
196
-			$id = $need['id'];
197
-			$v = isset($need['version']) ? $need['version'] : '';
198
-			$res[] = array('nom' => $id, 'id' => $id, 'version' => $v, 'compatibilite' => $v);
199
-		}
200
-	}
194
+    if (is_array($utilise)) {
195
+        foreach ($utilise as $need) {
196
+            $id = $need['id'];
197
+            $v = isset($need['version']) ? $need['version'] : '';
198
+            $res[] = array('nom' => $id, 'id' => $id, 'version' => $v, 'compatibilite' => $v);
199
+        }
200
+    }
201 201
 
202
-	return $res;
202
+    return $res;
203 203
 }
204 204
 
205 205
 /**
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
  *    Liste des procure modifiés.
214 214
  */
215 215
 function info_plugin_normalise_procure($procure) {
216
-	$res = array();
216
+    $res = array();
217 217
 
218
-	if (is_array($procure)) {
219
-		foreach ($procure as $need) {
220
-			$id = $need['id'];
221
-			$v = $need['version'];
222
-			$res[] = array('nom' => $id, 'id' => $id, 'version' => $v);
223
-		}
224
-	}
218
+    if (is_array($procure)) {
219
+        foreach ($procure as $need) {
220
+            $id = $need['id'];
221
+            $v = $need['version'];
222
+            $res[] = array('nom' => $id, 'id' => $id, 'version' => $v);
223
+        }
224
+    }
225 225
 
226
-	return $res;
226
+    return $res;
227 227
 }
228 228
 
229 229
 /**
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
  *    Liste des chemins modifiés.
238 238
  */
239 239
 function info_plugin_normalise_chemin($chemins) {
240
-	$res = array();
240
+    $res = array();
241 241
 
242
-	if (is_array($chemins)) {
243
-		foreach ($chemins as $c) {
244
-			$c['path'] = $c['dir'];
245
-			$res[] = $c;
246
-		}
247
-	}
242
+    if (is_array($chemins)) {
243
+        foreach ($chemins as $c) {
244
+            $c['path'] = $c['dir'];
245
+            $res[] = $c;
246
+        }
247
+    }
248 248
 
249
-	return $res;
249
+    return $res;
250 250
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@
 block discarded – undo
122 122
 	if (isset($arbre['erreur'])) {
123 123
 		$ret['erreur'] = $arbre['erreur'];
124 124
 		if ($plug) {
125
-			spip_log("infos_plugin $plug " . @join(' ', $arbre['erreur']));
125
+			spip_log("infos_plugin $plug ".@join(' ', $arbre['erreur']));
126 126
 		}
127 127
 	}
128 128
 
Please login to merge, or discard this patch.
ecrire/plugins/extraire_pipelines.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 
@@ -21,26 +21,26 @@  discard block
 block discarded – undo
21 21
  * @param array $arbre
22 22
  */
23 23
 function plugins_extraire_pipelines_dist(&$arbre) {
24
-	$pipeline = array();
25
-	if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) {
26
-		foreach ($pipes as $tag => $p) {
27
-			if (!is_array($p[0])) {
28
-				list($tag, $att) = spip_xml_decompose_tag($tag);
29
-				$pipeline[] = $att;
30
-			} else {
31
-				foreach ($p as $pipe) {
32
-					$att = array();
33
-					if (is_array($pipe)) {
34
-						foreach ($pipe as $k => $t) {
35
-							$att[$k] = trim(end($t));
36
-						}
37
-					}
38
-					$pipeline[] = $att;
39
-				}
40
-			}
41
-		}
42
-		unset($arbre[$tag]);
43
-	}
24
+    $pipeline = array();
25
+    if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) {
26
+        foreach ($pipes as $tag => $p) {
27
+            if (!is_array($p[0])) {
28
+                list($tag, $att) = spip_xml_decompose_tag($tag);
29
+                $pipeline[] = $att;
30
+            } else {
31
+                foreach ($p as $pipe) {
32
+                    $att = array();
33
+                    if (is_array($pipe)) {
34
+                        foreach ($pipe as $k => $t) {
35
+                            $att[$k] = trim(end($t));
36
+                        }
37
+                    }
38
+                    $pipeline[] = $att;
39
+                }
40
+            }
41
+        }
42
+        unset($arbre[$tag]);
43
+    }
44 44
 
45
-	return $pipeline;
45
+    return $pipeline;
46 46
 }
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
@@ -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
 /**
@@ -33,110 +33,110 @@  discard block
 block discarded – undo
33 33
  * @return array
34 34
  */
35 35
 function plugins_get_infos_dist($plug = false, $reload = false, $dir = _DIR_PLUGINS, $clean_old = false) {
36
-	static $cache = '';
37
-	static $filecache = '';
38
-
39
-	if ($cache === '') {
40
-		$filecache = _DIR_TMP . "plugin_xml_cache.gz";
41
-		if (is_file($filecache)) {
42
-			lire_fichier($filecache, $contenu);
43
-			$cache = unserialize($contenu);
44
-		}
45
-		if (!is_array($cache)) {
46
-			$cache = array();
47
-		}
48
-	}
49
-
50
-	if (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') {
51
-		$reload = true;
52
-	}
53
-
54
-	if ($plug === false) {
55
-		ecrire_fichier($filecache, serialize($cache));
56
-
57
-		return $cache;
58
-	} elseif (is_string($plug)) {
59
-		$res = plugins_get_infos_un($plug, $reload, $dir, $cache);
60
-	} elseif (is_array($plug)) {
61
-		$res = false;
62
-		if (!$reload) {
63
-			$reload = -1;
64
-		}
65
-		foreach ($plug as $nom) {
66
-			$res |= plugins_get_infos_un($nom, $reload, $dir, $cache);
67
-		}
68
-
69
-		// Nettoyer le cache des vieux plugins qui ne sont plus la
70
-		if ($clean_old and isset($cache[$dir]) and count($cache[$dir])) {
71
-			foreach (array_keys($cache[$dir]) as $p) {
72
-				if (!in_array($p, $plug)) {
73
-					unset($cache[$dir][$p]);
74
-				}
75
-			}
76
-		}
77
-	}
78
-	if ($res) {
79
-		ecrire_fichier($filecache, serialize($cache));
80
-	}
81
-	if (!isset($cache[$dir])) {
82
-		return array();
83
-	}
84
-	if (is_string($plug)) {
85
-		return isset($cache[$dir][$plug]) ? $cache[$dir][$plug] : array();
86
-	} else {
87
-		return $cache[$dir];
88
-	}
36
+    static $cache = '';
37
+    static $filecache = '';
38
+
39
+    if ($cache === '') {
40
+        $filecache = _DIR_TMP . "plugin_xml_cache.gz";
41
+        if (is_file($filecache)) {
42
+            lire_fichier($filecache, $contenu);
43
+            $cache = unserialize($contenu);
44
+        }
45
+        if (!is_array($cache)) {
46
+            $cache = array();
47
+        }
48
+    }
49
+
50
+    if (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') {
51
+        $reload = true;
52
+    }
53
+
54
+    if ($plug === false) {
55
+        ecrire_fichier($filecache, serialize($cache));
56
+
57
+        return $cache;
58
+    } elseif (is_string($plug)) {
59
+        $res = plugins_get_infos_un($plug, $reload, $dir, $cache);
60
+    } elseif (is_array($plug)) {
61
+        $res = false;
62
+        if (!$reload) {
63
+            $reload = -1;
64
+        }
65
+        foreach ($plug as $nom) {
66
+            $res |= plugins_get_infos_un($nom, $reload, $dir, $cache);
67
+        }
68
+
69
+        // Nettoyer le cache des vieux plugins qui ne sont plus la
70
+        if ($clean_old and isset($cache[$dir]) and count($cache[$dir])) {
71
+            foreach (array_keys($cache[$dir]) as $p) {
72
+                if (!in_array($p, $plug)) {
73
+                    unset($cache[$dir][$p]);
74
+                }
75
+            }
76
+        }
77
+    }
78
+    if ($res) {
79
+        ecrire_fichier($filecache, serialize($cache));
80
+    }
81
+    if (!isset($cache[$dir])) {
82
+        return array();
83
+    }
84
+    if (is_string($plug)) {
85
+        return isset($cache[$dir][$plug]) ? $cache[$dir][$plug] : array();
86
+    } else {
87
+        return $cache[$dir];
88
+    }
89 89
 }
90 90
 
91 91
 
92 92
 function plugins_get_infos_un($plug, $reload, $dir, &$cache) {
93
-	if (!is_readable($file = "$dir$plug/" . ($desc = "paquet") . ".xml")) {
94
-		if (!is_readable($file = "$dir$plug/" . ($desc = "plugin") . ".xml")) {
95
-			return false;
96
-		}
97
-	}
98
-
99
-	if (($time = intval(@filemtime($file))) < 0) {
100
-		return false;
101
-	}
102
-	$md5 = md5_file($file);
103
-
104
-	$pcache = isset($cache[$dir][$plug])
105
-		? $cache[$dir][$plug] : array('filemtime' => 0, 'md5_file' => '');
106
-
107
-	// si le cache est valide
108
-	if ((intval($reload) <= 0)
109
-		and ($time > 0)
110
-		and ($time <= $pcache['filemtime'])
111
-		and $md5 == $pcache['md5_file']
112
-	) {
113
-		return false;
114
-	}
115
-
116
-	// si on arrive pas a lire le fichier, se contenter du cache
117
-	if (!($texte = spip_file_get_contents($file))) {
118
-		return false;
119
-	}
120
-
121
-	$f = charger_fonction('infos_' . $desc, 'plugins');
122
-	$ret = $f($texte, $plug, $dir);
123
-	$ret['filemtime'] = $time;
124
-	$ret['md5_file'] = $md5;
125
-	// Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent
126
-	// utiliser un necessite php. SPIP procure donc la version php courante du serveur.
127
-	// chaque librairie php est aussi procurée, par exemple 'php:curl'.
128
-	if (isset($ret['prefix']) and $ret['prefix'] == 'spip') {
129
-		$ret['procure']['php'] = array('nom' => 'php', 'version' => phpversion());
130
-		foreach (get_loaded_extensions() as $ext) {
131
-			$ret['procure']['php:' . $ext] = array('nom' => 'php:' . $ext, 'version' => phpversion($ext));
132
-		}
133
-	}
134
-	$diff = ($ret != $pcache);
135
-
136
-	if ($diff) {
137
-		$cache[$dir][$plug] = $ret;
93
+    if (!is_readable($file = "$dir$plug/" . ($desc = "paquet") . ".xml")) {
94
+        if (!is_readable($file = "$dir$plug/" . ($desc = "plugin") . ".xml")) {
95
+            return false;
96
+        }
97
+    }
98
+
99
+    if (($time = intval(@filemtime($file))) < 0) {
100
+        return false;
101
+    }
102
+    $md5 = md5_file($file);
103
+
104
+    $pcache = isset($cache[$dir][$plug])
105
+        ? $cache[$dir][$plug] : array('filemtime' => 0, 'md5_file' => '');
106
+
107
+    // si le cache est valide
108
+    if ((intval($reload) <= 0)
109
+        and ($time > 0)
110
+        and ($time <= $pcache['filemtime'])
111
+        and $md5 == $pcache['md5_file']
112
+    ) {
113
+        return false;
114
+    }
115
+
116
+    // si on arrive pas a lire le fichier, se contenter du cache
117
+    if (!($texte = spip_file_get_contents($file))) {
118
+        return false;
119
+    }
120
+
121
+    $f = charger_fonction('infos_' . $desc, 'plugins');
122
+    $ret = $f($texte, $plug, $dir);
123
+    $ret['filemtime'] = $time;
124
+    $ret['md5_file'] = $md5;
125
+    // Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent
126
+    // utiliser un necessite php. SPIP procure donc la version php courante du serveur.
127
+    // chaque librairie php est aussi procurée, par exemple 'php:curl'.
128
+    if (isset($ret['prefix']) and $ret['prefix'] == 'spip') {
129
+        $ret['procure']['php'] = array('nom' => 'php', 'version' => phpversion());
130
+        foreach (get_loaded_extensions() as $ext) {
131
+            $ret['procure']['php:' . $ext] = array('nom' => 'php:' . $ext, 'version' => phpversion($ext));
132
+        }
133
+    }
134
+    $diff = ($ret != $pcache);
135
+
136
+    if ($diff) {
137
+        $cache[$dir][$plug] = $ret;
138 138
 #		echo count($cache[$dir]), $dir,$plug, " $reloadc<br>"; 
139
-	}
139
+    }
140 140
 
141
-	return $diff;
141
+    return $diff;
142 142
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	static $filecache = '';
38 38
 
39 39
 	if ($cache === '') {
40
-		$filecache = _DIR_TMP . "plugin_xml_cache.gz";
40
+		$filecache = _DIR_TMP."plugin_xml_cache.gz";
41 41
 		if (is_file($filecache)) {
42 42
 			lire_fichier($filecache, $contenu);
43 43
 			$cache = unserialize($contenu);
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 
91 91
 
92 92
 function plugins_get_infos_un($plug, $reload, $dir, &$cache) {
93
-	if (!is_readable($file = "$dir$plug/" . ($desc = "paquet") . ".xml")) {
94
-		if (!is_readable($file = "$dir$plug/" . ($desc = "plugin") . ".xml")) {
93
+	if (!is_readable($file = "$dir$plug/".($desc = "paquet").".xml")) {
94
+		if (!is_readable($file = "$dir$plug/".($desc = "plugin").".xml")) {
95 95
 			return false;
96 96
 		}
97 97
 	}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		return false;
119 119
 	}
120 120
 
121
-	$f = charger_fonction('infos_' . $desc, 'plugins');
121
+	$f = charger_fonction('infos_'.$desc, 'plugins');
122 122
 	$ret = $f($texte, $plug, $dir);
123 123
 	$ret['filemtime'] = $time;
124 124
 	$ret['md5_file'] = $md5;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	if (isset($ret['prefix']) and $ret['prefix'] == 'spip') {
129 129
 		$ret['procure']['php'] = array('nom' => 'php', 'version' => phpversion());
130 130
 		foreach (get_loaded_extensions() as $ext) {
131
-			$ret['procure']['php:' . $ext] = array('nom' => 'php:' . $ext, 'version' => phpversion($ext));
131
+			$ret['procure']['php:'.$ext] = array('nom' => 'php:'.$ext, 'version' => phpversion($ext));
132 132
 		}
133 133
 	}
134 134
 	$diff = ($ret != $pcache);
Please login to merge, or discard this patch.
ecrire/plugins/verifie_conformite.php 2 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 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/xml');
@@ -19,208 +19,208 @@  discard block
 block discarded – undo
19 19
 
20 20
 // http://code.spip.net/@plugin_verifie_conformite
21 21
 function plugins_verifie_conformite_dist($plug, &$arbre, $dir_plugins = _DIR_PLUGINS) {
22
-	static $etats = array('dev', 'experimental', 'test', 'stable');
22
+    static $etats = array('dev', 'experimental', 'test', 'stable');
23 23
 
24
-	$matches = array();
25
-	$silence = false;
26
-	$p = null;
27
-	// chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP
28
-	if ($n = spip_xml_match_nodes(",^plugin(\s|$),", $arbre, $matches)) {
29
-		// version de SPIP
30
-		$vspip = $GLOBALS['spip_version_branche'];
31
-		foreach ($matches as $tag => $sous) {
32
-			list($tagname, $atts) = spip_xml_decompose_tag($tag);
33
-			if ($tagname == 'plugin' and is_array($sous)) {
34
-				// On rajoute la condition sur $n :
35
-				// -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait
36
-				//    un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise
37
-				//    de la meme facon.
38
-				if (!isset($atts['spip'])
39
-					or $n == 1
40
-					or plugin_version_compatible($atts['spip'], $vspip, 'spip')
41
-				) {
42
-					// on prend la derniere declaration avec ce nom
43
-					$p = end($sous);
44
-					$compat_spip = isset($atts['spip']) ? $atts['spip'] : '';
45
-				}
46
-			}
47
-		}
48
-	}
49
-	if (is_null($p)) {
50
-		$arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug"));
51
-		$silence = true;
52
-	} else {
53
-		$arbre = $p;
54
-	}
55
-	if (!is_array($arbre)) {
56
-		$arbre = array();
57
-	}
58
-	// verification de la conformite du plugin avec quelques
59
-	// precautions elementaires
60
-	if (!isset($arbre['nom'])) {
61
-		if (!$silence) {
62
-			$arbre['erreur'][] = _T('erreur_plugin_nom_manquant');
63
-		}
64
-		$arbre['nom'] = array("");
65
-	}
66
-	if (!isset($arbre['version'])) {
67
-		if (!$silence) {
68
-			$arbre['erreur'][] = _T('erreur_plugin_version_manquant');
69
-		}
70
-		$arbre['version'] = array("");
71
-	}
72
-	if (!isset($arbre['prefix'])) {
73
-		if (!$silence) {
74
-			$arbre['erreur'][] = _T('erreur_plugin_prefix_manquant');
75
-		}
76
-		$arbre['prefix'] = array("");
77
-	} else {
78
-		$prefix = trim(end($arbre['prefix']));
79
-		if (strtoupper($prefix) == 'SPIP' and $plug != "./") {
80
-			$arbre['erreur'][] = _T('erreur_plugin_prefix_interdit');
81
-		}
82
-		if (isset($arbre['etat'])) {
83
-			$etat = trim(end($arbre['etat']));
84
-			if (!in_array($etat, $etats)) {
85
-				$arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'";
86
-			}
87
-		}
88
-		if (isset($arbre['options'])) {
89
-			foreach ($arbre['options'] as $optfile) {
90
-				$optfile = trim($optfile);
91
-				if (!@is_readable($dir_plugins . "$plug/$optfile")) {
92
-					if (!$silence) {
93
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
94
-					}
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")) {
102
-					if (!$silence) {
103
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
104
-					}
105
-				}
106
-			}
107
-		}
108
-		$fonctions = array();
109
-		if (isset($arbre['fonctions'])) {
110
-			$fonctions = $arbre['fonctions'];
111
-		}
112
-		$liste_methodes_reservees = array(
113
-			'__construct',
114
-			'__destruct',
115
-			'plugin',
116
-			'install',
117
-			'uninstall',
118
-			strtolower($prefix)
119
-		);
24
+    $matches = array();
25
+    $silence = false;
26
+    $p = null;
27
+    // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP
28
+    if ($n = spip_xml_match_nodes(",^plugin(\s|$),", $arbre, $matches)) {
29
+        // version de SPIP
30
+        $vspip = $GLOBALS['spip_version_branche'];
31
+        foreach ($matches as $tag => $sous) {
32
+            list($tagname, $atts) = spip_xml_decompose_tag($tag);
33
+            if ($tagname == 'plugin' and is_array($sous)) {
34
+                // On rajoute la condition sur $n :
35
+                // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait
36
+                //    un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise
37
+                //    de la meme facon.
38
+                if (!isset($atts['spip'])
39
+                    or $n == 1
40
+                    or plugin_version_compatible($atts['spip'], $vspip, 'spip')
41
+                ) {
42
+                    // on prend la derniere declaration avec ce nom
43
+                    $p = end($sous);
44
+                    $compat_spip = isset($atts['spip']) ? $atts['spip'] : '';
45
+                }
46
+            }
47
+        }
48
+    }
49
+    if (is_null($p)) {
50
+        $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug"));
51
+        $silence = true;
52
+    } else {
53
+        $arbre = $p;
54
+    }
55
+    if (!is_array($arbre)) {
56
+        $arbre = array();
57
+    }
58
+    // verification de la conformite du plugin avec quelques
59
+    // precautions elementaires
60
+    if (!isset($arbre['nom'])) {
61
+        if (!$silence) {
62
+            $arbre['erreur'][] = _T('erreur_plugin_nom_manquant');
63
+        }
64
+        $arbre['nom'] = array("");
65
+    }
66
+    if (!isset($arbre['version'])) {
67
+        if (!$silence) {
68
+            $arbre['erreur'][] = _T('erreur_plugin_version_manquant');
69
+        }
70
+        $arbre['version'] = array("");
71
+    }
72
+    if (!isset($arbre['prefix'])) {
73
+        if (!$silence) {
74
+            $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant');
75
+        }
76
+        $arbre['prefix'] = array("");
77
+    } else {
78
+        $prefix = trim(end($arbre['prefix']));
79
+        if (strtoupper($prefix) == 'SPIP' and $plug != "./") {
80
+            $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit');
81
+        }
82
+        if (isset($arbre['etat'])) {
83
+            $etat = trim(end($arbre['etat']));
84
+            if (!in_array($etat, $etats)) {
85
+                $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'";
86
+            }
87
+        }
88
+        if (isset($arbre['options'])) {
89
+            foreach ($arbre['options'] as $optfile) {
90
+                $optfile = trim($optfile);
91
+                if (!@is_readable($dir_plugins . "$plug/$optfile")) {
92
+                    if (!$silence) {
93
+                        $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
94
+                    }
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")) {
102
+                    if (!$silence) {
103
+                        $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
104
+                    }
105
+                }
106
+            }
107
+        }
108
+        $fonctions = array();
109
+        if (isset($arbre['fonctions'])) {
110
+            $fonctions = $arbre['fonctions'];
111
+        }
112
+        $liste_methodes_reservees = array(
113
+            '__construct',
114
+            '__destruct',
115
+            'plugin',
116
+            'install',
117
+            'uninstall',
118
+            strtolower($prefix)
119
+        );
120 120
 
121
-		$extraire_pipelines = charger_fonction("extraire_pipelines", "plugins");
122
-		$arbre['pipeline'] = $extraire_pipelines($arbre);
123
-		foreach ($arbre['pipeline'] as $pipe) {
124
-			if (!isset($pipe['nom'])) {
125
-				if (!$silence) {
126
-					$arbre['erreur'][] = _T("erreur_plugin_nom_pipeline_non_defini");
127
-				}
128
-			}
129
-			if (isset($pipe['action'])) {
130
-				$action = $pipe['action'];
131
-			} else {
132
-				$action = $pipe['nom'];
133
-			}
134
-			// verif que la methode a un nom autorise
135
-			if (in_array(strtolower($action), $liste_methodes_reservees)) {
136
-				if (!$silence) {
137
-					$arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action";
138
-				}
139
-			}
140
-			if (isset($pipe['inclure'])) {
141
-				$inclure = $dir_plugins . "$plug/" . $pipe['inclure'];
142
-				if (!@is_readable($inclure)) {
143
-					if (!$silence) {
144
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure";
145
-					}
146
-				}
147
-			}
148
-		}
149
-		$necessite = array();
150
-		$spip_trouve = false;
151
-		if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) {
152
-			foreach (array_keys($needs) as $tag) {
153
-				list($tag, $att) = spip_xml_decompose_tag($tag);
154
-				if (!isset($att['id'])) {
155
-					if (!$silence) {
156
-						$arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant',
157
-							array('attribut' => 'id', 'balise' => $att));
158
-					}
159
-				} else {
160
-					$necessite[] = $att;
161
-				}
162
-				if (strtolower($att['id']) == 'spip') {
163
-					$spip_trouve = true;
164
-				}
165
-			}
166
-		}
167
-		if ($compat_spip and !$spip_trouve) {
168
-			$necessite[] = array('id' => 'spip', 'version' => $compat_spip);
169
-		}
170
-		$arbre['necessite'] = $necessite;
171
-		$utilise = array();
172
-		if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) {
173
-			foreach (array_keys($uses) as $tag) {
174
-				list($tag, $att) = spip_xml_decompose_tag($tag);
175
-				if (!isset($att['id'])) {
176
-					if (!$silence) {
177
-						$arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant',
178
-							array('attribut' => 'id', 'balise' => $att));
179
-					}
180
-				} else {
181
-					$utilise[] = $att;
182
-				}
183
-			}
184
-		}
185
-		$arbre['utilise'] = $utilise;
186
-		$procure = array();
187
-		if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) {
188
-			foreach (array_keys($uses) as $tag) {
189
-				list($tag, $att) = spip_xml_decompose_tag($tag);
190
-				$procure[] = $att;
191
-			}
192
-		}
193
-		$arbre['procure'] = $procure;
194
-		$path = array();
195
-		if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) {
196
-			foreach (array_keys($paths) as $tag) {
197
-				list($tag, $att) = spip_xml_decompose_tag($tag);
198
-				$att['path'] = $att['dir']; // ancienne syntaxe
199
-				$path[] = $att;
200
-			}
201
-		} else {
202
-			$path = array(array('dir' => ''));
203
-		} // initialiser par defaut
204
-		$arbre['path'] = $path;
205
-		// exposer les noisettes
206
-		if (isset($arbre['noisette'])) {
207
-			foreach ($arbre['noisette'] as $k => $nut) {
208
-				$nut = preg_replace(',[.]html$,uims', '', trim($nut));
209
-				$arbre['noisette'][$k] = $nut;
210
-				if (!@is_readable($dir_plugins . "$plug/$nut.html")) {
211
-					if (!$silence) {
212
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut";
213
-					}
214
-				}
215
-			}
216
-		}
217
-		$traduire = array();
218
-		if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) {
219
-			foreach (array_keys($trads) as $tag) {
220
-				list($tag, $att) = spip_xml_decompose_tag($tag);
221
-				$traduire[] = $att;
222
-			}
223
-		}
224
-		$arbre['traduire'] = $traduire;
225
-	}
121
+        $extraire_pipelines = charger_fonction("extraire_pipelines", "plugins");
122
+        $arbre['pipeline'] = $extraire_pipelines($arbre);
123
+        foreach ($arbre['pipeline'] as $pipe) {
124
+            if (!isset($pipe['nom'])) {
125
+                if (!$silence) {
126
+                    $arbre['erreur'][] = _T("erreur_plugin_nom_pipeline_non_defini");
127
+                }
128
+            }
129
+            if (isset($pipe['action'])) {
130
+                $action = $pipe['action'];
131
+            } else {
132
+                $action = $pipe['nom'];
133
+            }
134
+            // verif que la methode a un nom autorise
135
+            if (in_array(strtolower($action), $liste_methodes_reservees)) {
136
+                if (!$silence) {
137
+                    $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action";
138
+                }
139
+            }
140
+            if (isset($pipe['inclure'])) {
141
+                $inclure = $dir_plugins . "$plug/" . $pipe['inclure'];
142
+                if (!@is_readable($inclure)) {
143
+                    if (!$silence) {
144
+                        $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure";
145
+                    }
146
+                }
147
+            }
148
+        }
149
+        $necessite = array();
150
+        $spip_trouve = false;
151
+        if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) {
152
+            foreach (array_keys($needs) as $tag) {
153
+                list($tag, $att) = spip_xml_decompose_tag($tag);
154
+                if (!isset($att['id'])) {
155
+                    if (!$silence) {
156
+                        $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant',
157
+                            array('attribut' => 'id', 'balise' => $att));
158
+                    }
159
+                } else {
160
+                    $necessite[] = $att;
161
+                }
162
+                if (strtolower($att['id']) == 'spip') {
163
+                    $spip_trouve = true;
164
+                }
165
+            }
166
+        }
167
+        if ($compat_spip and !$spip_trouve) {
168
+            $necessite[] = array('id' => 'spip', 'version' => $compat_spip);
169
+        }
170
+        $arbre['necessite'] = $necessite;
171
+        $utilise = array();
172
+        if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) {
173
+            foreach (array_keys($uses) as $tag) {
174
+                list($tag, $att) = spip_xml_decompose_tag($tag);
175
+                if (!isset($att['id'])) {
176
+                    if (!$silence) {
177
+                        $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant',
178
+                            array('attribut' => 'id', 'balise' => $att));
179
+                    }
180
+                } else {
181
+                    $utilise[] = $att;
182
+                }
183
+            }
184
+        }
185
+        $arbre['utilise'] = $utilise;
186
+        $procure = array();
187
+        if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) {
188
+            foreach (array_keys($uses) as $tag) {
189
+                list($tag, $att) = spip_xml_decompose_tag($tag);
190
+                $procure[] = $att;
191
+            }
192
+        }
193
+        $arbre['procure'] = $procure;
194
+        $path = array();
195
+        if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) {
196
+            foreach (array_keys($paths) as $tag) {
197
+                list($tag, $att) = spip_xml_decompose_tag($tag);
198
+                $att['path'] = $att['dir']; // ancienne syntaxe
199
+                $path[] = $att;
200
+            }
201
+        } else {
202
+            $path = array(array('dir' => ''));
203
+        } // initialiser par defaut
204
+        $arbre['path'] = $path;
205
+        // exposer les noisettes
206
+        if (isset($arbre['noisette'])) {
207
+            foreach ($arbre['noisette'] as $k => $nut) {
208
+                $nut = preg_replace(',[.]html$,uims', '', trim($nut));
209
+                $arbre['noisette'][$k] = $nut;
210
+                if (!@is_readable($dir_plugins . "$plug/$nut.html")) {
211
+                    if (!$silence) {
212
+                        $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut";
213
+                    }
214
+                }
215
+            }
216
+        }
217
+        $traduire = array();
218
+        if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) {
219
+            foreach (array_keys($trads) as $tag) {
220
+                list($tag, $att) = spip_xml_decompose_tag($tag);
221
+                $traduire[] = $att;
222
+            }
223
+        }
224
+        $arbre['traduire'] = $traduire;
225
+    }
226 226
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		}
48 48
 	}
49 49
 	if (is_null($p)) {
50
-		$arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug"));
50
+		$arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent')." : $plug"));
51 51
 		$silence = true;
52 52
 	} else {
53 53
 		$arbre = $p;
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 		if (isset($arbre['etat'])) {
83 83
 			$etat = trim(end($arbre['etat']));
84 84
 			if (!in_array($etat, $etats)) {
85
-				$arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'";
85
+				$arbre['erreur'][] = _T('erreur_plugin_etat_inconnu')." : '$etat'";
86 86
 			}
87 87
 		}
88 88
 		if (isset($arbre['options'])) {
89 89
 			foreach ($arbre['options'] as $optfile) {
90 90
 				$optfile = trim($optfile);
91
-				if (!@is_readable($dir_plugins . "$plug/$optfile")) {
91
+				if (!@is_readable($dir_plugins."$plug/$optfile")) {
92 92
 					if (!$silence) {
93
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
93
+						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile";
94 94
 					}
95 95
 				}
96 96
 			}
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
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")) {
101
+				if (!@is_readable($dir_plugins."$plug/$optfile")) {
102 102
 					if (!$silence) {
103
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
103
+						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile";
104 104
 					}
105 105
 				}
106 106
 			}
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 			// verif que la methode a un nom autorise
135 135
 			if (in_array(strtolower($action), $liste_methodes_reservees)) {
136 136
 				if (!$silence) {
137
-					$arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action";
137
+					$arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit")." : $action";
138 138
 				}
139 139
 			}
140 140
 			if (isset($pipe['inclure'])) {
141
-				$inclure = $dir_plugins . "$plug/" . $pipe['inclure'];
141
+				$inclure = $dir_plugins."$plug/".$pipe['inclure'];
142 142
 				if (!@is_readable($inclure)) {
143 143
 					if (!$silence) {
144
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure";
144
+						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $inclure";
145 145
 					}
146 146
 				}
147 147
 			}
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 			foreach ($arbre['noisette'] as $k => $nut) {
208 208
 				$nut = preg_replace(',[.]html$,uims', '', trim($nut));
209 209
 				$arbre['noisette'][$k] = $nut;
210
-				if (!@is_readable($dir_plugins . "$plug/$nut.html")) {
210
+				if (!@is_readable($dir_plugins."$plug/$nut.html")) {
211 211
 					if (!$silence) {
212
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut";
212
+						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $nut";
213 213
 					}
214 214
 				}
215 215
 			}
Please login to merge, or discard this patch.
ecrire/plugins/extraire_boutons.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -21,30 +21,30 @@  discard block
 block discarded – undo
21 21
  * @return <type>
22 22
  */
23 23
 function plugins_extraire_boutons_dist($arbre) {
24
-	$ret = array('bouton' => array(), 'onglet' => array());
25
-	// recuperer les boutons et onglets si necessaire
26
-	spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons);
27
-	if (is_array($les_boutons) && count($les_boutons)) {
28
-		$ret['bouton'] = array();
29
-		$ret['onglet'] = array();
30
-		foreach ($les_boutons as $bouton => $val) {
31
-			$bouton = spip_xml_decompose_tag($bouton);
32
-			$type = reset($bouton);
33
-			$bouton = end($bouton);
34
-			if (isset($bouton['id'])) {
35
-				$id = $bouton['id'];
36
-				$val = reset($val);
37
-				if (is_array($val)) {
38
-					$ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : '';
39
-					$ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : '';
40
-					$ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : '';
41
-					$ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : '';
42
-					$ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : '';
43
-					$ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : '';
44
-				}
45
-			}
46
-		}
47
-	}
24
+    $ret = array('bouton' => array(), 'onglet' => array());
25
+    // recuperer les boutons et onglets si necessaire
26
+    spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons);
27
+    if (is_array($les_boutons) && count($les_boutons)) {
28
+        $ret['bouton'] = array();
29
+        $ret['onglet'] = array();
30
+        foreach ($les_boutons as $bouton => $val) {
31
+            $bouton = spip_xml_decompose_tag($bouton);
32
+            $type = reset($bouton);
33
+            $bouton = end($bouton);
34
+            if (isset($bouton['id'])) {
35
+                $id = $bouton['id'];
36
+                $val = reset($val);
37
+                if (is_array($val)) {
38
+                    $ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : '';
39
+                    $ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : '';
40
+                    $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : '';
41
+                    $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : '';
42
+                    $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : '';
43
+                    $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : '';
44
+                }
45
+            }
46
+        }
47
+    }
48 48
 
49
-	return $ret;
49
+    return $ret;
50 50
 }
Please login to merge, or discard this patch.