@@ -102,10 +102,12 @@ |
||
| 102 | 102 | |
| 103 | 103 | // si le plugin CFG est la, l'essayer |
| 104 | 104 | if (defined('_DIR_PLUGIN_CFG')) { |
| 105 | - if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 105 | + if (include_spip('inc/cfg')) { |
|
| 106 | + // test CFG version >= 1.0.5 |
|
| 106 | 107 | { |
| 107 | 108 | if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
| 108 | 109 | return "<div class='cfg_link'>$cfg</div>"; |
| 110 | + } |
|
| 109 | 111 | } |
| 110 | 112 | } |
| 111 | 113 | } |
@@ -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,188 +25,188 @@ 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 = array(); |
|
| 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("plugin-dis-32.png", _T('plugin_info_non_compatible_spip'), " class='picto_err'", |
|
| 52 | - _T('plugin_info_non_compatible_spip')); |
|
| 53 | - $class_li .= " disabled"; |
|
| 54 | - $checkable = false; |
|
| 55 | - } elseif (isset($info['erreur'])) { |
|
| 56 | - $class_li .= " error"; |
|
| 57 | - $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
|
| 58 | - _T('plugin_info_erreur_xml')) |
|
| 59 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 60 | - $checkable = false; |
|
| 61 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 62 | - $class_li .= " error"; |
|
| 63 | - $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
|
| 64 | - " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
|
| 65 | - . "<div class='erreur'>" . implode("<br />", |
|
| 66 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 67 | - } else { |
|
| 68 | - $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - // numerotons les occurrences d'un meme prefix |
|
| 72 | - $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 73 | - |
|
| 74 | - $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 75 | - |
|
| 76 | - return "<li id='$prefix$id' class='$class_li'>" |
|
| 77 | - . ((!$checkable and !$checked) |
|
| 78 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 79 | - . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 80 | - . $cfg |
|
| 81 | - . $erreur |
|
| 82 | - . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 83 | - ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 84 | - . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 85 | - . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 86 | - . "</div>" |
|
| 87 | - . "</li>"; |
|
| 37 | + static $id_input = 0; |
|
| 38 | + static $versions = array(); |
|
| 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("plugin-dis-32.png", _T('plugin_info_non_compatible_spip'), " class='picto_err'", |
|
| 52 | + _T('plugin_info_non_compatible_spip')); |
|
| 53 | + $class_li .= " disabled"; |
|
| 54 | + $checkable = false; |
|
| 55 | + } elseif (isset($info['erreur'])) { |
|
| 56 | + $class_li .= " error"; |
|
| 57 | + $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
|
| 58 | + _T('plugin_info_erreur_xml')) |
|
| 59 | + . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 60 | + $checkable = false; |
|
| 61 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 62 | + $class_li .= " error"; |
|
| 63 | + $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
|
| 64 | + " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
|
| 65 | + . "<div class='erreur'>" . implode("<br />", |
|
| 66 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 67 | + } else { |
|
| 68 | + $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + // numerotons les occurrences d'un meme prefix |
|
| 72 | + $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 73 | + |
|
| 74 | + $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 75 | + |
|
| 76 | + return "<li id='$prefix$id' class='$class_li'>" |
|
| 77 | + . ((!$checkable and !$checked) |
|
| 78 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 79 | + . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 80 | + . $cfg |
|
| 81 | + . $erreur |
|
| 82 | + . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 83 | + ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 84 | + . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 85 | + . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 86 | + . "</div>" |
|
| 87 | + . "</li>"; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | function plugin_bouton_config($nom, $infos, $dir) { |
| 91 | - // la verification se base sur le filesystem |
|
| 92 | - // il faut donc n'utiliser que des minuscules, par convention |
|
| 93 | - $prefix = strtolower($infos['prefix']); |
|
| 94 | - // si paquet.xml fournit un squelette, le prendre |
|
| 95 | - if (isset($infos['config']) and $infos['config']) { |
|
| 96 | - return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 97 | - array( |
|
| 98 | - 'script' => 'configurer_' . $prefix, |
|
| 99 | - 'nom' => $nom |
|
| 100 | - )); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // si le plugin CFG est la, l'essayer |
|
| 104 | - if (defined('_DIR_PLUGIN_CFG')) { |
|
| 105 | - if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 106 | - { |
|
| 107 | - if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
|
| 108 | - return "<div class='cfg_link'>$cfg</div>"; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // sinon prendre le squelette std sur le nom std |
|
| 114 | - return recuperer_fond("prive/squelettes/inclure/cfg", |
|
| 115 | - array( |
|
| 116 | - 'script' => 'configurer_' . $prefix, |
|
| 117 | - 'nom' => $nom |
|
| 118 | - )); |
|
| 91 | + // la verification se base sur le filesystem |
|
| 92 | + // il faut donc n'utiliser que des minuscules, par convention |
|
| 93 | + $prefix = strtolower($infos['prefix']); |
|
| 94 | + // si paquet.xml fournit un squelette, le prendre |
|
| 95 | + if (isset($infos['config']) and $infos['config']) { |
|
| 96 | + return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 97 | + array( |
|
| 98 | + 'script' => 'configurer_' . $prefix, |
|
| 99 | + 'nom' => $nom |
|
| 100 | + )); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // si le plugin CFG est la, l'essayer |
|
| 104 | + if (defined('_DIR_PLUGIN_CFG')) { |
|
| 105 | + if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 106 | + { |
|
| 107 | + if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
|
| 108 | + return "<div class='cfg_link'>$cfg</div>"; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // sinon prendre le squelette std sur le nom std |
|
| 114 | + return recuperer_fond("prive/squelettes/inclure/cfg", |
|
| 115 | + array( |
|
| 116 | + 'script' => 'configurer_' . $prefix, |
|
| 117 | + 'nom' => $nom |
|
| 118 | + )); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // checkbox pour activer ou desactiver |
| 122 | 122 | // si ce n'est pas une extension |
| 123 | 123 | |
| 124 | 124 | function plugin_checkbox($id_input, $file, $actif) { |
| 125 | - $name = substr(md5($file), 0, 16); |
|
| 126 | - |
|
| 127 | - return "<div class='check'>\n" |
|
| 128 | - . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 129 | - . ($actif ? " checked='checked'" : "") |
|
| 130 | - . " class='checkbox' value='O' />" |
|
| 131 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 132 | - . "</div>"; |
|
| 125 | + $name = substr(md5($file), 0, 16); |
|
| 126 | + |
|
| 127 | + return "<div class='check'>\n" |
|
| 128 | + . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 129 | + . ($actif ? " checked='checked'" : "") |
|
| 130 | + . " class='checkbox' value='O' />" |
|
| 131 | + . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 132 | + . "</div>"; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | function plugin_nom($info, $dir_plugins, $plug_file) { |
| 136 | - $prefix = $info['prefix']; |
|
| 137 | - $dir = "$dir_plugins$plug_file"; |
|
| 138 | - // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 139 | - if ($info['dtd'] == "paquet") { |
|
| 140 | - $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 141 | - if (!$nom) { |
|
| 142 | - $nom = typo($info['nom']); |
|
| 143 | - } |
|
| 144 | - } else { |
|
| 145 | - $nom = typo(attribut_html($info['nom'])); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return trim($nom); |
|
| 136 | + $prefix = $info['prefix']; |
|
| 137 | + $dir = "$dir_plugins$plug_file"; |
|
| 138 | + // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 139 | + if ($info['dtd'] == "paquet") { |
|
| 140 | + $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 141 | + if (!$nom) { |
|
| 142 | + $nom = typo($info['nom']); |
|
| 143 | + } |
|
| 144 | + } else { |
|
| 145 | + $nom = typo(attribut_html($info['nom'])); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return trim($nom); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Cartouche Resume |
| 152 | 152 | function plugin_resume($info, $dir_plugins, $plug_file, $url_page) { |
| 153 | - $prefix = $info['prefix']; |
|
| 154 | - $dir = "$dir_plugins$plug_file"; |
|
| 155 | - $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 156 | - // une seule ligne dans le slogan : couper si besoin |
|
| 157 | - if (($p = strpos($slogan, "<br />")) !== false) { |
|
| 158 | - $slogan = substr($slogan, 0, $p); |
|
| 159 | - } |
|
| 160 | - // couper par securite |
|
| 161 | - $slogan = couper($slogan, 80); |
|
| 162 | - |
|
| 163 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 164 | - |
|
| 165 | - $url = parametre_url($url_page, "plugin", substr($dir, strlen(_DIR_RACINE))); |
|
| 166 | - |
|
| 167 | - $icon_class = 'icon'; |
|
| 168 | - $img = ''; |
|
| 169 | - if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 170 | - $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 171 | - if (!extraire_attribut($img, 'src')) { |
|
| 172 | - $img = ''; |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - if (!$img) { |
|
| 176 | - $img = http_img_pack("plugin-xx.svg", '', " width='32' height='32'"); |
|
| 177 | - $icon_class .= ' no-logo'; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 181 | - |
|
| 182 | - return "<div class='resume'>" |
|
| 183 | - . "<h3><a href='$url' rel='info'>" |
|
| 184 | - . $nom |
|
| 185 | - . "</a></h3>" |
|
| 186 | - . " <span class='version'>" . $info['version'] . "</span>" |
|
| 187 | - . " <span class='etat'> - " |
|
| 188 | - . plugin_etat_en_clair($info['etat']) |
|
| 189 | - . "</span>" |
|
| 190 | - . "<div class='short'>" . $slogan . "</div>" |
|
| 191 | - . $i |
|
| 192 | - . "</div>"; |
|
| 153 | + $prefix = $info['prefix']; |
|
| 154 | + $dir = "$dir_plugins$plug_file"; |
|
| 155 | + $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 156 | + // une seule ligne dans le slogan : couper si besoin |
|
| 157 | + if (($p = strpos($slogan, "<br />")) !== false) { |
|
| 158 | + $slogan = substr($slogan, 0, $p); |
|
| 159 | + } |
|
| 160 | + // couper par securite |
|
| 161 | + $slogan = couper($slogan, 80); |
|
| 162 | + |
|
| 163 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 164 | + |
|
| 165 | + $url = parametre_url($url_page, "plugin", substr($dir, strlen(_DIR_RACINE))); |
|
| 166 | + |
|
| 167 | + $icon_class = 'icon'; |
|
| 168 | + $img = ''; |
|
| 169 | + if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 170 | + $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 171 | + if (!extraire_attribut($img, 'src')) { |
|
| 172 | + $img = ''; |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + if (!$img) { |
|
| 176 | + $img = http_img_pack("plugin-xx.svg", '', " width='32' height='32'"); |
|
| 177 | + $icon_class .= ' no-logo'; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 181 | + |
|
| 182 | + return "<div class='resume'>" |
|
| 183 | + . "<h3><a href='$url' rel='info'>" |
|
| 184 | + . $nom |
|
| 185 | + . "</a></h3>" |
|
| 186 | + . " <span class='version'>" . $info['version'] . "</span>" |
|
| 187 | + . " <span class='etat'> - " |
|
| 188 | + . plugin_etat_en_clair($info['etat']) |
|
| 189 | + . "</span>" |
|
| 190 | + . "<div class='short'>" . $slogan . "</div>" |
|
| 191 | + . $i |
|
| 192 | + . "</div>"; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | function plugin_desintalle($plug_file, $nom, $dir_plugins = null) { |
| 196 | - if (!$dir_plugins) { |
|
| 197 | - $dir_plugins = _DIR_PLUGINS; |
|
| 198 | - } |
|
| 196 | + if (!$dir_plugins) { |
|
| 197 | + $dir_plugins = _DIR_PLUGINS; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 201 | - $text = _T('bouton_desinstaller'); |
|
| 202 | - $text2 = _T('info_desinstaller_plugin'); |
|
| 203 | - $file = basename($plug_file); |
|
| 200 | + $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 201 | + $text = _T('bouton_desinstaller'); |
|
| 202 | + $text2 = _T('info_desinstaller_plugin'); |
|
| 203 | + $file = basename($plug_file); |
|
| 204 | 204 | |
| 205 | - return "<div class='actions'>[" . |
|
| 206 | - "<a href='$action' |
|
| 205 | + return "<div class='actions'>[" . |
|
| 206 | + "<a href='$action' |
|
| 207 | 207 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 208 | - . $text |
|
| 209 | - . "</a>]</div>"; |
|
| 208 | + . $text |
|
| 209 | + . "</a>]</div>"; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -220,137 +220,137 @@ discard block |
||
| 220 | 220 | * Traduction de l'état dans la langue en cours |
| 221 | 221 | **/ |
| 222 | 222 | function plugin_etat_en_clair($etat) { |
| 223 | - if (!in_array($etat, array('stable', 'test', 'experimental'))) { |
|
| 224 | - $etat = 'developpement'; |
|
| 225 | - } |
|
| 223 | + if (!in_array($etat, array('stable', 'test', 'experimental'))) { |
|
| 224 | + $etat = 'developpement'; |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - return _T('plugin_etat_' . $etat); |
|
| 227 | + return _T('plugin_etat_' . $etat); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // https://code.spip.net/@plugin_propre |
| 231 | 231 | function plugin_propre($texte, $module = '',$propre='propre') { |
| 232 | - // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 233 | - if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 234 | - $module = substr($module, strlen(_DIR_RACINE)); |
|
| 235 | - } |
|
| 236 | - if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
|
| 237 | - $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - return $propre($texte); |
|
| 232 | + // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 233 | + if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 234 | + $module = substr($module, strlen(_DIR_RACINE)); |
|
| 235 | + } |
|
| 236 | + if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
|
| 237 | + $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + return $propre($texte); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | function plugin_typo($texte, $module = '') { |
| 244 | - return plugin_propre($texte, $module, 'typo'); |
|
| 244 | + return plugin_propre($texte, $module, 'typo'); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | // https://code.spip.net/@affiche_bloc_plugin |
| 249 | 249 | function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) { |
| 250 | - if (!$dir_plugins) { |
|
| 251 | - $dir_plugins = _DIR_PLUGINS; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $prefix = $info['prefix']; |
|
| 255 | - $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 256 | - |
|
| 257 | - $s = ""; |
|
| 258 | - // TODO: le traiter_multi ici n'est pas beau |
|
| 259 | - // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 260 | - // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 261 | - $description = ""; |
|
| 262 | - if (isset($info['description'])) { |
|
| 263 | - $description = plugin_propre($info['description'], $dir); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - if (isset($info['documentation']) |
|
| 267 | - and $lien = $info['documentation'] |
|
| 268 | - ) { |
|
| 269 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 270 | - } |
|
| 271 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 272 | - |
|
| 273 | - if (isset($info['auteur'])) { |
|
| 274 | - if (is_array($info['auteur'])) { |
|
| 275 | - $a = formater_credits($info['auteur'], ', '); |
|
| 276 | - } // pour compat mais ne doit plus arriver |
|
| 277 | - else { |
|
| 278 | - $a = trim($info['auteur']); |
|
| 279 | - } |
|
| 280 | - if ($a) { |
|
| 281 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 282 | - $dir)) . "</dd>\n"; |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - if (isset($info['credit'])) { |
|
| 287 | - if ($a = formater_credits($info['credit'], ', ')) { |
|
| 288 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 289 | - $dir)) . "</dd>\n"; |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - if (isset($info['licence'])) { |
|
| 294 | - if (is_array($info['licence'])) { |
|
| 295 | - $a = formater_credits($info['licence'], ', '); |
|
| 296 | - } // pour compat mais ne doit plus arriver |
|
| 297 | - else { |
|
| 298 | - $a = trim($info['licence']); |
|
| 299 | - } |
|
| 300 | - if ($a) { |
|
| 301 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 302 | - $dir)) . "</dd>\n"; |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - $s = "<dl class='description'>$s</dl>"; |
|
| 307 | - |
|
| 308 | - // |
|
| 309 | - // Ajouter les infos techniques |
|
| 310 | - // |
|
| 311 | - $infotech = array(); |
|
| 312 | - |
|
| 313 | - $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 314 | - // Version VCS |
|
| 315 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 316 | - $version .= ' ' . $vcs; |
|
| 317 | - } |
|
| 318 | - $version .= "</dd>"; |
|
| 319 | - $infotech[] = $version; |
|
| 320 | - $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 321 | - // source zip le cas echeant |
|
| 322 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 323 | - and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 324 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 325 | - : ''; |
|
| 326 | - |
|
| 327 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 328 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 329 | - array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 330 | - |
|
| 331 | - $s .= "<dl class='tech'>" |
|
| 332 | - . join('', $infotech) |
|
| 333 | - . "</dl>"; |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - return $s; |
|
| 250 | + if (!$dir_plugins) { |
|
| 251 | + $dir_plugins = _DIR_PLUGINS; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $prefix = $info['prefix']; |
|
| 255 | + $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 256 | + |
|
| 257 | + $s = ""; |
|
| 258 | + // TODO: le traiter_multi ici n'est pas beau |
|
| 259 | + // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 260 | + // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 261 | + $description = ""; |
|
| 262 | + if (isset($info['description'])) { |
|
| 263 | + $description = plugin_propre($info['description'], $dir); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + if (isset($info['documentation']) |
|
| 267 | + and $lien = $info['documentation'] |
|
| 268 | + ) { |
|
| 269 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 270 | + } |
|
| 271 | + $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 272 | + |
|
| 273 | + if (isset($info['auteur'])) { |
|
| 274 | + if (is_array($info['auteur'])) { |
|
| 275 | + $a = formater_credits($info['auteur'], ', '); |
|
| 276 | + } // pour compat mais ne doit plus arriver |
|
| 277 | + else { |
|
| 278 | + $a = trim($info['auteur']); |
|
| 279 | + } |
|
| 280 | + if ($a) { |
|
| 281 | + $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 282 | + $dir)) . "</dd>\n"; |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + if (isset($info['credit'])) { |
|
| 287 | + if ($a = formater_credits($info['credit'], ', ')) { |
|
| 288 | + $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 289 | + $dir)) . "</dd>\n"; |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + if (isset($info['licence'])) { |
|
| 294 | + if (is_array($info['licence'])) { |
|
| 295 | + $a = formater_credits($info['licence'], ', '); |
|
| 296 | + } // pour compat mais ne doit plus arriver |
|
| 297 | + else { |
|
| 298 | + $a = trim($info['licence']); |
|
| 299 | + } |
|
| 300 | + if ($a) { |
|
| 301 | + $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 302 | + $dir)) . "</dd>\n"; |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + $s = "<dl class='description'>$s</dl>"; |
|
| 307 | + |
|
| 308 | + // |
|
| 309 | + // Ajouter les infos techniques |
|
| 310 | + // |
|
| 311 | + $infotech = array(); |
|
| 312 | + |
|
| 313 | + $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 314 | + // Version VCS |
|
| 315 | + if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 316 | + $version .= ' ' . $vcs; |
|
| 317 | + } |
|
| 318 | + $version .= "</dd>"; |
|
| 319 | + $infotech[] = $version; |
|
| 320 | + $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 321 | + // source zip le cas echeant |
|
| 322 | + $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 323 | + and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 324 | + ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 325 | + : ''; |
|
| 326 | + |
|
| 327 | + $infotech[] = !$info['necessite'] ? '' : |
|
| 328 | + ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 329 | + array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 330 | + |
|
| 331 | + $s .= "<dl class='tech'>" |
|
| 332 | + . join('', $infotech) |
|
| 333 | + . "</dl>"; |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + return $s; |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | function formater_credits($infos, $sep = ', ') { |
| 340 | - $texte = ''; |
|
| 341 | - |
|
| 342 | - foreach ($infos as $_credit) { |
|
| 343 | - if ($texte) { |
|
| 344 | - $texte .= $sep; |
|
| 345 | - } |
|
| 346 | - // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 347 | - $texte .= |
|
| 348 | - (!is_array($_credit)) |
|
| 349 | - ? PtoBR(propre($_credit)) |
|
| 350 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 351 | - $_credit['nom'] . |
|
| 352 | - ($_credit['url'] ? '</a>' : ''); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - return $texte; |
|
| 340 | + $texte = ''; |
|
| 341 | + |
|
| 342 | + foreach ($infos as $_credit) { |
|
| 343 | + if ($texte) { |
|
| 344 | + $texte .= $sep; |
|
| 345 | + } |
|
| 346 | + // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 347 | + $texte .= |
|
| 348 | + (!is_array($_credit)) |
|
| 349 | + ? PtoBR(propre($_credit)) |
|
| 350 | + : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 351 | + $_credit['nom'] . |
|
| 352 | + ($_credit['url'] ? '</a>' : ''); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + return $texte; |
|
| 356 | 356 | } |