@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -47,26 +47,26 @@ discard block |
||
| 47 | 47 | * @return array |
| 48 | 48 | **/ |
| 49 | 49 | function liste_plugin_files($dir_plugins = null) { |
| 50 | - static $plugin_files = array(); |
|
| 51 | - if (is_null($dir_plugins)) { |
|
| 52 | - $dir_plugins = _DIR_PLUGINS; |
|
| 53 | - } |
|
| 54 | - if (!isset($plugin_files[$dir_plugins]) |
|
| 55 | - or count($plugin_files[$dir_plugins]) == 0 |
|
| 56 | - ) { |
|
| 57 | - $plugin_files[$dir_plugins] = array(); |
|
| 58 | - foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 59 | - $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - sort($plugin_files[$dir_plugins]); |
|
| 63 | - // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 64 | - // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 65 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 66 | - $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - return $plugin_files[$dir_plugins]; |
|
| 50 | + static $plugin_files = array(); |
|
| 51 | + if (is_null($dir_plugins)) { |
|
| 52 | + $dir_plugins = _DIR_PLUGINS; |
|
| 53 | + } |
|
| 54 | + if (!isset($plugin_files[$dir_plugins]) |
|
| 55 | + or count($plugin_files[$dir_plugins]) == 0 |
|
| 56 | + ) { |
|
| 57 | + $plugin_files[$dir_plugins] = array(); |
|
| 58 | + foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 59 | + $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + sort($plugin_files[$dir_plugins]); |
|
| 63 | + // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 64 | + // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 65 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 66 | + $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + return $plugin_files[$dir_plugins]; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -82,44 +82,44 @@ discard block |
||
| 82 | 82 | * Liste complète des répeertoires |
| 83 | 83 | **/ |
| 84 | 84 | function fast_find_plugin_dirs($dir, $max_prof = 100) { |
| 85 | - $fichiers = array(); |
|
| 86 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 87 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 88 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 89 | - if ($dir == '') { |
|
| 90 | - $dir = '.'; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - if (!is_dir($dir)) { |
|
| 94 | - return $fichiers; |
|
| 95 | - } |
|
| 96 | - if (is_plugin_dir($dir, '')) { |
|
| 97 | - $fichiers[] = $dir; |
|
| 98 | - |
|
| 99 | - return $fichiers; |
|
| 100 | - } |
|
| 101 | - if ($max_prof <= 0) { |
|
| 102 | - return $fichiers; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $subdirs = array(); |
|
| 106 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 107 | - while (($f = readdir($d)) !== false) { |
|
| 108 | - if ($f[0] != '.' # ignorer . .. .svn etc |
|
| 109 | - and $f != 'CVS' |
|
| 110 | - and is_dir($f = "$dir/$f") |
|
| 111 | - ) { |
|
| 112 | - $subdirs[] = $f; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - closedir($d); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - foreach ($subdirs as $d) { |
|
| 119 | - $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - return $fichiers; |
|
| 85 | + $fichiers = array(); |
|
| 86 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 87 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 88 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 89 | + if ($dir == '') { |
|
| 90 | + $dir = '.'; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + if (!is_dir($dir)) { |
|
| 94 | + return $fichiers; |
|
| 95 | + } |
|
| 96 | + if (is_plugin_dir($dir, '')) { |
|
| 97 | + $fichiers[] = $dir; |
|
| 98 | + |
|
| 99 | + return $fichiers; |
|
| 100 | + } |
|
| 101 | + if ($max_prof <= 0) { |
|
| 102 | + return $fichiers; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $subdirs = array(); |
|
| 106 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 107 | + while (($f = readdir($d)) !== false) { |
|
| 108 | + if ($f[0] != '.' # ignorer . .. .svn etc |
|
| 109 | + and $f != 'CVS' |
|
| 110 | + and is_dir($f = "$dir/$f") |
|
| 111 | + ) { |
|
| 112 | + $subdirs[] = $f; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + closedir($d); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + foreach ($subdirs as $d) { |
|
| 119 | + $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + return $fichiers; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -140,27 +140,27 @@ discard block |
||
| 140 | 140 | **/ |
| 141 | 141 | function is_plugin_dir($dir, $dir_plugins = null) { |
| 142 | 142 | |
| 143 | - if (is_array($dir)) { |
|
| 144 | - foreach ($dir as $k => $d) { |
|
| 145 | - if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 146 | - unset($dir[$k]); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - return $dir; |
|
| 151 | - } |
|
| 152 | - if (is_null($dir_plugins)) { |
|
| 153 | - $dir_plugins = _DIR_PLUGINS; |
|
| 154 | - } |
|
| 155 | - $search = array("$dir_plugins$dir/paquet.xml"); |
|
| 156 | - |
|
| 157 | - foreach ($search as $s) { |
|
| 158 | - if (file_exists($s)) { |
|
| 159 | - return $dir; |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - return ''; |
|
| 143 | + if (is_array($dir)) { |
|
| 144 | + foreach ($dir as $k => $d) { |
|
| 145 | + if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 146 | + unset($dir[$k]); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + return $dir; |
|
| 151 | + } |
|
| 152 | + if (is_null($dir_plugins)) { |
|
| 153 | + $dir_plugins = _DIR_PLUGINS; |
|
| 154 | + } |
|
| 155 | + $search = array("$dir_plugins$dir/paquet.xml"); |
|
| 156 | + |
|
| 157 | + foreach ($search as $s) { |
|
| 158 | + if (file_exists($s)) { |
|
| 159 | + return $dir; |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + return ''; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** Regexp d'extraction des informations d'un intervalle de compatibilité */ |
@@ -187,51 +187,51 @@ discard block |
||
| 187 | 187 | **/ |
| 188 | 188 | function plugin_version_compatible($intervalle, $version, $avec_quoi = '') { |
| 189 | 189 | |
| 190 | - if (!strlen($intervalle)) { |
|
| 191 | - return true; |
|
| 192 | - } |
|
| 193 | - if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 194 | - return false; |
|
| 195 | - } |
|
| 196 | - // Extraction des bornes et traitement de * pour la borne sup : |
|
| 197 | - // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 198 | - $minimum = $regs[1]; |
|
| 199 | - $maximum = $regs[2]; |
|
| 200 | - |
|
| 201 | - // si une version SPIP de compatibilité a été définie (dans |
|
| 202 | - // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 203 | - // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 204 | - // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 205 | - // entre plugins) |
|
| 206 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 207 | - if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 208 | - return true; |
|
| 209 | - } |
|
| 210 | - // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 211 | - // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - $minimum_inc = $intervalle[0] == "["; |
|
| 215 | - $maximum_inc = substr($intervalle, -1) == "]"; |
|
| 216 | - |
|
| 217 | - if (strlen($minimum)) { |
|
| 218 | - if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 219 | - return false; |
|
| 220 | - } |
|
| 221 | - if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 222 | - return false; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - if (strlen($maximum)) { |
|
| 226 | - if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 227 | - return false; |
|
| 228 | - } |
|
| 229 | - if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 230 | - return false; |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - return true; |
|
| 190 | + if (!strlen($intervalle)) { |
|
| 191 | + return true; |
|
| 192 | + } |
|
| 193 | + if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 194 | + return false; |
|
| 195 | + } |
|
| 196 | + // Extraction des bornes et traitement de * pour la borne sup : |
|
| 197 | + // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 198 | + $minimum = $regs[1]; |
|
| 199 | + $maximum = $regs[2]; |
|
| 200 | + |
|
| 201 | + // si une version SPIP de compatibilité a été définie (dans |
|
| 202 | + // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 203 | + // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 204 | + // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 205 | + // entre plugins) |
|
| 206 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 207 | + if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 208 | + return true; |
|
| 209 | + } |
|
| 210 | + // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 211 | + // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + $minimum_inc = $intervalle[0] == "["; |
|
| 215 | + $maximum_inc = substr($intervalle, -1) == "]"; |
|
| 216 | + |
|
| 217 | + if (strlen($minimum)) { |
|
| 218 | + if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 221 | + if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 222 | + return false; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + if (strlen($maximum)) { |
|
| 226 | + if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 227 | + return false; |
|
| 228 | + } |
|
| 229 | + if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 230 | + return false; |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + return true; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -248,62 +248,62 @@ discard block |
||
| 248 | 248 | * @return array |
| 249 | 249 | */ |
| 250 | 250 | function liste_plugin_valides($liste_plug, $force = false) { |
| 251 | - $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 252 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 253 | - $infos = array( |
|
| 254 | - // lister les extensions qui sont automatiquement actives |
|
| 255 | - '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 256 | - '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 257 | - ); |
|
| 258 | - |
|
| 259 | - // creer une premiere liste non ordonnee mais qui ne retient |
|
| 260 | - // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 261 | - $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 262 | - $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 263 | - $infos['_DIR_RESTREINT']['SPIP']['chemin'] = array(); |
|
| 264 | - $liste_non_classee = array( |
|
| 265 | - 'SPIP' => array( |
|
| 266 | - 'nom' => 'SPIP', |
|
| 267 | - 'etat' => 'stable', |
|
| 268 | - 'version' => $GLOBALS['spip_version_branche'], |
|
| 269 | - 'dir_type' => '_DIR_RESTREINT', |
|
| 270 | - 'dir' => '', |
|
| 271 | - ) |
|
| 272 | - ); |
|
| 273 | - |
|
| 274 | - $invalides = array(); |
|
| 275 | - foreach ($liste_ext as $plug) { |
|
| 276 | - if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 277 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - foreach ($liste_plug as $plug) { |
|
| 281 | - if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 282 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 283 | - if (is_array($r)) { |
|
| 284 | - $invalides = array_merge($invalides, $r); |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 290 | - $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 291 | - foreach ($liste_plug as $plug) { |
|
| 292 | - if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 293 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 294 | - if (is_array($r)) { |
|
| 295 | - $invalides = array_merge($invalides, $r); |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - plugin_fixer_procure($liste_non_classee, $infos); |
|
| 302 | - |
|
| 303 | - // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 304 | - $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 305 | - |
|
| 306 | - return array($infos, $liste_non_classee, $invalides); |
|
| 251 | + $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 252 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 253 | + $infos = array( |
|
| 254 | + // lister les extensions qui sont automatiquement actives |
|
| 255 | + '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 256 | + '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 257 | + ); |
|
| 258 | + |
|
| 259 | + // creer une premiere liste non ordonnee mais qui ne retient |
|
| 260 | + // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 261 | + $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 262 | + $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 263 | + $infos['_DIR_RESTREINT']['SPIP']['chemin'] = array(); |
|
| 264 | + $liste_non_classee = array( |
|
| 265 | + 'SPIP' => array( |
|
| 266 | + 'nom' => 'SPIP', |
|
| 267 | + 'etat' => 'stable', |
|
| 268 | + 'version' => $GLOBALS['spip_version_branche'], |
|
| 269 | + 'dir_type' => '_DIR_RESTREINT', |
|
| 270 | + 'dir' => '', |
|
| 271 | + ) |
|
| 272 | + ); |
|
| 273 | + |
|
| 274 | + $invalides = array(); |
|
| 275 | + foreach ($liste_ext as $plug) { |
|
| 276 | + if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 277 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + foreach ($liste_plug as $plug) { |
|
| 281 | + if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 282 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 283 | + if (is_array($r)) { |
|
| 284 | + $invalides = array_merge($invalides, $r); |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 290 | + $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 291 | + foreach ($liste_plug as $plug) { |
|
| 292 | + if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 293 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 294 | + if (is_array($r)) { |
|
| 295 | + $invalides = array_merge($invalides, $r); |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + plugin_fixer_procure($liste_non_classee, $infos); |
|
| 302 | + |
|
| 303 | + // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 304 | + $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 305 | + |
|
| 306 | + return array($infos, $liste_non_classee, $invalides); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -323,29 +323,29 @@ discard block |
||
| 323 | 323 | * array description short si on ne le retient pas (pour memorisation dans une table des erreurs) |
| 324 | 324 | */ |
| 325 | 325 | function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) { |
| 326 | - $i = $infos[$dir_type][$plug]; |
|
| 327 | - $p = strtoupper($i['prefix']); |
|
| 328 | - $short_desc = array( |
|
| 329 | - 'nom' => $i['nom'], |
|
| 330 | - 'etat' => $i['etat'], |
|
| 331 | - 'version' => $i['version'], |
|
| 332 | - 'dir' => $plug, |
|
| 333 | - 'dir_type' => $dir_type |
|
| 334 | - ); |
|
| 335 | - if (isset($i['erreur']) and $i['erreur']) { |
|
| 336 | - $short_desc['erreur'] = $i['erreur']; |
|
| 337 | - return array($p=>$short_desc); |
|
| 338 | - } |
|
| 339 | - if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 340 | - return array($p=>$short_desc); |
|
| 341 | - } |
|
| 342 | - if (!isset($liste[$p]) |
|
| 343 | - or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 344 | - ) { |
|
| 345 | - $liste[$p] = $short_desc; |
|
| 346 | - } |
|
| 347 | - // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 348 | - return $p; |
|
| 326 | + $i = $infos[$dir_type][$plug]; |
|
| 327 | + $p = strtoupper($i['prefix']); |
|
| 328 | + $short_desc = array( |
|
| 329 | + 'nom' => $i['nom'], |
|
| 330 | + 'etat' => $i['etat'], |
|
| 331 | + 'version' => $i['version'], |
|
| 332 | + 'dir' => $plug, |
|
| 333 | + 'dir_type' => $dir_type |
|
| 334 | + ); |
|
| 335 | + if (isset($i['erreur']) and $i['erreur']) { |
|
| 336 | + $short_desc['erreur'] = $i['erreur']; |
|
| 337 | + return array($p=>$short_desc); |
|
| 338 | + } |
|
| 339 | + if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 340 | + return array($p=>$short_desc); |
|
| 341 | + } |
|
| 342 | + if (!isset($liste[$p]) |
|
| 343 | + or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 344 | + ) { |
|
| 345 | + $liste[$p] = $short_desc; |
|
| 346 | + } |
|
| 347 | + // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 348 | + return $p; |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -361,46 +361,46 @@ discard block |
||
| 361 | 361 | * @param array $infos |
| 362 | 362 | */ |
| 363 | 363 | function plugin_fixer_procure(&$liste, &$infos) { |
| 364 | - foreach ($liste as $p => $resume) { |
|
| 365 | - $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 366 | - if (isset($i['procure']) and $i['procure']) { |
|
| 367 | - foreach ($i['procure'] as $procure) { |
|
| 368 | - $p = strtoupper($procure['nom']); |
|
| 369 | - $dir = $resume['dir']; |
|
| 370 | - if ($dir) { |
|
| 371 | - $dir .= "/"; |
|
| 372 | - } |
|
| 373 | - $dir .= "procure:" . $procure['nom']; |
|
| 374 | - |
|
| 375 | - $procure['etat'] = '?'; |
|
| 376 | - $procure['dir_type'] = $resume['dir_type']; |
|
| 377 | - $procure['dir'] = $dir; |
|
| 378 | - |
|
| 379 | - // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 380 | - // on ajoute cette version a la liste |
|
| 381 | - if (!isset($liste[$p]) |
|
| 382 | - or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 383 | - ) { |
|
| 384 | - $liste[$p] = $procure; |
|
| 385 | - |
|
| 386 | - // on fournit une information minimale pour ne pas perturber la compilation |
|
| 387 | - $infos[$resume['dir_type']][$dir] = array( |
|
| 388 | - 'prefix' => $procure['nom'], |
|
| 389 | - 'nom' => $procure['nom'], |
|
| 390 | - 'etat' => $procure['etat'], |
|
| 391 | - 'version' => $procure['version'], |
|
| 392 | - 'chemin' => array(), |
|
| 393 | - 'necessite' => array(), |
|
| 394 | - 'utilise' => array(), |
|
| 395 | - 'lib' => array(), |
|
| 396 | - 'menu' => array(), |
|
| 397 | - 'onglet' => array(), |
|
| 398 | - 'procure' => array(), |
|
| 399 | - ); |
|
| 400 | - } |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - } |
|
| 364 | + foreach ($liste as $p => $resume) { |
|
| 365 | + $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 366 | + if (isset($i['procure']) and $i['procure']) { |
|
| 367 | + foreach ($i['procure'] as $procure) { |
|
| 368 | + $p = strtoupper($procure['nom']); |
|
| 369 | + $dir = $resume['dir']; |
|
| 370 | + if ($dir) { |
|
| 371 | + $dir .= "/"; |
|
| 372 | + } |
|
| 373 | + $dir .= "procure:" . $procure['nom']; |
|
| 374 | + |
|
| 375 | + $procure['etat'] = '?'; |
|
| 376 | + $procure['dir_type'] = $resume['dir_type']; |
|
| 377 | + $procure['dir'] = $dir; |
|
| 378 | + |
|
| 379 | + // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 380 | + // on ajoute cette version a la liste |
|
| 381 | + if (!isset($liste[$p]) |
|
| 382 | + or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 383 | + ) { |
|
| 384 | + $liste[$p] = $procure; |
|
| 385 | + |
|
| 386 | + // on fournit une information minimale pour ne pas perturber la compilation |
|
| 387 | + $infos[$resume['dir_type']][$dir] = array( |
|
| 388 | + 'prefix' => $procure['nom'], |
|
| 389 | + 'nom' => $procure['nom'], |
|
| 390 | + 'etat' => $procure['etat'], |
|
| 391 | + 'version' => $procure['version'], |
|
| 392 | + 'chemin' => array(), |
|
| 393 | + 'necessite' => array(), |
|
| 394 | + 'utilise' => array(), |
|
| 395 | + 'lib' => array(), |
|
| 396 | + 'menu' => array(), |
|
| 397 | + 'onglet' => array(), |
|
| 398 | + 'procure' => array(), |
|
| 399 | + ); |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -414,19 +414,19 @@ discard block |
||
| 414 | 414 | * @return array |
| 415 | 415 | */ |
| 416 | 416 | function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) { |
| 417 | - foreach ($liste as $prefix => $infos) { |
|
| 418 | - if (!$dir_plugins |
|
| 419 | - or ( |
|
| 420 | - defined($infos['dir_type']) |
|
| 421 | - and constant($infos['dir_type']) == $dir_plugins) |
|
| 422 | - ) { |
|
| 423 | - $liste[$prefix] = $infos['dir']; |
|
| 424 | - } else { |
|
| 425 | - unset($liste[$prefix]); |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - return $liste; |
|
| 417 | + foreach ($liste as $prefix => $infos) { |
|
| 418 | + if (!$dir_plugins |
|
| 419 | + or ( |
|
| 420 | + defined($infos['dir_type']) |
|
| 421 | + and constant($infos['dir_type']) == $dir_plugins) |
|
| 422 | + ) { |
|
| 423 | + $liste[$prefix] = $infos['dir']; |
|
| 424 | + } else { |
|
| 425 | + unset($liste[$prefix]); |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + return $liste; |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -441,9 +441,9 @@ discard block |
||
| 441 | 441 | * @return array |
| 442 | 442 | */ |
| 443 | 443 | function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) { |
| 444 | - include_spip('plugins/installer'); |
|
| 444 | + include_spip('plugins/installer'); |
|
| 445 | 445 | |
| 446 | - return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 446 | + return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
@@ -474,53 +474,53 @@ discard block |
||
| 474 | 474 | * qui n'ont pas satisfait leurs dépendances |
| 475 | 475 | **/ |
| 476 | 476 | function plugin_trier($infos, $liste_non_classee) { |
| 477 | - $toute_la_liste = $liste_non_classee; |
|
| 478 | - $liste = $ordre = array(); |
|
| 479 | - $count = 0; |
|
| 480 | - |
|
| 481 | - while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 482 | - #echo "tour::";var_dump($liste_non_classee); |
|
| 483 | - $count = $c; |
|
| 484 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 485 | - $plug = $resume['dir']; |
|
| 486 | - $dir_type = $resume['dir_type']; |
|
| 487 | - $info1 = $infos[$dir_type][$plug]; |
|
| 488 | - // si des plugins sont necessaires, |
|
| 489 | - // on ne peut inserer qu'apres eux |
|
| 490 | - foreach ($info1['necessite'] as $need) { |
|
| 491 | - $nom = strtoupper($need['nom']); |
|
| 492 | - $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 493 | - if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 494 | - $info1 = false; |
|
| 495 | - break; |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - if (!$info1) { |
|
| 499 | - continue; |
|
| 500 | - } |
|
| 501 | - // idem si des plugins sont utiles, |
|
| 502 | - // sauf si ils sont de toute facon absents de la liste |
|
| 503 | - foreach ($info1['utilise'] as $need) { |
|
| 504 | - $nom = strtoupper($need['nom']); |
|
| 505 | - $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 506 | - if (isset($toute_la_liste[$nom])) { |
|
| 507 | - if (!isset($liste[$nom]) or |
|
| 508 | - !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 509 | - ) { |
|
| 510 | - $info1 = false; |
|
| 511 | - break; |
|
| 512 | - } |
|
| 513 | - } |
|
| 514 | - } |
|
| 515 | - if ($info1) { |
|
| 516 | - $ordre[$p] = $info1; |
|
| 517 | - $liste[$p] = $liste_non_classee[$p]; |
|
| 518 | - unset($liste_non_classee[$p]); |
|
| 519 | - } |
|
| 520 | - } |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - return array($liste, $ordre, $liste_non_classee); |
|
| 477 | + $toute_la_liste = $liste_non_classee; |
|
| 478 | + $liste = $ordre = array(); |
|
| 479 | + $count = 0; |
|
| 480 | + |
|
| 481 | + while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 482 | + #echo "tour::";var_dump($liste_non_classee); |
|
| 483 | + $count = $c; |
|
| 484 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 485 | + $plug = $resume['dir']; |
|
| 486 | + $dir_type = $resume['dir_type']; |
|
| 487 | + $info1 = $infos[$dir_type][$plug]; |
|
| 488 | + // si des plugins sont necessaires, |
|
| 489 | + // on ne peut inserer qu'apres eux |
|
| 490 | + foreach ($info1['necessite'] as $need) { |
|
| 491 | + $nom = strtoupper($need['nom']); |
|
| 492 | + $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 493 | + if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 494 | + $info1 = false; |
|
| 495 | + break; |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + if (!$info1) { |
|
| 499 | + continue; |
|
| 500 | + } |
|
| 501 | + // idem si des plugins sont utiles, |
|
| 502 | + // sauf si ils sont de toute facon absents de la liste |
|
| 503 | + foreach ($info1['utilise'] as $need) { |
|
| 504 | + $nom = strtoupper($need['nom']); |
|
| 505 | + $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 506 | + if (isset($toute_la_liste[$nom])) { |
|
| 507 | + if (!isset($liste[$nom]) or |
|
| 508 | + !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 509 | + ) { |
|
| 510 | + $info1 = false; |
|
| 511 | + break; |
|
| 512 | + } |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + if ($info1) { |
|
| 516 | + $ordre[$p] = $info1; |
|
| 517 | + $liste[$p] = $liste_non_classee[$p]; |
|
| 518 | + unset($liste_non_classee[$p]); |
|
| 519 | + } |
|
| 520 | + } |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + return array($liste, $ordre, $liste_non_classee); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
@@ -537,40 +537,40 @@ discard block |
||
| 537 | 537 | * Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent |
| 538 | 538 | **/ |
| 539 | 539 | function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = array()) { |
| 540 | - static $erreurs = array(); |
|
| 541 | - |
|
| 542 | - if (!is_array($liste)) { |
|
| 543 | - $liste = array(); |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 547 | - $liste = array_diff_key($liste, $liste_non_classee); |
|
| 548 | - |
|
| 549 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 550 | - $dir_type = $resume['dir_type']; |
|
| 551 | - $plug = $resume['dir']; |
|
| 552 | - $k = $infos[$dir_type][$plug]; |
|
| 553 | - |
|
| 554 | - $plug = constant($dir_type) . $plug; |
|
| 555 | - if (!isset($msg[$p])) { |
|
| 556 | - if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 557 | - $msg[$p] = array($resume['erreur']); |
|
| 558 | - } |
|
| 559 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 560 | - $msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')); |
|
| 561 | - } |
|
| 562 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 563 | - $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 564 | - } |
|
| 565 | - } else { |
|
| 566 | - foreach ($msg[$p] as $c => $l) { |
|
| 567 | - $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - $erreurs[$plug] = $msg[$p]; |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 540 | + static $erreurs = array(); |
|
| 541 | + |
|
| 542 | + if (!is_array($liste)) { |
|
| 543 | + $liste = array(); |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 547 | + $liste = array_diff_key($liste, $liste_non_classee); |
|
| 548 | + |
|
| 549 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 550 | + $dir_type = $resume['dir_type']; |
|
| 551 | + $plug = $resume['dir']; |
|
| 552 | + $k = $infos[$dir_type][$plug]; |
|
| 553 | + |
|
| 554 | + $plug = constant($dir_type) . $plug; |
|
| 555 | + if (!isset($msg[$p])) { |
|
| 556 | + if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 557 | + $msg[$p] = array($resume['erreur']); |
|
| 558 | + } |
|
| 559 | + elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 560 | + $msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')); |
|
| 561 | + } |
|
| 562 | + elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 563 | + $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 564 | + } |
|
| 565 | + } else { |
|
| 566 | + foreach ($msg[$p] as $c => $l) { |
|
| 567 | + $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + $erreurs[$plug] = $msg[$p]; |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | /** |
@@ -585,25 +585,25 @@ discard block |
||
| 585 | 585 | * - Liste des erreurs ou code HTML des erreurs |
| 586 | 586 | **/ |
| 587 | 587 | function plugin_donne_erreurs($raw = false, $raz = true) { |
| 588 | - if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 589 | - return $raw ? array() : ''; |
|
| 590 | - } |
|
| 591 | - $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 592 | - // Compat ancienne version |
|
| 593 | - if (!$list) { |
|
| 594 | - $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 595 | - } elseif (!$raw) { |
|
| 596 | - foreach ($list as $plug => $msg) { |
|
| 597 | - $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 598 | - . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>"; |
|
| 599 | - } |
|
| 600 | - $list = "<ul>" . join("\n", $list) . "</ul>"; |
|
| 601 | - } |
|
| 602 | - if ($raz) { |
|
| 603 | - effacer_meta('plugin_erreur_activation'); |
|
| 604 | - } |
|
| 605 | - |
|
| 606 | - return $list; |
|
| 588 | + if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 589 | + return $raw ? array() : ''; |
|
| 590 | + } |
|
| 591 | + $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 592 | + // Compat ancienne version |
|
| 593 | + if (!$list) { |
|
| 594 | + $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 595 | + } elseif (!$raw) { |
|
| 596 | + foreach ($list as $plug => $msg) { |
|
| 597 | + $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 598 | + . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>"; |
|
| 599 | + } |
|
| 600 | + $list = "<ul>" . join("\n", $list) . "</ul>"; |
|
| 601 | + } |
|
| 602 | + if ($raz) { |
|
| 603 | + effacer_meta('plugin_erreur_activation'); |
|
| 604 | + } |
|
| 605 | + |
|
| 606 | + return $list; |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | /** |
@@ -623,21 +623,21 @@ discard block |
||
| 623 | 623 | * |
| 624 | 624 | **/ |
| 625 | 625 | function plugin_necessite($n, $liste, $balise = 'necessite') { |
| 626 | - $msg = array(); |
|
| 627 | - foreach ($n as $need) { |
|
| 628 | - $id = strtoupper($need['nom']); |
|
| 629 | - $r = plugin_controler_necessite( |
|
| 630 | - $liste, |
|
| 631 | - $id, |
|
| 632 | - isset($need['compatibilite']) ? $need['compatibilite'] : '', |
|
| 633 | - $balise |
|
| 634 | - ); |
|
| 635 | - if ($r) { |
|
| 636 | - $msg[] = $r; |
|
| 637 | - } |
|
| 638 | - } |
|
| 639 | - |
|
| 640 | - return $msg; |
|
| 626 | + $msg = array(); |
|
| 627 | + foreach ($n as $need) { |
|
| 628 | + $id = strtoupper($need['nom']); |
|
| 629 | + $r = plugin_controler_necessite( |
|
| 630 | + $liste, |
|
| 631 | + $id, |
|
| 632 | + isset($need['compatibilite']) ? $need['compatibilite'] : '', |
|
| 633 | + $balise |
|
| 634 | + ); |
|
| 635 | + if ($r) { |
|
| 636 | + $msg[] = $r; |
|
| 637 | + } |
|
| 638 | + } |
|
| 639 | + |
|
| 640 | + return $msg; |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -659,19 +659,19 @@ discard block |
||
| 659 | 659 | * Message d'erreur lorsque la dépendance est absente. |
| 660 | 660 | **/ |
| 661 | 661 | function plugin_controler_necessite($liste, $nom, $intervalle, $balise) { |
| 662 | - if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 663 | - return ''; |
|
| 664 | - } |
|
| 665 | - // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 666 | - if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 667 | - return ''; |
|
| 668 | - } |
|
| 669 | - return plugin_message_incompatibilite( |
|
| 670 | - $intervalle, |
|
| 671 | - (isset($liste[$nom]) ? $liste[$nom]['version'] : ""), |
|
| 672 | - $nom, |
|
| 673 | - $balise |
|
| 674 | - ); |
|
| 662 | + if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 663 | + return ''; |
|
| 664 | + } |
|
| 665 | + // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 666 | + if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 667 | + return ''; |
|
| 668 | + } |
|
| 669 | + return plugin_message_incompatibilite( |
|
| 670 | + $intervalle, |
|
| 671 | + (isset($liste[$nom]) ? $liste[$nom]['version'] : ""), |
|
| 672 | + $nom, |
|
| 673 | + $balise |
|
| 674 | + ); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | /** |
@@ -688,70 +688,70 @@ discard block |
||
| 688 | 688 | */ |
| 689 | 689 | function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) { |
| 690 | 690 | |
| 691 | - // prendre en compte les erreurs de dépendances à PHP |
|
| 692 | - // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 693 | - $type = 'plugin'; |
|
| 694 | - if ($nom === 'SPIP') { |
|
| 695 | - $type = 'spip'; |
|
| 696 | - } elseif ($nom === 'PHP') { |
|
| 697 | - $type = 'php'; |
|
| 698 | - } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 699 | - $type = 'extension_php'; |
|
| 700 | - list(,$nom) = explode(':', $nom, 2); |
|
| 701 | - } |
|
| 702 | - |
|
| 703 | - if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 704 | - $minimum = $regs[1]; |
|
| 705 | - $maximum = $regs[2]; |
|
| 706 | - |
|
| 707 | - $minimum_inclus = $intervalle[0] == "["; |
|
| 708 | - $maximum_inclus = substr($intervalle, -1) == "]"; |
|
| 709 | - |
|
| 710 | - if (strlen($minimum)) { |
|
| 711 | - if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 712 | - return _T("plugin_${balise}_${type}", array( |
|
| 713 | - 'plugin' => $nom, |
|
| 714 | - 'version' => ' ≥ ' . $minimum |
|
| 715 | - )); |
|
| 716 | - } |
|
| 717 | - if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 718 | - return _T("plugin_${balise}_${type}", array( |
|
| 719 | - 'plugin' => $nom, |
|
| 720 | - 'version' => ' > ' . $minimum |
|
| 721 | - )); |
|
| 722 | - } |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - if (strlen($maximum)) { |
|
| 726 | - if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 727 | - return _T("plugin_${balise}_${type}", array( |
|
| 728 | - 'plugin' => $nom, |
|
| 729 | - 'version' => ' ≤ ' . $maximum |
|
| 730 | - )); |
|
| 731 | - } |
|
| 732 | - if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 733 | - return _T("plugin_${balise}_plugin", array( |
|
| 734 | - 'plugin' => $nom, |
|
| 735 | - 'version' => ' < ' . $maximum |
|
| 736 | - )); |
|
| 737 | - } |
|
| 738 | - } |
|
| 739 | - } |
|
| 740 | - |
|
| 741 | - // note : il ne peut pas y avoir d'erreur sur |
|
| 742 | - // - un 'utilise' sans version. |
|
| 743 | - // - un 'php' sans version. |
|
| 744 | - return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom)); |
|
| 691 | + // prendre en compte les erreurs de dépendances à PHP |
|
| 692 | + // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 693 | + $type = 'plugin'; |
|
| 694 | + if ($nom === 'SPIP') { |
|
| 695 | + $type = 'spip'; |
|
| 696 | + } elseif ($nom === 'PHP') { |
|
| 697 | + $type = 'php'; |
|
| 698 | + } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 699 | + $type = 'extension_php'; |
|
| 700 | + list(,$nom) = explode(':', $nom, 2); |
|
| 701 | + } |
|
| 702 | + |
|
| 703 | + if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 704 | + $minimum = $regs[1]; |
|
| 705 | + $maximum = $regs[2]; |
|
| 706 | + |
|
| 707 | + $minimum_inclus = $intervalle[0] == "["; |
|
| 708 | + $maximum_inclus = substr($intervalle, -1) == "]"; |
|
| 709 | + |
|
| 710 | + if (strlen($minimum)) { |
|
| 711 | + if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 712 | + return _T("plugin_${balise}_${type}", array( |
|
| 713 | + 'plugin' => $nom, |
|
| 714 | + 'version' => ' ≥ ' . $minimum |
|
| 715 | + )); |
|
| 716 | + } |
|
| 717 | + if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 718 | + return _T("plugin_${balise}_${type}", array( |
|
| 719 | + 'plugin' => $nom, |
|
| 720 | + 'version' => ' > ' . $minimum |
|
| 721 | + )); |
|
| 722 | + } |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + if (strlen($maximum)) { |
|
| 726 | + if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 727 | + return _T("plugin_${balise}_${type}", array( |
|
| 728 | + 'plugin' => $nom, |
|
| 729 | + 'version' => ' ≤ ' . $maximum |
|
| 730 | + )); |
|
| 731 | + } |
|
| 732 | + if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 733 | + return _T("plugin_${balise}_plugin", array( |
|
| 734 | + 'plugin' => $nom, |
|
| 735 | + 'version' => ' < ' . $maximum |
|
| 736 | + )); |
|
| 737 | + } |
|
| 738 | + } |
|
| 739 | + } |
|
| 740 | + |
|
| 741 | + // note : il ne peut pas y avoir d'erreur sur |
|
| 742 | + // - un 'utilise' sans version. |
|
| 743 | + // - un 'php' sans version. |
|
| 744 | + return _T("plugin_necessite_${type}_sans_version", array('plugin' => $nom)); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | |
| 748 | 748 | function plugin_controler_lib($lib, $url) { |
| 749 | - /* Feature sortie du core, voir STP |
|
| 749 | + /* Feature sortie du core, voir STP |
|
| 750 | 750 | * if ($url) { |
| 751 | 751 | include_spip('inc/charger_plugin'); |
| 752 | 752 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 753 | 753 | }*/ |
| 754 | - return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>"; |
|
| 754 | + return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>"; |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | * true si il y a eu des modifications sur la liste des plugins actifs, false sinon |
| 767 | 767 | **/ |
| 768 | 768 | function actualise_plugins_actifs($pipe_recherche = false) { |
| 769 | - return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 769 | + return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | |
@@ -793,113 +793,113 @@ discard block |
||
| 793 | 793 | **/ |
| 794 | 794 | function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') { |
| 795 | 795 | |
| 796 | - // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 797 | - $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 798 | - |
|
| 799 | - // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 800 | - if (!$cache and !spip_connect()) { |
|
| 801 | - return false; |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - if ($operation != 'raz') { |
|
| 805 | - $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 806 | - $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 807 | - if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 808 | - $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 809 | - $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 810 | - $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 811 | - } |
|
| 812 | - // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 813 | - // on les reinjecte ici |
|
| 814 | - if (isset($GLOBALS['meta']['plugin_attente']) |
|
| 815 | - and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 816 | - ) { |
|
| 817 | - $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - if ($operation == 'ajoute') { |
|
| 821 | - $plugin = array_merge($plugin_valides, $plugin); |
|
| 822 | - } elseif ($operation == 'enleve') { |
|
| 823 | - $plugin = array_diff($plugin_valides, $plugin); |
|
| 824 | - } else { |
|
| 825 | - $plugin = $plugin_valides; |
|
| 826 | - } |
|
| 827 | - } |
|
| 828 | - $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : ''; |
|
| 829 | - |
|
| 830 | - // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 831 | - if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) { |
|
| 832 | - $plugin = $ajouter_dependances($plugin); |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - // recharger le xml des plugins a activer |
|
| 836 | - // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 837 | - // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 838 | - // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 839 | - // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 840 | - list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true); |
|
| 841 | - // trouver l'ordre d'activation |
|
| 842 | - list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste); |
|
| 843 | - if ($invalides or $reste) { |
|
| 844 | - plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 845 | - } |
|
| 846 | - |
|
| 847 | - // Ignorer les plugins necessitant une lib absente |
|
| 848 | - // et preparer la meta d'entete Http |
|
| 849 | - $err = $msg = $header = array(); |
|
| 850 | - foreach ($plugin_valides as $p => $resume) { |
|
| 851 | - // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 852 | - if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 853 | - $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : ""); |
|
| 854 | - } |
|
| 855 | - if ($resume['dir']) { |
|
| 856 | - foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 857 | - if (!find_in_path($l['nom'], 'lib/')) { |
|
| 858 | - $err[$p] = $resume; |
|
| 859 | - $msg[$p][] = $l; |
|
| 860 | - unset($plugin_valides[$p]); |
|
| 861 | - } |
|
| 862 | - } |
|
| 863 | - } |
|
| 864 | - } |
|
| 865 | - if ($err) { |
|
| 866 | - plugins_erreurs($err, '', $infos, $msg); |
|
| 867 | - } |
|
| 868 | - |
|
| 869 | - if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 870 | - effacer_meta('message_crash_plugins'); |
|
| 871 | - } |
|
| 872 | - ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 873 | - $liste = array_diff_key($liste, $plugin_valides); |
|
| 874 | - ecrire_meta('plugin_attente', serialize($liste)); |
|
| 875 | - $header = strtolower(implode(",", $header)); |
|
| 876 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 877 | - ecrire_fichier(_DIR_VAR . "config.txt", |
|
| 878 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header); |
|
| 879 | - } else { |
|
| 880 | - @unlink(_DIR_VAR . "config.txt"); |
|
| 881 | - } |
|
| 882 | - // generer charger_plugins_chemin.php |
|
| 883 | - plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 884 | - // generer les fichiers |
|
| 885 | - // - charger_plugins_options.php |
|
| 886 | - // - charger_plugins_fonctions.php |
|
| 887 | - plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 888 | - // charger les chemins des plugins et les fichiers d'options |
|
| 889 | - // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 890 | - plugins_amorcer_plugins_actifs(); |
|
| 891 | - // mise a jour de la matrice des pipelines |
|
| 892 | - $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 893 | - // generer le fichier _CACHE_PIPELINE |
|
| 894 | - pipeline_precompile($prepend_code); |
|
| 895 | - |
|
| 896 | - if (spip_connect()) { |
|
| 897 | - // lancer et initialiser les nouveaux crons ! |
|
| 898 | - include_spip('inc/genie'); |
|
| 899 | - genie_queue_watch_dist(); |
|
| 900 | - } |
|
| 901 | - |
|
| 902 | - return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 796 | + // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 797 | + $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 798 | + |
|
| 799 | + // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 800 | + if (!$cache and !spip_connect()) { |
|
| 801 | + return false; |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + if ($operation != 'raz') { |
|
| 805 | + $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 806 | + $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 807 | + if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 808 | + $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 809 | + $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 810 | + $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 811 | + } |
|
| 812 | + // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 813 | + // on les reinjecte ici |
|
| 814 | + if (isset($GLOBALS['meta']['plugin_attente']) |
|
| 815 | + and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 816 | + ) { |
|
| 817 | + $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + if ($operation == 'ajoute') { |
|
| 821 | + $plugin = array_merge($plugin_valides, $plugin); |
|
| 822 | + } elseif ($operation == 'enleve') { |
|
| 823 | + $plugin = array_diff($plugin_valides, $plugin); |
|
| 824 | + } else { |
|
| 825 | + $plugin = $plugin_valides; |
|
| 826 | + } |
|
| 827 | + } |
|
| 828 | + $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : ''; |
|
| 829 | + |
|
| 830 | + // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 831 | + if ($ajouter_dependances = charger_fonction("ajouter_dependances", "plugins", true)) { |
|
| 832 | + $plugin = $ajouter_dependances($plugin); |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + // recharger le xml des plugins a activer |
|
| 836 | + // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 837 | + // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 838 | + // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 839 | + // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 840 | + list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true); |
|
| 841 | + // trouver l'ordre d'activation |
|
| 842 | + list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste); |
|
| 843 | + if ($invalides or $reste) { |
|
| 844 | + plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 845 | + } |
|
| 846 | + |
|
| 847 | + // Ignorer les plugins necessitant une lib absente |
|
| 848 | + // et preparer la meta d'entete Http |
|
| 849 | + $err = $msg = $header = array(); |
|
| 850 | + foreach ($plugin_valides as $p => $resume) { |
|
| 851 | + // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 852 | + if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 853 | + $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : ""); |
|
| 854 | + } |
|
| 855 | + if ($resume['dir']) { |
|
| 856 | + foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 857 | + if (!find_in_path($l['nom'], 'lib/')) { |
|
| 858 | + $err[$p] = $resume; |
|
| 859 | + $msg[$p][] = $l; |
|
| 860 | + unset($plugin_valides[$p]); |
|
| 861 | + } |
|
| 862 | + } |
|
| 863 | + } |
|
| 864 | + } |
|
| 865 | + if ($err) { |
|
| 866 | + plugins_erreurs($err, '', $infos, $msg); |
|
| 867 | + } |
|
| 868 | + |
|
| 869 | + if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 870 | + effacer_meta('message_crash_plugins'); |
|
| 871 | + } |
|
| 872 | + ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 873 | + $liste = array_diff_key($liste, $plugin_valides); |
|
| 874 | + ecrire_meta('plugin_attente', serialize($liste)); |
|
| 875 | + $header = strtolower(implode(",", $header)); |
|
| 876 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 877 | + ecrire_fichier(_DIR_VAR . "config.txt", |
|
| 878 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header); |
|
| 879 | + } else { |
|
| 880 | + @unlink(_DIR_VAR . "config.txt"); |
|
| 881 | + } |
|
| 882 | + // generer charger_plugins_chemin.php |
|
| 883 | + plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 884 | + // generer les fichiers |
|
| 885 | + // - charger_plugins_options.php |
|
| 886 | + // - charger_plugins_fonctions.php |
|
| 887 | + plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 888 | + // charger les chemins des plugins et les fichiers d'options |
|
| 889 | + // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 890 | + plugins_amorcer_plugins_actifs(); |
|
| 891 | + // mise a jour de la matrice des pipelines |
|
| 892 | + $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 893 | + // generer le fichier _CACHE_PIPELINE |
|
| 894 | + pipeline_precompile($prepend_code); |
|
| 895 | + |
|
| 896 | + if (spip_connect()) { |
|
| 897 | + // lancer et initialiser les nouveaux crons ! |
|
| 898 | + include_spip('inc/genie'); |
|
| 899 | + genie_queue_watch_dist(); |
|
| 900 | + } |
|
| 901 | + |
|
| 902 | + return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
@@ -918,68 +918,68 @@ discard block |
||
| 918 | 918 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 919 | 919 | **/ |
| 920 | 920 | function plugins_precompile_chemin($plugin_valides, $ordre) { |
| 921 | - $chemins = [ |
|
| 922 | - 'public' => [], |
|
| 923 | - 'prive' => [] |
|
| 924 | - ]; |
|
| 925 | - $contenu = ""; |
|
| 926 | - foreach ($ordre as $p => $info) { |
|
| 927 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 928 | - if (isset($plugin_valides[$p])) { |
|
| 929 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 930 | - $plug = $plugin_valides[$p]['dir']; |
|
| 931 | - // definir le plugin, donc le path avant l'include du fichier options |
|
| 932 | - // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 933 | - |
|
| 934 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 935 | - |
|
| 936 | - $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 937 | - if ( |
|
| 938 | - $prefix !== "SPIP" |
|
| 939 | - and strpos($dir, ":") === false // exclure le cas des procure: |
|
| 940 | - ) { |
|
| 941 | - $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 942 | - if (!$info['chemin']) { |
|
| 943 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 944 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 945 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 946 | - $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 947 | - } |
|
| 948 | - } |
|
| 949 | - else{ |
|
| 950 | - foreach ($info['chemin'] as $chemin) { |
|
| 951 | - if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'], |
|
| 952 | - $GLOBALS['spip_version_branche'], 'spip') |
|
| 953 | - ) { |
|
| 954 | - $dir = $chemin['path']; |
|
| 955 | - if (strlen($dir) and $dir[0] == "/") { |
|
| 956 | - $dir = substr($dir, 1); |
|
| 957 | - } |
|
| 958 | - if (strlen($dir) and $dir == "./") { |
|
| 959 | - $dir = ''; |
|
| 960 | - } |
|
| 961 | - if (strlen($dir)) { |
|
| 962 | - $dir = rtrim($dir, '/') . '/'; |
|
| 963 | - } |
|
| 964 | - if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 965 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 966 | - } |
|
| 967 | - if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 968 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 969 | - } |
|
| 970 | - } |
|
| 971 | - } |
|
| 972 | - } |
|
| 973 | - } |
|
| 974 | - } |
|
| 975 | - } |
|
| 976 | - if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 977 | - $contenu .= "if (_DIR_RESTREINT) _chemin([" . implode(',', |
|
| 978 | - array_reverse($chemins['public'])) . "]);\n" |
|
| 979 | - . "else _chemin([" . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 980 | - } |
|
| 981 | - |
|
| 982 | - ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 921 | + $chemins = [ |
|
| 922 | + 'public' => [], |
|
| 923 | + 'prive' => [] |
|
| 924 | + ]; |
|
| 925 | + $contenu = ""; |
|
| 926 | + foreach ($ordre as $p => $info) { |
|
| 927 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 928 | + if (isset($plugin_valides[$p])) { |
|
| 929 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 930 | + $plug = $plugin_valides[$p]['dir']; |
|
| 931 | + // definir le plugin, donc le path avant l'include du fichier options |
|
| 932 | + // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 933 | + |
|
| 934 | + $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 935 | + |
|
| 936 | + $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 937 | + if ( |
|
| 938 | + $prefix !== "SPIP" |
|
| 939 | + and strpos($dir, ":") === false // exclure le cas des procure: |
|
| 940 | + ) { |
|
| 941 | + $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 942 | + if (!$info['chemin']) { |
|
| 943 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 944 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 945 | + if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 946 | + $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 947 | + } |
|
| 948 | + } |
|
| 949 | + else{ |
|
| 950 | + foreach ($info['chemin'] as $chemin) { |
|
| 951 | + if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'], |
|
| 952 | + $GLOBALS['spip_version_branche'], 'spip') |
|
| 953 | + ) { |
|
| 954 | + $dir = $chemin['path']; |
|
| 955 | + if (strlen($dir) and $dir[0] == "/") { |
|
| 956 | + $dir = substr($dir, 1); |
|
| 957 | + } |
|
| 958 | + if (strlen($dir) and $dir == "./") { |
|
| 959 | + $dir = ''; |
|
| 960 | + } |
|
| 961 | + if (strlen($dir)) { |
|
| 962 | + $dir = rtrim($dir, '/') . '/'; |
|
| 963 | + } |
|
| 964 | + if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 965 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 966 | + } |
|
| 967 | + if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 968 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 969 | + } |
|
| 970 | + } |
|
| 971 | + } |
|
| 972 | + } |
|
| 973 | + } |
|
| 974 | + } |
|
| 975 | + } |
|
| 976 | + if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 977 | + $contenu .= "if (_DIR_RESTREINT) _chemin([" . implode(',', |
|
| 978 | + array_reverse($chemins['public'])) . "]);\n" |
|
| 979 | + . "else _chemin([" . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 980 | + } |
|
| 981 | + |
|
| 982 | + ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | /** |
@@ -997,65 +997,65 @@ discard block |
||
| 997 | 997 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 998 | 998 | **/ |
| 999 | 999 | function plugins_precompile_xxxtions($plugin_valides, $ordre) { |
| 1000 | - $contenu = array('options' => '', 'fonctions' => ''); |
|
| 1001 | - $boutons = array(); |
|
| 1002 | - $onglets = array(); |
|
| 1003 | - $sign = ""; |
|
| 1004 | - |
|
| 1005 | - foreach ($ordre as $p => $info) { |
|
| 1006 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1007 | - if (isset($plugin_valides[$p])) { |
|
| 1008 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1009 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1010 | - $dir = constant($dir_type); |
|
| 1011 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1012 | - if ($info['menu']) { |
|
| 1013 | - $boutons = array_merge($boutons, $info['menu']); |
|
| 1014 | - } |
|
| 1015 | - if ($info['onglet']) { |
|
| 1016 | - $onglets = array_merge($onglets, $info['onglet']); |
|
| 1017 | - } |
|
| 1018 | - foreach ($contenu as $charge => $v) { |
|
| 1019 | - // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1020 | - // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1021 | - // donc ni sa relecture, ni sa detection |
|
| 1022 | - if (!isset($info[$charge]) |
|
| 1023 | - and $dir // exclure le cas du plugin "SPIP" |
|
| 1024 | - and strpos($dir, ":") === false // exclure le cas des procure: |
|
| 1025 | - and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1026 | - ) { |
|
| 1027 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) { |
|
| 1028 | - $info[$charge] = array($file); |
|
| 1029 | - } |
|
| 1030 | - } |
|
| 1031 | - if (isset($info[$charge])) { |
|
| 1032 | - $files = $info[$charge]; |
|
| 1033 | - foreach ($files as $k => $file) { |
|
| 1034 | - // on genere un if file_exists devant chaque include |
|
| 1035 | - // pour pouvoir garder le meme niveau d'erreur general |
|
| 1036 | - $file = trim($file); |
|
| 1037 | - if (!is_readable("$dir$plug/$file") |
|
| 1038 | - // uniquement pour les paquet.xml |
|
| 1039 | - and file_exists("$dir$plug/paquet.xml") |
|
| 1040 | - ) { |
|
| 1041 | - unset($info[$charge][$k]); |
|
| 1042 | - } else { |
|
| 1043 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1044 | - $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1045 | - } |
|
| 1046 | - } |
|
| 1047 | - } |
|
| 1048 | - } |
|
| 1049 | - $sign .= md5(serialize($info)); |
|
| 1050 | - } |
|
| 1051 | - } |
|
| 1052 | - |
|
| 1053 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1054 | - $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons) |
|
| 1055 | - . plugin_ongletbouton("onglets_plugins", $onglets); |
|
| 1056 | - |
|
| 1057 | - ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1058 | - ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1000 | + $contenu = array('options' => '', 'fonctions' => ''); |
|
| 1001 | + $boutons = array(); |
|
| 1002 | + $onglets = array(); |
|
| 1003 | + $sign = ""; |
|
| 1004 | + |
|
| 1005 | + foreach ($ordre as $p => $info) { |
|
| 1006 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1007 | + if (isset($plugin_valides[$p])) { |
|
| 1008 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1009 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1010 | + $dir = constant($dir_type); |
|
| 1011 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1012 | + if ($info['menu']) { |
|
| 1013 | + $boutons = array_merge($boutons, $info['menu']); |
|
| 1014 | + } |
|
| 1015 | + if ($info['onglet']) { |
|
| 1016 | + $onglets = array_merge($onglets, $info['onglet']); |
|
| 1017 | + } |
|
| 1018 | + foreach ($contenu as $charge => $v) { |
|
| 1019 | + // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1020 | + // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1021 | + // donc ni sa relecture, ni sa detection |
|
| 1022 | + if (!isset($info[$charge]) |
|
| 1023 | + and $dir // exclure le cas du plugin "SPIP" |
|
| 1024 | + and strpos($dir, ":") === false // exclure le cas des procure: |
|
| 1025 | + and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1026 | + ) { |
|
| 1027 | + if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) { |
|
| 1028 | + $info[$charge] = array($file); |
|
| 1029 | + } |
|
| 1030 | + } |
|
| 1031 | + if (isset($info[$charge])) { |
|
| 1032 | + $files = $info[$charge]; |
|
| 1033 | + foreach ($files as $k => $file) { |
|
| 1034 | + // on genere un if file_exists devant chaque include |
|
| 1035 | + // pour pouvoir garder le meme niveau d'erreur general |
|
| 1036 | + $file = trim($file); |
|
| 1037 | + if (!is_readable("$dir$plug/$file") |
|
| 1038 | + // uniquement pour les paquet.xml |
|
| 1039 | + and file_exists("$dir$plug/paquet.xml") |
|
| 1040 | + ) { |
|
| 1041 | + unset($info[$charge][$k]); |
|
| 1042 | + } else { |
|
| 1043 | + $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1044 | + $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1045 | + } |
|
| 1046 | + } |
|
| 1047 | + } |
|
| 1048 | + } |
|
| 1049 | + $sign .= md5(serialize($info)); |
|
| 1050 | + } |
|
| 1051 | + } |
|
| 1052 | + |
|
| 1053 | + $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1054 | + $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons) |
|
| 1055 | + . plugin_ongletbouton("onglets_plugins", $onglets); |
|
| 1056 | + |
|
| 1057 | + ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1058 | + ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | /** |
@@ -1074,24 +1074,24 @@ discard block |
||
| 1074 | 1074 | * @return string Code php |
| 1075 | 1075 | */ |
| 1076 | 1076 | function plugin_ongletbouton($nom, $val) { |
| 1077 | - if (!$val) { |
|
| 1078 | - $val = array(); |
|
| 1079 | - } |
|
| 1080 | - |
|
| 1081 | - $val = serialize($val); |
|
| 1082 | - $md5 = md5($val); |
|
| 1083 | - |
|
| 1084 | - if (!defined("_UPDATED_$nom")) { |
|
| 1085 | - define("_UPDATED_$nom", $val); |
|
| 1086 | - define("_UPDATED_md5_$nom", $md5); |
|
| 1087 | - } |
|
| 1088 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1089 | - |
|
| 1090 | - return |
|
| 1091 | - "if (!function_exists('$nom')) {\n" |
|
| 1092 | - . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1093 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1094 | - . "}\n"; |
|
| 1077 | + if (!$val) { |
|
| 1078 | + $val = array(); |
|
| 1079 | + } |
|
| 1080 | + |
|
| 1081 | + $val = serialize($val); |
|
| 1082 | + $md5 = md5($val); |
|
| 1083 | + |
|
| 1084 | + if (!defined("_UPDATED_$nom")) { |
|
| 1085 | + define("_UPDATED_$nom", $val); |
|
| 1086 | + define("_UPDATED_md5_$nom", $md5); |
|
| 1087 | + } |
|
| 1088 | + $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1089 | + |
|
| 1090 | + return |
|
| 1091 | + "if (!function_exists('$nom')) {\n" |
|
| 1092 | + . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1093 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1094 | + . "}\n"; |
|
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | 1097 | /** |
@@ -1106,15 +1106,15 @@ discard block |
||
| 1106 | 1106 | **/ |
| 1107 | 1107 | function plugins_amorcer_plugins_actifs() { |
| 1108 | 1108 | |
| 1109 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1110 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1111 | - } |
|
| 1109 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1110 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1111 | + } |
|
| 1112 | 1112 | |
| 1113 | - if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1114 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 1115 | - } else { |
|
| 1116 | - spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT); |
|
| 1117 | - } |
|
| 1113 | + if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1114 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 1115 | + } else { |
|
| 1116 | + spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT); |
|
| 1117 | + } |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | /** |
@@ -1137,136 +1137,136 @@ discard block |
||
| 1137 | 1137 | * Couples (nom du pipeline => Code PHP à insérer au début du pipeline) |
| 1138 | 1138 | **/ |
| 1139 | 1139 | function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) { |
| 1140 | - static $liste_pipe_manquants = array(); |
|
| 1141 | - if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1142 | - $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1143 | - } |
|
| 1144 | - |
|
| 1145 | - $prepend_code = array(); |
|
| 1146 | - |
|
| 1147 | - foreach ($ordre as $p => $info) { |
|
| 1148 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1149 | - if (isset($plugin_valides[$p])) { |
|
| 1150 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1151 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1152 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1153 | - $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_"); |
|
| 1154 | - if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1155 | - foreach ($info['pipeline'] as $pipe) { |
|
| 1156 | - $nom = $pipe['nom']; |
|
| 1157 | - if (isset($pipe['action'])) { |
|
| 1158 | - $action = $pipe['action']; |
|
| 1159 | - } else { |
|
| 1160 | - $action = $nom; |
|
| 1161 | - } |
|
| 1162 | - $nomlower = strtolower($nom); |
|
| 1163 | - if ($nomlower != $nom |
|
| 1164 | - and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1165 | - and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1166 | - ) { |
|
| 1167 | - $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1168 | - unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1169 | - } |
|
| 1170 | - $nom = $nomlower; |
|
| 1171 | - // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1172 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel |
|
| 1173 | - { |
|
| 1174 | - $GLOBALS['spip_pipeline'][$nom] = ""; |
|
| 1175 | - } |
|
| 1176 | - if ($action) { |
|
| 1177 | - if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) { |
|
| 1178 | - $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1", |
|
| 1179 | - $GLOBALS['spip_pipeline'][$nom], 1); |
|
| 1180 | - } |
|
| 1181 | - if (isset($pipe['inclure'])) { |
|
| 1182 | - $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1183 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1184 | - } |
|
| 1185 | - } |
|
| 1186 | - } |
|
| 1187 | - } |
|
| 1188 | - if (isset($info['genie']) and count($info['genie'])) { |
|
| 1189 | - if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1190 | - $prepend_code['taches_generales_cron'] = ""; |
|
| 1191 | - } |
|
| 1192 | - foreach ($info['genie'] as $genie) { |
|
| 1193 | - $nom = $prefix . $genie['nom']; |
|
| 1194 | - $periode = max(60, intval($genie['periode'])); |
|
| 1195 | - if (charger_fonction($nom, "genie", true)) { |
|
| 1196 | - $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1197 | - } else { |
|
| 1198 | - spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1199 | - } |
|
| 1200 | - } |
|
| 1201 | - } |
|
| 1202 | - if (isset($info['style']) and count($info['style'])) { |
|
| 1203 | - if (!isset($prepend_code['insert_head_css'])) { |
|
| 1204 | - $prepend_code['insert_head_css'] = ""; |
|
| 1205 | - } |
|
| 1206 | - if (!isset($prepend_code['header_prive_css'])) { |
|
| 1207 | - $prepend_code['header_prive_css'] = ""; |
|
| 1208 | - } |
|
| 1209 | - foreach ($info['style'] as $style) { |
|
| 1210 | - if (isset($style['path']) and $style['path']) { |
|
| 1211 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1212 | - } else { |
|
| 1213 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1214 | - } |
|
| 1215 | - $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1216 | - if (isset($style['media']) and strlen($style['media'])) { |
|
| 1217 | - $code .= " media=\"" . addslashes($style['media']) . "\""; |
|
| 1218 | - } |
|
| 1219 | - $code .= "/>';\n"; |
|
| 1220 | - if ($style['type'] != 'prive') { |
|
| 1221 | - $prepend_code['insert_head_css'] .= $code; |
|
| 1222 | - } |
|
| 1223 | - if ($style['type'] != 'public') { |
|
| 1224 | - $prepend_code['header_prive_css'] .= $code; |
|
| 1225 | - } |
|
| 1226 | - } |
|
| 1227 | - } |
|
| 1228 | - if (!isset($prepend_code['insert_head'])) { |
|
| 1229 | - $prepend_code['insert_head'] = ""; |
|
| 1230 | - } |
|
| 1231 | - if (!isset($prepend_code['header_prive'])) { |
|
| 1232 | - $prepend_code['header_prive'] = ""; |
|
| 1233 | - } |
|
| 1234 | - if (isset($info['script']) and count($info['script'])) { |
|
| 1235 | - foreach ($info['script'] as $script) { |
|
| 1236 | - if (isset($script['path']) and $script['path']) { |
|
| 1237 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1238 | - } else { |
|
| 1239 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1240 | - } |
|
| 1241 | - $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1242 | - if ($script['type'] != 'prive') { |
|
| 1243 | - $prepend_code['insert_head'] .= $code; |
|
| 1244 | - } |
|
| 1245 | - if ($script['type'] != 'public') { |
|
| 1246 | - $prepend_code['header_prive'] .= $code; |
|
| 1247 | - } |
|
| 1248 | - } |
|
| 1249 | - } |
|
| 1250 | - } |
|
| 1251 | - } |
|
| 1252 | - |
|
| 1253 | - $prepend_code['insert_head'] = |
|
| 1254 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1255 | - . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1256 | - . $prepend_code['insert_head']; |
|
| 1257 | - $prepend_code['header_prive'] = |
|
| 1258 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1259 | - . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1260 | - . $prepend_code['header_prive']; |
|
| 1261 | - |
|
| 1262 | - // on ajoute les pipe qui ont ete recenses manquants |
|
| 1263 | - foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1264 | - if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1265 | - $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1266 | - } |
|
| 1267 | - } |
|
| 1268 | - |
|
| 1269 | - return $prepend_code; |
|
| 1140 | + static $liste_pipe_manquants = array(); |
|
| 1141 | + if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1142 | + $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1143 | + } |
|
| 1144 | + |
|
| 1145 | + $prepend_code = array(); |
|
| 1146 | + |
|
| 1147 | + foreach ($ordre as $p => $info) { |
|
| 1148 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1149 | + if (isset($plugin_valides[$p])) { |
|
| 1150 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1151 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1152 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1153 | + $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_"); |
|
| 1154 | + if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1155 | + foreach ($info['pipeline'] as $pipe) { |
|
| 1156 | + $nom = $pipe['nom']; |
|
| 1157 | + if (isset($pipe['action'])) { |
|
| 1158 | + $action = $pipe['action']; |
|
| 1159 | + } else { |
|
| 1160 | + $action = $nom; |
|
| 1161 | + } |
|
| 1162 | + $nomlower = strtolower($nom); |
|
| 1163 | + if ($nomlower != $nom |
|
| 1164 | + and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1165 | + and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1166 | + ) { |
|
| 1167 | + $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1168 | + unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1169 | + } |
|
| 1170 | + $nom = $nomlower; |
|
| 1171 | + // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1172 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel |
|
| 1173 | + { |
|
| 1174 | + $GLOBALS['spip_pipeline'][$nom] = ""; |
|
| 1175 | + } |
|
| 1176 | + if ($action) { |
|
| 1177 | + if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) { |
|
| 1178 | + $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1", |
|
| 1179 | + $GLOBALS['spip_pipeline'][$nom], 1); |
|
| 1180 | + } |
|
| 1181 | + if (isset($pipe['inclure'])) { |
|
| 1182 | + $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1183 | + "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1184 | + } |
|
| 1185 | + } |
|
| 1186 | + } |
|
| 1187 | + } |
|
| 1188 | + if (isset($info['genie']) and count($info['genie'])) { |
|
| 1189 | + if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1190 | + $prepend_code['taches_generales_cron'] = ""; |
|
| 1191 | + } |
|
| 1192 | + foreach ($info['genie'] as $genie) { |
|
| 1193 | + $nom = $prefix . $genie['nom']; |
|
| 1194 | + $periode = max(60, intval($genie['periode'])); |
|
| 1195 | + if (charger_fonction($nom, "genie", true)) { |
|
| 1196 | + $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1197 | + } else { |
|
| 1198 | + spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1199 | + } |
|
| 1200 | + } |
|
| 1201 | + } |
|
| 1202 | + if (isset($info['style']) and count($info['style'])) { |
|
| 1203 | + if (!isset($prepend_code['insert_head_css'])) { |
|
| 1204 | + $prepend_code['insert_head_css'] = ""; |
|
| 1205 | + } |
|
| 1206 | + if (!isset($prepend_code['header_prive_css'])) { |
|
| 1207 | + $prepend_code['header_prive_css'] = ""; |
|
| 1208 | + } |
|
| 1209 | + foreach ($info['style'] as $style) { |
|
| 1210 | + if (isset($style['path']) and $style['path']) { |
|
| 1211 | + $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1212 | + } else { |
|
| 1213 | + $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1214 | + } |
|
| 1215 | + $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1216 | + if (isset($style['media']) and strlen($style['media'])) { |
|
| 1217 | + $code .= " media=\"" . addslashes($style['media']) . "\""; |
|
| 1218 | + } |
|
| 1219 | + $code .= "/>';\n"; |
|
| 1220 | + if ($style['type'] != 'prive') { |
|
| 1221 | + $prepend_code['insert_head_css'] .= $code; |
|
| 1222 | + } |
|
| 1223 | + if ($style['type'] != 'public') { |
|
| 1224 | + $prepend_code['header_prive_css'] .= $code; |
|
| 1225 | + } |
|
| 1226 | + } |
|
| 1227 | + } |
|
| 1228 | + if (!isset($prepend_code['insert_head'])) { |
|
| 1229 | + $prepend_code['insert_head'] = ""; |
|
| 1230 | + } |
|
| 1231 | + if (!isset($prepend_code['header_prive'])) { |
|
| 1232 | + $prepend_code['header_prive'] = ""; |
|
| 1233 | + } |
|
| 1234 | + if (isset($info['script']) and count($info['script'])) { |
|
| 1235 | + foreach ($info['script'] as $script) { |
|
| 1236 | + if (isset($script['path']) and $script['path']) { |
|
| 1237 | + $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1238 | + } else { |
|
| 1239 | + $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1240 | + } |
|
| 1241 | + $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1242 | + if ($script['type'] != 'prive') { |
|
| 1243 | + $prepend_code['insert_head'] .= $code; |
|
| 1244 | + } |
|
| 1245 | + if ($script['type'] != 'public') { |
|
| 1246 | + $prepend_code['header_prive'] .= $code; |
|
| 1247 | + } |
|
| 1248 | + } |
|
| 1249 | + } |
|
| 1250 | + } |
|
| 1251 | + } |
|
| 1252 | + |
|
| 1253 | + $prepend_code['insert_head'] = |
|
| 1254 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1255 | + . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1256 | + . $prepend_code['insert_head']; |
|
| 1257 | + $prepend_code['header_prive'] = |
|
| 1258 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1259 | + . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1260 | + . $prepend_code['header_prive']; |
|
| 1261 | + |
|
| 1262 | + // on ajoute les pipe qui ont ete recenses manquants |
|
| 1263 | + foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1264 | + if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1265 | + $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1266 | + } |
|
| 1267 | + } |
|
| 1268 | + |
|
| 1269 | + return $prepend_code; |
|
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | /** |
@@ -1293,62 +1293,62 @@ discard block |
||
| 1293 | 1293 | **/ |
| 1294 | 1294 | function pipeline_precompile($prepend_code = array()) { |
| 1295 | 1295 | |
| 1296 | - $all_pipes = $all_pipes_end = ''; |
|
| 1297 | - if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1298 | - $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1299 | - unset($GLOBALS['spip_pipeline']['all']); |
|
| 1300 | - $all_pipes = trim(array_shift($a)); |
|
| 1301 | - if ($all_pipes) { |
|
| 1302 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1303 | - } |
|
| 1304 | - if (count($a)) { |
|
| 1305 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1306 | - } |
|
| 1307 | - } |
|
| 1308 | - $content = ""; |
|
| 1309 | - foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1310 | - $s_inc = ""; |
|
| 1311 | - $s_call = ""; |
|
| 1312 | - if ($all_pipes) { |
|
| 1313 | - $pipeline = preg_replace(",(\|\||$),", "$all_pipes\\1", $pipeline, 1); |
|
| 1314 | - } |
|
| 1315 | - if ($all_pipes_end) { |
|
| 1316 | - $pipeline .= $all_pipes_end; |
|
| 1317 | - } |
|
| 1318 | - $pipe = array_filter(explode('|', $pipeline)); |
|
| 1319 | - // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1320 | - foreach ($pipe as $fonc) { |
|
| 1321 | - $fonc = trim($fonc); |
|
| 1322 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1323 | - if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1324 | - $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1325 | - $file = "'$file'"; |
|
| 1326 | - // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1327 | - if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) { |
|
| 1328 | - $dir = $regs[1]; |
|
| 1329 | - $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1330 | - if (defined($root_dir)) { |
|
| 1331 | - $dir = $root_dir; |
|
| 1332 | - } |
|
| 1333 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1334 | - $file = str_replace("''.", "", $file); |
|
| 1335 | - $file = str_replace(constant($dir), '', $file); |
|
| 1336 | - } |
|
| 1337 | - $s_inc .= "include_once_check($file);\n"; |
|
| 1338 | - } |
|
| 1339 | - } |
|
| 1340 | - if (strlen($s_inc)) { |
|
| 1341 | - $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1342 | - } |
|
| 1343 | - $content .= "// Pipeline $action \n" |
|
| 1344 | - . "function execute_pipeline_$action(&\$val){\n" |
|
| 1345 | - . $s_inc |
|
| 1346 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1347 | - . $s_call |
|
| 1348 | - . "return \$val;\n}\n"; |
|
| 1349 | - } |
|
| 1350 | - ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1351 | - clear_path_cache(); |
|
| 1296 | + $all_pipes = $all_pipes_end = ''; |
|
| 1297 | + if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1298 | + $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1299 | + unset($GLOBALS['spip_pipeline']['all']); |
|
| 1300 | + $all_pipes = trim(array_shift($a)); |
|
| 1301 | + if ($all_pipes) { |
|
| 1302 | + $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1303 | + } |
|
| 1304 | + if (count($a)) { |
|
| 1305 | + $all_pipes_end = '||' . array_shift($a); |
|
| 1306 | + } |
|
| 1307 | + } |
|
| 1308 | + $content = ""; |
|
| 1309 | + foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1310 | + $s_inc = ""; |
|
| 1311 | + $s_call = ""; |
|
| 1312 | + if ($all_pipes) { |
|
| 1313 | + $pipeline = preg_replace(",(\|\||$),", "$all_pipes\\1", $pipeline, 1); |
|
| 1314 | + } |
|
| 1315 | + if ($all_pipes_end) { |
|
| 1316 | + $pipeline .= $all_pipes_end; |
|
| 1317 | + } |
|
| 1318 | + $pipe = array_filter(explode('|', $pipeline)); |
|
| 1319 | + // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1320 | + foreach ($pipe as $fonc) { |
|
| 1321 | + $fonc = trim($fonc); |
|
| 1322 | + $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1323 | + if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1324 | + $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1325 | + $file = "'$file'"; |
|
| 1326 | + // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1327 | + if (preg_match(",(_(DIR|ROOT)_[A-Z_]+):,Ums", $file, $regs)) { |
|
| 1328 | + $dir = $regs[1]; |
|
| 1329 | + $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1330 | + if (defined($root_dir)) { |
|
| 1331 | + $dir = $root_dir; |
|
| 1332 | + } |
|
| 1333 | + $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1334 | + $file = str_replace("''.", "", $file); |
|
| 1335 | + $file = str_replace(constant($dir), '', $file); |
|
| 1336 | + } |
|
| 1337 | + $s_inc .= "include_once_check($file);\n"; |
|
| 1338 | + } |
|
| 1339 | + } |
|
| 1340 | + if (strlen($s_inc)) { |
|
| 1341 | + $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1342 | + } |
|
| 1343 | + $content .= "// Pipeline $action \n" |
|
| 1344 | + . "function execute_pipeline_$action(&\$val){\n" |
|
| 1345 | + . $s_inc |
|
| 1346 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1347 | + . $s_call |
|
| 1348 | + . "return \$val;\n}\n"; |
|
| 1349 | + } |
|
| 1350 | + ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1351 | + clear_path_cache(); |
|
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | |
@@ -1361,12 +1361,12 @@ discard block |
||
| 1361 | 1361 | * true si le plugin est actif, false sinon |
| 1362 | 1362 | **/ |
| 1363 | 1363 | function plugin_est_installe($plug_path) { |
| 1364 | - $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array(); |
|
| 1365 | - if (!$plugin_installes) { |
|
| 1366 | - return false; |
|
| 1367 | - } |
|
| 1364 | + $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : array(); |
|
| 1365 | + if (!$plugin_installes) { |
|
| 1366 | + return false; |
|
| 1367 | + } |
|
| 1368 | 1368 | |
| 1369 | - return in_array($plug_path, $plugin_installes); |
|
| 1369 | + return in_array($plug_path, $plugin_installes); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | |
@@ -1379,46 +1379,46 @@ discard block |
||
| 1379 | 1379 | * @uses plugins_installer_dist() |
| 1380 | 1380 | **/ |
| 1381 | 1381 | function plugin_installes_meta() { |
| 1382 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1383 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 1384 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1385 | - } |
|
| 1386 | - |
|
| 1387 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1388 | - $meta_plug_installes = array(); |
|
| 1389 | - foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1390 | - if ($plug = $resume['dir']) { |
|
| 1391 | - $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1392 | - if ($infos) { |
|
| 1393 | - if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1394 | - $meta_plug_installes[] = $plug; |
|
| 1395 | - } |
|
| 1396 | - if (is_array($infos)) { |
|
| 1397 | - list($ok, $trace) = $infos['install_test']; |
|
| 1398 | - $titre = _T('plugin_titre_installation', array('plugin' => typo($infos['nom']))); |
|
| 1399 | - $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec")); |
|
| 1400 | - if (_IS_CLI) { |
|
| 1401 | - include_spip('inc/filtres'); |
|
| 1402 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1403 | - $trace = " " . str_replace("\n", "\n ", $trace); |
|
| 1404 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1405 | - $trace, |
|
| 1406 | - "\n"; |
|
| 1407 | - } |
|
| 1408 | - else { |
|
| 1409 | - include_spip('inc/filtres_boites'); |
|
| 1410 | - echo "<div class='install-plugins svp_retour'>" |
|
| 1411 | - . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1412 | - . $trace |
|
| 1413 | - . "<div class='result'>$result</div>" |
|
| 1414 | - . boite_fermer() |
|
| 1415 | - . "</div>"; |
|
| 1416 | - } |
|
| 1417 | - } |
|
| 1418 | - } |
|
| 1419 | - } |
|
| 1420 | - } |
|
| 1421 | - ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1382 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1383 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 1384 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1385 | + } |
|
| 1386 | + |
|
| 1387 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1388 | + $meta_plug_installes = array(); |
|
| 1389 | + foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1390 | + if ($plug = $resume['dir']) { |
|
| 1391 | + $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1392 | + if ($infos) { |
|
| 1393 | + if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1394 | + $meta_plug_installes[] = $plug; |
|
| 1395 | + } |
|
| 1396 | + if (is_array($infos)) { |
|
| 1397 | + list($ok, $trace) = $infos['install_test']; |
|
| 1398 | + $titre = _T('plugin_titre_installation', array('plugin' => typo($infos['nom']))); |
|
| 1399 | + $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec")); |
|
| 1400 | + if (_IS_CLI) { |
|
| 1401 | + include_spip('inc/filtres'); |
|
| 1402 | + $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1403 | + $trace = " " . str_replace("\n", "\n ", $trace); |
|
| 1404 | + echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1405 | + $trace, |
|
| 1406 | + "\n"; |
|
| 1407 | + } |
|
| 1408 | + else { |
|
| 1409 | + include_spip('inc/filtres_boites'); |
|
| 1410 | + echo "<div class='install-plugins svp_retour'>" |
|
| 1411 | + . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1412 | + . $trace |
|
| 1413 | + . "<div class='result'>$result</div>" |
|
| 1414 | + . boite_fermer() |
|
| 1415 | + . "</div>"; |
|
| 1416 | + } |
|
| 1417 | + } |
|
| 1418 | + } |
|
| 1419 | + } |
|
| 1420 | + } |
|
| 1421 | + ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | 1424 | /** |
@@ -1432,29 +1432,29 @@ discard block |
||
| 1432 | 1432 | * Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante |
| 1433 | 1433 | **/ |
| 1434 | 1434 | function ecrire_fichier_php($nom, $contenu, $comment = '') { |
| 1435 | - if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1436 | - $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1437 | - } |
|
| 1438 | - |
|
| 1439 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1440 | - // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1441 | - // si pas de modif on ne touche pas au fichier initial |
|
| 1442 | - if (file_exists($nom)) { |
|
| 1443 | - if (substr($nom, -4) == '.php') { |
|
| 1444 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1445 | - } |
|
| 1446 | - else { |
|
| 1447 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1448 | - } |
|
| 1449 | - file_put_contents($fichier_tmp, $contenu); |
|
| 1450 | - if(md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1451 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1452 | - @unlink($fichier_tmp); |
|
| 1453 | - return; |
|
| 1454 | - } |
|
| 1455 | - @unlink($fichier_tmp); |
|
| 1456 | - } |
|
| 1457 | - ecrire_fichier($nom, $contenu); |
|
| 1458 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1459 | - spip_clear_opcode_cache(realpath($nom)); |
|
| 1435 | + if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1436 | + $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1437 | + } |
|
| 1438 | + |
|
| 1439 | + $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1440 | + // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1441 | + // si pas de modif on ne touche pas au fichier initial |
|
| 1442 | + if (file_exists($nom)) { |
|
| 1443 | + if (substr($nom, -4) == '.php') { |
|
| 1444 | + $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1445 | + } |
|
| 1446 | + else { |
|
| 1447 | + $fichier_tmp = $nom . '.tmp'; |
|
| 1448 | + } |
|
| 1449 | + file_put_contents($fichier_tmp, $contenu); |
|
| 1450 | + if(md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1451 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1452 | + @unlink($fichier_tmp); |
|
| 1453 | + return; |
|
| 1454 | + } |
|
| 1455 | + @unlink($fichier_tmp); |
|
| 1456 | + } |
|
| 1457 | + ecrire_fichier($nom, $contenu); |
|
| 1458 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1459 | + spip_clear_opcode_cache(realpath($nom)); |
|
| 1460 | 1460 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | if ($dir) { |
| 371 | 371 | $dir .= "/"; |
| 372 | 372 | } |
| 373 | - $dir .= "procure:" . $procure['nom']; |
|
| 373 | + $dir .= "procure:".$procure['nom']; |
|
| 374 | 374 | |
| 375 | 375 | $procure['etat'] = '?'; |
| 376 | 376 | $procure['dir_type'] = $resume['dir_type']; |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | $plug = $resume['dir']; |
| 552 | 552 | $k = $infos[$dir_type][$plug]; |
| 553 | 553 | |
| 554 | - $plug = constant($dir_type) . $plug; |
|
| 554 | + $plug = constant($dir_type).$plug; |
|
| 555 | 555 | if (!isset($msg[$p])) { |
| 556 | 556 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 557 | 557 | $msg[$p] = array($resume['erreur']); |
@@ -594,10 +594,10 @@ discard block |
||
| 594 | 594 | $list = $raw ? array() : $GLOBALS['meta']['plugin_erreur_activation']; |
| 595 | 595 | } elseif (!$raw) { |
| 596 | 596 | foreach ($list as $plug => $msg) { |
| 597 | - $list[$plug] = "<li>" . _T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 598 | - . "<ul><li>" . implode("</li><li>", $msg) . "</li></ul></li>"; |
|
| 597 | + $list[$plug] = "<li>"._T('plugin_impossible_activer', array('plugin' => $plug)) |
|
| 598 | + . "<ul><li>".implode("</li><li>", $msg)."</li></ul></li>"; |
|
| 599 | 599 | } |
| 600 | - $list = "<ul>" . join("\n", $list) . "</ul>"; |
|
| 600 | + $list = "<ul>".join("\n", $list)."</ul>"; |
|
| 601 | 601 | } |
| 602 | 602 | if ($raz) { |
| 603 | 603 | effacer_meta('plugin_erreur_activation'); |
@@ -711,13 +711,13 @@ discard block |
||
| 711 | 711 | if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
| 712 | 712 | return _T("plugin_${balise}_${type}", array( |
| 713 | 713 | 'plugin' => $nom, |
| 714 | - 'version' => ' ≥ ' . $minimum |
|
| 714 | + 'version' => ' ≥ '.$minimum |
|
| 715 | 715 | )); |
| 716 | 716 | } |
| 717 | 717 | if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
| 718 | 718 | return _T("plugin_${balise}_${type}", array( |
| 719 | 719 | 'plugin' => $nom, |
| 720 | - 'version' => ' > ' . $minimum |
|
| 720 | + 'version' => ' > '.$minimum |
|
| 721 | 721 | )); |
| 722 | 722 | } |
| 723 | 723 | } |
@@ -726,13 +726,13 @@ discard block |
||
| 726 | 726 | if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
| 727 | 727 | return _T("plugin_${balise}_${type}", array( |
| 728 | 728 | 'plugin' => $nom, |
| 729 | - 'version' => ' ≤ ' . $maximum |
|
| 729 | + 'version' => ' ≤ '.$maximum |
|
| 730 | 730 | )); |
| 731 | 731 | } |
| 732 | 732 | if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
| 733 | 733 | return _T("plugin_${balise}_plugin", array( |
| 734 | 734 | 'plugin' => $nom, |
| 735 | - 'version' => ' < ' . $maximum |
|
| 735 | + 'version' => ' < '.$maximum |
|
| 736 | 736 | )); |
| 737 | 737 | } |
| 738 | 738 | } |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | include_spip('inc/charger_plugin'); |
| 752 | 752 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 753 | 753 | }*/ |
| 754 | - return _T('plugin_necessite_lib', array('lib' => $lib)) . " <a href='$url'>$url</a>"; |
|
| 754 | + return _T('plugin_necessite_lib', array('lib' => $lib))." <a href='$url'>$url</a>"; |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | foreach ($plugin_valides as $p => $resume) { |
| 851 | 851 | // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
| 852 | 852 | if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
| 853 | - $header[] = $p . ($resume['version'] ? "(" . $resume['version'] . ")" : ""); |
|
| 853 | + $header[] = $p.($resume['version'] ? "(".$resume['version'].")" : ""); |
|
| 854 | 854 | } |
| 855 | 855 | if ($resume['dir']) { |
| 856 | 856 | foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
@@ -874,10 +874,10 @@ discard block |
||
| 874 | 874 | ecrire_meta('plugin_attente', serialize($liste)); |
| 875 | 875 | $header = strtolower(implode(",", $header)); |
| 876 | 876 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 877 | - ecrire_fichier(_DIR_VAR . "config.txt", |
|
| 878 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP") . ' ' . $GLOBALS['spip_version_affichee'] . " @ www.spip.net + " . $header); |
|
| 877 | + ecrire_fichier(_DIR_VAR."config.txt", |
|
| 878 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : "Composed-By: SPIP").' '.$GLOBALS['spip_version_affichee']." @ www.spip.net + ".$header); |
|
| 879 | 879 | } else { |
| 880 | - @unlink(_DIR_VAR . "config.txt"); |
|
| 880 | + @unlink(_DIR_VAR."config.txt"); |
|
| 881 | 881 | } |
| 882 | 882 | // generer charger_plugins_chemin.php |
| 883 | 883 | plugins_precompile_chemin($plugin_valides, $ordre); |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | // definir le plugin, donc le path avant l'include du fichier options |
| 932 | 932 | // permet de faire des include_spip pour attraper un inc_ du plugin |
| 933 | 933 | |
| 934 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 934 | + $dir = $dir_type.".'".$plug."/'"; |
|
| 935 | 935 | |
| 936 | 936 | $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
| 937 | 937 | if ( |
@@ -942,11 +942,11 @@ discard block |
||
| 942 | 942 | if (!$info['chemin']) { |
| 943 | 943 | $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
| 944 | 944 | $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
| 945 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 945 | + if (is_dir(constant($dir_type).$plug.'/squelettes/')) { |
|
| 946 | 946 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 947 | 947 | } |
| 948 | 948 | } |
| 949 | - else{ |
|
| 949 | + else { |
|
| 950 | 950 | foreach ($info['chemin'] as $chemin) { |
| 951 | 951 | if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'], |
| 952 | 952 | $GLOBALS['spip_version_branche'], 'spip') |
@@ -959,13 +959,13 @@ discard block |
||
| 959 | 959 | $dir = ''; |
| 960 | 960 | } |
| 961 | 961 | if (strlen($dir)) { |
| 962 | - $dir = rtrim($dir, '/') . '/'; |
|
| 962 | + $dir = rtrim($dir, '/').'/'; |
|
| 963 | 963 | } |
| 964 | 964 | if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
| 965 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 965 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ""); |
|
| 966 | 966 | } |
| 967 | 967 | if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
| 968 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ""); |
|
| 968 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ""); |
|
| 969 | 969 | } |
| 970 | 970 | } |
| 971 | 971 | } |
@@ -974,9 +974,9 @@ discard block |
||
| 974 | 974 | } |
| 975 | 975 | } |
| 976 | 976 | if (count($chemins['public']) or count($chemins['prive'])) { |
| 977 | - $contenu .= "if (_DIR_RESTREINT) _chemin([" . implode(',', |
|
| 978 | - array_reverse($chemins['public'])) . "]);\n" |
|
| 979 | - . "else _chemin([" . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 977 | + $contenu .= "if (_DIR_RESTREINT) _chemin([".implode(',', |
|
| 978 | + array_reverse($chemins['public']))."]);\n" |
|
| 979 | + . "else _chemin([".implode(',', array_reverse($chemins['prive']))."]);\n"; |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | and strpos($dir, ":") === false // exclure le cas des procure: |
| 1025 | 1025 | and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
| 1026 | 1026 | ) { |
| 1027 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . "_" . $charge . ".php"))) { |
|
| 1027 | + if (is_readable("$dir$plug/".($file = $info['prefix']."_".$charge.".php"))) { |
|
| 1028 | 1028 | $info[$charge] = array($file); |
| 1029 | 1029 | } |
| 1030 | 1030 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | ) { |
| 1041 | 1041 | unset($info[$charge][$k]); |
| 1042 | 1042 | } else { |
| 1043 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1043 | + $_file = $root_dir_type.".'$plug/$file'"; |
|
| 1044 | 1044 | $contenu[$charge] .= "include_once_check($_file);\n"; |
| 1045 | 1045 | } |
| 1046 | 1046 | } |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | } |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1053 | + $contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options']; |
|
| 1054 | 1054 | $contenu['fonctions'] .= plugin_ongletbouton("boutons_plugins", $boutons) |
| 1055 | 1055 | . plugin_ongletbouton("onglets_plugins", $onglets); |
| 1056 | 1056 | |
@@ -1085,12 +1085,12 @@ discard block |
||
| 1085 | 1085 | define("_UPDATED_$nom", $val); |
| 1086 | 1086 | define("_UPDATED_md5_$nom", $md5); |
| 1087 | 1087 | } |
| 1088 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1088 | + $val = "unserialize('".str_replace("'", "\'", $val)."')"; |
|
| 1089 | 1089 | |
| 1090 | 1090 | return |
| 1091 | 1091 | "if (!function_exists('$nom')) {\n" |
| 1092 | 1092 | . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
| 1093 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1093 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n" |
|
| 1094 | 1094 | . "}\n"; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
@@ -1113,7 +1113,7 @@ discard block |
||
| 1113 | 1113 | if (@is_readable(_CACHE_PLUGINS_OPT)) { |
| 1114 | 1114 | include_once(_CACHE_PLUGINS_OPT); |
| 1115 | 1115 | } else { |
| 1116 | - spip_log("pipelines desactives: impossible de produire " . _CACHE_PLUGINS_OPT); |
|
| 1116 | + spip_log("pipelines desactives: impossible de produire "._CACHE_PLUGINS_OPT); |
|
| 1117 | 1117 | } |
| 1118 | 1118 | } |
| 1119 | 1119 | |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | $dir_type = $plugin_valides[$p]['dir_type']; |
| 1151 | 1151 | $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
| 1152 | 1152 | $plug = $plugin_valides[$p]['dir']; |
| 1153 | - $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix'] . "_"); |
|
| 1153 | + $prefix = (($info['prefix'] == "spip") ? "" : $info['prefix']."_"); |
|
| 1154 | 1154 | if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
| 1155 | 1155 | foreach ($info['pipeline'] as $pipe) { |
| 1156 | 1156 | $nom = $pipe['nom']; |
@@ -1180,7 +1180,7 @@ discard block |
||
| 1180 | 1180 | } |
| 1181 | 1181 | if (isset($pipe['inclure'])) { |
| 1182 | 1182 | $GLOBALS['spip_matrice']["$prefix$action"] = |
| 1183 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1183 | + "$root_dir_type:$plug/".$pipe['inclure']; |
|
| 1184 | 1184 | } |
| 1185 | 1185 | } |
| 1186 | 1186 | } |
@@ -1190,7 +1190,7 @@ discard block |
||
| 1190 | 1190 | $prepend_code['taches_generales_cron'] = ""; |
| 1191 | 1191 | } |
| 1192 | 1192 | foreach ($info['genie'] as $genie) { |
| 1193 | - $nom = $prefix . $genie['nom']; |
|
| 1193 | + $nom = $prefix.$genie['nom']; |
|
| 1194 | 1194 | $periode = max(60, intval($genie['periode'])); |
| 1195 | 1195 | if (charger_fonction($nom, "genie", true)) { |
| 1196 | 1196 | $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
@@ -1208,13 +1208,13 @@ discard block |
||
| 1208 | 1208 | } |
| 1209 | 1209 | foreach ($info['style'] as $style) { |
| 1210 | 1210 | if (isset($style['path']) and $style['path']) { |
| 1211 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1211 | + $code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) "; |
|
| 1212 | 1212 | } else { |
| 1213 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1213 | + $code = "if (\$f='".addslashes($style['url'])."') "; |
|
| 1214 | 1214 | } |
| 1215 | 1215 | $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
| 1216 | 1216 | if (isset($style['media']) and strlen($style['media'])) { |
| 1217 | - $code .= " media=\"" . addslashes($style['media']) . "\""; |
|
| 1217 | + $code .= " media=\"".addslashes($style['media'])."\""; |
|
| 1218 | 1218 | } |
| 1219 | 1219 | $code .= "/>';\n"; |
| 1220 | 1220 | if ($style['type'] != 'prive') { |
@@ -1234,9 +1234,9 @@ discard block |
||
| 1234 | 1234 | if (isset($info['script']) and count($info['script'])) { |
| 1235 | 1235 | foreach ($info['script'] as $script) { |
| 1236 | 1236 | if (isset($script['path']) and $script['path']) { |
| 1237 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1237 | + $code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) "; |
|
| 1238 | 1238 | } else { |
| 1239 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1239 | + $code = "if (\$f='".addslashes($script['url'])."') "; |
|
| 1240 | 1240 | } |
| 1241 | 1241 | $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
| 1242 | 1242 | if ($script['type'] != 'prive') { |
@@ -1299,10 +1299,10 @@ discard block |
||
| 1299 | 1299 | unset($GLOBALS['spip_pipeline']['all']); |
| 1300 | 1300 | $all_pipes = trim(array_shift($a)); |
| 1301 | 1301 | if ($all_pipes) { |
| 1302 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1302 | + $all_pipes = '|'.ltrim($all_pipes, '|'); |
|
| 1303 | 1303 | } |
| 1304 | 1304 | if (count($a)) { |
| 1305 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1305 | + $all_pipes_end = '||'.array_shift($a); |
|
| 1306 | 1306 | } |
| 1307 | 1307 | } |
| 1308 | 1308 | $content = ""; |
@@ -1319,7 +1319,7 @@ discard block |
||
| 1319 | 1319 | // Eclater le pipeline en filtres et appliquer chaque filtre |
| 1320 | 1320 | foreach ($pipe as $fonc) { |
| 1321 | 1321 | $fonc = trim($fonc); |
| 1322 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1322 | + $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; |
|
| 1323 | 1323 | if (isset($GLOBALS['spip_matrice'][$fonc])) { |
| 1324 | 1324 | $file = $GLOBALS['spip_matrice'][$fonc]; |
| 1325 | 1325 | $file = "'$file'"; |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | if (defined($root_dir)) { |
| 1331 | 1331 | $dir = $root_dir; |
| 1332 | 1332 | } |
| 1333 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1333 | + $file = str_replace($regs[0], "'.".$dir.".'", $file); |
|
| 1334 | 1334 | $file = str_replace("''.", "", $file); |
| 1335 | 1335 | $file = str_replace(constant($dir), '', $file); |
| 1336 | 1336 | } |
@@ -1343,7 +1343,7 @@ discard block |
||
| 1343 | 1343 | $content .= "// Pipeline $action \n" |
| 1344 | 1344 | . "function execute_pipeline_$action(&\$val){\n" |
| 1345 | 1345 | . $s_inc |
| 1346 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1346 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '') |
|
| 1347 | 1347 | . $s_call |
| 1348 | 1348 | . "return \$val;\n}\n"; |
| 1349 | 1349 | } |
@@ -1399,9 +1399,9 @@ discard block |
||
| 1399 | 1399 | $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T("plugin_info_upgrade_ok") : _T("plugin_info_install_ok")) : _T("avis_operation_echec")); |
| 1400 | 1400 | if (_IS_CLI) { |
| 1401 | 1401 | include_spip('inc/filtres'); |
| 1402 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1403 | - $trace = " " . str_replace("\n", "\n ", $trace); |
|
| 1404 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1402 | + $trace = ltrim(textebrut($trace)."\n".$result); |
|
| 1403 | + $trace = " ".str_replace("\n", "\n ", $trace); |
|
| 1404 | + echo "\n".($ok ? 'OK ' : '/!\ ').textebrut($titre)."\n", |
|
| 1405 | 1405 | $trace, |
| 1406 | 1406 | "\n"; |
| 1407 | 1407 | } |
@@ -1436,18 +1436,18 @@ discard block |
||
| 1436 | 1436 | $GLOBALS['fichier_php_compile_recent'] = 0; |
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1439 | + $contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>'; |
|
| 1440 | 1440 | // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
| 1441 | 1441 | // si pas de modif on ne touche pas au fichier initial |
| 1442 | 1442 | if (file_exists($nom)) { |
| 1443 | 1443 | if (substr($nom, -4) == '.php') { |
| 1444 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1444 | + $fichier_tmp = substr($nom, 0, -4).'.tmp.php'; |
|
| 1445 | 1445 | } |
| 1446 | 1446 | else { |
| 1447 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1447 | + $fichier_tmp = $nom.'.tmp'; |
|
| 1448 | 1448 | } |
| 1449 | 1449 | file_put_contents($fichier_tmp, $contenu); |
| 1450 | - if(md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1450 | + if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1451 | 1451 | $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
| 1452 | 1452 | @unlink($fichier_tmp); |
| 1453 | 1453 | return; |
@@ -555,11 +555,9 @@ discard block |
||
| 555 | 555 | if (!isset($msg[$p])) { |
| 556 | 556 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 557 | 557 | $msg[$p] = array($resume['erreur']); |
| 558 | - } |
|
| 559 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 558 | + } elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 560 | 559 | $msg[$p] = array(plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')); |
| 561 | - } |
|
| 562 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 560 | + } elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 563 | 561 | $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
| 564 | 562 | } |
| 565 | 563 | } else { |
@@ -945,8 +943,7 @@ discard block |
||
| 945 | 943 | if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
| 946 | 944 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 947 | 945 | } |
| 948 | - } |
|
| 949 | - else{ |
|
| 946 | + } else{ |
|
| 950 | 947 | foreach ($info['chemin'] as $chemin) { |
| 951 | 948 | if (!isset($chemin['version']) or plugin_version_compatible($chemin['version'], |
| 952 | 949 | $GLOBALS['spip_version_branche'], 'spip') |
@@ -1169,10 +1166,12 @@ discard block |
||
| 1169 | 1166 | } |
| 1170 | 1167 | $nom = $nomlower; |
| 1171 | 1168 | // une action vide est une declaration qui ne doit pas etre compilee ! |
| 1172 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) // creer le pipeline eventuel |
|
| 1169 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) { |
|
| 1170 | + // creer le pipeline eventuel |
|
| 1173 | 1171 | { |
| 1174 | 1172 | $GLOBALS['spip_pipeline'][$nom] = ""; |
| 1175 | 1173 | } |
| 1174 | + } |
|
| 1176 | 1175 | if ($action) { |
| 1177 | 1176 | if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) { |
| 1178 | 1177 | $GLOBALS['spip_pipeline'][$nom] = preg_replace(",(\|\||$),", "|$prefix$action\\1", |
@@ -1404,8 +1403,7 @@ discard block |
||
| 1404 | 1403 | echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
| 1405 | 1404 | $trace, |
| 1406 | 1405 | "\n"; |
| 1407 | - } |
|
| 1408 | - else { |
|
| 1406 | + } else { |
|
| 1409 | 1407 | include_spip('inc/filtres_boites'); |
| 1410 | 1408 | echo "<div class='install-plugins svp_retour'>" |
| 1411 | 1409 | . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
@@ -1442,8 +1440,7 @@ discard block |
||
| 1442 | 1440 | if (file_exists($nom)) { |
| 1443 | 1441 | if (substr($nom, -4) == '.php') { |
| 1444 | 1442 | $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
| 1445 | - } |
|
| 1446 | - else { |
|
| 1443 | + } else { |
|
| 1447 | 1444 | $fichier_tmp = $nom . '.tmp'; |
| 1448 | 1445 | } |
| 1449 | 1446 | file_put_contents($fichier_tmp, $contenu); |
@@ -17,17 +17,17 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!defined('_UPGRADE_TIME_OUT')) { |
| 24 | - /** |
|
| 25 | - * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | - * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | - * |
|
| 28 | - * @var int |
|
| 29 | - **/ |
|
| 30 | - define('_UPGRADE_TIME_OUT', 20); |
|
| 24 | + /** |
|
| 25 | + * Durée en secondes pour relancer les scripts de mises à jour, x secondes |
|
| 26 | + * avant que la durée d'exécution du script provoque un timeout |
|
| 27 | + * |
|
| 28 | + * @var int |
|
| 29 | + **/ |
|
| 30 | + define('_UPGRADE_TIME_OUT', 20); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -50,40 +50,40 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | function base_upgrade_dist($titre = '', $reprise = '') { |
| 53 | - if (!$titre) { |
|
| 54 | - return; |
|
| 55 | - } // anti-testeur automatique |
|
| 56 | - if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | - if (!is_numeric(_request('reinstall'))) { |
|
| 58 | - include_spip('base/create'); |
|
| 59 | - spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | - creer_base(); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | - // lancement de l'upgrade SPIP |
|
| 65 | - $res = maj_base(); |
|
| 66 | - |
|
| 67 | - if ($res) { |
|
| 68 | - // on arrete tout ici ! |
|
| 69 | - exit; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | - |
|
| 74 | - // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | - @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | - @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | - @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | - @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | - @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | - @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | - @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | - |
|
| 83 | - include_spip('inc/auth'); |
|
| 84 | - auth_synchroniser_distant(); |
|
| 85 | - $config = charger_fonction('config', 'inc'); |
|
| 86 | - $config(); |
|
| 53 | + if (!$titre) { |
|
| 54 | + return; |
|
| 55 | + } // anti-testeur automatique |
|
| 56 | + if ($GLOBALS['spip_version_base'] != $GLOBALS['meta']['version_installee']) { |
|
| 57 | + if (!is_numeric(_request('reinstall'))) { |
|
| 58 | + include_spip('base/create'); |
|
| 59 | + spip_log('recree les tables eventuellement disparues', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 60 | + creer_base(); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // quand on rentre par ici, c'est toujours une mise a jour de SPIP |
|
| 64 | + // lancement de l'upgrade SPIP |
|
| 65 | + $res = maj_base(); |
|
| 66 | + |
|
| 67 | + if ($res) { |
|
| 68 | + // on arrete tout ici ! |
|
| 69 | + exit; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + spip_log('Fin de mise a jour SQL. Debut m-a-j acces et config', 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 73 | + |
|
| 74 | + // supprimer quelques fichiers temporaires qui peuvent se retrouver invalides |
|
| 75 | + @spip_unlink(_CACHE_RUBRIQUES); |
|
| 76 | + @spip_unlink(_CACHE_PIPELINES); |
|
| 77 | + @spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 78 | + @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 79 | + @spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 80 | + @spip_unlink(_CACHE_CHEMIN); |
|
| 81 | + @spip_unlink(_DIR_TMP . 'plugin_xml_cache.gz'); |
|
| 82 | + |
|
| 83 | + include_spip('inc/auth'); |
|
| 84 | + auth_synchroniser_distant(); |
|
| 85 | + $config = charger_fonction('config', 'inc'); |
|
| 86 | + $config(); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -114,51 +114,51 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | function maj_base($version_cible = 0, $redirect = '', $debut_page = true) { |
| 116 | 116 | |
| 117 | - $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | - |
|
| 119 | - spip_log( |
|
| 120 | - "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | - ); |
|
| 123 | - if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | - sql_replace( |
|
| 125 | - 'spip_meta', |
|
| 126 | - array( |
|
| 127 | - 'nom' => 'version_installee', |
|
| 128 | - 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | - 'impt' => 'non' |
|
| 130 | - ) |
|
| 131 | - ); |
|
| 132 | - return false; |
|
| 133 | - } |
|
| 134 | - if (!upgrade_test()) { |
|
| 135 | - return true; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $cible = ($version_cible ? $version_cible : $GLOBALS['spip_version_base']); |
|
| 139 | - |
|
| 140 | - if ($version_installee < 2021010100) { |
|
| 141 | - include_spip('maj/legacy/v21'); |
|
| 142 | - include_spip('maj/legacy/v30'); |
|
| 143 | - include_spip('maj/legacy/v31'); |
|
| 144 | - include_spip('maj/legacy/v32'); |
|
| 145 | - include_spip('maj/legacy/v40'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - include_spip('maj/2021'); |
|
| 149 | - |
|
| 150 | - ksort($GLOBALS['maj']); |
|
| 151 | - $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | - if ($res) { |
|
| 153 | - if (!is_array($res)) { |
|
| 154 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 155 | - } else { |
|
| 156 | - echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | - echo install_fin_html(); |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $res; |
|
| 117 | + $version_installee = $GLOBALS['meta']['version_installee'] ?? null; |
|
| 118 | + |
|
| 119 | + spip_log( |
|
| 120 | + "Version anterieure: $version_installee. Courante: " . $GLOBALS['spip_version_base'], |
|
| 121 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 122 | + ); |
|
| 123 | + if (!$version_installee or ($GLOBALS['spip_version_base'] < $version_installee)) { |
|
| 124 | + sql_replace( |
|
| 125 | + 'spip_meta', |
|
| 126 | + array( |
|
| 127 | + 'nom' => 'version_installee', |
|
| 128 | + 'valeur' => $GLOBALS['spip_version_base'], |
|
| 129 | + 'impt' => 'non' |
|
| 130 | + ) |
|
| 131 | + ); |
|
| 132 | + return false; |
|
| 133 | + } |
|
| 134 | + if (!upgrade_test()) { |
|
| 135 | + return true; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $cible = ($version_cible ? $version_cible : $GLOBALS['spip_version_base']); |
|
| 139 | + |
|
| 140 | + if ($version_installee < 2021010100) { |
|
| 141 | + include_spip('maj/legacy/v21'); |
|
| 142 | + include_spip('maj/legacy/v30'); |
|
| 143 | + include_spip('maj/legacy/v31'); |
|
| 144 | + include_spip('maj/legacy/v32'); |
|
| 145 | + include_spip('maj/legacy/v40'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + include_spip('maj/2021'); |
|
| 149 | + |
|
| 150 | + ksort($GLOBALS['maj']); |
|
| 151 | + $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee', 'meta', $redirect, $debut_page); |
|
| 152 | + if ($res) { |
|
| 153 | + if (!is_array($res)) { |
|
| 154 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 155 | + } else { |
|
| 156 | + echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
|
| 157 | + echo install_fin_html(); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $res; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -200,52 +200,52 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta = 'meta') { |
| 202 | 202 | |
| 203 | - if ($table_meta !== 'meta') { |
|
| 204 | - installer_table_meta($table_meta); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - $current_version = null; |
|
| 208 | - |
|
| 209 | - if ((!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 210 | - || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 211 | - ) { |
|
| 212 | - // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 213 | - // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 214 | - if (isset($maj['create'])) { |
|
| 215 | - if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 216 | - // installation : on ne fait que l'operation create |
|
| 217 | - $maj = array('init' => $maj['create']); |
|
| 218 | - // et on lui ajoute un appel a inc/config |
|
| 219 | - // pour creer les metas par defaut |
|
| 220 | - $config = charger_fonction('config', 'inc'); |
|
| 221 | - $maj[$version_cible] = array(array($config)); |
|
| 222 | - } |
|
| 223 | - // dans tous les cas enlever cet index du tableau |
|
| 224 | - unset($maj['create']); |
|
| 225 | - } |
|
| 226 | - // si init, deja dans le bon ordre |
|
| 227 | - if (!isset($maj['init'])) { |
|
| 228 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 229 | - uksort($maj, 'spip_version_compare'); |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 233 | - // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 234 | - // ou define _REDIRECT_MAJ_PLUGIN |
|
| 235 | - $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 236 | - if (defined('_ECRIRE_INSTALL')) { |
|
| 237 | - $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 241 | - if ($res) { |
|
| 242 | - if (!is_array($res)) { |
|
| 243 | - spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 244 | - } else { |
|
| 245 | - echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - } |
|
| 203 | + if ($table_meta !== 'meta') { |
|
| 204 | + installer_table_meta($table_meta); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + $current_version = null; |
|
| 208 | + |
|
| 209 | + if ((!isset($GLOBALS[$table_meta][$nom_meta_base_version])) |
|
| 210 | + || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version], $version_cible, '=')) |
|
| 211 | + ) { |
|
| 212 | + // $maj['create'] contient les directives propres a la premiere creation de base |
|
| 213 | + // c'est une operation derogatoire qui fait aboutir directement dans la version_cible |
|
| 214 | + if (isset($maj['create'])) { |
|
| 215 | + if (!isset($GLOBALS[$table_meta][$nom_meta_base_version])) { |
|
| 216 | + // installation : on ne fait que l'operation create |
|
| 217 | + $maj = array('init' => $maj['create']); |
|
| 218 | + // et on lui ajoute un appel a inc/config |
|
| 219 | + // pour creer les metas par defaut |
|
| 220 | + $config = charger_fonction('config', 'inc'); |
|
| 221 | + $maj[$version_cible] = array(array($config)); |
|
| 222 | + } |
|
| 223 | + // dans tous les cas enlever cet index du tableau |
|
| 224 | + unset($maj['create']); |
|
| 225 | + } |
|
| 226 | + // si init, deja dans le bon ordre |
|
| 227 | + if (!isset($maj['init'])) { |
|
| 228 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 229 | + uksort($maj, 'spip_version_compare'); |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + // la redirection se fait par defaut sur la page d'administration des plugins |
|
| 233 | + // sauf lorsque nous sommes sur l'installation de SPIP |
|
| 234 | + // ou define _REDIRECT_MAJ_PLUGIN |
|
| 235 | + $redirect = (defined('_REDIRECT_MAJ_PLUGIN') ? _REDIRECT_MAJ_PLUGIN : generer_url_ecrire('admin_plugin')); |
|
| 236 | + if (defined('_ECRIRE_INSTALL')) { |
|
| 237 | + $redirect = parametre_url(generer_url_ecrire('install'), 'etape', _request('etape')); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
|
| 241 | + if ($res) { |
|
| 242 | + if (!is_array($res)) { |
|
| 243 | + spip_log("Pb d'acces SQL a la mise a jour", 'maj.' . _LOG_INFO_ERREUR); |
|
| 244 | + } else { |
|
| 245 | + echo '<p>' . _T('avis_operation_echec') . ' ' . join(' ', $res) . '</p>'; |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -262,17 +262,17 @@ discard block |
||
| 262 | 262 | * @return void |
| 263 | 263 | */ |
| 264 | 264 | function relance_maj($meta, $table, $redirect = '') { |
| 265 | - include_spip('inc/headers'); |
|
| 266 | - if (!$redirect) { |
|
| 267 | - // recuperer la valeur installee en cours |
|
| 268 | - // on la tronque numeriquement, elle ne sert pas reellement |
|
| 269 | - // sauf pour verifier que ce n'est pas oui ou non |
|
| 270 | - // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 271 | - $installee = intval($GLOBALS[$table][$meta]); |
|
| 272 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 273 | - } |
|
| 274 | - echo redirige_formulaire($redirect); |
|
| 275 | - exit(); |
|
| 265 | + include_spip('inc/headers'); |
|
| 266 | + if (!$redirect) { |
|
| 267 | + // recuperer la valeur installee en cours |
|
| 268 | + // on la tronque numeriquement, elle ne sert pas reellement |
|
| 269 | + // sauf pour verifier que ce n'est pas oui ou non |
|
| 270 | + // sinon is_numeric va echouer sur un numero de version 1.2.3 |
|
| 271 | + $installee = intval($GLOBALS[$table][$meta]); |
|
| 272 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 273 | + } |
|
| 274 | + echo redirige_formulaire($redirect); |
|
| 275 | + exit(); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -285,26 +285,26 @@ discard block |
||
| 285 | 285 | * @return void |
| 286 | 286 | */ |
| 287 | 287 | function maj_debut_page($installee, $meta, $table) { |
| 288 | - static $done = false; |
|
| 289 | - if ($done) { |
|
| 290 | - return; |
|
| 291 | - } |
|
| 292 | - include_spip('inc/minipres'); |
|
| 293 | - @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 294 | - $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 295 | - $titre = _T('titre_page_upgrade'); |
|
| 296 | - $balise_img = charger_filtre('balise_img'); |
|
| 297 | - $titre .= $balise_img(chemin_image('loader.svg'),'','loader'); |
|
| 298 | - echo(install_debut_html($titre)); |
|
| 299 | - // script de rechargement auto sur timeout |
|
| 300 | - $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 301 | - echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 302 | - echo "<div style='text-align: left'>\n"; |
|
| 303 | - if (ob_get_level()) { |
|
| 304 | - ob_flush(); |
|
| 305 | - } |
|
| 306 | - flush(); |
|
| 307 | - $done = true; |
|
| 288 | + static $done = false; |
|
| 289 | + if ($done) { |
|
| 290 | + return; |
|
| 291 | + } |
|
| 292 | + include_spip('inc/minipres'); |
|
| 293 | + @ini_set('zlib.output_compression', '0'); // pour permettre l'affichage au fur et a mesure |
|
| 294 | + $timeout = _UPGRADE_TIME_OUT * 2; |
|
| 295 | + $titre = _T('titre_page_upgrade'); |
|
| 296 | + $balise_img = charger_filtre('balise_img'); |
|
| 297 | + $titre .= $balise_img(chemin_image('loader.svg'),'','loader'); |
|
| 298 | + echo(install_debut_html($titre)); |
|
| 299 | + // script de rechargement auto sur timeout |
|
| 300 | + $redirect = generer_url_ecrire('upgrade', "reinstall=$installee&meta=$meta&table=$table", true); |
|
| 301 | + echo http_script("window.setTimeout('location.href=\"" . $redirect . "\";'," . ($timeout * 1000) . ')'); |
|
| 302 | + echo "<div style='text-align: left'>\n"; |
|
| 303 | + if (ob_get_level()) { |
|
| 304 | + ob_flush(); |
|
| 305 | + } |
|
| 306 | + flush(); |
|
| 307 | + $done = true; |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | |
@@ -348,63 +348,63 @@ discard block |
||
| 348 | 348 | * - tableau vide sinon. |
| 349 | 349 | */ |
| 350 | 350 | function maj_while($installee, $cible, $maj, $meta = '', $table = 'meta', $redirect = '', $debut_page = false) { |
| 351 | - # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 352 | - include_spip('base/create'); |
|
| 353 | - include_spip('base/abstract_sql'); |
|
| 354 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 355 | - include_spip('inc/plugin'); // pour spip_version_compare |
|
| 356 | - $n = 0; |
|
| 357 | - $time = time(); |
|
| 358 | - |
|
| 359 | - if (!defined('_TIME_OUT')) { |
|
| 360 | - /** |
|
| 361 | - * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 362 | - * de mises à jour qui durent trop longtemps |
|
| 363 | - * |
|
| 364 | - * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 365 | - * |
|
| 366 | - * @var int |
|
| 367 | - */ |
|
| 368 | - define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - foreach ($maj as $v => $operations) { |
|
| 372 | - // si une maj pour cette version |
|
| 373 | - if ($v == 'init' or |
|
| 374 | - (spip_version_compare($v, $installee, '>') |
|
| 375 | - and spip_version_compare($v, $cible, '<=')) |
|
| 376 | - ) { |
|
| 377 | - if ($debut_page) { |
|
| 378 | - maj_debut_page($v, $meta, $table); |
|
| 379 | - } |
|
| 380 | - echo "MAJ $v"; |
|
| 381 | - $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 382 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 383 | - # echec sur une etape en cours ? |
|
| 384 | - # on sort |
|
| 385 | - if ($etape) { |
|
| 386 | - return array($v, $etape); |
|
| 387 | - } |
|
| 388 | - $n = time() - $time; |
|
| 389 | - spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 390 | - if ($meta) { |
|
| 391 | - ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 392 | - } |
|
| 393 | - echo (_IS_CLI ? "\n" : '<br />'); |
|
| 394 | - } |
|
| 395 | - if (time() >= _TIME_OUT) { |
|
| 396 | - relance_maj($meta, $table, $redirect); |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - $trouver_table(''); // vider le cache des descriptions de table |
|
| 400 | - // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 401 | - // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 402 | - if ($meta) { |
|
| 403 | - ecrire_meta($meta, $cible, 'oui', $table); |
|
| 404 | - } |
|
| 405 | - spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 406 | - |
|
| 407 | - return array(); |
|
| 351 | + # inclusions pour que les procedures d'upgrade disposent des fonctions de base |
|
| 352 | + include_spip('base/create'); |
|
| 353 | + include_spip('base/abstract_sql'); |
|
| 354 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 355 | + include_spip('inc/plugin'); // pour spip_version_compare |
|
| 356 | + $n = 0; |
|
| 357 | + $time = time(); |
|
| 358 | + |
|
| 359 | + if (!defined('_TIME_OUT')) { |
|
| 360 | + /** |
|
| 361 | + * Définir le timeout qui peut-être utilisé dans les fonctions |
|
| 362 | + * de mises à jour qui durent trop longtemps |
|
| 363 | + * |
|
| 364 | + * À utiliser tel que : `if (time() >= _TIME_OUT)` |
|
| 365 | + * |
|
| 366 | + * @var int |
|
| 367 | + */ |
|
| 368 | + define('_TIME_OUT', $time + _UPGRADE_TIME_OUT); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + foreach ($maj as $v => $operations) { |
|
| 372 | + // si une maj pour cette version |
|
| 373 | + if ($v == 'init' or |
|
| 374 | + (spip_version_compare($v, $installee, '>') |
|
| 375 | + and spip_version_compare($v, $cible, '<=')) |
|
| 376 | + ) { |
|
| 377 | + if ($debut_page) { |
|
| 378 | + maj_debut_page($v, $meta, $table); |
|
| 379 | + } |
|
| 380 | + echo "MAJ $v"; |
|
| 381 | + $etape = serie_alter($v, $operations, $meta, $table, $redirect); |
|
| 382 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 383 | + # echec sur une etape en cours ? |
|
| 384 | + # on sort |
|
| 385 | + if ($etape) { |
|
| 386 | + return array($v, $etape); |
|
| 387 | + } |
|
| 388 | + $n = time() - $time; |
|
| 389 | + spip_log("$table $meta: $v en $n secondes", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 390 | + if ($meta) { |
|
| 391 | + ecrire_meta($meta, $installee = $v, 'oui', $table); |
|
| 392 | + } |
|
| 393 | + echo (_IS_CLI ? "\n" : '<br />'); |
|
| 394 | + } |
|
| 395 | + if (time() >= _TIME_OUT) { |
|
| 396 | + relance_maj($meta, $table, $redirect); |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + $trouver_table(''); // vider le cache des descriptions de table |
|
| 400 | + // indispensable pour les chgt de versions qui n'ecrivent pas en base |
|
| 401 | + // tant pis pour la redondance eventuelle avec ci-dessus |
|
| 402 | + if ($meta) { |
|
| 403 | + ecrire_meta($meta, $cible, 'oui', $table); |
|
| 404 | + } |
|
| 405 | + spip_log("MAJ terminee. $meta: $installee", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 406 | + |
|
| 407 | + return array(); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -427,52 +427,52 @@ discard block |
||
| 427 | 427 | * @return int |
| 428 | 428 | */ |
| 429 | 429 | function serie_alter($serie, $q = array(), $meta = '', $table = 'meta', $redirect = '') { |
| 430 | - $meta2 = $meta . '_maj_' . $serie; |
|
| 431 | - $etape = 0; |
|
| 432 | - if (isset($GLOBALS[$table][$meta2])) { |
|
| 433 | - $etape = intval($GLOBALS[$table][$meta2]); |
|
| 434 | - } |
|
| 435 | - foreach ($q as $i => $r) { |
|
| 436 | - if ($i >= $etape) { |
|
| 437 | - $msg = "maj $table $meta2 etape $i"; |
|
| 438 | - if (is_array($r) |
|
| 439 | - and function_exists($f = array_shift($r)) |
|
| 440 | - ) { |
|
| 441 | - // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 442 | - spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 443 | - // pour les fonctions atomiques sql_xx |
|
| 444 | - // on enregistre le meta avant de lancer la fonction, |
|
| 445 | - // de maniere a eviter de boucler sur timeout |
|
| 446 | - // mais pour les fonctions complexes, |
|
| 447 | - // il faut les rejouer jusqu'a achevement. |
|
| 448 | - // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 449 | - if (strncmp($f, 'sql_', 4) == 0) { |
|
| 450 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 451 | - } |
|
| 452 | - echo (_IS_CLI ? "." : " <span title='$i'>.</span>"); |
|
| 453 | - call_user_func_array($f, $r); |
|
| 454 | - // si temps imparti depasse, on relance sans ecrire en meta |
|
| 455 | - // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 456 | - if (time() >= _TIME_OUT) { |
|
| 457 | - relance_maj($meta, $table, $redirect); |
|
| 458 | - } |
|
| 459 | - ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 460 | - spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 461 | - } else { |
|
| 462 | - if (!is_array($r)) { |
|
| 463 | - spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 464 | - } else { |
|
| 465 | - spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 466 | - } |
|
| 467 | - // en cas d'erreur serieuse, on s'arrete |
|
| 468 | - // mais on permet de passer par dessus en rechargeant la page. |
|
| 469 | - return $i + 1; |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - } |
|
| 473 | - effacer_meta($meta2, $table); |
|
| 474 | - |
|
| 475 | - return 0; |
|
| 430 | + $meta2 = $meta . '_maj_' . $serie; |
|
| 431 | + $etape = 0; |
|
| 432 | + if (isset($GLOBALS[$table][$meta2])) { |
|
| 433 | + $etape = intval($GLOBALS[$table][$meta2]); |
|
| 434 | + } |
|
| 435 | + foreach ($q as $i => $r) { |
|
| 436 | + if ($i >= $etape) { |
|
| 437 | + $msg = "maj $table $meta2 etape $i"; |
|
| 438 | + if (is_array($r) |
|
| 439 | + and function_exists($f = array_shift($r)) |
|
| 440 | + ) { |
|
| 441 | + // note: $r (arguments de la fonction $f) peut avoir des données tabulaires |
|
| 442 | + spip_log("$msg: $f " . @join(',', $r), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 443 | + // pour les fonctions atomiques sql_xx |
|
| 444 | + // on enregistre le meta avant de lancer la fonction, |
|
| 445 | + // de maniere a eviter de boucler sur timeout |
|
| 446 | + // mais pour les fonctions complexes, |
|
| 447 | + // il faut les rejouer jusqu'a achevement. |
|
| 448 | + // C'est a elle d'assurer qu'elles progressent a chaque rappel |
|
| 449 | + if (strncmp($f, 'sql_', 4) == 0) { |
|
| 450 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 451 | + } |
|
| 452 | + echo (_IS_CLI ? "." : " <span title='$i'>.</span>"); |
|
| 453 | + call_user_func_array($f, $r); |
|
| 454 | + // si temps imparti depasse, on relance sans ecrire en meta |
|
| 455 | + // car on est peut etre sorti sur timeout si c'est une fonction longue |
|
| 456 | + if (time() >= _TIME_OUT) { |
|
| 457 | + relance_maj($meta, $table, $redirect); |
|
| 458 | + } |
|
| 459 | + ecrire_meta($meta2, $i + 1, 'non', $table); |
|
| 460 | + spip_log("$meta2: ok", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 461 | + } else { |
|
| 462 | + if (!is_array($r)) { |
|
| 463 | + spip_log("maj $i format incorrect", 'maj.' . _LOG_ERREUR); |
|
| 464 | + } else { |
|
| 465 | + spip_log("maj $i fonction $f non definie", 'maj.' . _LOG_ERREUR); |
|
| 466 | + } |
|
| 467 | + // en cas d'erreur serieuse, on s'arrete |
|
| 468 | + // mais on permet de passer par dessus en rechargeant la page. |
|
| 469 | + return $i + 1; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | + effacer_meta($meta2, $table); |
|
| 474 | + |
|
| 475 | + return 0; |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /** |
@@ -481,16 +481,16 @@ discard block |
||
| 481 | 481 | * @return bool True si possible. |
| 482 | 482 | **/ |
| 483 | 483 | function upgrade_test() { |
| 484 | - sql_drop_table('spip_test', true); |
|
| 485 | - sql_create('spip_test', array('a' => 'int')); |
|
| 486 | - sql_alter('TABLE spip_test ADD b INT'); |
|
| 487 | - sql_insertq('spip_test', array('b' => 1), array('field' => array('b' => 'int'))); |
|
| 488 | - $result = sql_select('b', 'spip_test'); |
|
| 489 | - // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 490 | - // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 491 | - // car cette table serait alors 'verouillee' |
|
| 492 | - $result = $result ? true : false; |
|
| 493 | - sql_alter('TABLE spip_test DROP b'); |
|
| 494 | - |
|
| 495 | - return $result; |
|
| 484 | + sql_drop_table('spip_test', true); |
|
| 485 | + sql_create('spip_test', array('a' => 'int')); |
|
| 486 | + sql_alter('TABLE spip_test ADD b INT'); |
|
| 487 | + sql_insertq('spip_test', array('b' => 1), array('field' => array('b' => 'int'))); |
|
| 488 | + $result = sql_select('b', 'spip_test'); |
|
| 489 | + // ne pas garder le resultat de la requete sinon sqlite3 |
|
| 490 | + // ne peut pas supprimer la table spip_test lors du sql_alter qui suit |
|
| 491 | + // car cette table serait alors 'verouillee' |
|
| 492 | + $result = $result ? true : false; |
|
| 493 | + sql_alter('TABLE spip_test DROP b'); |
|
| 494 | + |
|
| 495 | + return $result; |
|
| 496 | 496 | } |