@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -33,110 +33,110 @@ discard block |
||
| 33 | 33 | * @return array |
| 34 | 34 | */ |
| 35 | 35 | function plugins_get_infos_dist($plug = false, $reload = false, $dir = _DIR_PLUGINS, $clean_old = false) { |
| 36 | - $contenu = null; |
|
| 37 | - $res = null; |
|
| 38 | - static $cache = ''; |
|
| 39 | - static $filecache = ''; |
|
| 40 | - |
|
| 41 | - if ($cache === '') { |
|
| 42 | - $filecache = _DIR_TMP . 'plugin_xml_cache.gz'; |
|
| 43 | - if (is_file($filecache)) { |
|
| 44 | - lire_fichier($filecache, $contenu); |
|
| 45 | - $cache = unserialize($contenu); |
|
| 46 | - } |
|
| 47 | - if (!is_array($cache)) { |
|
| 48 | - $cache = []; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - if (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') { |
|
| 53 | - $reload = true; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - if ($plug === false) { |
|
| 57 | - ecrire_fichier($filecache, serialize($cache)); |
|
| 58 | - |
|
| 59 | - return $cache; |
|
| 60 | - } elseif (is_string($plug)) { |
|
| 61 | - $res = plugins_get_infos_un($plug, $reload, $dir, $cache); |
|
| 62 | - } elseif (is_array($plug)) { |
|
| 63 | - $res = false; |
|
| 64 | - if (!$reload) { |
|
| 65 | - $reload = -1; |
|
| 66 | - } |
|
| 67 | - foreach ($plug as $nom) { |
|
| 68 | - $res |= plugins_get_infos_un($nom, $reload, $dir, $cache); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // Nettoyer le cache des vieux plugins qui ne sont plus la |
|
| 72 | - if ($clean_old and isset($cache[$dir]) and is_countable($cache[$dir]) ? count($cache[$dir]) : 0) { |
|
| 73 | - foreach (array_keys($cache[$dir]) as $p) { |
|
| 74 | - if (!in_array($p, $plug)) { |
|
| 75 | - unset($cache[$dir][$p]); |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - if ($res) { |
|
| 81 | - ecrire_fichier($filecache, serialize($cache)); |
|
| 82 | - } |
|
| 83 | - if (!isset($cache[$dir])) { |
|
| 84 | - return []; |
|
| 85 | - } |
|
| 86 | - if (is_string($plug)) { |
|
| 87 | - return $cache[$dir][$plug] ?? []; |
|
| 88 | - } else { |
|
| 89 | - return $cache[$dir]; |
|
| 90 | - } |
|
| 36 | + $contenu = null; |
|
| 37 | + $res = null; |
|
| 38 | + static $cache = ''; |
|
| 39 | + static $filecache = ''; |
|
| 40 | + |
|
| 41 | + if ($cache === '') { |
|
| 42 | + $filecache = _DIR_TMP . 'plugin_xml_cache.gz'; |
|
| 43 | + if (is_file($filecache)) { |
|
| 44 | + lire_fichier($filecache, $contenu); |
|
| 45 | + $cache = unserialize($contenu); |
|
| 46 | + } |
|
| 47 | + if (!is_array($cache)) { |
|
| 48 | + $cache = []; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + if (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') { |
|
| 53 | + $reload = true; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + if ($plug === false) { |
|
| 57 | + ecrire_fichier($filecache, serialize($cache)); |
|
| 58 | + |
|
| 59 | + return $cache; |
|
| 60 | + } elseif (is_string($plug)) { |
|
| 61 | + $res = plugins_get_infos_un($plug, $reload, $dir, $cache); |
|
| 62 | + } elseif (is_array($plug)) { |
|
| 63 | + $res = false; |
|
| 64 | + if (!$reload) { |
|
| 65 | + $reload = -1; |
|
| 66 | + } |
|
| 67 | + foreach ($plug as $nom) { |
|
| 68 | + $res |= plugins_get_infos_un($nom, $reload, $dir, $cache); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // Nettoyer le cache des vieux plugins qui ne sont plus la |
|
| 72 | + if ($clean_old and isset($cache[$dir]) and is_countable($cache[$dir]) ? count($cache[$dir]) : 0) { |
|
| 73 | + foreach (array_keys($cache[$dir]) as $p) { |
|
| 74 | + if (!in_array($p, $plug)) { |
|
| 75 | + unset($cache[$dir][$p]); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + if ($res) { |
|
| 81 | + ecrire_fichier($filecache, serialize($cache)); |
|
| 82 | + } |
|
| 83 | + if (!isset($cache[$dir])) { |
|
| 84 | + return []; |
|
| 85 | + } |
|
| 86 | + if (is_string($plug)) { |
|
| 87 | + return $cache[$dir][$plug] ?? []; |
|
| 88 | + } else { |
|
| 89 | + return $cache[$dir]; |
|
| 90 | + } |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | function plugins_get_infos_un($plug, $reload, $dir, &$cache) { |
| 95 | - if (!is_readable($file = "$dir$plug/paquet.xml")) { |
|
| 96 | - return false; |
|
| 97 | - } |
|
| 98 | - $time = intval(@filemtime($file)); |
|
| 99 | - if ($time < 0) { |
|
| 100 | - return false; |
|
| 101 | - } |
|
| 102 | - $md5 = md5_file($file); |
|
| 103 | - |
|
| 104 | - $pcache = $cache[$dir][$plug] ?? ['filemtime' => 0, 'md5_file' => '']; |
|
| 105 | - |
|
| 106 | - // si le cache est valide |
|
| 107 | - if ( |
|
| 108 | - (intval($reload) <= 0) |
|
| 109 | - and ($time > 0) |
|
| 110 | - and ($time <= $pcache['filemtime']) |
|
| 111 | - and $md5 == $pcache['md5_file'] |
|
| 112 | - ) { |
|
| 113 | - return false; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - // si on arrive pas a lire le fichier, se contenter du cache |
|
| 117 | - if (!($texte = spip_file_get_contents($file))) { |
|
| 118 | - return false; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $f = charger_fonction('infos_paquet', 'plugins'); |
|
| 122 | - $ret = $f($texte, $plug, $dir); |
|
| 123 | - $ret['filemtime'] = $time; |
|
| 124 | - $ret['md5_file'] = $md5; |
|
| 125 | - // Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent |
|
| 126 | - // utiliser un necessite php. SPIP procure donc la version php courante du serveur. |
|
| 127 | - // chaque librairie php est aussi procurée, par exemple 'php:curl'. |
|
| 128 | - if (isset($ret['prefix']) and $ret['prefix'] == 'spip') { |
|
| 129 | - $ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()]; |
|
| 130 | - foreach (get_loaded_extensions() as $ext) { |
|
| 131 | - $ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)]; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - $diff = ($ret != $pcache); |
|
| 135 | - |
|
| 136 | - if ($diff) { |
|
| 137 | - $cache[$dir][$plug] = $ret; |
|
| 95 | + if (!is_readable($file = "$dir$plug/paquet.xml")) { |
|
| 96 | + return false; |
|
| 97 | + } |
|
| 98 | + $time = intval(@filemtime($file)); |
|
| 99 | + if ($time < 0) { |
|
| 100 | + return false; |
|
| 101 | + } |
|
| 102 | + $md5 = md5_file($file); |
|
| 103 | + |
|
| 104 | + $pcache = $cache[$dir][$plug] ?? ['filemtime' => 0, 'md5_file' => '']; |
|
| 105 | + |
|
| 106 | + // si le cache est valide |
|
| 107 | + if ( |
|
| 108 | + (intval($reload) <= 0) |
|
| 109 | + and ($time > 0) |
|
| 110 | + and ($time <= $pcache['filemtime']) |
|
| 111 | + and $md5 == $pcache['md5_file'] |
|
| 112 | + ) { |
|
| 113 | + return false; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + // si on arrive pas a lire le fichier, se contenter du cache |
|
| 117 | + if (!($texte = spip_file_get_contents($file))) { |
|
| 118 | + return false; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $f = charger_fonction('infos_paquet', 'plugins'); |
|
| 122 | + $ret = $f($texte, $plug, $dir); |
|
| 123 | + $ret['filemtime'] = $time; |
|
| 124 | + $ret['md5_file'] = $md5; |
|
| 125 | + // Si on lit le paquet.xml de SPIP, on rajoute un procure php afin que les plugins puissent |
|
| 126 | + // utiliser un necessite php. SPIP procure donc la version php courante du serveur. |
|
| 127 | + // chaque librairie php est aussi procurée, par exemple 'php:curl'. |
|
| 128 | + if (isset($ret['prefix']) and $ret['prefix'] == 'spip') { |
|
| 129 | + $ret['procure']['php'] = ['nom' => 'php', 'version' => phpversion()]; |
|
| 130 | + foreach (get_loaded_extensions() as $ext) { |
|
| 131 | + $ret['procure']['php:' . $ext] = ['nom' => 'php:' . $ext, 'version' => phpversion($ext)]; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + $diff = ($ret != $pcache); |
|
| 135 | + |
|
| 136 | + if ($diff) { |
|
| 137 | + $cache[$dir][$plug] = $ret; |
|
| 138 | 138 | # echo count($cache[$dir]), $dir,$plug, " $reloadc<br>"; |
| 139 | - } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - return $diff; |
|
| 141 | + return $diff; |
|
| 142 | 142 | } |
@@ -11,68 +11,68 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // https://code.spip.net/@affiche_arbre_plugins |
| 18 | 18 | function plugins_afficher_repertoires_dist($url_page, $liste_plugins, $liste_plugins_actifs) { |
| 19 | - $ligne_plug = charger_fonction('afficher_plugin', 'plugins'); |
|
| 20 | - $racine = basename(_DIR_PLUGINS); |
|
| 21 | - $init_dir = $current_dir = ''; |
|
| 22 | - // liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif |
|
| 23 | - // des qu'un path est deja note deplie on s'arrete |
|
| 24 | - $deplie = [$racine => true]; |
|
| 25 | - $fast_liste_plugins_actifs = []; |
|
| 26 | - foreach ($liste_plugins_actifs as $key => $plug) { |
|
| 27 | - $chemin_plug = chemin_plug($racine, $plug); |
|
| 28 | - $fast_liste_plugins_actifs[$chemin_plug] = true; |
|
| 29 | - $dir = dirname($chemin_plug); |
|
| 30 | - $maxiter = 100; |
|
| 31 | - while (strlen($dir) && !isset($deplie[$dir]) && $dir != $racine && $maxiter-- > 0) { |
|
| 32 | - $deplie[$dir] = true; |
|
| 33 | - $dir = dirname($dir); |
|
| 34 | - } |
|
| 35 | - } |
|
| 19 | + $ligne_plug = charger_fonction('afficher_plugin', 'plugins'); |
|
| 20 | + $racine = basename(_DIR_PLUGINS); |
|
| 21 | + $init_dir = $current_dir = ''; |
|
| 22 | + // liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif |
|
| 23 | + // des qu'un path est deja note deplie on s'arrete |
|
| 24 | + $deplie = [$racine => true]; |
|
| 25 | + $fast_liste_plugins_actifs = []; |
|
| 26 | + foreach ($liste_plugins_actifs as $key => $plug) { |
|
| 27 | + $chemin_plug = chemin_plug($racine, $plug); |
|
| 28 | + $fast_liste_plugins_actifs[$chemin_plug] = true; |
|
| 29 | + $dir = dirname($chemin_plug); |
|
| 30 | + $maxiter = 100; |
|
| 31 | + while (strlen($dir) && !isset($deplie[$dir]) && $dir != $racine && $maxiter-- > 0) { |
|
| 32 | + $deplie[$dir] = true; |
|
| 33 | + $dir = dirname($dir); |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - // index repertoires --> plugin |
|
| 38 | - $dir_index = []; |
|
| 39 | - foreach ($liste_plugins as $key => $plug) { |
|
| 40 | - $liste_plugins[$key] = chemin_plug($racine, $plug); |
|
| 41 | - $dir_index[dirname($liste_plugins[$key])][] = $key; |
|
| 42 | - } |
|
| 37 | + // index repertoires --> plugin |
|
| 38 | + $dir_index = []; |
|
| 39 | + foreach ($liste_plugins as $key => $plug) { |
|
| 40 | + $liste_plugins[$key] = chemin_plug($racine, $plug); |
|
| 41 | + $dir_index[dirname($liste_plugins[$key])][] = $key; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - $visible = @isset($deplie[$current_dir]); |
|
| 45 | - $maxiter = 1000; |
|
| 44 | + $visible = @isset($deplie[$current_dir]); |
|
| 45 | + $maxiter = 1000; |
|
| 46 | 46 | |
| 47 | - $res = ''; |
|
| 48 | - while ((is_countable($liste_plugins) ? count($liste_plugins) : 0) && $maxiter--) { |
|
| 49 | - // le rep suivant |
|
| 50 | - $dir = dirname(reset($liste_plugins)); |
|
| 51 | - if ($dir != $current_dir) { |
|
| 52 | - $res .= tree_open_close_dir($current_dir, $dir, $deplie); |
|
| 53 | - } |
|
| 47 | + $res = ''; |
|
| 48 | + while ((is_countable($liste_plugins) ? count($liste_plugins) : 0) && $maxiter--) { |
|
| 49 | + // le rep suivant |
|
| 50 | + $dir = dirname(reset($liste_plugins)); |
|
| 51 | + if ($dir != $current_dir) { |
|
| 52 | + $res .= tree_open_close_dir($current_dir, $dir, $deplie); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // d'abord tous les plugins du rep courant |
|
| 56 | - if (isset($dir_index[$current_dir])) { |
|
| 57 | - foreach ($dir_index[$current_dir] as $key) { |
|
| 58 | - $plug = $liste_plugins[$key]; |
|
| 59 | - $actif = @isset($fast_liste_plugins_actifs[$plug]); |
|
| 60 | - $id = substr(md5($plug), 0, 16); |
|
| 61 | - $res .= $ligne_plug( |
|
| 62 | - $url_page, |
|
| 63 | - str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), |
|
| 64 | - $actif, |
|
| 65 | - 'menu-entree' |
|
| 66 | - ) . "\n"; |
|
| 67 | - unset($liste_plugins[$key]); |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - $res .= tree_open_close_dir($current_dir, $init_dir, true); |
|
| 55 | + // d'abord tous les plugins du rep courant |
|
| 56 | + if (isset($dir_index[$current_dir])) { |
|
| 57 | + foreach ($dir_index[$current_dir] as $key) { |
|
| 58 | + $plug = $liste_plugins[$key]; |
|
| 59 | + $actif = @isset($fast_liste_plugins_actifs[$plug]); |
|
| 60 | + $id = substr(md5($plug), 0, 16); |
|
| 61 | + $res .= $ligne_plug( |
|
| 62 | + $url_page, |
|
| 63 | + str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), |
|
| 64 | + $actif, |
|
| 65 | + 'menu-entree' |
|
| 66 | + ) . "\n"; |
|
| 67 | + unset($liste_plugins[$key]); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + $res .= tree_open_close_dir($current_dir, $init_dir, true); |
|
| 72 | 72 | |
| 73 | - return "<ul class='menu-liste plugins'>" |
|
| 74 | - . $res |
|
| 75 | - . '</ul>'; |
|
| 73 | + return "<ul class='menu-liste plugins'>" |
|
| 74 | + . $res |
|
| 75 | + . '</ul>'; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
@@ -80,44 +80,44 @@ discard block |
||
| 80 | 80 | // une fonction pour aider... |
| 81 | 81 | // https://code.spip.net/@chemin_plug |
| 82 | 82 | function chemin_plug($racine, $plug) { |
| 83 | - return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug"); |
|
| 83 | + return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug"); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // https://code.spip.net/@tree_open_close_dir |
| 87 | 87 | function tree_open_close_dir(&$current, $target, $deplie = []) { |
| 88 | - if ($current == $target) { |
|
| 89 | - return ''; |
|
| 90 | - } |
|
| 91 | - $tcur = explode('/', $current); |
|
| 92 | - $ttarg = explode('/', $target); |
|
| 93 | - $tcom = []; |
|
| 94 | - $output = ''; |
|
| 95 | - // la partie commune |
|
| 96 | - while (reset($tcur) == reset($ttarg)) { |
|
| 97 | - $tcom[] = array_shift($tcur); |
|
| 98 | - array_shift($ttarg); |
|
| 99 | - } |
|
| 100 | - // fermer les repertoires courant jusqu'au point de fork |
|
| 101 | - while ($close = array_pop($tcur)) { |
|
| 102 | - $output .= "</ul>\n"; |
|
| 103 | - $output .= fin_block(); |
|
| 104 | - $output .= "</li>\n"; |
|
| 105 | - } |
|
| 106 | - $chemin = ''; |
|
| 107 | - if (count($tcom)) { |
|
| 108 | - $chemin .= implode('/', $tcom) . '/'; |
|
| 109 | - } |
|
| 110 | - // ouvrir les repertoires jusqu'a la cible |
|
| 111 | - while ($open = array_shift($ttarg)) { |
|
| 112 | - $visible = @isset($deplie[$chemin . $open]); |
|
| 113 | - $chemin .= $open . '/'; |
|
| 114 | - $output .= '<li>'; |
|
| 115 | - $output .= bouton_block_depliable($chemin, $visible); |
|
| 116 | - $output .= debut_block_depliable($visible); |
|
| 88 | + if ($current == $target) { |
|
| 89 | + return ''; |
|
| 90 | + } |
|
| 91 | + $tcur = explode('/', $current); |
|
| 92 | + $ttarg = explode('/', $target); |
|
| 93 | + $tcom = []; |
|
| 94 | + $output = ''; |
|
| 95 | + // la partie commune |
|
| 96 | + while (reset($tcur) == reset($ttarg)) { |
|
| 97 | + $tcom[] = array_shift($tcur); |
|
| 98 | + array_shift($ttarg); |
|
| 99 | + } |
|
| 100 | + // fermer les repertoires courant jusqu'au point de fork |
|
| 101 | + while ($close = array_pop($tcur)) { |
|
| 102 | + $output .= "</ul>\n"; |
|
| 103 | + $output .= fin_block(); |
|
| 104 | + $output .= "</li>\n"; |
|
| 105 | + } |
|
| 106 | + $chemin = ''; |
|
| 107 | + if (count($tcom)) { |
|
| 108 | + $chemin .= implode('/', $tcom) . '/'; |
|
| 109 | + } |
|
| 110 | + // ouvrir les repertoires jusqu'a la cible |
|
| 111 | + while ($open = array_shift($ttarg)) { |
|
| 112 | + $visible = @isset($deplie[$chemin . $open]); |
|
| 113 | + $chemin .= $open . '/'; |
|
| 114 | + $output .= '<li>'; |
|
| 115 | + $output .= bouton_block_depliable($chemin, $visible); |
|
| 116 | + $output .= debut_block_depliable($visible); |
|
| 117 | 117 | |
| 118 | - $output .= "<ul>\n"; |
|
| 119 | - } |
|
| 120 | - $current = $target; |
|
| 118 | + $output .= "<ul>\n"; |
|
| 119 | + } |
|
| 120 | + $current = $target; |
|
| 121 | 121 | |
| 122 | - return $output; |
|
| 122 | + return $output; |
|
| 123 | 123 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |
@@ -21,28 +21,28 @@ discard block |
||
| 21 | 21 | * @param array $arbre |
| 22 | 22 | */ |
| 23 | 23 | function plugins_extraire_pipelines_dist(&$arbre) { |
| 24 | - $pipes = null; |
|
| 25 | - $tag = null; |
|
| 26 | - $pipeline = []; |
|
| 27 | - if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 28 | - foreach ($pipes as $tag => $p) { |
|
| 29 | - if (!is_array($p[0])) { |
|
| 30 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 31 | - $pipeline[] = $att; |
|
| 32 | - } else { |
|
| 33 | - foreach ($p as $pipe) { |
|
| 34 | - $att = []; |
|
| 35 | - if (is_array($pipe)) { |
|
| 36 | - foreach ($pipe as $k => $t) { |
|
| 37 | - $att[$k] = trim(end($t)); |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - $pipeline[] = $att; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - unset($arbre[$tag]); |
|
| 45 | - } |
|
| 24 | + $pipes = null; |
|
| 25 | + $tag = null; |
|
| 26 | + $pipeline = []; |
|
| 27 | + if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 28 | + foreach ($pipes as $tag => $p) { |
|
| 29 | + if (!is_array($p[0])) { |
|
| 30 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 31 | + $pipeline[] = $att; |
|
| 32 | + } else { |
|
| 33 | + foreach ($p as $pipe) { |
|
| 34 | + $att = []; |
|
| 35 | + if (is_array($pipe)) { |
|
| 36 | + foreach ($pipe as $k => $t) { |
|
| 37 | + $att[$k] = trim(end($t)); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + $pipeline[] = $att; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + unset($arbre[$tag]); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $pipeline; |
|
| 47 | + return $pipeline; |
|
| 48 | 48 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -25,64 +25,64 @@ discard block |
||
| 25 | 25 | * @return array |
| 26 | 26 | */ |
| 27 | 27 | function plugins_infos_paquet($desc, $plug = '', $dir_plugins = _DIR_PLUGINS) { |
| 28 | - static $process = [ // tableau constant |
|
| 29 | - 'debut' => 'paquet_debutElement', |
|
| 30 | - 'fin' => 'paquet_finElement', |
|
| 31 | - 'text' => 'paquet_textElement' |
|
| 32 | - ]; |
|
| 33 | - |
|
| 34 | - $valider_xml = charger_fonction('valider', 'xml'); |
|
| 35 | - $vxml = $valider_xml($desc, false, $process, 'paquet.dtd', 'utf-8'); |
|
| 36 | - if (!$vxml->err) { |
|
| 37 | - // On veut toutes les variantes selon la version de SPIP |
|
| 38 | - if (!$plug) { |
|
| 39 | - return $vxml->versions; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - // compatibilite avec l'existant: |
|
| 43 | - $tree = $vxml->versions['0']; |
|
| 44 | - |
|
| 45 | - // l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca. |
|
| 46 | - if (isset($tree['']) and !strlen($tree[''])) { |
|
| 47 | - unset($tree['']); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - $tree['slogan'] = $tree['prefix'] . '_slogan'; |
|
| 51 | - $tree['description'] = $tree['prefix'] . '_description'; |
|
| 52 | - paquet_readable_files($tree, "$dir_plugins$plug/"); |
|
| 53 | - if (!$tree['chemin']) { |
|
| 54 | - $tree['chemin'] = []; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - // On verifie qu'il existe des balises spip qu'il faudrait rajouter dans |
|
| 58 | - // la structure d'infos du paquet en fonction de la version spip courante |
|
| 59 | - if ((is_countable($vxml->versions) ? count($vxml->versions) : 0) > 1) { |
|
| 60 | - $vspip = $GLOBALS['spip_version_branche']; |
|
| 61 | - foreach ($vxml->versions as $_compatibilite => $_version) { |
|
| 62 | - if ( |
|
| 63 | - ($_version['balise'] == 'spip') |
|
| 64 | - and (plugin_version_compatible($_compatibilite, $vspip, 'spip')) |
|
| 65 | - ) { |
|
| 66 | - // on merge les sous-balises de la balise spip compatible avec celles de la |
|
| 67 | - // balise paquet |
|
| 68 | - foreach ($_version as $_index => $_balise) { |
|
| 69 | - if ($_index and $_index != 'balise') { |
|
| 70 | - $tree[$_index] = array_merge($tree[$_index], $_balise); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - return $tree; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // Prendre les messages d'erreur sans les numeros de lignes |
|
| 81 | - $msg = array_column($vxml->err, 0); |
|
| 82 | - $t = _T('plugins_erreur', ['plugins' => $plug]); |
|
| 83 | - array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>'); |
|
| 84 | - |
|
| 85 | - return ['erreur' => $msg]; |
|
| 28 | + static $process = [ // tableau constant |
|
| 29 | + 'debut' => 'paquet_debutElement', |
|
| 30 | + 'fin' => 'paquet_finElement', |
|
| 31 | + 'text' => 'paquet_textElement' |
|
| 32 | + ]; |
|
| 33 | + |
|
| 34 | + $valider_xml = charger_fonction('valider', 'xml'); |
|
| 35 | + $vxml = $valider_xml($desc, false, $process, 'paquet.dtd', 'utf-8'); |
|
| 36 | + if (!$vxml->err) { |
|
| 37 | + // On veut toutes les variantes selon la version de SPIP |
|
| 38 | + if (!$plug) { |
|
| 39 | + return $vxml->versions; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + // compatibilite avec l'existant: |
|
| 43 | + $tree = $vxml->versions['0']; |
|
| 44 | + |
|
| 45 | + // l'arbre renvoie parfois un tag vide... etrange. Pas la peine de garder ca. |
|
| 46 | + if (isset($tree['']) and !strlen($tree[''])) { |
|
| 47 | + unset($tree['']); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + $tree['slogan'] = $tree['prefix'] . '_slogan'; |
|
| 51 | + $tree['description'] = $tree['prefix'] . '_description'; |
|
| 52 | + paquet_readable_files($tree, "$dir_plugins$plug/"); |
|
| 53 | + if (!$tree['chemin']) { |
|
| 54 | + $tree['chemin'] = []; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + // On verifie qu'il existe des balises spip qu'il faudrait rajouter dans |
|
| 58 | + // la structure d'infos du paquet en fonction de la version spip courante |
|
| 59 | + if ((is_countable($vxml->versions) ? count($vxml->versions) : 0) > 1) { |
|
| 60 | + $vspip = $GLOBALS['spip_version_branche']; |
|
| 61 | + foreach ($vxml->versions as $_compatibilite => $_version) { |
|
| 62 | + if ( |
|
| 63 | + ($_version['balise'] == 'spip') |
|
| 64 | + and (plugin_version_compatible($_compatibilite, $vspip, 'spip')) |
|
| 65 | + ) { |
|
| 66 | + // on merge les sous-balises de la balise spip compatible avec celles de la |
|
| 67 | + // balise paquet |
|
| 68 | + foreach ($_version as $_index => $_balise) { |
|
| 69 | + if ($_index and $_index != 'balise') { |
|
| 70 | + $tree[$_index] = array_merge($tree[$_index], $_balise); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + return $tree; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // Prendre les messages d'erreur sans les numeros de lignes |
|
| 81 | + $msg = array_column($vxml->err, 0); |
|
| 82 | + $t = _T('plugins_erreur', ['plugins' => $plug]); |
|
| 83 | + array_unshift($msg, $t . " <ul class='erreur_xml'><li>" . reset($msg) . '</li></ul>'); |
|
| 84 | + |
|
| 85 | + return ['erreur' => $msg]; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | * @return void |
| 95 | 95 | */ |
| 96 | 96 | function paquet_readable_files(&$tree, $dir) { |
| 97 | - $prefix = strtolower($tree['prefix']); |
|
| 97 | + $prefix = strtolower($tree['prefix']); |
|
| 98 | 98 | |
| 99 | - $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : []; |
|
| 100 | - $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : []; |
|
| 101 | - $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : []; |
|
| 99 | + $tree['options'] = (is_readable($dir . $f = ($prefix . '_options.php'))) ? [$f] : []; |
|
| 100 | + $tree['fonctions'] = (is_readable($dir . $f = ($prefix . '_fonctions.php'))) ? [$f] : []; |
|
| 101 | + $tree['install'] = (is_readable($dir . $f = ($prefix . '_administrations.php'))) ? [$f] : []; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -115,35 +115,35 @@ discard block |
||
| 115 | 115 | * @param array $attrs |
| 116 | 116 | */ |
| 117 | 117 | function paquet_debutElement($phraseur, $name, $attrs) { |
| 118 | - xml_debutElement($phraseur, $name, $attrs); |
|
| 119 | - if ($phraseur->err) { |
|
| 120 | - return; |
|
| 121 | - } |
|
| 122 | - if (($name == 'paquet') or ($name == 'spip')) { |
|
| 123 | - if ($name == 'spip') { |
|
| 124 | - $n = $attrs['compatibilite']; |
|
| 125 | - $attrs = []; |
|
| 126 | - } else { |
|
| 127 | - $n = '0'; |
|
| 128 | - $phraseur->contenu['paquet'] = $attrs; |
|
| 129 | - $attrs['menu'] = []; |
|
| 130 | - $attrs['chemin'] = []; |
|
| 131 | - $attrs['necessite'] = []; |
|
| 132 | - $attrs['lib'] = []; |
|
| 133 | - $attrs['onglet'] = []; |
|
| 134 | - $attrs['procure'] = []; |
|
| 135 | - $attrs['pipeline'] = []; |
|
| 136 | - $attrs['utilise'] = []; |
|
| 137 | - $attrs['style'] = []; |
|
| 138 | - $attrs['script'] = []; |
|
| 139 | - $attrs['genie'] = []; |
|
| 140 | - } |
|
| 141 | - $phraseur->contenu['compatible'] = $n; |
|
| 142 | - $phraseur->versions[$phraseur->contenu['compatible']] = $attrs; |
|
| 143 | - } else { |
|
| 144 | - $phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs; |
|
| 145 | - } |
|
| 146 | - $phraseur->versions[$phraseur->contenu['compatible']][''] = ''; |
|
| 118 | + xml_debutElement($phraseur, $name, $attrs); |
|
| 119 | + if ($phraseur->err) { |
|
| 120 | + return; |
|
| 121 | + } |
|
| 122 | + if (($name == 'paquet') or ($name == 'spip')) { |
|
| 123 | + if ($name == 'spip') { |
|
| 124 | + $n = $attrs['compatibilite']; |
|
| 125 | + $attrs = []; |
|
| 126 | + } else { |
|
| 127 | + $n = '0'; |
|
| 128 | + $phraseur->contenu['paquet'] = $attrs; |
|
| 129 | + $attrs['menu'] = []; |
|
| 130 | + $attrs['chemin'] = []; |
|
| 131 | + $attrs['necessite'] = []; |
|
| 132 | + $attrs['lib'] = []; |
|
| 133 | + $attrs['onglet'] = []; |
|
| 134 | + $attrs['procure'] = []; |
|
| 135 | + $attrs['pipeline'] = []; |
|
| 136 | + $attrs['utilise'] = []; |
|
| 137 | + $attrs['style'] = []; |
|
| 138 | + $attrs['script'] = []; |
|
| 139 | + $attrs['genie'] = []; |
|
| 140 | + } |
|
| 141 | + $phraseur->contenu['compatible'] = $n; |
|
| 142 | + $phraseur->versions[$phraseur->contenu['compatible']] = $attrs; |
|
| 143 | + } else { |
|
| 144 | + $phraseur->versions[$phraseur->contenu['compatible']][$name][0] = $attrs; |
|
| 145 | + } |
|
| 146 | + $phraseur->versions[$phraseur->contenu['compatible']][''] = ''; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | * @param string $data |
| 156 | 156 | */ |
| 157 | 157 | function paquet_textElement($phraseur, $data) { |
| 158 | - xml_textElement($phraseur, $data); |
|
| 159 | - if ($phraseur->err or !(trim($data))) { |
|
| 160 | - return; |
|
| 161 | - } |
|
| 162 | - $phraseur->versions[$phraseur->contenu['compatible']][''] .= $data; |
|
| 158 | + xml_textElement($phraseur, $data); |
|
| 159 | + if ($phraseur->err or !(trim($data))) { |
|
| 160 | + return; |
|
| 161 | + } |
|
| 162 | + $phraseur->versions[$phraseur->contenu['compatible']][''] .= $data; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -171,32 +171,32 @@ discard block |
||
| 171 | 171 | * @param string $name |
| 172 | 172 | */ |
| 173 | 173 | function paquet_finElement($phraseur, $name) { |
| 174 | - if ($phraseur->err) { |
|
| 175 | - return; |
|
| 176 | - } |
|
| 177 | - $n = $phraseur->contenu['compatible']; |
|
| 178 | - |
|
| 179 | - if (isset($phraseur->versions[$n][$name][0]) and is_array($phraseur->versions[$n][$name][0])) { |
|
| 180 | - $attrs = $phraseur->versions[$n][$name][0]; |
|
| 181 | - unset($phraseur->versions[$n][$name][0]); |
|
| 182 | - } else { |
|
| 183 | - $attrs = []; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - $texte = trim($phraseur->versions[$n]['']); |
|
| 187 | - $phraseur->versions[$n][''] = ''; |
|
| 188 | - |
|
| 189 | - $f = 'info_paquet_' . $name; |
|
| 190 | - if (function_exists($f)) { |
|
| 191 | - $f($phraseur, $attrs, $texte); |
|
| 192 | - } elseif (!$attrs) { |
|
| 193 | - $phraseur->versions[$n][$name] = $texte; |
|
| 194 | - } else { |
|
| 195 | - // Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici |
|
| 196 | - $phraseur->versions[$n][$name][$attrs['nom']] = $attrs; |
|
| 197 | - # echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]); |
|
| 198 | - } |
|
| 199 | - xml_finElement($phraseur, $name, $attrs); |
|
| 174 | + if ($phraseur->err) { |
|
| 175 | + return; |
|
| 176 | + } |
|
| 177 | + $n = $phraseur->contenu['compatible']; |
|
| 178 | + |
|
| 179 | + if (isset($phraseur->versions[$n][$name][0]) and is_array($phraseur->versions[$n][$name][0])) { |
|
| 180 | + $attrs = $phraseur->versions[$n][$name][0]; |
|
| 181 | + unset($phraseur->versions[$n][$name][0]); |
|
| 182 | + } else { |
|
| 183 | + $attrs = []; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + $texte = trim($phraseur->versions[$n]['']); |
|
| 187 | + $phraseur->versions[$n][''] = ''; |
|
| 188 | + |
|
| 189 | + $f = 'info_paquet_' . $name; |
|
| 190 | + if (function_exists($f)) { |
|
| 191 | + $f($phraseur, $attrs, $texte); |
|
| 192 | + } elseif (!$attrs) { |
|
| 193 | + $phraseur->versions[$n][$name] = $texte; |
|
| 194 | + } else { |
|
| 195 | + // Traitement generique. Si $attrs['nom'] n'existe pas, ce n'est pas normal ici |
|
| 196 | + $phraseur->versions[$n][$name][$attrs['nom']] = $attrs; |
|
| 197 | + # echo("<br>pour $name $n " . $attrs['nom']); var_dump($phraseur->versions[$n]); |
|
| 198 | + } |
|
| 199 | + xml_finElement($phraseur, $name, $attrs); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | * @param string $texte |
| 209 | 209 | */ |
| 210 | 210 | function info_paquet_licence($phraseur, $attrs, $texte) { |
| 211 | - if (isset($attrs['lien'])) { |
|
| 212 | - $lien = $attrs['lien']; |
|
| 213 | - } else { |
|
| 214 | - $lien = ''; |
|
| 215 | - } |
|
| 216 | - $n = $phraseur->contenu['compatible']; |
|
| 217 | - $phraseur->versions[$n]['licence'][] = ['nom' => $texte, 'url' => $lien]; |
|
| 211 | + if (isset($attrs['lien'])) { |
|
| 212 | + $lien = $attrs['lien']; |
|
| 213 | + } else { |
|
| 214 | + $lien = ''; |
|
| 215 | + } |
|
| 216 | + $n = $phraseur->contenu['compatible']; |
|
| 217 | + $phraseur->versions[$n]['licence'][] = ['nom' => $texte, 'url' => $lien]; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -226,14 +226,14 @@ discard block |
||
| 226 | 226 | * @param string $texte |
| 227 | 227 | */ |
| 228 | 228 | function info_paquet_chemin($phraseur, $attrs, $texte) { |
| 229 | - $n = $phraseur->contenu['compatible']; |
|
| 230 | - if (isset($attrs['path'])) { |
|
| 231 | - if (isset($attrs['type'])) { |
|
| 232 | - $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path'], 'type' => $attrs['type']]; |
|
| 233 | - } else { |
|
| 234 | - $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path']]; |
|
| 235 | - } |
|
| 236 | - } |
|
| 229 | + $n = $phraseur->contenu['compatible']; |
|
| 230 | + if (isset($attrs['path'])) { |
|
| 231 | + if (isset($attrs['type'])) { |
|
| 232 | + $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path'], 'type' => $attrs['type']]; |
|
| 233 | + } else { |
|
| 234 | + $phraseur->versions[$n]['chemin'][] = ['path' => $attrs['path']]; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | |
@@ -247,24 +247,24 @@ discard block |
||
| 247 | 247 | * @param string $texte |
| 248 | 248 | */ |
| 249 | 249 | function info_paquet_auteur($phraseur, $attrs, $texte) { |
| 250 | - # echo 'auteur ', $texte; var_dump($attrs); |
|
| 251 | - if (isset($attrs['mail'])) { |
|
| 252 | - if (strpos($attrs['mail'], '@')) { |
|
| 253 | - $attrs['mail'] = str_replace('@', ' AT ', $attrs['mail']); |
|
| 254 | - } |
|
| 255 | - $mail = $attrs['mail']; |
|
| 256 | - } else { |
|
| 257 | - $mail = ''; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - if (isset($attrs['lien'])) { |
|
| 261 | - $lien = $attrs['lien']; |
|
| 262 | - } else { |
|
| 263 | - $lien = ''; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - $n = $phraseur->contenu['compatible']; |
|
| 267 | - $phraseur->versions[$n]['auteur'][] = ['nom' => $texte, 'url' => $lien, 'mail' => $mail]; |
|
| 250 | + # echo 'auteur ', $texte; var_dump($attrs); |
|
| 251 | + if (isset($attrs['mail'])) { |
|
| 252 | + if (strpos($attrs['mail'], '@')) { |
|
| 253 | + $attrs['mail'] = str_replace('@', ' AT ', $attrs['mail']); |
|
| 254 | + } |
|
| 255 | + $mail = $attrs['mail']; |
|
| 256 | + } else { |
|
| 257 | + $mail = ''; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + if (isset($attrs['lien'])) { |
|
| 261 | + $lien = $attrs['lien']; |
|
| 262 | + } else { |
|
| 263 | + $lien = ''; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + $n = $phraseur->contenu['compatible']; |
|
| 267 | + $phraseur->versions[$n]['auteur'][] = ['nom' => $texte, 'url' => $lien, 'mail' => $mail]; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -277,14 +277,14 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | function info_paquet_credit($phraseur, $attrs, $texte) { |
| 279 | 279 | |
| 280 | - if (isset($attrs['lien'])) { |
|
| 281 | - $lien = $attrs['lien']; |
|
| 282 | - } else { |
|
| 283 | - $lien = ''; |
|
| 284 | - } |
|
| 280 | + if (isset($attrs['lien'])) { |
|
| 281 | + $lien = $attrs['lien']; |
|
| 282 | + } else { |
|
| 283 | + $lien = ''; |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - $n = $phraseur->contenu['compatible']; |
|
| 287 | - $phraseur->versions[$n]['credit'][] = ['nom' => $texte, 'url' => $lien]; |
|
| 286 | + $n = $phraseur->contenu['compatible']; |
|
| 287 | + $phraseur->versions[$n]['credit'][] = ['nom' => $texte, 'url' => $lien]; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -296,8 +296,8 @@ discard block |
||
| 296 | 296 | * @param string $texte |
| 297 | 297 | */ |
| 298 | 298 | function info_paquet_copyright($phraseur, $attrs, $texte) { |
| 299 | - $n = $phraseur->contenu['compatible']; |
|
| 300 | - $phraseur->versions[$n]['copyright'][] = $texte; |
|
| 299 | + $n = $phraseur->contenu['compatible']; |
|
| 300 | + $phraseur->versions[$n]['copyright'][] = $texte; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | * @param string $texte |
| 310 | 310 | */ |
| 311 | 311 | function info_paquet_paquet($phraseur, $attrs, $texte) { |
| 312 | - $n = 0; |
|
| 313 | - $phraseur->versions[$n]['dtd'] = 'paquet'; |
|
| 314 | - $phraseur->versions[$n]['balise'] = 'paquet'; |
|
| 312 | + $n = 0; |
|
| 313 | + $phraseur->versions[$n]['dtd'] = 'paquet'; |
|
| 314 | + $phraseur->versions[$n]['balise'] = 'paquet'; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -323,8 +323,8 @@ discard block |
||
| 323 | 323 | * @param string $texte |
| 324 | 324 | **/ |
| 325 | 325 | function info_paquet_traduire($phraseur, $attrs, $texte) { |
| 326 | - $n = $phraseur->contenu['compatible']; |
|
| 327 | - $phraseur->versions[$n]['traduire'][] = $attrs; |
|
| 326 | + $n = $phraseur->contenu['compatible']; |
|
| 327 | + $phraseur->versions[$n]['traduire'][] = $attrs; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | * @param string $texte |
| 337 | 337 | */ |
| 338 | 338 | function info_paquet_spip($phraseur, $attrs, $texte) { |
| 339 | - $n = $phraseur->contenu['compatible']; |
|
| 340 | - $phraseur->versions[$n]['balise'] = 'spip'; |
|
| 339 | + $n = $phraseur->contenu['compatible']; |
|
| 340 | + $phraseur->versions[$n]['balise'] = 'spip'; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | |
@@ -349,8 +349,8 @@ discard block |
||
| 349 | 349 | * @param string $texte |
| 350 | 350 | */ |
| 351 | 351 | function info_paquet_pipeline($phraseur, $attrs, $texte) { |
| 352 | - $n = $phraseur->contenu['compatible']; |
|
| 353 | - $phraseur->versions[$n]['pipeline'][] = $attrs; |
|
| 352 | + $n = $phraseur->contenu['compatible']; |
|
| 353 | + $phraseur->versions[$n]['pipeline'][] = $attrs; |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | |
@@ -363,23 +363,23 @@ discard block |
||
| 363 | 363 | * @param string $texte |
| 364 | 364 | */ |
| 365 | 365 | function info_paquet_style($phraseur, $attrs, $texte) { |
| 366 | - $lien = $chemin = $type = $media = ''; |
|
| 367 | - |
|
| 368 | - include_spip('inc/utils'); |
|
| 369 | - if (tester_url_absolue($attrs['source'])) { |
|
| 370 | - $lien = $attrs['source']; |
|
| 371 | - } else { |
|
| 372 | - $chemin = $attrs['source']; |
|
| 373 | - } |
|
| 374 | - if (isset($attrs['type'])) { |
|
| 375 | - $type = $attrs['type']; |
|
| 376 | - } |
|
| 377 | - if (isset($attrs['media'])) { |
|
| 378 | - $media = $attrs['media']; |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - $n = $phraseur->contenu['compatible']; |
|
| 382 | - $phraseur->versions[$n]['style'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media]; |
|
| 366 | + $lien = $chemin = $type = $media = ''; |
|
| 367 | + |
|
| 368 | + include_spip('inc/utils'); |
|
| 369 | + if (tester_url_absolue($attrs['source'])) { |
|
| 370 | + $lien = $attrs['source']; |
|
| 371 | + } else { |
|
| 372 | + $chemin = $attrs['source']; |
|
| 373 | + } |
|
| 374 | + if (isset($attrs['type'])) { |
|
| 375 | + $type = $attrs['type']; |
|
| 376 | + } |
|
| 377 | + if (isset($attrs['media'])) { |
|
| 378 | + $media = $attrs['media']; |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + $n = $phraseur->contenu['compatible']; |
|
| 382 | + $phraseur->versions[$n]['style'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type, 'media' => $media]; |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
@@ -392,20 +392,20 @@ discard block |
||
| 392 | 392 | * @param string $texte |
| 393 | 393 | */ |
| 394 | 394 | function info_paquet_script($phraseur, $attrs, $texte) { |
| 395 | - $lien = $chemin = $type = $media = ''; |
|
| 396 | - |
|
| 397 | - include_spip('inc/utils'); |
|
| 398 | - if (tester_url_absolue($attrs['source'])) { |
|
| 399 | - $lien = $attrs['source']; |
|
| 400 | - } else { |
|
| 401 | - $chemin = $attrs['source']; |
|
| 402 | - } |
|
| 403 | - if (isset($attrs['type'])) { |
|
| 404 | - $type = $attrs['type']; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - $n = $phraseur->contenu['compatible']; |
|
| 408 | - $phraseur->versions[$n]['script'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type]; |
|
| 395 | + $lien = $chemin = $type = $media = ''; |
|
| 396 | + |
|
| 397 | + include_spip('inc/utils'); |
|
| 398 | + if (tester_url_absolue($attrs['source'])) { |
|
| 399 | + $lien = $attrs['source']; |
|
| 400 | + } else { |
|
| 401 | + $chemin = $attrs['source']; |
|
| 402 | + } |
|
| 403 | + if (isset($attrs['type'])) { |
|
| 404 | + $type = $attrs['type']; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + $n = $phraseur->contenu['compatible']; |
|
| 408 | + $phraseur->versions[$n]['script'][] = ['url' => $lien, 'path' => $chemin, 'type' => $type]; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -416,6 +416,6 @@ discard block |
||
| 416 | 416 | * @param string $texte |
| 417 | 417 | */ |
| 418 | 418 | function info_paquet_genie($phraseur, $attrs, $texte) { |
| 419 | - $n = $phraseur->contenu['compatible']; |
|
| 420 | - $phraseur->versions[$n]['genie'][] = $attrs; |
|
| 419 | + $n = $phraseur->contenu['compatible']; |
|
| 420 | + $phraseur->versions[$n]['genie'][] = $attrs; |
|
| 421 | 421 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -21,31 +21,31 @@ discard block |
||
| 21 | 21 | * @return <type> |
| 22 | 22 | */ |
| 23 | 23 | function plugins_extraire_boutons_dist($arbre) { |
| 24 | - $les_boutons = null; |
|
| 25 | - $ret = ['bouton' => [], 'onglet' => []]; |
|
| 26 | - // recuperer les boutons et onglets si necessaire |
|
| 27 | - spip_xml_match_nodes(',^(bouton|onglet)\s,', $arbre, $les_boutons); |
|
| 28 | - if (is_array($les_boutons) && count($les_boutons)) { |
|
| 29 | - $ret['bouton'] = []; |
|
| 30 | - $ret['onglet'] = []; |
|
| 31 | - foreach ($les_boutons as $bouton => $val) { |
|
| 32 | - $bouton = spip_xml_decompose_tag($bouton); |
|
| 33 | - $type = reset($bouton); |
|
| 34 | - $bouton = end($bouton); |
|
| 35 | - if (isset($bouton['id'])) { |
|
| 36 | - $id = $bouton['id']; |
|
| 37 | - $val = reset($val); |
|
| 38 | - if (is_array($val)) { |
|
| 39 | - $ret[$type][$id]['parent'] = $bouton['parent'] ?? ''; |
|
| 40 | - $ret[$type][$id]['position'] = $bouton['position'] ?? ''; |
|
| 41 | - $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : ''; |
|
| 42 | - $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : ''; |
|
| 43 | - $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : ''; |
|
| 44 | - $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : ''; |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 24 | + $les_boutons = null; |
|
| 25 | + $ret = ['bouton' => [], 'onglet' => []]; |
|
| 26 | + // recuperer les boutons et onglets si necessaire |
|
| 27 | + spip_xml_match_nodes(',^(bouton|onglet)\s,', $arbre, $les_boutons); |
|
| 28 | + if (is_array($les_boutons) && count($les_boutons)) { |
|
| 29 | + $ret['bouton'] = []; |
|
| 30 | + $ret['onglet'] = []; |
|
| 31 | + foreach ($les_boutons as $bouton => $val) { |
|
| 32 | + $bouton = spip_xml_decompose_tag($bouton); |
|
| 33 | + $type = reset($bouton); |
|
| 34 | + $bouton = end($bouton); |
|
| 35 | + if (isset($bouton['id'])) { |
|
| 36 | + $id = $bouton['id']; |
|
| 37 | + $val = reset($val); |
|
| 38 | + if (is_array($val)) { |
|
| 39 | + $ret[$type][$id]['parent'] = $bouton['parent'] ?? ''; |
|
| 40 | + $ret[$type][$id]['position'] = $bouton['position'] ?? ''; |
|
| 41 | + $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : ''; |
|
| 42 | + $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : ''; |
|
| 43 | + $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : ''; |
|
| 44 | + $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : ''; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return $ret; |
|
| 50 | + return $ret; |
|
| 51 | 51 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | include_spip('inc/charsets'); |
| 23 | 23 | include_spip('inc/texte'); |
@@ -25,214 +25,214 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // https://code.spip.net/@ligne_plug |
| 27 | 27 | function plugins_afficher_plugin_dist( |
| 28 | - $url_page, |
|
| 29 | - $plug_file, |
|
| 30 | - $checked, |
|
| 31 | - $actif, |
|
| 32 | - $expose = false, |
|
| 33 | - $class_li = 'item', |
|
| 34 | - $dir_plugins = _DIR_PLUGINS |
|
| 28 | + $url_page, |
|
| 29 | + $plug_file, |
|
| 30 | + $checked, |
|
| 31 | + $actif, |
|
| 32 | + $expose = false, |
|
| 33 | + $class_li = 'item', |
|
| 34 | + $dir_plugins = _DIR_PLUGINS |
|
| 35 | 35 | ) { |
| 36 | 36 | |
| 37 | - static $id_input = 0; |
|
| 38 | - static $versions = []; |
|
| 39 | - |
|
| 40 | - $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 41 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 42 | - $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 43 | - $prefix = $info['prefix']; |
|
| 44 | - $cfg = ''; |
|
| 45 | - $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 46 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 47 | - $erreur = ''; |
|
| 48 | - |
|
| 49 | - if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 50 | - $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 51 | - $erreur = http_img_pack( |
|
| 52 | - 'plugin-dis-32.png', |
|
| 53 | - _T('plugin_info_non_compatible_spip'), |
|
| 54 | - " class='picto_err'", |
|
| 55 | - _T('plugin_info_non_compatible_spip') |
|
| 56 | - ); |
|
| 57 | - $class_li .= ' disabled'; |
|
| 58 | - $checkable = false; |
|
| 59 | - } elseif (isset($info['erreur'])) { |
|
| 60 | - $class_li .= ' error'; |
|
| 61 | - $erreur = http_img_pack( |
|
| 62 | - 'plugin-err-32.png', |
|
| 63 | - _T('plugin_info_erreur_xml'), |
|
| 64 | - " class='picto_err'", |
|
| 65 | - _T('plugin_info_erreur_xml') |
|
| 66 | - ) |
|
| 67 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 68 | - $checkable = false; |
|
| 69 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 70 | - $class_li .= ' error'; |
|
| 71 | - $erreur = http_img_pack( |
|
| 72 | - 'plugin-err-32.png', |
|
| 73 | - _T('plugin_impossible_activer', ['plugin' => $nom]), |
|
| 74 | - " class='picto_err'", |
|
| 75 | - _T('plugin_impossible_activer', ['plugin' => $nom]) |
|
| 76 | - ) |
|
| 77 | - . "<div class='erreur'>" . implode( |
|
| 78 | - '<br />', |
|
| 79 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 80 | - ) . '</div>'; |
|
| 81 | - } else { |
|
| 82 | - $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
|
| 83 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
|
| 84 | - //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 85 | - $erreur = http_img_pack( |
|
| 86 | - 'plugin-dis-32.png', |
|
| 87 | - _T('plugin_info_non_compatible_spip'), |
|
| 88 | - " class='picto_err picto_compat_forcee'", |
|
| 89 | - _L('Version incompatible : compatibilité forcée') |
|
| 90 | - ); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - // numerotons les occurrences d'un meme prefix |
|
| 95 | - $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 96 | - |
|
| 97 | - $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 98 | - |
|
| 99 | - return "<li id='$prefix$id' class='$class_li'>" |
|
| 100 | - . ((!$checkable and !$checked) |
|
| 101 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 102 | - . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 103 | - . $cfg |
|
| 104 | - . $erreur |
|
| 105 | - . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 106 | - ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 107 | - . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 108 | - . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 109 | - . '</div>' |
|
| 110 | - . '</li>'; |
|
| 37 | + static $id_input = 0; |
|
| 38 | + static $versions = []; |
|
| 39 | + |
|
| 40 | + $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 41 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 42 | + $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 43 | + $prefix = $info['prefix']; |
|
| 44 | + $cfg = ''; |
|
| 45 | + $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 46 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 47 | + $erreur = ''; |
|
| 48 | + |
|
| 49 | + if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 50 | + $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 51 | + $erreur = http_img_pack( |
|
| 52 | + 'plugin-dis-32.png', |
|
| 53 | + _T('plugin_info_non_compatible_spip'), |
|
| 54 | + " class='picto_err'", |
|
| 55 | + _T('plugin_info_non_compatible_spip') |
|
| 56 | + ); |
|
| 57 | + $class_li .= ' disabled'; |
|
| 58 | + $checkable = false; |
|
| 59 | + } elseif (isset($info['erreur'])) { |
|
| 60 | + $class_li .= ' error'; |
|
| 61 | + $erreur = http_img_pack( |
|
| 62 | + 'plugin-err-32.png', |
|
| 63 | + _T('plugin_info_erreur_xml'), |
|
| 64 | + " class='picto_err'", |
|
| 65 | + _T('plugin_info_erreur_xml') |
|
| 66 | + ) |
|
| 67 | + . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 68 | + $checkable = false; |
|
| 69 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 70 | + $class_li .= ' error'; |
|
| 71 | + $erreur = http_img_pack( |
|
| 72 | + 'plugin-err-32.png', |
|
| 73 | + _T('plugin_impossible_activer', ['plugin' => $nom]), |
|
| 74 | + " class='picto_err'", |
|
| 75 | + _T('plugin_impossible_activer', ['plugin' => $nom]) |
|
| 76 | + ) |
|
| 77 | + . "<div class='erreur'>" . implode( |
|
| 78 | + '<br />', |
|
| 79 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 80 | + ) . '</div>'; |
|
| 81 | + } else { |
|
| 82 | + $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
|
| 83 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
|
| 84 | + //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 85 | + $erreur = http_img_pack( |
|
| 86 | + 'plugin-dis-32.png', |
|
| 87 | + _T('plugin_info_non_compatible_spip'), |
|
| 88 | + " class='picto_err picto_compat_forcee'", |
|
| 89 | + _L('Version incompatible : compatibilité forcée') |
|
| 90 | + ); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + // numerotons les occurrences d'un meme prefix |
|
| 95 | + $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 96 | + |
|
| 97 | + $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 98 | + |
|
| 99 | + return "<li id='$prefix$id' class='$class_li'>" |
|
| 100 | + . ((!$checkable and !$checked) |
|
| 101 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 102 | + . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 103 | + . $cfg |
|
| 104 | + . $erreur |
|
| 105 | + . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 106 | + ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 107 | + . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 108 | + . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 109 | + . '</div>' |
|
| 110 | + . '</li>'; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | function plugin_bouton_config($nom, $infos, $dir) { |
| 114 | - // la verification se base sur le filesystem |
|
| 115 | - // il faut donc n'utiliser que des minuscules, par convention |
|
| 116 | - $prefix = strtolower($infos['prefix']); |
|
| 117 | - // si paquet.xml fournit un squelette, le prendre |
|
| 118 | - if (isset($infos['config']) and $infos['config']) { |
|
| 119 | - return recuperer_fond( |
|
| 120 | - "$dir$nom/" . $infos['config'], |
|
| 121 | - [ |
|
| 122 | - 'script' => 'configurer_' . $prefix, |
|
| 123 | - 'nom' => $nom |
|
| 124 | - ] |
|
| 125 | - ); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - // si le plugin CFG est la, l'essayer |
|
| 129 | - if (defined('_DIR_PLUGIN_CFG')) { |
|
| 130 | - if (include_spip('inc/cfg')) { // test CFG version >= 1.0.5 |
|
| 131 | - if ($cfg = icone_lien_cfg("$dir$nom", 'cfg')) { |
|
| 132 | - return "<div class='cfg_link'>$cfg</div>"; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // sinon prendre le squelette std sur le nom std |
|
| 138 | - return recuperer_fond( |
|
| 139 | - 'prive/squelettes/inclure/cfg', |
|
| 140 | - [ |
|
| 141 | - 'script' => 'configurer_' . $prefix, |
|
| 142 | - 'nom' => $nom |
|
| 143 | - ] |
|
| 144 | - ); |
|
| 114 | + // la verification se base sur le filesystem |
|
| 115 | + // il faut donc n'utiliser que des minuscules, par convention |
|
| 116 | + $prefix = strtolower($infos['prefix']); |
|
| 117 | + // si paquet.xml fournit un squelette, le prendre |
|
| 118 | + if (isset($infos['config']) and $infos['config']) { |
|
| 119 | + return recuperer_fond( |
|
| 120 | + "$dir$nom/" . $infos['config'], |
|
| 121 | + [ |
|
| 122 | + 'script' => 'configurer_' . $prefix, |
|
| 123 | + 'nom' => $nom |
|
| 124 | + ] |
|
| 125 | + ); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + // si le plugin CFG est la, l'essayer |
|
| 129 | + if (defined('_DIR_PLUGIN_CFG')) { |
|
| 130 | + if (include_spip('inc/cfg')) { // test CFG version >= 1.0.5 |
|
| 131 | + if ($cfg = icone_lien_cfg("$dir$nom", 'cfg')) { |
|
| 132 | + return "<div class='cfg_link'>$cfg</div>"; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // sinon prendre le squelette std sur le nom std |
|
| 138 | + return recuperer_fond( |
|
| 139 | + 'prive/squelettes/inclure/cfg', |
|
| 140 | + [ |
|
| 141 | + 'script' => 'configurer_' . $prefix, |
|
| 142 | + 'nom' => $nom |
|
| 143 | + ] |
|
| 144 | + ); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // checkbox pour activer ou desactiver |
| 148 | 148 | // si ce n'est pas une extension |
| 149 | 149 | |
| 150 | 150 | function plugin_checkbox($id_input, $file, $actif) { |
| 151 | - $name = substr(md5($file), 0, 16); |
|
| 152 | - |
|
| 153 | - return "<div class='check'>\n" |
|
| 154 | - . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 155 | - . ($actif ? " checked='checked'" : '') |
|
| 156 | - . " class='checkbox' value='O' />" |
|
| 157 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 158 | - . '</div>'; |
|
| 151 | + $name = substr(md5($file), 0, 16); |
|
| 152 | + |
|
| 153 | + return "<div class='check'>\n" |
|
| 154 | + . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 155 | + . ($actif ? " checked='checked'" : '') |
|
| 156 | + . " class='checkbox' value='O' />" |
|
| 157 | + . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 158 | + . '</div>'; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | function plugin_nom($info, $dir_plugins, $plug_file) { |
| 162 | - $prefix = $info['prefix']; |
|
| 163 | - $dir = "$dir_plugins$plug_file"; |
|
| 164 | - // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 165 | - if ($info['dtd'] == 'paquet') { |
|
| 166 | - $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 167 | - if (!$nom) { |
|
| 168 | - $nom = typo($info['nom']); |
|
| 169 | - } |
|
| 170 | - } else { |
|
| 171 | - $nom = typo(attribut_html($info['nom'])); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - return trim($nom); |
|
| 162 | + $prefix = $info['prefix']; |
|
| 163 | + $dir = "$dir_plugins$plug_file"; |
|
| 164 | + // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 165 | + if ($info['dtd'] == 'paquet') { |
|
| 166 | + $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 167 | + if (!$nom) { |
|
| 168 | + $nom = typo($info['nom']); |
|
| 169 | + } |
|
| 170 | + } else { |
|
| 171 | + $nom = typo(attribut_html($info['nom'])); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + return trim($nom); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // Cartouche Resume |
| 178 | 178 | function plugin_resume($info, $dir_plugins, $plug_file, $url_page) { |
| 179 | - $prefix = $info['prefix']; |
|
| 180 | - $dir = "$dir_plugins$plug_file"; |
|
| 181 | - $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 182 | - // une seule ligne dans le slogan : couper si besoin |
|
| 183 | - if (($p = strpos($slogan, '<br />')) !== false) { |
|
| 184 | - $slogan = substr($slogan, 0, $p); |
|
| 185 | - } |
|
| 186 | - // couper par securite |
|
| 187 | - $slogan = couper($slogan, 80); |
|
| 188 | - |
|
| 189 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 190 | - |
|
| 191 | - $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE))); |
|
| 192 | - |
|
| 193 | - $icon_class = 'icon'; |
|
| 194 | - $img = ''; |
|
| 195 | - if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 196 | - $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 197 | - if (!extraire_attribut($img, 'src')) { |
|
| 198 | - $img = ''; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - if (!$img) { |
|
| 202 | - $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'"); |
|
| 203 | - $icon_class .= ' no-logo'; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 207 | - |
|
| 208 | - return "<div class='resume'>" |
|
| 209 | - . "<h3><a href='$url' rel='info'>" |
|
| 210 | - . $nom |
|
| 211 | - . '</a></h3>' |
|
| 212 | - . " <span class='version'>" . $info['version'] . '</span>' |
|
| 213 | - . " <span class='etat'> - " |
|
| 214 | - . plugin_etat_en_clair($info['etat']) |
|
| 215 | - . '</span>' |
|
| 216 | - . "<div class='short'>" . $slogan . '</div>' |
|
| 217 | - . $i |
|
| 218 | - . '</div>'; |
|
| 179 | + $prefix = $info['prefix']; |
|
| 180 | + $dir = "$dir_plugins$plug_file"; |
|
| 181 | + $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 182 | + // une seule ligne dans le slogan : couper si besoin |
|
| 183 | + if (($p = strpos($slogan, '<br />')) !== false) { |
|
| 184 | + $slogan = substr($slogan, 0, $p); |
|
| 185 | + } |
|
| 186 | + // couper par securite |
|
| 187 | + $slogan = couper($slogan, 80); |
|
| 188 | + |
|
| 189 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 190 | + |
|
| 191 | + $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE))); |
|
| 192 | + |
|
| 193 | + $icon_class = 'icon'; |
|
| 194 | + $img = ''; |
|
| 195 | + if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 196 | + $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 197 | + if (!extraire_attribut($img, 'src')) { |
|
| 198 | + $img = ''; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + if (!$img) { |
|
| 202 | + $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'"); |
|
| 203 | + $icon_class .= ' no-logo'; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 207 | + |
|
| 208 | + return "<div class='resume'>" |
|
| 209 | + . "<h3><a href='$url' rel='info'>" |
|
| 210 | + . $nom |
|
| 211 | + . '</a></h3>' |
|
| 212 | + . " <span class='version'>" . $info['version'] . '</span>' |
|
| 213 | + . " <span class='etat'> - " |
|
| 214 | + . plugin_etat_en_clair($info['etat']) |
|
| 215 | + . '</span>' |
|
| 216 | + . "<div class='short'>" . $slogan . '</div>' |
|
| 217 | + . $i |
|
| 218 | + . '</div>'; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | function plugin_desintalle($plug_file, $nom, $dir_plugins = null) { |
| 222 | - if (!$dir_plugins) { |
|
| 223 | - $dir_plugins = _DIR_PLUGINS; |
|
| 224 | - } |
|
| 222 | + if (!$dir_plugins) { |
|
| 223 | + $dir_plugins = _DIR_PLUGINS; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 227 | - $text = _T('bouton_desinstaller'); |
|
| 228 | - $text2 = _T('info_desinstaller_plugin'); |
|
| 229 | - $file = basename($plug_file); |
|
| 226 | + $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 227 | + $text = _T('bouton_desinstaller'); |
|
| 228 | + $text2 = _T('info_desinstaller_plugin'); |
|
| 229 | + $file = basename($plug_file); |
|
| 230 | 230 | |
| 231 | - return "<div class='actions'>[" . |
|
| 232 | - "<a href='$action' |
|
| 231 | + return "<div class='actions'>[" . |
|
| 232 | + "<a href='$action' |
|
| 233 | 233 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 234 | - . $text |
|
| 235 | - . '</a>]</div>'; |
|
| 234 | + . $text |
|
| 235 | + . '</a>]</div>'; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -246,147 +246,147 @@ discard block |
||
| 246 | 246 | * Traduction de l'état dans la langue en cours |
| 247 | 247 | **/ |
| 248 | 248 | function plugin_etat_en_clair($etat) { |
| 249 | - if (!in_array($etat, ['stable', 'test', 'experimental'])) { |
|
| 250 | - $etat = 'developpement'; |
|
| 251 | - } |
|
| 249 | + if (!in_array($etat, ['stable', 'test', 'experimental'])) { |
|
| 250 | + $etat = 'developpement'; |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - return _T('plugin_etat_' . $etat); |
|
| 253 | + return _T('plugin_etat_' . $etat); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | // https://code.spip.net/@plugin_propre |
| 257 | 257 | function plugin_propre($texte, $module = '', $propre = 'propre') { |
| 258 | - // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 259 | - if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 260 | - $module = substr($module, strlen(_DIR_RACINE)); |
|
| 261 | - } |
|
| 262 | - if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
|
| 263 | - $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - return $propre($texte); |
|
| 258 | + // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 259 | + if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 260 | + $module = substr($module, strlen(_DIR_RACINE)); |
|
| 261 | + } |
|
| 262 | + if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
|
| 263 | + $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + return $propre($texte); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | function plugin_typo($texte, $module = '') { |
| 270 | - return plugin_propre($texte, $module, 'typo'); |
|
| 270 | + return plugin_propre($texte, $module, 'typo'); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | |
| 274 | 274 | // https://code.spip.net/@affiche_bloc_plugin |
| 275 | 275 | function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) { |
| 276 | - $log = null; |
|
| 277 | - if (!$dir_plugins) { |
|
| 278 | - $dir_plugins = _DIR_PLUGINS; |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - $prefix = $info['prefix']; |
|
| 282 | - $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 283 | - |
|
| 284 | - $s = ''; |
|
| 285 | - // TODO: le traiter_multi ici n'est pas beau |
|
| 286 | - // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 287 | - // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 288 | - $description = ''; |
|
| 289 | - if (isset($info['description'])) { |
|
| 290 | - $description = plugin_propre($info['description'], $dir); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - if ( |
|
| 294 | - isset($info['documentation']) |
|
| 295 | - and $lien = $info['documentation'] |
|
| 296 | - ) { |
|
| 297 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 298 | - } |
|
| 299 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 300 | - |
|
| 301 | - if (isset($info['auteur'])) { |
|
| 302 | - if (is_array($info['auteur'])) { |
|
| 303 | - $a = formater_credits($info['auteur'], ', '); |
|
| 304 | - } // pour compat mais ne doit plus arriver |
|
| 305 | - else { |
|
| 306 | - $a = trim($info['auteur']); |
|
| 307 | - } |
|
| 308 | - if ($a) { |
|
| 309 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 310 | - $a, |
|
| 311 | - $dir |
|
| 312 | - )) . "</dd>\n"; |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - if (isset($info['credit'])) { |
|
| 317 | - if ($a = formater_credits($info['credit'], ', ')) { |
|
| 318 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 319 | - $a, |
|
| 320 | - $dir |
|
| 321 | - )) . "</dd>\n"; |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - if (isset($info['licence'])) { |
|
| 326 | - if (is_array($info['licence'])) { |
|
| 327 | - $a = formater_credits($info['licence'], ', '); |
|
| 328 | - } // pour compat mais ne doit plus arriver |
|
| 329 | - else { |
|
| 330 | - $a = trim($info['licence']); |
|
| 331 | - } |
|
| 332 | - if ($a) { |
|
| 333 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 334 | - $a, |
|
| 335 | - $dir |
|
| 336 | - )) . "</dd>\n"; |
|
| 337 | - } |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - $s = "<dl class='description'>$s</dl>"; |
|
| 341 | - |
|
| 342 | - // |
|
| 343 | - // Ajouter les infos techniques |
|
| 344 | - // |
|
| 345 | - $infotech = []; |
|
| 346 | - |
|
| 347 | - $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 348 | - // Version VCS |
|
| 349 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 350 | - $version .= ' ' . $vcs; |
|
| 351 | - } |
|
| 352 | - $version .= '</dd>'; |
|
| 353 | - $infotech[] = $version; |
|
| 354 | - $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 355 | - // source zip le cas echeant |
|
| 356 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 357 | - and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 358 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 359 | - : ''; |
|
| 360 | - |
|
| 361 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 362 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 363 | - ' ', |
|
| 364 | - array_map('array_shift', $info['necessite']) |
|
| 365 | - ) . '</dd>'); |
|
| 366 | - |
|
| 367 | - $s .= "<dl class='tech'>" |
|
| 368 | - . join('', $infotech) |
|
| 369 | - . '</dl>'; |
|
| 370 | - |
|
| 371 | - |
|
| 372 | - return $s; |
|
| 276 | + $log = null; |
|
| 277 | + if (!$dir_plugins) { |
|
| 278 | + $dir_plugins = _DIR_PLUGINS; |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + $prefix = $info['prefix']; |
|
| 282 | + $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 283 | + |
|
| 284 | + $s = ''; |
|
| 285 | + // TODO: le traiter_multi ici n'est pas beau |
|
| 286 | + // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 287 | + // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 288 | + $description = ''; |
|
| 289 | + if (isset($info['description'])) { |
|
| 290 | + $description = plugin_propre($info['description'], $dir); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + if ( |
|
| 294 | + isset($info['documentation']) |
|
| 295 | + and $lien = $info['documentation'] |
|
| 296 | + ) { |
|
| 297 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 298 | + } |
|
| 299 | + $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 300 | + |
|
| 301 | + if (isset($info['auteur'])) { |
|
| 302 | + if (is_array($info['auteur'])) { |
|
| 303 | + $a = formater_credits($info['auteur'], ', '); |
|
| 304 | + } // pour compat mais ne doit plus arriver |
|
| 305 | + else { |
|
| 306 | + $a = trim($info['auteur']); |
|
| 307 | + } |
|
| 308 | + if ($a) { |
|
| 309 | + $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 310 | + $a, |
|
| 311 | + $dir |
|
| 312 | + )) . "</dd>\n"; |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + if (isset($info['credit'])) { |
|
| 317 | + if ($a = formater_credits($info['credit'], ', ')) { |
|
| 318 | + $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 319 | + $a, |
|
| 320 | + $dir |
|
| 321 | + )) . "</dd>\n"; |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + if (isset($info['licence'])) { |
|
| 326 | + if (is_array($info['licence'])) { |
|
| 327 | + $a = formater_credits($info['licence'], ', '); |
|
| 328 | + } // pour compat mais ne doit plus arriver |
|
| 329 | + else { |
|
| 330 | + $a = trim($info['licence']); |
|
| 331 | + } |
|
| 332 | + if ($a) { |
|
| 333 | + $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 334 | + $a, |
|
| 335 | + $dir |
|
| 336 | + )) . "</dd>\n"; |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + $s = "<dl class='description'>$s</dl>"; |
|
| 341 | + |
|
| 342 | + // |
|
| 343 | + // Ajouter les infos techniques |
|
| 344 | + // |
|
| 345 | + $infotech = []; |
|
| 346 | + |
|
| 347 | + $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 348 | + // Version VCS |
|
| 349 | + if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 350 | + $version .= ' ' . $vcs; |
|
| 351 | + } |
|
| 352 | + $version .= '</dd>'; |
|
| 353 | + $infotech[] = $version; |
|
| 354 | + $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 355 | + // source zip le cas echeant |
|
| 356 | + $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 357 | + and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 358 | + ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 359 | + : ''; |
|
| 360 | + |
|
| 361 | + $infotech[] = !$info['necessite'] ? '' : |
|
| 362 | + ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 363 | + ' ', |
|
| 364 | + array_map('array_shift', $info['necessite']) |
|
| 365 | + ) . '</dd>'); |
|
| 366 | + |
|
| 367 | + $s .= "<dl class='tech'>" |
|
| 368 | + . join('', $infotech) |
|
| 369 | + . '</dl>'; |
|
| 370 | + |
|
| 371 | + |
|
| 372 | + return $s; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | function formater_credits($infos, $sep = ', ') { |
| 376 | - $texte = ''; |
|
| 377 | - |
|
| 378 | - foreach ($infos as $_credit) { |
|
| 379 | - if ($texte) { |
|
| 380 | - $texte .= $sep; |
|
| 381 | - } |
|
| 382 | - // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 383 | - $texte .= |
|
| 384 | - (!is_array($_credit)) |
|
| 385 | - ? PtoBR(propre($_credit)) |
|
| 386 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 387 | - $_credit['nom'] . |
|
| 388 | - ($_credit['url'] ? '</a>' : ''); |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - return $texte; |
|
| 376 | + $texte = ''; |
|
| 377 | + |
|
| 378 | + foreach ($infos as $_credit) { |
|
| 379 | + if ($texte) { |
|
| 380 | + $texte .= $sep; |
|
| 381 | + } |
|
| 382 | + // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 383 | + $texte .= |
|
| 384 | + (!is_array($_credit)) |
|
| 385 | + ? PtoBR(propre($_credit)) |
|
| 386 | + : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 387 | + $_credit['nom'] . |
|
| 388 | + ($_credit['url'] ? '</a>' : ''); |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + return $texte; |
|
| 392 | 392 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -54,96 +54,96 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function plugins_installer_dist($plug, $action, $dir_type = '_DIR_PLUGINS') { |
| 56 | 56 | |
| 57 | - // Charger les informations du XML du plugin et vérification de l'existence d'une installation |
|
| 58 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 59 | - $infos = $get_infos($plug, false, constant($dir_type)); |
|
| 60 | - if (!isset($infos['install']) or !$infos['install']) { |
|
| 61 | - return false; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - // Passer en chemin absolu si possible, c'est plus efficace |
|
| 65 | - $dir = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 66 | - if (!defined($dir)) { |
|
| 67 | - $dir = $dir_type; |
|
| 68 | - } |
|
| 69 | - $dir = constant($dir); |
|
| 70 | - foreach ($infos['install'] as $file) { |
|
| 71 | - $file = $dir . $plug . '/' . trim($file); |
|
| 72 | - if (file_exists($file)) { |
|
| 73 | - include_once($file); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // Détermination de la table meta et du nom de la meta plugin |
|
| 78 | - $table = 'meta'; |
|
| 79 | - if (isset($infos['meta']) and ($infos['meta'] !== 'meta')) { |
|
| 80 | - $table = $infos['meta']; |
|
| 81 | - // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
|
| 82 | - lire_metas($table); |
|
| 83 | - } |
|
| 84 | - $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 85 | - |
|
| 86 | - // Détermination de la fonction à appeler et de ses arguments |
|
| 87 | - $f = $infos['prefix'] . '_install'; |
|
| 88 | - if (!function_exists($f)) { |
|
| 89 | - $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
|
| 90 | - $arg = $infos; |
|
| 91 | - // On passe la table et la meta pour éviter de les recalculer dans la fonction appelée |
|
| 92 | - $arg['meta'] = $table; |
|
| 93 | - $arg['nom_meta'] = $nom_meta; |
|
| 94 | - } else { |
|
| 95 | - // Ancienne méthode d'installation - TODO à supprimer à terme |
|
| 96 | - // stupide: info deja dans le nom |
|
| 97 | - $arg = $infos['prefix']; |
|
| 98 | - } |
|
| 99 | - $version = $infos['schema'] ?? ''; |
|
| 100 | - |
|
| 101 | - if (!$f) { |
|
| 102 | - // installation sans operation particuliere |
|
| 103 | - $infos['install_test'] = [true, '']; |
|
| 104 | - return $infos; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // Tester si l'action demandée est nécessaire ou pas. |
|
| 108 | - $test = $f('test', $arg, $version); |
|
| 109 | - if ($action == 'uninstall') { |
|
| 110 | - $test = !$test; |
|
| 111 | - } |
|
| 112 | - // Si deja fait, on ne fait rien et on ne dit rien |
|
| 113 | - if ($test) { |
|
| 114 | - return true; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - // Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos |
|
| 118 | - // pour renvoyer le bon message en retour de la fonction. |
|
| 119 | - if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) { |
|
| 120 | - $infos['upgrade'] = true; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // executer l'installation ou l'inverse |
|
| 124 | - // et renvoyer la trace (mais il faudrait passer en AJAX plutot) |
|
| 125 | - ob_start(); |
|
| 126 | - $f($action, $arg, $version); |
|
| 127 | - $aff = ob_get_contents(); |
|
| 128 | - ob_end_clean(); |
|
| 129 | - |
|
| 130 | - // vider le cache des descriptions de tables a chaque (de)installation |
|
| 131 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 132 | - $trouver_table(''); |
|
| 133 | - $infos['install_test'] = [$f('test', $arg, $version), $aff]; |
|
| 134 | - |
|
| 135 | - // Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin |
|
| 136 | - // on force la création du fichier cache à la date du moment. |
|
| 137 | - // On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta. |
|
| 138 | - if ( |
|
| 139 | - ($table !== 'meta') |
|
| 140 | - and ($action == 'install') |
|
| 141 | - and empty($infos['upgrade']) |
|
| 142 | - ) { |
|
| 143 | - touch_meta(false, $table); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return $infos; |
|
| 57 | + // Charger les informations du XML du plugin et vérification de l'existence d'une installation |
|
| 58 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 59 | + $infos = $get_infos($plug, false, constant($dir_type)); |
|
| 60 | + if (!isset($infos['install']) or !$infos['install']) { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + // Passer en chemin absolu si possible, c'est plus efficace |
|
| 65 | + $dir = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 66 | + if (!defined($dir)) { |
|
| 67 | + $dir = $dir_type; |
|
| 68 | + } |
|
| 69 | + $dir = constant($dir); |
|
| 70 | + foreach ($infos['install'] as $file) { |
|
| 71 | + $file = $dir . $plug . '/' . trim($file); |
|
| 72 | + if (file_exists($file)) { |
|
| 73 | + include_once($file); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // Détermination de la table meta et du nom de la meta plugin |
|
| 78 | + $table = 'meta'; |
|
| 79 | + if (isset($infos['meta']) and ($infos['meta'] !== 'meta')) { |
|
| 80 | + $table = $infos['meta']; |
|
| 81 | + // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
|
| 82 | + lire_metas($table); |
|
| 83 | + } |
|
| 84 | + $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 85 | + |
|
| 86 | + // Détermination de la fonction à appeler et de ses arguments |
|
| 87 | + $f = $infos['prefix'] . '_install'; |
|
| 88 | + if (!function_exists($f)) { |
|
| 89 | + $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
|
| 90 | + $arg = $infos; |
|
| 91 | + // On passe la table et la meta pour éviter de les recalculer dans la fonction appelée |
|
| 92 | + $arg['meta'] = $table; |
|
| 93 | + $arg['nom_meta'] = $nom_meta; |
|
| 94 | + } else { |
|
| 95 | + // Ancienne méthode d'installation - TODO à supprimer à terme |
|
| 96 | + // stupide: info deja dans le nom |
|
| 97 | + $arg = $infos['prefix']; |
|
| 98 | + } |
|
| 99 | + $version = $infos['schema'] ?? ''; |
|
| 100 | + |
|
| 101 | + if (!$f) { |
|
| 102 | + // installation sans operation particuliere |
|
| 103 | + $infos['install_test'] = [true, '']; |
|
| 104 | + return $infos; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // Tester si l'action demandée est nécessaire ou pas. |
|
| 108 | + $test = $f('test', $arg, $version); |
|
| 109 | + if ($action == 'uninstall') { |
|
| 110 | + $test = !$test; |
|
| 111 | + } |
|
| 112 | + // Si deja fait, on ne fait rien et on ne dit rien |
|
| 113 | + if ($test) { |
|
| 114 | + return true; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + // Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos |
|
| 118 | + // pour renvoyer le bon message en retour de la fonction. |
|
| 119 | + if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) { |
|
| 120 | + $infos['upgrade'] = true; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // executer l'installation ou l'inverse |
|
| 124 | + // et renvoyer la trace (mais il faudrait passer en AJAX plutot) |
|
| 125 | + ob_start(); |
|
| 126 | + $f($action, $arg, $version); |
|
| 127 | + $aff = ob_get_contents(); |
|
| 128 | + ob_end_clean(); |
|
| 129 | + |
|
| 130 | + // vider le cache des descriptions de tables a chaque (de)installation |
|
| 131 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 132 | + $trouver_table(''); |
|
| 133 | + $infos['install_test'] = [$f('test', $arg, $version), $aff]; |
|
| 134 | + |
|
| 135 | + // Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin |
|
| 136 | + // on force la création du fichier cache à la date du moment. |
|
| 137 | + // On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta. |
|
| 138 | + if ( |
|
| 139 | + ($table !== 'meta') |
|
| 140 | + and ($action == 'install') |
|
| 141 | + and empty($infos['upgrade']) |
|
| 142 | + ) { |
|
| 143 | + touch_meta(false, $table); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return $infos; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -159,25 +159,25 @@ discard block |
||
| 159 | 159 | * @return bool|void |
| 160 | 160 | */ |
| 161 | 161 | function spip_plugin_install($action, $infos, $version_cible) { |
| 162 | - $nom_meta = $infos['nom_meta']; |
|
| 163 | - $table = $infos['meta']; |
|
| 164 | - switch ($action) { |
|
| 165 | - case 'test': |
|
| 166 | - return (isset($GLOBALS[$table]) |
|
| 167 | - and isset($GLOBALS[$table][$nom_meta]) |
|
| 168 | - and spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
|
| 169 | - break; |
|
| 170 | - case 'install': |
|
| 171 | - if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 172 | - $upgrade($nom_meta, $version_cible, $table); |
|
| 173 | - } |
|
| 174 | - break; |
|
| 175 | - case 'uninstall': |
|
| 176 | - if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 177 | - $vider_tables($nom_meta, $table); |
|
| 178 | - } |
|
| 179 | - break; |
|
| 180 | - } |
|
| 162 | + $nom_meta = $infos['nom_meta']; |
|
| 163 | + $table = $infos['meta']; |
|
| 164 | + switch ($action) { |
|
| 165 | + case 'test': |
|
| 166 | + return (isset($GLOBALS[$table]) |
|
| 167 | + and isset($GLOBALS[$table][$nom_meta]) |
|
| 168 | + and spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
|
| 169 | + break; |
|
| 170 | + case 'install': |
|
| 171 | + if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 172 | + $upgrade($nom_meta, $version_cible, $table); |
|
| 173 | + } |
|
| 174 | + break; |
|
| 175 | + case 'uninstall': |
|
| 176 | + if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 177 | + $vider_tables($nom_meta, $table); |
|
| 178 | + } |
|
| 179 | + break; |
|
| 180 | + } |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
@@ -196,29 +196,29 @@ discard block |
||
| 196 | 196 | * @return array Tableau des plugins actifs |
| 197 | 197 | **/ |
| 198 | 198 | function liste_plugin_actifs() { |
| 199 | - $liste = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 200 | - if (!$liste) { |
|
| 201 | - return []; |
|
| 202 | - } |
|
| 203 | - if (!is_array($liste = unserialize($liste))) { |
|
| 204 | - // compatibilite pre 1.9.2, mettre a jour la meta |
|
| 205 | - spip_log("MAJ meta plugin vieille version : $liste", 'plugin'); |
|
| 206 | - $new = true; |
|
| 207 | - [, $liste] = liste_plugin_valides(explode(',', $liste)); |
|
| 208 | - } else { |
|
| 209 | - $new = false; |
|
| 210 | - // compat au moment d'une migration depuis version anterieure |
|
| 211 | - // si pas de dir_type, alors c'est _DIR_PLUGINS |
|
| 212 | - foreach ($liste as $prefix => $infos) { |
|
| 213 | - if (!isset($infos['dir_type'])) { |
|
| 214 | - $liste[$prefix]['dir_type'] = '_DIR_PLUGINS'; |
|
| 215 | - $new = true; |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - if ($new) { |
|
| 220 | - ecrire_meta('plugin', serialize($liste)); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - return $liste; |
|
| 199 | + $liste = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 200 | + if (!$liste) { |
|
| 201 | + return []; |
|
| 202 | + } |
|
| 203 | + if (!is_array($liste = unserialize($liste))) { |
|
| 204 | + // compatibilite pre 1.9.2, mettre a jour la meta |
|
| 205 | + spip_log("MAJ meta plugin vieille version : $liste", 'plugin'); |
|
| 206 | + $new = true; |
|
| 207 | + [, $liste] = liste_plugin_valides(explode(',', $liste)); |
|
| 208 | + } else { |
|
| 209 | + $new = false; |
|
| 210 | + // compat au moment d'une migration depuis version anterieure |
|
| 211 | + // si pas de dir_type, alors c'est _DIR_PLUGINS |
|
| 212 | + foreach ($liste as $prefix => $infos) { |
|
| 213 | + if (!isset($infos['dir_type'])) { |
|
| 214 | + $liste[$prefix]['dir_type'] = '_DIR_PLUGINS'; |
|
| 215 | + $new = true; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + if ($new) { |
|
| 220 | + ecrire_meta('plugin', serialize($liste)); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + return $liste; |
|
| 224 | 224 | } |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | * @package SPIP\Core\SQL\Upgrade |
| 20 | 20 | **/ |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | $GLOBALS['maj'][2021_02_18_00] = [ |
| 26 | - ['sql_alter', "TABLE spip_auteurs CHANGE imessage imessage VARCHAR(3) DEFAULT '' NOT NULL" ], |
|
| 27 | - ['sql_updateq', 'spip_auteurs', ['imessage' => 'oui'], "imessage != 'non' OR imessage IS NULL" ], |
|
| 26 | + ['sql_alter', "TABLE spip_auteurs CHANGE imessage imessage VARCHAR(3) DEFAULT '' NOT NULL" ], |
|
| 27 | + ['sql_updateq', 'spip_auteurs', ['imessage' => 'oui'], "imessage != 'non' OR imessage IS NULL" ], |
|
| 28 | 28 | ]; |
@@ -18,18 +18,18 @@ discard block |
||
| 18 | 18 | * @package SPIP\Core\SQL\Upgrade |
| 19 | 19 | **/ |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | $GLOBALS['maj'][16428] = [ |
| 26 | - ['maj_liens', 'auteur'], // creer la table liens |
|
| 27 | - ['maj_liens', 'auteur', 'article'], |
|
| 28 | - ['sql_drop_table', 'spip_auteurs_articles'], |
|
| 29 | - ['maj_liens', 'auteur', 'rubrique'], |
|
| 30 | - ['sql_drop_table', 'spip_auteurs_rubriques'], |
|
| 31 | - ['maj_liens', 'auteur', 'message'], |
|
| 32 | - ['sql_drop_table', 'spip_auteurs_messages'], |
|
| 26 | + ['maj_liens', 'auteur'], // creer la table liens |
|
| 27 | + ['maj_liens', 'auteur', 'article'], |
|
| 28 | + ['sql_drop_table', 'spip_auteurs_articles'], |
|
| 29 | + ['maj_liens', 'auteur', 'rubrique'], |
|
| 30 | + ['sql_drop_table', 'spip_auteurs_rubriques'], |
|
| 31 | + ['maj_liens', 'auteur', 'message'], |
|
| 32 | + ['sql_drop_table', 'spip_auteurs_messages'], |
|
| 33 | 33 | ]; |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -55,89 +55,89 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | function maj_liens($pivot, $l = '') { |
| 57 | 57 | |
| 58 | - @define('_LOG_FILTRE_GRAVITE', 8); |
|
| 59 | - |
|
| 60 | - $exceptions_pluriel = ['forum' => 'forum', 'syndic' => 'syndic']; |
|
| 61 | - |
|
| 62 | - $pivot = preg_replace(',[^\w],', '', $pivot); // securite |
|
| 63 | - $pivots = ($exceptions_pluriel[$pivot] ?? $pivot . 's'); |
|
| 64 | - $liens = 'spip_' . $pivots . '_liens'; |
|
| 65 | - $id_pivot = 'id_' . $pivot; |
|
| 66 | - // Creer spip_auteurs_liens |
|
| 67 | - global $tables_auxiliaires; |
|
| 68 | - if (!$l) { |
|
| 69 | - include_spip('base/auxiliaires'); |
|
| 70 | - include_spip('base/create'); |
|
| 71 | - creer_ou_upgrader_table($liens, $tables_auxiliaires[$liens], false); |
|
| 72 | - } else { |
|
| 73 | - // Preparer |
|
| 74 | - $l = preg_replace(',[^\w],', '', $l); // securite |
|
| 75 | - $primary = "id_$l"; |
|
| 76 | - $objet = ($l == 'syndic' ? 'site' : $l); |
|
| 77 | - $ls = ($exceptions_pluriel[$l] ?? $l . 's'); |
|
| 78 | - $ancienne_table = 'spip_' . $pivots . '_' . $ls; |
|
| 79 | - $pool = 400; |
|
| 80 | - |
|
| 81 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 82 | - if (!$desc = $trouver_table($ancienne_table)) { |
|
| 83 | - return; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - // securite pour ne pas perdre de donnees |
|
| 87 | - if (!$trouver_table($liens)) { |
|
| 88 | - return; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $champs = $desc['field']; |
|
| 92 | - if (isset($champs['maj'])) { |
|
| 93 | - unset($champs['maj']); |
|
| 94 | - } |
|
| 95 | - if (isset($champs[$primary])) { |
|
| 96 | - unset($champs[$primary]); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $champs = array_keys($champs); |
|
| 100 | - // ne garder que les champs qui existent sur la table destination |
|
| 101 | - if ($desc_cible = $trouver_table($liens)) { |
|
| 102 | - $champs = array_intersect($champs, array_keys($desc_cible['field'])); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $champs[] = "$primary as id_objet"; |
|
| 106 | - $champs[] = "'$objet' as objet"; |
|
| 107 | - $champs = implode(', ', $champs); |
|
| 108 | - |
|
| 109 | - // Recopier les donnees |
|
| 110 | - $sub_pool = 100; |
|
| 111 | - while ($ids = array_map('reset', sql_allfetsel("$primary", $ancienne_table, '', '', '', "0,$sub_pool"))) { |
|
| 112 | - $insert = []; |
|
| 113 | - foreach ($ids as $id) { |
|
| 114 | - $n = sql_countsel($liens, "objet='$objet' AND id_objet=" . intval($id)); |
|
| 115 | - while ($t = sql_allfetsel($champs, $ancienne_table, "$primary=" . intval($id), '', $id_pivot, "$n,$pool")) { |
|
| 116 | - $n += is_countable($t) ? count($t) : 0; |
|
| 117 | - // empiler en s'assurant a minima de l'unicite |
|
| 118 | - while ($r = array_shift($t)) { |
|
| 119 | - $insert[$r[$id_pivot] . ':' . $r['id_objet']] = $r; |
|
| 120 | - } |
|
| 121 | - if (count($insert) >= $sub_pool) { |
|
| 122 | - maj_liens_insertq_multi_check($liens, $insert, $tables_auxiliaires[$liens]); |
|
| 123 | - $insert = []; |
|
| 124 | - } |
|
| 125 | - // si timeout, sortir, la relance nous ramenera dans cette fonction |
|
| 126 | - // et on verifiera/repartira de la |
|
| 127 | - if (time() >= _TIME_OUT) { |
|
| 128 | - return; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - if (time() >= _TIME_OUT) { |
|
| 132 | - return; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - if (count($insert)) { |
|
| 136 | - maj_liens_insertq_multi_check($liens, $insert, $tables_auxiliaires[$liens]); |
|
| 137 | - } |
|
| 138 | - sql_delete($ancienne_table, sql_in($primary, $ids)); |
|
| 139 | - } |
|
| 140 | - } |
|
| 58 | + @define('_LOG_FILTRE_GRAVITE', 8); |
|
| 59 | + |
|
| 60 | + $exceptions_pluriel = ['forum' => 'forum', 'syndic' => 'syndic']; |
|
| 61 | + |
|
| 62 | + $pivot = preg_replace(',[^\w],', '', $pivot); // securite |
|
| 63 | + $pivots = ($exceptions_pluriel[$pivot] ?? $pivot . 's'); |
|
| 64 | + $liens = 'spip_' . $pivots . '_liens'; |
|
| 65 | + $id_pivot = 'id_' . $pivot; |
|
| 66 | + // Creer spip_auteurs_liens |
|
| 67 | + global $tables_auxiliaires; |
|
| 68 | + if (!$l) { |
|
| 69 | + include_spip('base/auxiliaires'); |
|
| 70 | + include_spip('base/create'); |
|
| 71 | + creer_ou_upgrader_table($liens, $tables_auxiliaires[$liens], false); |
|
| 72 | + } else { |
|
| 73 | + // Preparer |
|
| 74 | + $l = preg_replace(',[^\w],', '', $l); // securite |
|
| 75 | + $primary = "id_$l"; |
|
| 76 | + $objet = ($l == 'syndic' ? 'site' : $l); |
|
| 77 | + $ls = ($exceptions_pluriel[$l] ?? $l . 's'); |
|
| 78 | + $ancienne_table = 'spip_' . $pivots . '_' . $ls; |
|
| 79 | + $pool = 400; |
|
| 80 | + |
|
| 81 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 82 | + if (!$desc = $trouver_table($ancienne_table)) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + // securite pour ne pas perdre de donnees |
|
| 87 | + if (!$trouver_table($liens)) { |
|
| 88 | + return; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $champs = $desc['field']; |
|
| 92 | + if (isset($champs['maj'])) { |
|
| 93 | + unset($champs['maj']); |
|
| 94 | + } |
|
| 95 | + if (isset($champs[$primary])) { |
|
| 96 | + unset($champs[$primary]); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $champs = array_keys($champs); |
|
| 100 | + // ne garder que les champs qui existent sur la table destination |
|
| 101 | + if ($desc_cible = $trouver_table($liens)) { |
|
| 102 | + $champs = array_intersect($champs, array_keys($desc_cible['field'])); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $champs[] = "$primary as id_objet"; |
|
| 106 | + $champs[] = "'$objet' as objet"; |
|
| 107 | + $champs = implode(', ', $champs); |
|
| 108 | + |
|
| 109 | + // Recopier les donnees |
|
| 110 | + $sub_pool = 100; |
|
| 111 | + while ($ids = array_map('reset', sql_allfetsel("$primary", $ancienne_table, '', '', '', "0,$sub_pool"))) { |
|
| 112 | + $insert = []; |
|
| 113 | + foreach ($ids as $id) { |
|
| 114 | + $n = sql_countsel($liens, "objet='$objet' AND id_objet=" . intval($id)); |
|
| 115 | + while ($t = sql_allfetsel($champs, $ancienne_table, "$primary=" . intval($id), '', $id_pivot, "$n,$pool")) { |
|
| 116 | + $n += is_countable($t) ? count($t) : 0; |
|
| 117 | + // empiler en s'assurant a minima de l'unicite |
|
| 118 | + while ($r = array_shift($t)) { |
|
| 119 | + $insert[$r[$id_pivot] . ':' . $r['id_objet']] = $r; |
|
| 120 | + } |
|
| 121 | + if (count($insert) >= $sub_pool) { |
|
| 122 | + maj_liens_insertq_multi_check($liens, $insert, $tables_auxiliaires[$liens]); |
|
| 123 | + $insert = []; |
|
| 124 | + } |
|
| 125 | + // si timeout, sortir, la relance nous ramenera dans cette fonction |
|
| 126 | + // et on verifiera/repartira de la |
|
| 127 | + if (time() >= _TIME_OUT) { |
|
| 128 | + return; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + if (time() >= _TIME_OUT) { |
|
| 132 | + return; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + if (count($insert)) { |
|
| 136 | + maj_liens_insertq_multi_check($liens, $insert, $tables_auxiliaires[$liens]); |
|
| 137 | + } |
|
| 138 | + sql_delete($ancienne_table, sql_in($primary, $ids)); |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -151,86 +151,86 @@ discard block |
||
| 151 | 151 | * @return void |
| 152 | 152 | **/ |
| 153 | 153 | function maj_liens_insertq_multi_check($table, $couples, $desc = []) { |
| 154 | - $n_before = sql_countsel($table); |
|
| 155 | - sql_insertq_multi($table, $couples, $desc); |
|
| 156 | - $n_after = sql_countsel($table); |
|
| 157 | - if (($n_after - $n_before) == count($couples)) { |
|
| 158 | - return; |
|
| 159 | - } |
|
| 160 | - // si ecart, on recommence l'insertion ligne par ligne... |
|
| 161 | - // moins rapide mais secure : seul le couple en doublon echouera, et non toute la serie |
|
| 162 | - foreach ($couples as $c) { |
|
| 163 | - sql_insertq($table, $c, $desc); |
|
| 164 | - } |
|
| 154 | + $n_before = sql_countsel($table); |
|
| 155 | + sql_insertq_multi($table, $couples, $desc); |
|
| 156 | + $n_after = sql_countsel($table); |
|
| 157 | + if (($n_after - $n_before) == count($couples)) { |
|
| 158 | + return; |
|
| 159 | + } |
|
| 160 | + // si ecart, on recommence l'insertion ligne par ligne... |
|
| 161 | + // moins rapide mais secure : seul le couple en doublon echouera, et non toute la serie |
|
| 162 | + foreach ($couples as $c) { |
|
| 163 | + sql_insertq($table, $c, $desc); |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $GLOBALS['maj'][17311] = [ |
| 168 | - [ |
|
| 169 | - 'ecrire_meta', |
|
| 170 | - 'multi_objets', |
|
| 171 | - implode( |
|
| 172 | - ',', |
|
| 173 | - array_diff( |
|
| 174 | - [ |
|
| 175 | - (isset($GLOBALS['meta']['multi_rubriques']) and $GLOBALS['meta']['multi_rubriques'] == 'oui') |
|
| 176 | - ? 'spip_rubriques' : '', |
|
| 177 | - (isset($GLOBALS['meta']['multi_articles']) and $GLOBALS['meta']['multi_articles'] == 'oui') |
|
| 178 | - ? 'spip_articles' : '' |
|
| 179 | - ], |
|
| 180 | - [''] |
|
| 181 | - ) |
|
| 182 | - ) |
|
| 183 | - ], |
|
| 184 | - [ |
|
| 185 | - 'ecrire_meta', |
|
| 186 | - 'gerer_trad_objets', |
|
| 187 | - implode( |
|
| 188 | - ',', |
|
| 189 | - array_diff( |
|
| 190 | - [ |
|
| 191 | - (isset($GLOBALS['meta']['gerer_trad']) and $GLOBALS['meta']['gerer_trad'] == 'oui') |
|
| 192 | - ? 'spip_articles' : '' |
|
| 193 | - ], |
|
| 194 | - [''] |
|
| 195 | - ) |
|
| 196 | - ) |
|
| 197 | - ], |
|
| 168 | + [ |
|
| 169 | + 'ecrire_meta', |
|
| 170 | + 'multi_objets', |
|
| 171 | + implode( |
|
| 172 | + ',', |
|
| 173 | + array_diff( |
|
| 174 | + [ |
|
| 175 | + (isset($GLOBALS['meta']['multi_rubriques']) and $GLOBALS['meta']['multi_rubriques'] == 'oui') |
|
| 176 | + ? 'spip_rubriques' : '', |
|
| 177 | + (isset($GLOBALS['meta']['multi_articles']) and $GLOBALS['meta']['multi_articles'] == 'oui') |
|
| 178 | + ? 'spip_articles' : '' |
|
| 179 | + ], |
|
| 180 | + [''] |
|
| 181 | + ) |
|
| 182 | + ) |
|
| 183 | + ], |
|
| 184 | + [ |
|
| 185 | + 'ecrire_meta', |
|
| 186 | + 'gerer_trad_objets', |
|
| 187 | + implode( |
|
| 188 | + ',', |
|
| 189 | + array_diff( |
|
| 190 | + [ |
|
| 191 | + (isset($GLOBALS['meta']['gerer_trad']) and $GLOBALS['meta']['gerer_trad'] == 'oui') |
|
| 192 | + ? 'spip_articles' : '' |
|
| 193 | + ], |
|
| 194 | + [''] |
|
| 195 | + ) |
|
| 196 | + ) |
|
| 197 | + ], |
|
| 198 | 198 | ]; |
| 199 | 199 | $GLOBALS['maj'][17555] = [ |
| 200 | - ['sql_alter', "TABLE spip_resultats ADD table_objet varchar(30) DEFAULT '' NOT NULL"], |
|
| 201 | - ['sql_alter', "TABLE spip_resultats ADD serveur char(16) DEFAULT '' NOT NULL"], |
|
| 200 | + ['sql_alter', "TABLE spip_resultats ADD table_objet varchar(30) DEFAULT '' NOT NULL"], |
|
| 201 | + ['sql_alter', "TABLE spip_resultats ADD serveur char(16) DEFAULT '' NOT NULL"], |
|
| 202 | 202 | ]; |
| 203 | 203 | |
| 204 | 204 | $GLOBALS['maj'][17563] = [ |
| 205 | - ['sql_alter', "TABLE spip_articles ADD virtuel VARCHAR(255) DEFAULT '' NOT NULL"], |
|
| 206 | - ['sql_update', 'spip_articles', ['virtuel' => 'SUBSTRING(chapo,2)', 'chapo' => "''"], "chapo LIKE '=_%'"], |
|
| 205 | + ['sql_alter', "TABLE spip_articles ADD virtuel VARCHAR(255) DEFAULT '' NOT NULL"], |
|
| 206 | + ['sql_update', 'spip_articles', ['virtuel' => 'SUBSTRING(chapo,2)', 'chapo' => "''"], "chapo LIKE '=_%'"], |
|
| 207 | 207 | ]; |
| 208 | 208 | |
| 209 | 209 | $GLOBALS['maj'][17577] = [ |
| 210 | - ['maj_tables', ['spip_jobs', 'spip_jobs_liens']], |
|
| 210 | + ['maj_tables', ['spip_jobs', 'spip_jobs_liens']], |
|
| 211 | 211 | ]; |
| 212 | 212 | |
| 213 | 213 | $GLOBALS['maj'][17743] = [ |
| 214 | - ['sql_update', 'spip_auteurs', ['prefs' => 'bio', 'bio' => "''"], "statut='nouveau' AND bio<>''"], |
|
| 214 | + ['sql_update', 'spip_auteurs', ['prefs' => 'bio', 'bio' => "''"], "statut='nouveau' AND bio<>''"], |
|
| 215 | 215 | ]; |
| 216 | 216 | |
| 217 | 217 | $GLOBALS['maj'][18219] = [ |
| 218 | - ['sql_alter', 'TABLE spip_rubriques DROP id_import'], |
|
| 219 | - ['sql_alter', 'TABLE spip_rubriques DROP export'], |
|
| 218 | + ['sql_alter', 'TABLE spip_rubriques DROP id_import'], |
|
| 219 | + ['sql_alter', 'TABLE spip_rubriques DROP export'], |
|
| 220 | 220 | ]; |
| 221 | 221 | |
| 222 | 222 | $GLOBALS['maj'][18310] = [ |
| 223 | - ['sql_alter', "TABLE spip_auteurs_liens CHANGE vu vu VARCHAR(6) DEFAULT 'non' NOT NULL"], |
|
| 223 | + ['sql_alter', "TABLE spip_auteurs_liens CHANGE vu vu VARCHAR(6) DEFAULT 'non' NOT NULL"], |
|
| 224 | 224 | ]; |
| 225 | 225 | |
| 226 | 226 | $GLOBALS['maj'][18597] = [ |
| 227 | - ['sql_alter', "TABLE spip_rubriques ADD profondeur smallint(5) DEFAULT '0' NOT NULL"], |
|
| 228 | - ['maj_propager_les_secteurs'], |
|
| 227 | + ['sql_alter', "TABLE spip_rubriques ADD profondeur smallint(5) DEFAULT '0' NOT NULL"], |
|
| 228 | + ['maj_propager_les_secteurs'], |
|
| 229 | 229 | ]; |
| 230 | 230 | |
| 231 | 231 | $GLOBALS['maj'][18955] = [ |
| 232 | - ['sql_alter', 'TABLE spip_auteurs_liens ADD INDEX id_objet (id_objet)'], |
|
| 233 | - ['sql_alter', 'TABLE spip_auteurs_liens ADD INDEX objet (objet)'], |
|
| 232 | + ['sql_alter', 'TABLE spip_auteurs_liens ADD INDEX id_objet (id_objet)'], |
|
| 233 | + ['sql_alter', 'TABLE spip_auteurs_liens ADD INDEX objet (objet)'], |
|
| 234 | 234 | ]; |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | * @uses propager_les_secteurs() |
| 240 | 240 | **/ |
| 241 | 241 | function maj_propager_les_secteurs() { |
| 242 | - include_spip('inc/rubriques'); |
|
| 243 | - propager_les_secteurs(); |
|
| 242 | + include_spip('inc/rubriques'); |
|
| 243 | + propager_les_secteurs(); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -253,87 +253,87 @@ discard block |
||
| 253 | 253 | function maj_collation_sqlite() { |
| 254 | 254 | |
| 255 | 255 | |
| 256 | - include_spip('base/dump'); |
|
| 257 | - $tables = base_lister_toutes_tables(); |
|
| 258 | - |
|
| 259 | - // rien a faire si base non sqlite |
|
| 260 | - if (strncmp($GLOBALS['connexions'][0]['type'], 'sqlite', 6) !== 0) { |
|
| 261 | - return; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 265 | - // forcer le vidage de cache |
|
| 266 | - $trouver_table(''); |
|
| 267 | - |
|
| 268 | - // cas particulier spip_auteurs : retablir le collate binary sur le login |
|
| 269 | - $desc = $trouver_table('spip_auteurs'); |
|
| 270 | - spip_log('spip_auteurs : ' . var_export($desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 271 | - if (stripos($desc['field']['login'], 'BINARY') === false) { |
|
| 272 | - spip_log('Retablir champ login BINARY sur table spip_auteurs', 'maj'); |
|
| 273 | - sql_alter('table spip_auteurs change login login VARCHAR(255) BINARY'); |
|
| 274 | - $trouver_table(''); |
|
| 275 | - $new_desc = $trouver_table('spip_auteurs'); |
|
| 276 | - spip_log('Apres conversion spip_auteurs : ' . var_export($new_desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - foreach ($tables as $table) { |
|
| 280 | - if (time() >= _TIME_OUT) { |
|
| 281 | - return; |
|
| 282 | - } |
|
| 283 | - if ($desc = $trouver_table($table)) { |
|
| 284 | - $desc_collate = _sqlite_remplacements_definitions_table($desc['field']); |
|
| 285 | - if ($d = array_diff($desc['field'], $desc_collate)) { |
|
| 286 | - spip_log("Table $table COLLATE incorrects", 'maj'); |
|
| 287 | - |
|
| 288 | - // cas particulier spip_urls : |
|
| 289 | - // supprimer les doublons avant conversion sinon echec (on garde les urls les plus recentes) |
|
| 290 | - if ($table == 'spip_urls') { |
|
| 291 | - // par date DESC pour conserver les urls les plus recentes |
|
| 292 | - $data = sql_allfetsel('*', 'spip_urls', '', '', 'date DESC'); |
|
| 293 | - $urls = []; |
|
| 294 | - foreach ($data as $d) { |
|
| 295 | - $key = $d['id_parent'] . '::' . strtolower($d['url']); |
|
| 296 | - if (!isset($urls[$key])) { |
|
| 297 | - $urls[$key] = true; |
|
| 298 | - } else { |
|
| 299 | - spip_log( |
|
| 300 | - 'Suppression doublon dans spip_urls avant conversion : ' . serialize($d), |
|
| 301 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 302 | - ); |
|
| 303 | - sql_delete('spip_urls', 'id_parent=' . sql_quote($d['id_parent']) . ' AND url=' . sql_quote($d['url'])); |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - foreach ($desc['field'] as $field => $type) { |
|
| 308 | - if ($desc['field'][$field] !== $desc_collate[$field]) { |
|
| 309 | - spip_log("Conversion COLLATE table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 310 | - sql_alter("table $table change $field $field " . $desc_collate[$field]); |
|
| 311 | - $trouver_table(''); |
|
| 312 | - $new_desc = $trouver_table($table); |
|
| 313 | - spip_log( |
|
| 314 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 315 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 316 | - ); |
|
| 317 | - continue 2; // inutile de continuer pour cette table : un seul alter remet tout a jour en sqlite |
|
| 318 | - } |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - // forcer le vidage de cache |
|
| 325 | - $trouver_table(''); |
|
| 256 | + include_spip('base/dump'); |
|
| 257 | + $tables = base_lister_toutes_tables(); |
|
| 258 | + |
|
| 259 | + // rien a faire si base non sqlite |
|
| 260 | + if (strncmp($GLOBALS['connexions'][0]['type'], 'sqlite', 6) !== 0) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 265 | + // forcer le vidage de cache |
|
| 266 | + $trouver_table(''); |
|
| 267 | + |
|
| 268 | + // cas particulier spip_auteurs : retablir le collate binary sur le login |
|
| 269 | + $desc = $trouver_table('spip_auteurs'); |
|
| 270 | + spip_log('spip_auteurs : ' . var_export($desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 271 | + if (stripos($desc['field']['login'], 'BINARY') === false) { |
|
| 272 | + spip_log('Retablir champ login BINARY sur table spip_auteurs', 'maj'); |
|
| 273 | + sql_alter('table spip_auteurs change login login VARCHAR(255) BINARY'); |
|
| 274 | + $trouver_table(''); |
|
| 275 | + $new_desc = $trouver_table('spip_auteurs'); |
|
| 276 | + spip_log('Apres conversion spip_auteurs : ' . var_export($new_desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + foreach ($tables as $table) { |
|
| 280 | + if (time() >= _TIME_OUT) { |
|
| 281 | + return; |
|
| 282 | + } |
|
| 283 | + if ($desc = $trouver_table($table)) { |
|
| 284 | + $desc_collate = _sqlite_remplacements_definitions_table($desc['field']); |
|
| 285 | + if ($d = array_diff($desc['field'], $desc_collate)) { |
|
| 286 | + spip_log("Table $table COLLATE incorrects", 'maj'); |
|
| 287 | + |
|
| 288 | + // cas particulier spip_urls : |
|
| 289 | + // supprimer les doublons avant conversion sinon echec (on garde les urls les plus recentes) |
|
| 290 | + if ($table == 'spip_urls') { |
|
| 291 | + // par date DESC pour conserver les urls les plus recentes |
|
| 292 | + $data = sql_allfetsel('*', 'spip_urls', '', '', 'date DESC'); |
|
| 293 | + $urls = []; |
|
| 294 | + foreach ($data as $d) { |
|
| 295 | + $key = $d['id_parent'] . '::' . strtolower($d['url']); |
|
| 296 | + if (!isset($urls[$key])) { |
|
| 297 | + $urls[$key] = true; |
|
| 298 | + } else { |
|
| 299 | + spip_log( |
|
| 300 | + 'Suppression doublon dans spip_urls avant conversion : ' . serialize($d), |
|
| 301 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 302 | + ); |
|
| 303 | + sql_delete('spip_urls', 'id_parent=' . sql_quote($d['id_parent']) . ' AND url=' . sql_quote($d['url'])); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + foreach ($desc['field'] as $field => $type) { |
|
| 308 | + if ($desc['field'][$field] !== $desc_collate[$field]) { |
|
| 309 | + spip_log("Conversion COLLATE table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 310 | + sql_alter("table $table change $field $field " . $desc_collate[$field]); |
|
| 311 | + $trouver_table(''); |
|
| 312 | + $new_desc = $trouver_table($table); |
|
| 313 | + spip_log( |
|
| 314 | + "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 315 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 316 | + ); |
|
| 317 | + continue 2; // inutile de continuer pour cette table : un seul alter remet tout a jour en sqlite |
|
| 318 | + } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + // forcer le vidage de cache |
|
| 325 | + $trouver_table(''); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | |
| 329 | 329 | $GLOBALS['maj'][19236] = [ |
| 330 | - ['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom='version_installee'"], // version base principale |
|
| 331 | - ['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom LIKE '%_base_version'"], // version base plugins |
|
| 332 | - ['maj_collation_sqlite'], |
|
| 330 | + ['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom='version_installee'"], // version base principale |
|
| 331 | + ['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom LIKE '%_base_version'"], // version base plugins |
|
| 332 | + ['maj_collation_sqlite'], |
|
| 333 | 333 | ]; |
| 334 | 334 | |
| 335 | 335 | $GLOBALS['maj'][19268] = [ |
| 336 | - ['supprimer_toutes_sessions'], |
|
| 336 | + ['supprimer_toutes_sessions'], |
|
| 337 | 337 | ]; |
| 338 | 338 | |
| 339 | 339 | /** |
@@ -342,13 +342,13 @@ discard block |
||
| 342 | 342 | * Obligera tous les auteurs à se reconnecter ! |
| 343 | 343 | **/ |
| 344 | 344 | function supprimer_toutes_sessions() { |
| 345 | - spip_log('supprimer sessions auteur'); |
|
| 346 | - if ($dir = opendir(_DIR_SESSIONS)) { |
|
| 347 | - while (($f = readdir($dir)) !== false) { |
|
| 348 | - spip_unlink(_DIR_SESSIONS . $f); |
|
| 349 | - if (time() >= _TIME_OUT) { |
|
| 350 | - return; |
|
| 351 | - } |
|
| 352 | - } |
|
| 353 | - } |
|
| 345 | + spip_log('supprimer sessions auteur'); |
|
| 346 | + if ($dir = opendir(_DIR_SESSIONS)) { |
|
| 347 | + while (($f = readdir($dir)) !== false) { |
|
| 348 | + spip_unlink(_DIR_SESSIONS . $f); |
|
| 349 | + if (time() >= _TIME_OUT) { |
|
| 350 | + return; |
|
| 351 | + } |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | 354 | } |