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