@@ -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,26 +21,26 @@ discard block |
||
| 21 | 21 | * @param array $arbre |
| 22 | 22 | */ |
| 23 | 23 | function plugins_extraire_pipelines_dist(&$arbre) { |
| 24 | - $pipeline = array(); |
|
| 25 | - if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 26 | - foreach ($pipes as $tag => $p) { |
|
| 27 | - if (!is_array($p[0])) { |
|
| 28 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 29 | - $pipeline[] = $att; |
|
| 30 | - } else { |
|
| 31 | - foreach ($p as $pipe) { |
|
| 32 | - $att = array(); |
|
| 33 | - if (is_array($pipe)) { |
|
| 34 | - foreach ($pipe as $k => $t) { |
|
| 35 | - $att[$k] = trim(end($t)); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - $pipeline[] = $att; |
|
| 39 | - } |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - unset($arbre[$tag]); |
|
| 43 | - } |
|
| 24 | + $pipeline = array(); |
|
| 25 | + if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 26 | + foreach ($pipes as $tag => $p) { |
|
| 27 | + if (!is_array($p[0])) { |
|
| 28 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 29 | + $pipeline[] = $att; |
|
| 30 | + } else { |
|
| 31 | + foreach ($p as $pipe) { |
|
| 32 | + $att = array(); |
|
| 33 | + if (is_array($pipe)) { |
|
| 34 | + foreach ($pipe as $k => $t) { |
|
| 35 | + $att[$k] = trim(end($t)); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + $pipeline[] = $att; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + unset($arbre[$tag]); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return $pipeline; |
|
| 45 | + return $pipeline; |
|
| 46 | 46 | } |
@@ -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,195 +25,195 @@ 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 | - |
|
| 56 | - } elseif (isset($info['erreur'])) { |
|
| 57 | - $class_li .= " error"; |
|
| 58 | - $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
|
| 59 | - _T('plugin_info_erreur_xml')) |
|
| 60 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 61 | - $checkable = false; |
|
| 62 | - |
|
| 63 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 64 | - $class_li .= " error"; |
|
| 65 | - $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
|
| 66 | - " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
|
| 67 | - . "<div class='erreur'>" . implode("<br />", |
|
| 68 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 69 | - } else { |
|
| 70 | - $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
|
| 71 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])){ |
|
| 72 | - //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 73 | - $erreur = http_img_pack("plugin-dis-32.png", _T('plugin_info_non_compatible_spip'), " class='picto_err picto_compat_forcee'", |
|
| 74 | - _L('Version incompatible : compatibilité forcée')); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - // numerotons les occurrences d'un meme prefix |
|
| 79 | - $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 80 | - |
|
| 81 | - $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 82 | - |
|
| 83 | - return "<li id='$prefix$id' class='$class_li'>" |
|
| 84 | - . ((!$checkable and !$checked) |
|
| 85 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 86 | - . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 87 | - . $cfg |
|
| 88 | - . $erreur |
|
| 89 | - . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 90 | - ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 91 | - . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 92 | - . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 93 | - . "</div>" |
|
| 94 | - . "</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 | + |
|
| 56 | + } elseif (isset($info['erreur'])) { |
|
| 57 | + $class_li .= " error"; |
|
| 58 | + $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
|
| 59 | + _T('plugin_info_erreur_xml')) |
|
| 60 | + . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 61 | + $checkable = false; |
|
| 62 | + |
|
| 63 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 64 | + $class_li .= " error"; |
|
| 65 | + $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
|
| 66 | + " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
|
| 67 | + . "<div class='erreur'>" . implode("<br />", |
|
| 68 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 69 | + } else { |
|
| 70 | + $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
|
| 71 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])){ |
|
| 72 | + //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 73 | + $erreur = http_img_pack("plugin-dis-32.png", _T('plugin_info_non_compatible_spip'), " class='picto_err picto_compat_forcee'", |
|
| 74 | + _L('Version incompatible : compatibilité forcée')); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + // numerotons les occurrences d'un meme prefix |
|
| 79 | + $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 80 | + |
|
| 81 | + $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 82 | + |
|
| 83 | + return "<li id='$prefix$id' class='$class_li'>" |
|
| 84 | + . ((!$checkable and !$checked) |
|
| 85 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 86 | + . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 87 | + . $cfg |
|
| 88 | + . $erreur |
|
| 89 | + . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 90 | + ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 91 | + . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 92 | + . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 93 | + . "</div>" |
|
| 94 | + . "</li>"; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | function plugin_bouton_config($nom, $infos, $dir) { |
| 98 | - // la verification se base sur le filesystem |
|
| 99 | - // il faut donc n'utiliser que des minuscules, par convention |
|
| 100 | - $prefix = strtolower($infos['prefix']); |
|
| 101 | - // si paquet.xml fournit un squelette, le prendre |
|
| 102 | - if (isset($infos['config']) and $infos['config']) { |
|
| 103 | - return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 104 | - array( |
|
| 105 | - 'script' => 'configurer_' . $prefix, |
|
| 106 | - 'nom' => $nom |
|
| 107 | - )); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - // si le plugin CFG est la, l'essayer |
|
| 111 | - if (defined('_DIR_PLUGIN_CFG')) { |
|
| 112 | - if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 113 | - { |
|
| 114 | - if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
|
| 115 | - return "<div class='cfg_link'>$cfg</div>"; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - // sinon prendre le squelette std sur le nom std |
|
| 121 | - return recuperer_fond("prive/squelettes/inclure/cfg", |
|
| 122 | - array( |
|
| 123 | - 'script' => 'configurer_' . $prefix, |
|
| 124 | - 'nom' => $nom |
|
| 125 | - )); |
|
| 98 | + // la verification se base sur le filesystem |
|
| 99 | + // il faut donc n'utiliser que des minuscules, par convention |
|
| 100 | + $prefix = strtolower($infos['prefix']); |
|
| 101 | + // si paquet.xml fournit un squelette, le prendre |
|
| 102 | + if (isset($infos['config']) and $infos['config']) { |
|
| 103 | + return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 104 | + array( |
|
| 105 | + 'script' => 'configurer_' . $prefix, |
|
| 106 | + 'nom' => $nom |
|
| 107 | + )); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + // si le plugin CFG est la, l'essayer |
|
| 111 | + if (defined('_DIR_PLUGIN_CFG')) { |
|
| 112 | + if (include_spip('inc/cfg')) // test CFG version >= 1.0.5 |
|
| 113 | + { |
|
| 114 | + if ($cfg = icone_lien_cfg("$dir$nom", "cfg")) { |
|
| 115 | + return "<div class='cfg_link'>$cfg</div>"; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + // sinon prendre le squelette std sur le nom std |
|
| 121 | + return recuperer_fond("prive/squelettes/inclure/cfg", |
|
| 122 | + array( |
|
| 123 | + 'script' => 'configurer_' . $prefix, |
|
| 124 | + 'nom' => $nom |
|
| 125 | + )); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // checkbox pour activer ou desactiver |
| 129 | 129 | // si ce n'est pas une extension |
| 130 | 130 | |
| 131 | 131 | function plugin_checkbox($id_input, $file, $actif) { |
| 132 | - $name = substr(md5($file), 0, 16); |
|
| 133 | - |
|
| 134 | - return "<div class='check'>\n" |
|
| 135 | - . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 136 | - . ($actif ? " checked='checked'" : "") |
|
| 137 | - . " class='checkbox' value='O' />" |
|
| 138 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 139 | - . "</div>"; |
|
| 132 | + $name = substr(md5($file), 0, 16); |
|
| 133 | + |
|
| 134 | + return "<div class='check'>\n" |
|
| 135 | + . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 136 | + . ($actif ? " checked='checked'" : "") |
|
| 137 | + . " class='checkbox' value='O' />" |
|
| 138 | + . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 139 | + . "</div>"; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | function plugin_nom($info, $dir_plugins, $plug_file) { |
| 143 | - $prefix = $info['prefix']; |
|
| 144 | - $dir = "$dir_plugins$plug_file"; |
|
| 145 | - // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 146 | - if ($info['dtd'] == "paquet") { |
|
| 147 | - $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 148 | - if (!$nom) { |
|
| 149 | - $nom = typo($info['nom']); |
|
| 150 | - } |
|
| 151 | - } else { |
|
| 152 | - $nom = typo(attribut_html($info['nom'])); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - return trim($nom); |
|
| 143 | + $prefix = $info['prefix']; |
|
| 144 | + $dir = "$dir_plugins$plug_file"; |
|
| 145 | + // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 146 | + if ($info['dtd'] == "paquet") { |
|
| 147 | + $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 148 | + if (!$nom) { |
|
| 149 | + $nom = typo($info['nom']); |
|
| 150 | + } |
|
| 151 | + } else { |
|
| 152 | + $nom = typo(attribut_html($info['nom'])); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + return trim($nom); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Cartouche Resume |
| 159 | 159 | function plugin_resume($info, $dir_plugins, $plug_file, $url_page) { |
| 160 | - $prefix = $info['prefix']; |
|
| 161 | - $dir = "$dir_plugins$plug_file"; |
|
| 162 | - $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 163 | - // une seule ligne dans le slogan : couper si besoin |
|
| 164 | - if (($p = strpos($slogan, "<br />")) !== false) { |
|
| 165 | - $slogan = substr($slogan, 0, $p); |
|
| 166 | - } |
|
| 167 | - // couper par securite |
|
| 168 | - $slogan = couper($slogan, 80); |
|
| 169 | - |
|
| 170 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 171 | - |
|
| 172 | - $url = parametre_url($url_page, "plugin", substr($dir, strlen(_DIR_RACINE))); |
|
| 173 | - |
|
| 174 | - $icon_class = 'icon'; |
|
| 175 | - $img = ''; |
|
| 176 | - if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 177 | - $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 178 | - if (!extraire_attribut($img, 'src')) { |
|
| 179 | - $img = ''; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - if (!$img) { |
|
| 183 | - $img = http_img_pack("plugin-xx.svg", '', " width='32' height='32'"); |
|
| 184 | - $icon_class .= ' no-logo'; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 188 | - |
|
| 189 | - return "<div class='resume'>" |
|
| 190 | - . "<h3><a href='$url' rel='info'>" |
|
| 191 | - . $nom |
|
| 192 | - . "</a></h3>" |
|
| 193 | - . " <span class='version'>" . $info['version'] . "</span>" |
|
| 194 | - . " <span class='etat'> - " |
|
| 195 | - . plugin_etat_en_clair($info['etat']) |
|
| 196 | - . "</span>" |
|
| 197 | - . "<div class='short'>" . $slogan . "</div>" |
|
| 198 | - . $i |
|
| 199 | - . "</div>"; |
|
| 160 | + $prefix = $info['prefix']; |
|
| 161 | + $dir = "$dir_plugins$plug_file"; |
|
| 162 | + $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 163 | + // une seule ligne dans le slogan : couper si besoin |
|
| 164 | + if (($p = strpos($slogan, "<br />")) !== false) { |
|
| 165 | + $slogan = substr($slogan, 0, $p); |
|
| 166 | + } |
|
| 167 | + // couper par securite |
|
| 168 | + $slogan = couper($slogan, 80); |
|
| 169 | + |
|
| 170 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 171 | + |
|
| 172 | + $url = parametre_url($url_page, "plugin", substr($dir, strlen(_DIR_RACINE))); |
|
| 173 | + |
|
| 174 | + $icon_class = 'icon'; |
|
| 175 | + $img = ''; |
|
| 176 | + if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 177 | + $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 178 | + if (!extraire_attribut($img, 'src')) { |
|
| 179 | + $img = ''; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + if (!$img) { |
|
| 183 | + $img = http_img_pack("plugin-xx.svg", '', " width='32' height='32'"); |
|
| 184 | + $icon_class .= ' no-logo'; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 188 | + |
|
| 189 | + return "<div class='resume'>" |
|
| 190 | + . "<h3><a href='$url' rel='info'>" |
|
| 191 | + . $nom |
|
| 192 | + . "</a></h3>" |
|
| 193 | + . " <span class='version'>" . $info['version'] . "</span>" |
|
| 194 | + . " <span class='etat'> - " |
|
| 195 | + . plugin_etat_en_clair($info['etat']) |
|
| 196 | + . "</span>" |
|
| 197 | + . "<div class='short'>" . $slogan . "</div>" |
|
| 198 | + . $i |
|
| 199 | + . "</div>"; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | function plugin_desintalle($plug_file, $nom, $dir_plugins = null) { |
| 203 | - if (!$dir_plugins) { |
|
| 204 | - $dir_plugins = _DIR_PLUGINS; |
|
| 205 | - } |
|
| 203 | + if (!$dir_plugins) { |
|
| 204 | + $dir_plugins = _DIR_PLUGINS; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 208 | - $text = _T('bouton_desinstaller'); |
|
| 209 | - $text2 = _T('info_desinstaller_plugin'); |
|
| 210 | - $file = basename($plug_file); |
|
| 207 | + $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 208 | + $text = _T('bouton_desinstaller'); |
|
| 209 | + $text2 = _T('info_desinstaller_plugin'); |
|
| 210 | + $file = basename($plug_file); |
|
| 211 | 211 | |
| 212 | - return "<div class='actions'>[" . |
|
| 213 | - "<a href='$action' |
|
| 212 | + return "<div class='actions'>[" . |
|
| 213 | + "<a href='$action' |
|
| 214 | 214 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 215 | - . $text |
|
| 216 | - . "</a>]</div>"; |
|
| 215 | + . $text |
|
| 216 | + . "</a>]</div>"; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -227,137 +227,137 @@ discard block |
||
| 227 | 227 | * Traduction de l'état dans la langue en cours |
| 228 | 228 | **/ |
| 229 | 229 | function plugin_etat_en_clair($etat) { |
| 230 | - if (!in_array($etat, array('stable', 'test', 'experimental'))) { |
|
| 231 | - $etat = 'developpement'; |
|
| 232 | - } |
|
| 230 | + if (!in_array($etat, array('stable', 'test', 'experimental'))) { |
|
| 231 | + $etat = 'developpement'; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - return _T('plugin_etat_' . $etat); |
|
| 234 | + return _T('plugin_etat_' . $etat); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | // https://code.spip.net/@plugin_propre |
| 238 | 238 | function plugin_propre($texte, $module = '',$propre='propre') { |
| 239 | - // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 240 | - if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 241 | - $module = substr($module, strlen(_DIR_RACINE)); |
|
| 242 | - } |
|
| 243 | - if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
|
| 244 | - $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - return $propre($texte); |
|
| 239 | + // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 240 | + if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 241 | + $module = substr($module, strlen(_DIR_RACINE)); |
|
| 242 | + } |
|
| 243 | + if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
|
| 244 | + $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + return $propre($texte); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | function plugin_typo($texte, $module = '') { |
| 251 | - return plugin_propre($texte, $module, 'typo'); |
|
| 251 | + return plugin_propre($texte, $module, 'typo'); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | |
| 255 | 255 | // https://code.spip.net/@affiche_bloc_plugin |
| 256 | 256 | function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) { |
| 257 | - if (!$dir_plugins) { |
|
| 258 | - $dir_plugins = _DIR_PLUGINS; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - $prefix = $info['prefix']; |
|
| 262 | - $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 263 | - |
|
| 264 | - $s = ""; |
|
| 265 | - // TODO: le traiter_multi ici n'est pas beau |
|
| 266 | - // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 267 | - // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 268 | - $description = ""; |
|
| 269 | - if (isset($info['description'])) { |
|
| 270 | - $description = plugin_propre($info['description'], $dir); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - if (isset($info['documentation']) |
|
| 274 | - and $lien = $info['documentation'] |
|
| 275 | - ) { |
|
| 276 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 277 | - } |
|
| 278 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 279 | - |
|
| 280 | - if (isset($info['auteur'])) { |
|
| 281 | - if (is_array($info['auteur'])) { |
|
| 282 | - $a = formater_credits($info['auteur'], ', '); |
|
| 283 | - } // pour compat mais ne doit plus arriver |
|
| 284 | - else { |
|
| 285 | - $a = trim($info['auteur']); |
|
| 286 | - } |
|
| 287 | - if ($a) { |
|
| 288 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 289 | - $dir)) . "</dd>\n"; |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - if (isset($info['credit'])) { |
|
| 294 | - if ($a = formater_credits($info['credit'], ', ')) { |
|
| 295 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 296 | - $dir)) . "</dd>\n"; |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - if (isset($info['licence'])) { |
|
| 301 | - if (is_array($info['licence'])) { |
|
| 302 | - $a = formater_credits($info['licence'], ', '); |
|
| 303 | - } // pour compat mais ne doit plus arriver |
|
| 304 | - else { |
|
| 305 | - $a = trim($info['licence']); |
|
| 306 | - } |
|
| 307 | - if ($a) { |
|
| 308 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 309 | - $dir)) . "</dd>\n"; |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - $s = "<dl class='description'>$s</dl>"; |
|
| 314 | - |
|
| 315 | - // |
|
| 316 | - // Ajouter les infos techniques |
|
| 317 | - // |
|
| 318 | - $infotech = array(); |
|
| 319 | - |
|
| 320 | - $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 321 | - // Version VCS |
|
| 322 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 323 | - $version .= ' ' . $vcs; |
|
| 324 | - } |
|
| 325 | - $version .= "</dd>"; |
|
| 326 | - $infotech[] = $version; |
|
| 327 | - $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 328 | - // source zip le cas echeant |
|
| 329 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 330 | - and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 331 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 332 | - : ''; |
|
| 333 | - |
|
| 334 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 335 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 336 | - array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 337 | - |
|
| 338 | - $s .= "<dl class='tech'>" |
|
| 339 | - . join('', $infotech) |
|
| 340 | - . "</dl>"; |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - return $s; |
|
| 257 | + if (!$dir_plugins) { |
|
| 258 | + $dir_plugins = _DIR_PLUGINS; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + $prefix = $info['prefix']; |
|
| 262 | + $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 263 | + |
|
| 264 | + $s = ""; |
|
| 265 | + // TODO: le traiter_multi ici n'est pas beau |
|
| 266 | + // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 267 | + // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 268 | + $description = ""; |
|
| 269 | + if (isset($info['description'])) { |
|
| 270 | + $description = plugin_propre($info['description'], $dir); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + if (isset($info['documentation']) |
|
| 274 | + and $lien = $info['documentation'] |
|
| 275 | + ) { |
|
| 276 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 277 | + } |
|
| 278 | + $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 279 | + |
|
| 280 | + if (isset($info['auteur'])) { |
|
| 281 | + if (is_array($info['auteur'])) { |
|
| 282 | + $a = formater_credits($info['auteur'], ', '); |
|
| 283 | + } // pour compat mais ne doit plus arriver |
|
| 284 | + else { |
|
| 285 | + $a = trim($info['auteur']); |
|
| 286 | + } |
|
| 287 | + if ($a) { |
|
| 288 | + $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 289 | + $dir)) . "</dd>\n"; |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + if (isset($info['credit'])) { |
|
| 294 | + if ($a = formater_credits($info['credit'], ', ')) { |
|
| 295 | + $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 296 | + $dir)) . "</dd>\n"; |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + if (isset($info['licence'])) { |
|
| 301 | + if (is_array($info['licence'])) { |
|
| 302 | + $a = formater_credits($info['licence'], ', '); |
|
| 303 | + } // pour compat mais ne doit plus arriver |
|
| 304 | + else { |
|
| 305 | + $a = trim($info['licence']); |
|
| 306 | + } |
|
| 307 | + if ($a) { |
|
| 308 | + $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 309 | + $dir)) . "</dd>\n"; |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + $s = "<dl class='description'>$s</dl>"; |
|
| 314 | + |
|
| 315 | + // |
|
| 316 | + // Ajouter les infos techniques |
|
| 317 | + // |
|
| 318 | + $infotech = array(); |
|
| 319 | + |
|
| 320 | + $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 321 | + // Version VCS |
|
| 322 | + if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 323 | + $version .= ' ' . $vcs; |
|
| 324 | + } |
|
| 325 | + $version .= "</dd>"; |
|
| 326 | + $infotech[] = $version; |
|
| 327 | + $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 328 | + // source zip le cas echeant |
|
| 329 | + $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 330 | + and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 331 | + ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 332 | + : ''; |
|
| 333 | + |
|
| 334 | + $infotech[] = !$info['necessite'] ? '' : |
|
| 335 | + ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 336 | + array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 337 | + |
|
| 338 | + $s .= "<dl class='tech'>" |
|
| 339 | + . join('', $infotech) |
|
| 340 | + . "</dl>"; |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + return $s; |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | function formater_credits($infos, $sep = ', ') { |
| 347 | - $texte = ''; |
|
| 348 | - |
|
| 349 | - foreach ($infos as $_credit) { |
|
| 350 | - if ($texte) { |
|
| 351 | - $texte .= $sep; |
|
| 352 | - } |
|
| 353 | - // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 354 | - $texte .= |
|
| 355 | - (!is_array($_credit)) |
|
| 356 | - ? PtoBR(propre($_credit)) |
|
| 357 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 358 | - $_credit['nom'] . |
|
| 359 | - ($_credit['url'] ? '</a>' : ''); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - return $texte; |
|
| 347 | + $texte = ''; |
|
| 348 | + |
|
| 349 | + foreach ($infos as $_credit) { |
|
| 350 | + if ($texte) { |
|
| 351 | + $texte .= $sep; |
|
| 352 | + } |
|
| 353 | + // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 354 | + $texte .= |
|
| 355 | + (!is_array($_credit)) |
|
| 356 | + ? PtoBR(propre($_credit)) |
|
| 357 | + : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 358 | + $_credit['nom'] . |
|
| 359 | + ($_credit['url'] ? '</a>' : ''); |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + return $texte; |
|
| 363 | 363 | } |
@@ -57,18 +57,18 @@ discard block |
||
| 57 | 57 | $class_li .= " error"; |
| 58 | 58 | $erreur = http_img_pack("plugin-err-32.png", _T('plugin_info_erreur_xml'), " class='picto_err'", |
| 59 | 59 | _T('plugin_info_erreur_xml')) |
| 60 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>"; |
|
| 60 | + . "<div class='erreur'>".join('<br >', $info['erreur'])."</div>"; |
|
| 61 | 61 | $checkable = false; |
| 62 | 62 | |
| 63 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 63 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file])) { |
|
| 64 | 64 | $class_li .= " error"; |
| 65 | 65 | $erreur = http_img_pack("plugin-err-32.png", _T('plugin_impossible_activer', array('plugin' => $nom)), |
| 66 | 66 | " class='picto_err'", _T('plugin_impossible_activer', array('plugin' => $nom))) |
| 67 | - . "<div class='erreur'>" . implode("<br />", |
|
| 68 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file]) . "</div>"; |
|
| 67 | + . "<div class='erreur'>".implode("<br />", |
|
| 68 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file])."</div>"; |
|
| 69 | 69 | } else { |
| 70 | 70 | $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ""; |
| 71 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])){ |
|
| 71 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
|
| 72 | 72 | //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
| 73 | 73 | $erreur = http_img_pack("plugin-dis-32.png", _T('plugin_info_non_compatible_spip'), " class='picto_err picto_compat_forcee'", |
| 74 | 74 | _L('Version incompatible : compatibilité forcée')); |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | // numerotons les occurrences d'un meme prefix |
| 79 | 79 | $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
| 80 | 80 | |
| 81 | - $class_li .= ($actif ? " actif" : "") . ($expose ? " on" : ""); |
|
| 81 | + $class_li .= ($actif ? " actif" : "").($expose ? " on" : ""); |
|
| 82 | 82 | |
| 83 | 83 | return "<li id='$prefix$id' class='$class_li'>" |
| 84 | 84 | . ((!$checkable and !$checked) |
| 85 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 85 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins.$plug_file, $checked)) |
|
| 86 | 86 | . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
| 87 | 87 | . $cfg |
| 88 | 88 | . $erreur |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | $prefix = strtolower($infos['prefix']); |
| 101 | 101 | // si paquet.xml fournit un squelette, le prendre |
| 102 | 102 | if (isset($infos['config']) and $infos['config']) { |
| 103 | - return recuperer_fond("$dir$nom/" . $infos['config'], |
|
| 103 | + return recuperer_fond("$dir$nom/".$infos['config'], |
|
| 104 | 104 | array( |
| 105 | - 'script' => 'configurer_' . $prefix, |
|
| 105 | + 'script' => 'configurer_'.$prefix, |
|
| 106 | 106 | 'nom' => $nom |
| 107 | 107 | )); |
| 108 | 108 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | // sinon prendre le squelette std sur le nom std |
| 121 | 121 | return recuperer_fond("prive/squelettes/inclure/cfg", |
| 122 | 122 | array( |
| 123 | - 'script' => 'configurer_' . $prefix, |
|
| 123 | + 'script' => 'configurer_'.$prefix, |
|
| 124 | 124 | 'nom' => $nom |
| 125 | 125 | )); |
| 126 | 126 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | . "<input type='checkbox' name='s$name' id='label_$id_input'" |
| 136 | 136 | . ($actif ? " checked='checked'" : "") |
| 137 | 137 | . " class='checkbox' value='O' />" |
| 138 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . "</label>" |
|
| 138 | + . "\n<label for='label_$id_input'>"._T('activer_plugin')."</label>" |
|
| 139 | 139 | . "</div>"; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | . "<h3><a href='$url' rel='info'>" |
| 191 | 191 | . $nom |
| 192 | 192 | . "</a></h3>" |
| 193 | - . " <span class='version'>" . $info['version'] . "</span>" |
|
| 193 | + . " <span class='version'>".$info['version']."</span>" |
|
| 194 | 194 | . " <span class='etat'> - " |
| 195 | 195 | . plugin_etat_en_clair($info['etat']) |
| 196 | 196 | . "</span>" |
| 197 | - . "<div class='short'>" . $slogan . "</div>" |
|
| 197 | + . "<div class='short'>".$slogan."</div>" |
|
| 198 | 198 | . $i |
| 199 | 199 | . "</div>"; |
| 200 | 200 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $text2 = _T('info_desinstaller_plugin'); |
| 210 | 210 | $file = basename($plug_file); |
| 211 | 211 | |
| 212 | - return "<div class='actions'>[" . |
|
| 212 | + return "<div class='actions'>[". |
|
| 213 | 213 | "<a href='$action' |
| 214 | 214 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 215 | 215 | . $text |
@@ -231,17 +231,17 @@ discard block |
||
| 231 | 231 | $etat = 'developpement'; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - return _T('plugin_etat_' . $etat); |
|
| 234 | + return _T('plugin_etat_'.$etat); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | // https://code.spip.net/@plugin_propre |
| 238 | -function plugin_propre($texte, $module = '',$propre='propre') { |
|
| 238 | +function plugin_propre($texte, $module = '', $propre = 'propre') { |
|
| 239 | 239 | // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
| 240 | 240 | if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
| 241 | 241 | $module = substr($module, strlen(_DIR_RACINE)); |
| 242 | 242 | } |
| 243 | 243 | if (preg_match("|^\w+_[\w_]+$|", $texte)) { |
| 244 | - $texte = _T(($module ? "$module:" : '') . $texte, array(), array('force' => false)); |
|
| 244 | + $texte = _T(($module ? "$module:" : '').$texte, array(), array('force' => false)); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | return $propre($texte); |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | if (isset($info['documentation']) |
| 274 | 274 | and $lien = $info['documentation'] |
| 275 | 275 | ) { |
| 276 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 276 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>"._T('en_savoir_plus').'</a></em></p>'; |
|
| 277 | 277 | } |
| 278 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 278 | + $s .= "<dd class='desc'>".$description."</dd>\n"; |
|
| 279 | 279 | |
| 280 | 280 | if (isset($info['auteur'])) { |
| 281 | 281 | if (is_array($info['auteur'])) { |
@@ -285,15 +285,15 @@ discard block |
||
| 285 | 285 | $a = trim($info['auteur']); |
| 286 | 286 | } |
| 287 | 287 | if ($a) { |
| 288 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre($a, |
|
| 289 | - $dir)) . "</dd>\n"; |
|
| 288 | + $s .= "<dt class='auteurs'>"._T('public:par_auteur')."</dt><dd class='auteurs'>".PtoBR(propre($a, |
|
| 289 | + $dir))."</dd>\n"; |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | if (isset($info['credit'])) { |
| 294 | 294 | if ($a = formater_credits($info['credit'], ', ')) { |
| 295 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre($a, |
|
| 296 | - $dir)) . "</dd>\n"; |
|
| 295 | + $s .= "<dt class='credits'>"._T('plugin_info_credit')."</dt><dd class='credits'>".PtoBR(propre($a, |
|
| 296 | + $dir))."</dd>\n"; |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | $a = trim($info['licence']); |
| 306 | 306 | } |
| 307 | 307 | if ($a) { |
| 308 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre($a, |
|
| 309 | - $dir)) . "</dd>\n"; |
|
| 308 | + $s .= "<dt class='licence'>"._T('intitule_licence')."</dt><dd class='licence'>".PtoBR(propre($a, |
|
| 309 | + $dir))."</dd>\n"; |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
@@ -317,23 +317,22 @@ discard block |
||
| 317 | 317 | // |
| 318 | 318 | $infotech = array(); |
| 319 | 319 | |
| 320 | - $version = "<dt>" . _T('version') . "</dt><dd>" . $info['version']; |
|
| 320 | + $version = "<dt>"._T('version')."</dt><dd>".$info['version']; |
|
| 321 | 321 | // Version VCS |
| 322 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 323 | - $version .= ' ' . $vcs; |
|
| 322 | + if ($vcs = version_vcs_courante($dir_plugins.$plug_file)) { |
|
| 323 | + $version .= ' '.$vcs; |
|
| 324 | 324 | } |
| 325 | 325 | $version .= "</dd>"; |
| 326 | 326 | $infotech[] = $version; |
| 327 | - $infotech[] = "<dt>" . _T('repertoire_plugins') . "</dt><dd>" . joli_repertoire("$dir_plugins$plug_file") . "</dd>"; |
|
| 327 | + $infotech[] = "<dt>"._T('repertoire_plugins')."</dt><dd>".joli_repertoire("$dir_plugins$plug_file")."</dd>"; |
|
| 328 | 328 | // source zip le cas echeant |
| 329 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 329 | + $infotech[] = (lire_fichier($dir_plugins.$plug_file.'/install.log', $log) |
|
| 330 | 330 | and preg_match(',^source:(.*)$,m', $log, $r)) |
| 331 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . "</dd>" |
|
| 331 | + ? '<dt>'._T('plugin_source').'</dt><dd>'.trim($r[1])."</dd>" |
|
| 332 | 332 | : ''; |
| 333 | 333 | |
| 334 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 335 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join(' ', |
|
| 336 | - array_map('array_shift', $info['necessite'])) . '</dd>'); |
|
| 334 | + $infotech[] = !$info['necessite'] ? '' : ('<dt>'._T('plugin_info_necessite').'</dt><dd>'.join(' ', |
|
| 335 | + array_map('array_shift', $info['necessite'])).'</dd>'); |
|
| 337 | 336 | |
| 338 | 337 | $s .= "<dl class='tech'>" |
| 339 | 338 | . join('', $infotech) |
@@ -354,8 +353,8 @@ discard block |
||
| 354 | 353 | $texte .= |
| 355 | 354 | (!is_array($_credit)) |
| 356 | 355 | ? PtoBR(propre($_credit)) |
| 357 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 358 | - $_credit['nom'] . |
|
| 356 | + : ($_credit['url'] ? '<a href="'.$_credit['url'].'">' : ''). |
|
| 357 | + $_credit['nom']. |
|
| 359 | 358 | ($_credit['url'] ? '</a>' : ''); |
| 360 | 359 | } |
| 361 | 360 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | if (is_null($p)) { |
| 50 | - $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug")); |
|
| 50 | + $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent')." : $plug")); |
|
| 51 | 51 | $silence = true; |
| 52 | 52 | } else { |
| 53 | 53 | $arbre = $p; |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | if (isset($arbre['etat'])) { |
| 83 | 83 | $etat = trim(end($arbre['etat'])); |
| 84 | 84 | if (!in_array($etat, $etats)) { |
| 85 | - $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 85 | + $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu')." : '$etat'"; |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | if (isset($arbre['options'])) { |
| 89 | 89 | foreach ($arbre['options'] as $optfile) { |
| 90 | 90 | $optfile = trim($optfile); |
| 91 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 91 | + if (!@is_readable($dir_plugins."$plug/$optfile")) { |
|
| 92 | 92 | if (!$silence) { |
| 93 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 93 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile"; |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | if (isset($arbre['fonctions'])) { |
| 99 | 99 | foreach ($arbre['fonctions'] as $optfile) { |
| 100 | 100 | $optfile = trim($optfile); |
| 101 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 101 | + if (!@is_readable($dir_plugins."$plug/$optfile")) { |
|
| 102 | 102 | if (!$silence) { |
| 103 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 103 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile"; |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | // verif que la methode a un nom autorise |
| 135 | 135 | if (in_array(strtolower($action), $liste_methodes_reservees)) { |
| 136 | 136 | if (!$silence) { |
| 137 | - $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action"; |
|
| 137 | + $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit")." : $action"; |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | if (isset($pipe['inclure'])) { |
| 141 | - $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 141 | + $inclure = $dir_plugins."$plug/".$pipe['inclure']; |
|
| 142 | 142 | if (!@is_readable($inclure)) { |
| 143 | 143 | if (!$silence) { |
| 144 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 144 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $inclure"; |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | foreach ($arbre['noisette'] as $k => $nut) { |
| 208 | 208 | $nut = preg_replace(',[.]html$,uims', '', trim($nut)); |
| 209 | 209 | $arbre['noisette'][$k] = $nut; |
| 210 | - if (!@is_readable($dir_plugins . "$plug/$nut.html")) { |
|
| 210 | + if (!@is_readable($dir_plugins."$plug/$nut.html")) { |
|
| 211 | 211 | if (!$silence) { |
| 212 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 212 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $nut"; |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -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 | include_spip('inc/xml'); |
@@ -19,208 +19,208 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // https://code.spip.net/@plugin_verifie_conformite |
| 21 | 21 | function plugins_verifie_conformite_dist($plug, &$arbre, $dir_plugins = _DIR_PLUGINS) { |
| 22 | - static $etats = array('dev', 'experimental', 'test', 'stable'); |
|
| 22 | + static $etats = array('dev', 'experimental', 'test', 'stable'); |
|
| 23 | 23 | |
| 24 | - $matches = array(); |
|
| 25 | - $silence = false; |
|
| 26 | - $p = null; |
|
| 27 | - // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 28 | - if ($n = spip_xml_match_nodes(",^plugin(\s|$),", $arbre, $matches)) { |
|
| 29 | - // version de SPIP |
|
| 30 | - $vspip = $GLOBALS['spip_version_branche']; |
|
| 31 | - foreach ($matches as $tag => $sous) { |
|
| 32 | - list($tagname, $atts) = spip_xml_decompose_tag($tag); |
|
| 33 | - if ($tagname == 'plugin' and is_array($sous)) { |
|
| 34 | - // On rajoute la condition sur $n : |
|
| 35 | - // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 36 | - // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 37 | - // de la meme facon. |
|
| 38 | - if (!isset($atts['spip']) |
|
| 39 | - or $n == 1 |
|
| 40 | - or plugin_version_compatible($atts['spip'], $vspip, 'spip') |
|
| 41 | - ) { |
|
| 42 | - // on prend la derniere declaration avec ce nom |
|
| 43 | - $p = end($sous); |
|
| 44 | - $compat_spip = isset($atts['spip']) ? $atts['spip'] : ''; |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - if (is_null($p)) { |
|
| 50 | - $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug")); |
|
| 51 | - $silence = true; |
|
| 52 | - } else { |
|
| 53 | - $arbre = $p; |
|
| 54 | - } |
|
| 55 | - if (!is_array($arbre)) { |
|
| 56 | - $arbre = array(); |
|
| 57 | - } |
|
| 58 | - // verification de la conformite du plugin avec quelques |
|
| 59 | - // precautions elementaires |
|
| 60 | - if (!isset($arbre['nom'])) { |
|
| 61 | - if (!$silence) { |
|
| 62 | - $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 63 | - } |
|
| 64 | - $arbre['nom'] = array(""); |
|
| 65 | - } |
|
| 66 | - if (!isset($arbre['version'])) { |
|
| 67 | - if (!$silence) { |
|
| 68 | - $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 69 | - } |
|
| 70 | - $arbre['version'] = array(""); |
|
| 71 | - } |
|
| 72 | - if (!isset($arbre['prefix'])) { |
|
| 73 | - if (!$silence) { |
|
| 74 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 75 | - } |
|
| 76 | - $arbre['prefix'] = array(""); |
|
| 77 | - } else { |
|
| 78 | - $prefix = trim(end($arbre['prefix'])); |
|
| 79 | - if (strtoupper($prefix) == 'SPIP' and $plug != "./") { |
|
| 80 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 81 | - } |
|
| 82 | - if (isset($arbre['etat'])) { |
|
| 83 | - $etat = trim(end($arbre['etat'])); |
|
| 84 | - if (!in_array($etat, $etats)) { |
|
| 85 | - $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - if (isset($arbre['options'])) { |
|
| 89 | - foreach ($arbre['options'] as $optfile) { |
|
| 90 | - $optfile = trim($optfile); |
|
| 91 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 92 | - if (!$silence) { |
|
| 93 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - if (isset($arbre['fonctions'])) { |
|
| 99 | - foreach ($arbre['fonctions'] as $optfile) { |
|
| 100 | - $optfile = trim($optfile); |
|
| 101 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 102 | - if (!$silence) { |
|
| 103 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - $fonctions = array(); |
|
| 109 | - if (isset($arbre['fonctions'])) { |
|
| 110 | - $fonctions = $arbre['fonctions']; |
|
| 111 | - } |
|
| 112 | - $liste_methodes_reservees = array( |
|
| 113 | - '__construct', |
|
| 114 | - '__destruct', |
|
| 115 | - 'plugin', |
|
| 116 | - 'install', |
|
| 117 | - 'uninstall', |
|
| 118 | - strtolower($prefix) |
|
| 119 | - ); |
|
| 24 | + $matches = array(); |
|
| 25 | + $silence = false; |
|
| 26 | + $p = null; |
|
| 27 | + // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 28 | + if ($n = spip_xml_match_nodes(",^plugin(\s|$),", $arbre, $matches)) { |
|
| 29 | + // version de SPIP |
|
| 30 | + $vspip = $GLOBALS['spip_version_branche']; |
|
| 31 | + foreach ($matches as $tag => $sous) { |
|
| 32 | + list($tagname, $atts) = spip_xml_decompose_tag($tag); |
|
| 33 | + if ($tagname == 'plugin' and is_array($sous)) { |
|
| 34 | + // On rajoute la condition sur $n : |
|
| 35 | + // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 36 | + // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 37 | + // de la meme facon. |
|
| 38 | + if (!isset($atts['spip']) |
|
| 39 | + or $n == 1 |
|
| 40 | + or plugin_version_compatible($atts['spip'], $vspip, 'spip') |
|
| 41 | + ) { |
|
| 42 | + // on prend la derniere declaration avec ce nom |
|
| 43 | + $p = end($sous); |
|
| 44 | + $compat_spip = isset($atts['spip']) ? $atts['spip'] : ''; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + if (is_null($p)) { |
|
| 50 | + $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug")); |
|
| 51 | + $silence = true; |
|
| 52 | + } else { |
|
| 53 | + $arbre = $p; |
|
| 54 | + } |
|
| 55 | + if (!is_array($arbre)) { |
|
| 56 | + $arbre = array(); |
|
| 57 | + } |
|
| 58 | + // verification de la conformite du plugin avec quelques |
|
| 59 | + // precautions elementaires |
|
| 60 | + if (!isset($arbre['nom'])) { |
|
| 61 | + if (!$silence) { |
|
| 62 | + $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 63 | + } |
|
| 64 | + $arbre['nom'] = array(""); |
|
| 65 | + } |
|
| 66 | + if (!isset($arbre['version'])) { |
|
| 67 | + if (!$silence) { |
|
| 68 | + $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 69 | + } |
|
| 70 | + $arbre['version'] = array(""); |
|
| 71 | + } |
|
| 72 | + if (!isset($arbre['prefix'])) { |
|
| 73 | + if (!$silence) { |
|
| 74 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 75 | + } |
|
| 76 | + $arbre['prefix'] = array(""); |
|
| 77 | + } else { |
|
| 78 | + $prefix = trim(end($arbre['prefix'])); |
|
| 79 | + if (strtoupper($prefix) == 'SPIP' and $plug != "./") { |
|
| 80 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 81 | + } |
|
| 82 | + if (isset($arbre['etat'])) { |
|
| 83 | + $etat = trim(end($arbre['etat'])); |
|
| 84 | + if (!in_array($etat, $etats)) { |
|
| 85 | + $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + if (isset($arbre['options'])) { |
|
| 89 | + foreach ($arbre['options'] as $optfile) { |
|
| 90 | + $optfile = trim($optfile); |
|
| 91 | + if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 92 | + if (!$silence) { |
|
| 93 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + if (isset($arbre['fonctions'])) { |
|
| 99 | + foreach ($arbre['fonctions'] as $optfile) { |
|
| 100 | + $optfile = trim($optfile); |
|
| 101 | + if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 102 | + if (!$silence) { |
|
| 103 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + $fonctions = array(); |
|
| 109 | + if (isset($arbre['fonctions'])) { |
|
| 110 | + $fonctions = $arbre['fonctions']; |
|
| 111 | + } |
|
| 112 | + $liste_methodes_reservees = array( |
|
| 113 | + '__construct', |
|
| 114 | + '__destruct', |
|
| 115 | + 'plugin', |
|
| 116 | + 'install', |
|
| 117 | + 'uninstall', |
|
| 118 | + strtolower($prefix) |
|
| 119 | + ); |
|
| 120 | 120 | |
| 121 | - $extraire_pipelines = charger_fonction("extraire_pipelines", "plugins"); |
|
| 122 | - $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 123 | - foreach ($arbre['pipeline'] as $pipe) { |
|
| 124 | - if (!isset($pipe['nom'])) { |
|
| 125 | - if (!$silence) { |
|
| 126 | - $arbre['erreur'][] = _T("erreur_plugin_nom_pipeline_non_defini"); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - if (isset($pipe['action'])) { |
|
| 130 | - $action = $pipe['action']; |
|
| 131 | - } else { |
|
| 132 | - $action = $pipe['nom']; |
|
| 133 | - } |
|
| 134 | - // verif que la methode a un nom autorise |
|
| 135 | - if (in_array(strtolower($action), $liste_methodes_reservees)) { |
|
| 136 | - if (!$silence) { |
|
| 137 | - $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action"; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - if (isset($pipe['inclure'])) { |
|
| 141 | - $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 142 | - if (!@is_readable($inclure)) { |
|
| 143 | - if (!$silence) { |
|
| 144 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - $necessite = array(); |
|
| 150 | - $spip_trouve = false; |
|
| 151 | - if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 152 | - foreach (array_keys($needs) as $tag) { |
|
| 153 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 154 | - if (!isset($att['id'])) { |
|
| 155 | - if (!$silence) { |
|
| 156 | - $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant', |
|
| 157 | - array('attribut' => 'id', 'balise' => $att)); |
|
| 158 | - } |
|
| 159 | - } else { |
|
| 160 | - $necessite[] = $att; |
|
| 161 | - } |
|
| 162 | - if (strtolower($att['id']) == 'spip') { |
|
| 163 | - $spip_trouve = true; |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - if ($compat_spip and !$spip_trouve) { |
|
| 168 | - $necessite[] = array('id' => 'spip', 'version' => $compat_spip); |
|
| 169 | - } |
|
| 170 | - $arbre['necessite'] = $necessite; |
|
| 171 | - $utilise = array(); |
|
| 172 | - if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 173 | - foreach (array_keys($uses) as $tag) { |
|
| 174 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 175 | - if (!isset($att['id'])) { |
|
| 176 | - if (!$silence) { |
|
| 177 | - $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant', |
|
| 178 | - array('attribut' => 'id', 'balise' => $att)); |
|
| 179 | - } |
|
| 180 | - } else { |
|
| 181 | - $utilise[] = $att; |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - $arbre['utilise'] = $utilise; |
|
| 186 | - $procure = array(); |
|
| 187 | - if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 188 | - foreach (array_keys($uses) as $tag) { |
|
| 189 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 190 | - $procure[] = $att; |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - $arbre['procure'] = $procure; |
|
| 194 | - $path = array(); |
|
| 195 | - if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 196 | - foreach (array_keys($paths) as $tag) { |
|
| 197 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 198 | - $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 199 | - $path[] = $att; |
|
| 200 | - } |
|
| 201 | - } else { |
|
| 202 | - $path = array(array('dir' => '')); |
|
| 203 | - } // initialiser par defaut |
|
| 204 | - $arbre['path'] = $path; |
|
| 205 | - // exposer les noisettes |
|
| 206 | - if (isset($arbre['noisette'])) { |
|
| 207 | - foreach ($arbre['noisette'] as $k => $nut) { |
|
| 208 | - $nut = preg_replace(',[.]html$,uims', '', trim($nut)); |
|
| 209 | - $arbre['noisette'][$k] = $nut; |
|
| 210 | - if (!@is_readable($dir_plugins . "$plug/$nut.html")) { |
|
| 211 | - if (!$silence) { |
|
| 212 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - $traduire = array(); |
|
| 218 | - if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 219 | - foreach (array_keys($trads) as $tag) { |
|
| 220 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 221 | - $traduire[] = $att; |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - $arbre['traduire'] = $traduire; |
|
| 225 | - } |
|
| 121 | + $extraire_pipelines = charger_fonction("extraire_pipelines", "plugins"); |
|
| 122 | + $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 123 | + foreach ($arbre['pipeline'] as $pipe) { |
|
| 124 | + if (!isset($pipe['nom'])) { |
|
| 125 | + if (!$silence) { |
|
| 126 | + $arbre['erreur'][] = _T("erreur_plugin_nom_pipeline_non_defini"); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + if (isset($pipe['action'])) { |
|
| 130 | + $action = $pipe['action']; |
|
| 131 | + } else { |
|
| 132 | + $action = $pipe['nom']; |
|
| 133 | + } |
|
| 134 | + // verif que la methode a un nom autorise |
|
| 135 | + if (in_array(strtolower($action), $liste_methodes_reservees)) { |
|
| 136 | + if (!$silence) { |
|
| 137 | + $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action"; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + if (isset($pipe['inclure'])) { |
|
| 141 | + $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 142 | + if (!@is_readable($inclure)) { |
|
| 143 | + if (!$silence) { |
|
| 144 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + $necessite = array(); |
|
| 150 | + $spip_trouve = false; |
|
| 151 | + if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 152 | + foreach (array_keys($needs) as $tag) { |
|
| 153 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 154 | + if (!isset($att['id'])) { |
|
| 155 | + if (!$silence) { |
|
| 156 | + $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant', |
|
| 157 | + array('attribut' => 'id', 'balise' => $att)); |
|
| 158 | + } |
|
| 159 | + } else { |
|
| 160 | + $necessite[] = $att; |
|
| 161 | + } |
|
| 162 | + if (strtolower($att['id']) == 'spip') { |
|
| 163 | + $spip_trouve = true; |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + if ($compat_spip and !$spip_trouve) { |
|
| 168 | + $necessite[] = array('id' => 'spip', 'version' => $compat_spip); |
|
| 169 | + } |
|
| 170 | + $arbre['necessite'] = $necessite; |
|
| 171 | + $utilise = array(); |
|
| 172 | + if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 173 | + foreach (array_keys($uses) as $tag) { |
|
| 174 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 175 | + if (!isset($att['id'])) { |
|
| 176 | + if (!$silence) { |
|
| 177 | + $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant', |
|
| 178 | + array('attribut' => 'id', 'balise' => $att)); |
|
| 179 | + } |
|
| 180 | + } else { |
|
| 181 | + $utilise[] = $att; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + $arbre['utilise'] = $utilise; |
|
| 186 | + $procure = array(); |
|
| 187 | + if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 188 | + foreach (array_keys($uses) as $tag) { |
|
| 189 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 190 | + $procure[] = $att; |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + $arbre['procure'] = $procure; |
|
| 194 | + $path = array(); |
|
| 195 | + if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 196 | + foreach (array_keys($paths) as $tag) { |
|
| 197 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 198 | + $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 199 | + $path[] = $att; |
|
| 200 | + } |
|
| 201 | + } else { |
|
| 202 | + $path = array(array('dir' => '')); |
|
| 203 | + } // initialiser par defaut |
|
| 204 | + $arbre['path'] = $path; |
|
| 205 | + // exposer les noisettes |
|
| 206 | + if (isset($arbre['noisette'])) { |
|
| 207 | + foreach ($arbre['noisette'] as $k => $nut) { |
|
| 208 | + $nut = preg_replace(',[.]html$,uims', '', trim($nut)); |
|
| 209 | + $arbre['noisette'][$k] = $nut; |
|
| 210 | + if (!@is_readable($dir_plugins . "$plug/$nut.html")) { |
|
| 211 | + if (!$silence) { |
|
| 212 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + $traduire = array(); |
|
| 218 | + if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 219 | + foreach (array_keys($trads) as $tag) { |
|
| 220 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 221 | + $traduire[] = $att; |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + $arbre['traduire'] = $traduire; |
|
| 225 | + } |
|
| 226 | 226 | } |
@@ -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,30 +21,30 @@ discard block |
||
| 21 | 21 | * @return <type> |
| 22 | 22 | */ |
| 23 | 23 | function plugins_extraire_boutons_dist($arbre) { |
| 24 | - $ret = array('bouton' => array(), 'onglet' => array()); |
|
| 25 | - // recuperer les boutons et onglets si necessaire |
|
| 26 | - spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons); |
|
| 27 | - if (is_array($les_boutons) && count($les_boutons)) { |
|
| 28 | - $ret['bouton'] = array(); |
|
| 29 | - $ret['onglet'] = array(); |
|
| 30 | - foreach ($les_boutons as $bouton => $val) { |
|
| 31 | - $bouton = spip_xml_decompose_tag($bouton); |
|
| 32 | - $type = reset($bouton); |
|
| 33 | - $bouton = end($bouton); |
|
| 34 | - if (isset($bouton['id'])) { |
|
| 35 | - $id = $bouton['id']; |
|
| 36 | - $val = reset($val); |
|
| 37 | - if (is_array($val)) { |
|
| 38 | - $ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : ''; |
|
| 39 | - $ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : ''; |
|
| 40 | - $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : ''; |
|
| 41 | - $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : ''; |
|
| 42 | - $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : ''; |
|
| 43 | - $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : ''; |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 24 | + $ret = array('bouton' => array(), 'onglet' => array()); |
|
| 25 | + // recuperer les boutons et onglets si necessaire |
|
| 26 | + spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons); |
|
| 27 | + if (is_array($les_boutons) && count($les_boutons)) { |
|
| 28 | + $ret['bouton'] = array(); |
|
| 29 | + $ret['onglet'] = array(); |
|
| 30 | + foreach ($les_boutons as $bouton => $val) { |
|
| 31 | + $bouton = spip_xml_decompose_tag($bouton); |
|
| 32 | + $type = reset($bouton); |
|
| 33 | + $bouton = end($bouton); |
|
| 34 | + if (isset($bouton['id'])) { |
|
| 35 | + $id = $bouton['id']; |
|
| 36 | + $val = reset($val); |
|
| 37 | + if (is_array($val)) { |
|
| 38 | + $ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : ''; |
|
| 39 | + $ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : ''; |
|
| 40 | + $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : ''; |
|
| 41 | + $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : ''; |
|
| 42 | + $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : ''; |
|
| 43 | + $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : ''; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return $ret; |
|
| 49 | + return $ret; |
|
| 50 | 50 | } |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | $plug = $liste_plugins[$key]; |
| 59 | 59 | $actif = @isset($fast_liste_plugins_actifs[$plug]); |
| 60 | 60 | $id = substr(md5($plug), 0, 16); |
| 61 | - $res .= $ligne_plug($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), $actif, |
|
| 62 | - 'menu-entree') . "\n"; |
|
| 61 | + $res .= $ligne_plug($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE.$plug), $actif, |
|
| 62 | + 'menu-entree')."\n"; |
|
| 63 | 63 | unset($liste_plugins[$key]); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | $chemin = ""; |
| 103 | 103 | if (count($tcom)) { |
| 104 | - $chemin .= implode("/", $tcom) . "/"; |
|
| 104 | + $chemin .= implode("/", $tcom)."/"; |
|
| 105 | 105 | } |
| 106 | 106 | // ouvrir les repertoires jusqu'a la cible |
| 107 | 107 | while ($open = array_shift($ttarg)) { |
| 108 | - $visible = @isset($deplie[$chemin . $open]); |
|
| 109 | - $chemin .= $open . "/"; |
|
| 108 | + $visible = @isset($deplie[$chemin.$open]); |
|
| 109 | + $chemin .= $open."/"; |
|
| 110 | 110 | $output .= "<li>"; |
| 111 | 111 | $output .= bouton_block_depliable($chemin, $visible); |
| 112 | 112 | $output .= debut_block_depliable($visible); |
@@ -11,64 +11,64 @@ 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 = array($racine => true); |
|
| 25 | - $fast_liste_plugins_actifs = array(); |
|
| 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 = array($racine => true); |
|
| 25 | + $fast_liste_plugins_actifs = array(); |
|
| 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 = array(); |
|
| 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 = array(); |
|
| 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 (count($liste_plugins) && $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 (count($liste_plugins) && $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($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), $actif, |
|
| 62 | - 'menu-entree') . "\n"; |
|
| 63 | - unset($liste_plugins[$key]); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - $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($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), $actif, |
|
| 62 | + 'menu-entree') . "\n"; |
|
| 63 | + unset($liste_plugins[$key]); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + $res .= tree_open_close_dir($current_dir, $init_dir, true); |
|
| 68 | 68 | |
| 69 | - return "<ul class='menu-liste plugins'>" |
|
| 70 | - . $res |
|
| 71 | - . "</ul>"; |
|
| 69 | + return "<ul class='menu-liste plugins'>" |
|
| 70 | + . $res |
|
| 71 | + . "</ul>"; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
@@ -76,44 +76,44 @@ discard block |
||
| 76 | 76 | // une fonction pour aider... |
| 77 | 77 | // https://code.spip.net/@chemin_plug |
| 78 | 78 | function chemin_plug($racine, $plug) { |
| 79 | - return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug"); |
|
| 79 | + return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug"); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // https://code.spip.net/@tree_open_close_dir |
| 83 | 83 | function tree_open_close_dir(&$current, $target, $deplie = array()) { |
| 84 | - if ($current == $target) { |
|
| 85 | - return ""; |
|
| 86 | - } |
|
| 87 | - $tcur = explode("/", $current); |
|
| 88 | - $ttarg = explode("/", $target); |
|
| 89 | - $tcom = array(); |
|
| 90 | - $output = ""; |
|
| 91 | - // la partie commune |
|
| 92 | - while (reset($tcur) == reset($ttarg)) { |
|
| 93 | - $tcom[] = array_shift($tcur); |
|
| 94 | - array_shift($ttarg); |
|
| 95 | - } |
|
| 96 | - // fermer les repertoires courant jusqu'au point de fork |
|
| 97 | - while ($close = array_pop($tcur)) { |
|
| 98 | - $output .= "</ul>\n"; |
|
| 99 | - $output .= fin_block(); |
|
| 100 | - $output .= "</li>\n"; |
|
| 101 | - } |
|
| 102 | - $chemin = ""; |
|
| 103 | - if (count($tcom)) { |
|
| 104 | - $chemin .= implode("/", $tcom) . "/"; |
|
| 105 | - } |
|
| 106 | - // ouvrir les repertoires jusqu'a la cible |
|
| 107 | - while ($open = array_shift($ttarg)) { |
|
| 108 | - $visible = @isset($deplie[$chemin . $open]); |
|
| 109 | - $chemin .= $open . "/"; |
|
| 110 | - $output .= "<li>"; |
|
| 111 | - $output .= bouton_block_depliable($chemin, $visible); |
|
| 112 | - $output .= debut_block_depliable($visible); |
|
| 84 | + if ($current == $target) { |
|
| 85 | + return ""; |
|
| 86 | + } |
|
| 87 | + $tcur = explode("/", $current); |
|
| 88 | + $ttarg = explode("/", $target); |
|
| 89 | + $tcom = array(); |
|
| 90 | + $output = ""; |
|
| 91 | + // la partie commune |
|
| 92 | + while (reset($tcur) == reset($ttarg)) { |
|
| 93 | + $tcom[] = array_shift($tcur); |
|
| 94 | + array_shift($ttarg); |
|
| 95 | + } |
|
| 96 | + // fermer les repertoires courant jusqu'au point de fork |
|
| 97 | + while ($close = array_pop($tcur)) { |
|
| 98 | + $output .= "</ul>\n"; |
|
| 99 | + $output .= fin_block(); |
|
| 100 | + $output .= "</li>\n"; |
|
| 101 | + } |
|
| 102 | + $chemin = ""; |
|
| 103 | + if (count($tcom)) { |
|
| 104 | + $chemin .= implode("/", $tcom) . "/"; |
|
| 105 | + } |
|
| 106 | + // ouvrir les repertoires jusqu'a la cible |
|
| 107 | + while ($open = array_shift($ttarg)) { |
|
| 108 | + $visible = @isset($deplie[$chemin . $open]); |
|
| 109 | + $chemin .= $open . "/"; |
|
| 110 | + $output .= "<li>"; |
|
| 111 | + $output .= bouton_block_depliable($chemin, $visible); |
|
| 112 | + $output .= debut_block_depliable($visible); |
|
| 113 | 113 | |
| 114 | - $output .= "<ul>\n"; |
|
| 115 | - } |
|
| 116 | - $current = $target; |
|
| 114 | + $output .= "<ul>\n"; |
|
| 115 | + } |
|
| 116 | + $current = $target; |
|
| 117 | 117 | |
| 118 | - return $output; |
|
| 118 | + return $output; |
|
| 119 | 119 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | asort($liste_plugins); |
| 65 | 65 | $exposed = urldecode(_request('plugin')); |
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 67 | + $block_par_lettre = false; //count($liste_plugins)>10; |
|
| 68 | 68 | $fast_liste_plugins_actifs = array(); |
| 69 | 69 | $fast_liste_plugins_checked = array(); |
| 70 | 70 | if (is_array($liste_plugins_actifs)) { |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | $actif = isset($fast_liste_plugins_actifs[$plug]); |
| 90 | 90 | $checked = isset($fast_liste_plugins_checked[$plug]); |
| 91 | 91 | $block_actif = $block_actif | $actif; |
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins, |
|
| 93 | - strlen(_DIR_RACINE)) . $plug)); |
|
| 94 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n"; |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins.$plug or $exposed == substr($dir_plugins, |
|
| 93 | + strlen(_DIR_RACINE)).$plug)); |
|
| 94 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins)."\n"; |
|
| 95 | 95 | } |
| 96 | 96 | $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
| 97 | 97 | $class = basename($dir_plugins); |
@@ -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 | include_spip('inc/charsets'); |
| 17 | 17 | |
@@ -28,88 +28,88 @@ discard block |
||
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | 30 | function plugins_afficher_liste_dist( |
| 31 | - $url_page, |
|
| 32 | - $liste_plugins, |
|
| 33 | - $liste_plugins_checked, |
|
| 34 | - $liste_plugins_actifs, |
|
| 35 | - $dir_plugins = _DIR_PLUGINS, |
|
| 36 | - $afficher_un = 'afficher_plugin' |
|
| 31 | + $url_page, |
|
| 32 | + $liste_plugins, |
|
| 33 | + $liste_plugins_checked, |
|
| 34 | + $liste_plugins_actifs, |
|
| 35 | + $dir_plugins = _DIR_PLUGINS, |
|
| 36 | + $afficher_un = 'afficher_plugin' |
|
| 37 | 37 | ) { |
| 38 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 39 | - $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 38 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 39 | + $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 40 | 40 | |
| 41 | - $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 41 | + $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 42 | 42 | |
| 43 | - $all_infos = pipeline('filtrer_liste_plugins', |
|
| 44 | - array( |
|
| 45 | - 'args' => array( |
|
| 46 | - 'liste_plugins' => $liste_plugins, |
|
| 47 | - 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | - 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | - 'dir_plugins' => $dir_plugins |
|
| 50 | - ), |
|
| 51 | - 'data' => $all_infos |
|
| 52 | - ) |
|
| 53 | - ); |
|
| 43 | + $all_infos = pipeline('filtrer_liste_plugins', |
|
| 44 | + array( |
|
| 45 | + 'args' => array( |
|
| 46 | + 'liste_plugins' => $liste_plugins, |
|
| 47 | + 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | + 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | + 'dir_plugins' => $dir_plugins |
|
| 50 | + ), |
|
| 51 | + 'data' => $all_infos |
|
| 52 | + ) |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | - $liste_plugins = array_flip($liste_plugins); |
|
| 56 | - foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | - // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | - if (isset($all_infos[$chemin])) { |
|
| 59 | - $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | - } else { |
|
| 61 | - unset($liste_plugins[$chemin]); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - asort($liste_plugins); |
|
| 65 | - $exposed = urldecode(_request('plugin')); |
|
| 55 | + $liste_plugins = array_flip($liste_plugins); |
|
| 56 | + foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | + // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | + if (isset($all_infos[$chemin])) { |
|
| 59 | + $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | + } else { |
|
| 61 | + unset($liste_plugins[$chemin]); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + asort($liste_plugins); |
|
| 65 | + $exposed = urldecode(_request('plugin')); |
|
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | - $fast_liste_plugins_actifs = array(); |
|
| 69 | - $fast_liste_plugins_checked = array(); |
|
| 70 | - if (is_array($liste_plugins_actifs)) { |
|
| 71 | - $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | - } |
|
| 73 | - if (is_array($liste_plugins_checked)) { |
|
| 74 | - $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | - } |
|
| 67 | + $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | + $fast_liste_plugins_actifs = array(); |
|
| 69 | + $fast_liste_plugins_checked = array(); |
|
| 70 | + if (is_array($liste_plugins_actifs)) { |
|
| 71 | + $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | + } |
|
| 73 | + if (is_array($liste_plugins_checked)) { |
|
| 74 | + $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $res = ''; |
|
| 78 | - $block = ''; |
|
| 79 | - $initiale = ''; |
|
| 80 | - $block_actif = false; |
|
| 81 | - foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | - if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | - $initiale = $i; |
|
| 85 | - $block = ''; |
|
| 86 | - $block_actif = false; |
|
| 87 | - } |
|
| 88 | - // le rep suivant |
|
| 89 | - $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | - $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | - $block_actif = $block_actif | $actif; |
|
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins, |
|
| 93 | - strlen(_DIR_RACINE)) . $plug)); |
|
| 94 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n"; |
|
| 95 | - } |
|
| 96 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 97 | - $class = basename($dir_plugins); |
|
| 77 | + $res = ''; |
|
| 78 | + $block = ''; |
|
| 79 | + $initiale = ''; |
|
| 80 | + $block_actif = false; |
|
| 81 | + foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | + if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | + $initiale = $i; |
|
| 85 | + $block = ''; |
|
| 86 | + $block_actif = false; |
|
| 87 | + } |
|
| 88 | + // le rep suivant |
|
| 89 | + $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | + $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | + $block_actif = $block_actif | $actif; |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins, |
|
| 93 | + strlen(_DIR_RACINE)) . $plug)); |
|
| 94 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n"; |
|
| 95 | + } |
|
| 96 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 97 | + $class = basename($dir_plugins); |
|
| 98 | 98 | |
| 99 | - return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ""; |
|
| 99 | + return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ""; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | // https://code.spip.net/@affiche_block_initiale |
| 104 | 104 | function affiche_block_initiale($initiale, $block, $block_actif) { |
| 105 | - if (strlen($block)) { |
|
| 106 | - return "<li class='item'>" |
|
| 107 | - . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 108 | - . debut_block_depliable($block_actif) |
|
| 109 | - . "<ul>$block</ul>" |
|
| 110 | - . fin_block() |
|
| 111 | - . "</li>"; |
|
| 112 | - } |
|
| 105 | + if (strlen($block)) { |
|
| 106 | + return "<li class='item'>" |
|
| 107 | + . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 108 | + . debut_block_depliable($block_actif) |
|
| 109 | + . "<ul>$block</ul>" |
|
| 110 | + . fin_block() |
|
| 111 | + . "</li>"; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return ""; |
|
| 114 | + return ""; |
|
| 115 | 115 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite |
| 24 | 24 | define('_separateur_urls_page', ''); |
| 25 | 25 | # on peut indiquer '' si on a installe le .htaccess |
| 26 | -define('_debut_urls_page', get_spip_script('./') . '?'); |
|
| 26 | +define('_debut_urls_page', get_spip_script('./').'?'); |
|
| 27 | 27 | ####### |
| 28 | 28 | |
| 29 | 29 | |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 41 | - . $id . _terminaison_urls_page; |
|
| 40 | + $url = _debut_urls_page.$type._separateur_urls_page |
|
| 41 | + . $id._terminaison_urls_page; |
|
| 42 | 42 | |
| 43 | 43 | if ($args) { |
| 44 | 44 | $args = strpos($url, '?') ? "&$args" : "?$args"; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 47 | + return _DIR_RACINE.$url.$args.($ancre ? "#$ancre" : ''); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // retrouve le fond et les parametres d'une URL abregee |
@@ -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 | define('URLS_PAGE_EXEMPLE', 'spip.php?article12'); |
@@ -30,74 +30,74 @@ discard block |
||
| 30 | 30 | // https://code.spip.net/@_generer_url_page |
| 31 | 31 | function _generer_url_page($type, $id, $args = '', $ancre = '') { |
| 32 | 32 | |
| 33 | - if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) { |
|
| 34 | - $url = $generer_url_externe($id, $args, $ancre); |
|
| 35 | - if (null != $url) { |
|
| 36 | - return $url; |
|
| 37 | - } |
|
| 38 | - } |
|
| 33 | + if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) { |
|
| 34 | + $url = $generer_url_externe($id, $args, $ancre); |
|
| 35 | + if (null != $url) { |
|
| 36 | + return $url; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 41 | - . $id . _terminaison_urls_page; |
|
| 40 | + $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 41 | + . $id . _terminaison_urls_page; |
|
| 42 | 42 | |
| 43 | - if ($args) { |
|
| 44 | - $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 45 | - } |
|
| 43 | + if ($args) { |
|
| 44 | + $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 47 | + return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // retrouve le fond et les parametres d'une URL abregee |
| 51 | 51 | // le contexte deja existant est fourni dans args sous forme de tableau ou query string |
| 52 | 52 | // https://code.spip.net/@urls_page_dist |
| 53 | 53 | function urls_page_dist($i, &$entite, $args = '', $ancre = '') { |
| 54 | - if (is_numeric($i)) { |
|
| 55 | - return _generer_url_page($entite, $i, $args, $ancre); |
|
| 56 | - } |
|
| 54 | + if (is_numeric($i)) { |
|
| 55 | + return _generer_url_page($entite, $i, $args, $ancre); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 59 | - if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 60 | - return array(array(), '404'); |
|
| 61 | - } |
|
| 58 | + // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 59 | + if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 60 | + return array(array(), '404'); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // voir s'il faut recuperer le id_* implicite et les &debut_xx; |
|
| 64 | - if (is_array($args)) { |
|
| 65 | - $contexte = $args; |
|
| 66 | - } else { |
|
| 67 | - parse_str($args, $contexte); |
|
| 68 | - } |
|
| 69 | - include_spip('inc/urls'); |
|
| 70 | - $r = nettoyer_url_page($i, $contexte); |
|
| 71 | - if ($r) { |
|
| 72 | - array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | - return $r; |
|
| 74 | - } |
|
| 63 | + // voir s'il faut recuperer le id_* implicite et les &debut_xx; |
|
| 64 | + if (is_array($args)) { |
|
| 65 | + $contexte = $args; |
|
| 66 | + } else { |
|
| 67 | + parse_str($args, $contexte); |
|
| 68 | + } |
|
| 69 | + include_spip('inc/urls'); |
|
| 70 | + $r = nettoyer_url_page($i, $contexte); |
|
| 71 | + if ($r) { |
|
| 72 | + array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | + return $r; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /* |
|
| 76 | + /* |
|
| 77 | 77 | * Le bloc qui suit sert a faciliter les transitions depuis |
| 78 | 78 | * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html' |
| 79 | 79 | * Il est inutile de le recopier si vous personnalisez vos URLs |
| 80 | 80 | * et votre .htaccess |
| 81 | 81 | */ |
| 82 | - // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | - // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | - $url = $i; |
|
| 85 | - $url_propre = isset($url) |
|
| 86 | - ? $url |
|
| 87 | - : (isset($_SERVER['REDIRECT_url_propre']) |
|
| 88 | - ? $_SERVER['REDIRECT_url_propre'] |
|
| 89 | - : (isset($_ENV['url_propre']) |
|
| 90 | - ? $_ENV['url_propre'] |
|
| 91 | - : '' |
|
| 92 | - )); |
|
| 93 | - if ($url_propre) { |
|
| 94 | - if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 95 | - $urls_anciennes = charger_fonction('propres', 'urls', true); |
|
| 96 | - } else { |
|
| 97 | - $urls_anciennes = charger_fonction('arbo', 'urls', true); |
|
| 98 | - } |
|
| 82 | + // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | + // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | + $url = $i; |
|
| 85 | + $url_propre = isset($url) |
|
| 86 | + ? $url |
|
| 87 | + : (isset($_SERVER['REDIRECT_url_propre']) |
|
| 88 | + ? $_SERVER['REDIRECT_url_propre'] |
|
| 89 | + : (isset($_ENV['url_propre']) |
|
| 90 | + ? $_ENV['url_propre'] |
|
| 91 | + : '' |
|
| 92 | + )); |
|
| 93 | + if ($url_propre) { |
|
| 94 | + if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 95 | + $urls_anciennes = charger_fonction('propres', 'urls', true); |
|
| 96 | + } else { |
|
| 97 | + $urls_anciennes = charger_fonction('arbo', 'urls', true); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : ''; |
|
| 101 | - } |
|
| 102 | - /* Fin du bloc compatibilite url-propres */ |
|
| 100 | + return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : ''; |
|
| 101 | + } |
|
| 102 | + /* Fin du bloc compatibilite url-propres */ |
|
| 103 | 103 | } |
@@ -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 | define('_REGEXP_DOCTYPE', |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
| 34 | 34 | define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA'); |
| 35 | 35 | define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' . |
| 36 | - _SUB_REGEXP_SYMBOL . |
|
| 37 | - '+;?)\s+(' . |
|
| 38 | - _REGEXP_TYPE_XML . |
|
| 39 | - ')?\s*(' . |
|
| 40 | - "('([^']*)')" . |
|
| 41 | - '|("([^"]*)")' . |
|
| 42 | - '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 43 | - ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 36 | + _SUB_REGEXP_SYMBOL . |
|
| 37 | + '+;?)\s+(' . |
|
| 38 | + _REGEXP_TYPE_XML . |
|
| 39 | + ')?\s*(' . |
|
| 40 | + "('([^']*)')" . |
|
| 41 | + '|("([^"]*)")' . |
|
| 42 | + '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 43 | + ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 44 | 44 | |
| 45 | 45 | define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s'); |
| 46 | 46 | |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | * Document Type Compilation |
| 51 | 51 | **/ |
| 52 | 52 | class DTC { |
| 53 | - public $macros = array(); |
|
| 54 | - public $elements = array(); |
|
| 55 | - public $peres = array(); |
|
| 56 | - public $attributs = array(); |
|
| 57 | - public $entites = array(); |
|
| 58 | - public $regles = array(); |
|
| 59 | - public $pcdata = array(); |
|
| 53 | + public $macros = array(); |
|
| 54 | + public $elements = array(); |
|
| 55 | + public $peres = array(); |
|
| 56 | + public $attributs = array(); |
|
| 57 | + public $entites = array(); |
|
| 58 | + public $regles = array(); |
|
| 59 | + public $pcdata = array(); |
|
| 60 | 60 | } |
@@ -23,23 +23,23 @@ |
||
| 23 | 23 | |
| 24 | 24 | define('_SUB_REGEXP_SYMBOL', '[\w_:.-]'); |
| 25 | 25 | |
| 26 | -define('_REGEXP_NMTOKEN', '/^' . _SUB_REGEXP_SYMBOL . '+$/'); |
|
| 26 | +define('_REGEXP_NMTOKEN', '/^'._SUB_REGEXP_SYMBOL.'+$/'); |
|
| 27 | 27 | |
| 28 | -define('_REGEXP_NMTOKENS', '/^(' . _SUB_REGEXP_SYMBOL . '+\s*)*$/'); |
|
| 28 | +define('_REGEXP_NMTOKENS', '/^('._SUB_REGEXP_SYMBOL.'+\s*)*$/'); |
|
| 29 | 29 | |
| 30 | -define('_REGEXP_ID', '/^[A-Za-z_:]' . _SUB_REGEXP_SYMBOL . '*$/'); |
|
| 30 | +define('_REGEXP_ID', '/^[A-Za-z_:]'._SUB_REGEXP_SYMBOL.'*$/'); |
|
| 31 | 31 | |
| 32 | -define('_REGEXP_ENTITY_USE', '/%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
|
| 33 | -define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
|
| 32 | +define('_REGEXP_ENTITY_USE', '/%('._SUB_REGEXP_SYMBOL.'+);/'); |
|
| 33 | +define('_REGEXP_ENTITY_DEF', '/^%('._SUB_REGEXP_SYMBOL.'+);/'); |
|
| 34 | 34 | define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA'); |
| 35 | -define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' . |
|
| 36 | - _SUB_REGEXP_SYMBOL . |
|
| 37 | - '+;?)\s+(' . |
|
| 38 | - _REGEXP_TYPE_XML . |
|
| 39 | - ')?\s*(' . |
|
| 40 | - "('([^']*)')" . |
|
| 41 | - '|("([^"]*)")' . |
|
| 42 | - '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 35 | +define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*('. |
|
| 36 | + _SUB_REGEXP_SYMBOL. |
|
| 37 | + '+;?)\s+('. |
|
| 38 | + _REGEXP_TYPE_XML. |
|
| 39 | + ')?\s*('. |
|
| 40 | + "('([^']*)')". |
|
| 41 | + '|("([^"]*)")'. |
|
| 42 | + '|\s*(%'._SUB_REGEXP_SYMBOL.'+;)\s*'. |
|
| 43 | 43 | ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
| 44 | 44 | |
| 45 | 45 | define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s'); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $grammaire = find_in_path($grammaire); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $file = _DIR_CACHE_XML . preg_replace('/[^\w.]/', '_', $rotlvl) . '.gz'; |
|
| 31 | + $file = _DIR_CACHE_XML.preg_replace('/[^\w.]/', '_', $rotlvl).'.gz'; |
|
| 32 | 32 | |
| 33 | 33 | if (lire_fichier($file, $r)) { |
| 34 | 34 | if (!$grammaire) { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $dtc->peres[$k] = $v; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - spip_log("Analyser DTD $avail $grammaire (" . spip_timer('dtd') . ") " . count($dtc->macros) . ' macros, ' . count($dtc->elements) . ' elements, ' . count($dtc->attributs) . " listes d'attributs, " . count($dtc->entites) . " entites"); |
|
| 58 | + spip_log("Analyser DTD $avail $grammaire (".spip_timer('dtd').") ".count($dtc->macros).' macros, '.count($dtc->elements).' elements, '.count($dtc->attributs)." listes d'attributs, ".count($dtc->entites)." entites"); |
|
| 59 | 59 | # $r = $dtc->regles; ksort($r);foreach($r as $l => $v) {$t=array_keys($dtc->attributs[$l]);echo "<b>$l</b> '$v' ", count($t), " attributs: ", join (', ',$t);$t=$dtc->peres[$l];echo "<br />",count($t), " peres: ", @join (', ',$t), "<br />\n";}exit; |
| 60 | 60 | ecrire_fichier($file, serialize($dtc), true); |
| 61 | 61 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | if (!is_string($r)) { |
| 159 | - spip_log("erreur $r dans la DTD " . substr($dtd, 0, 80) . "....."); |
|
| 159 | + spip_log("erreur $r dans la DTD ".substr($dtd, 0, 80)."....."); |
|
| 160 | 160 | |
| 161 | 161 | return false; |
| 162 | 162 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | if (($n[0] == 'PUBLIC') |
| 204 | 204 | and !tester_url_absolue($n[1]) |
| 205 | 205 | ) { |
| 206 | - $n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1) . $n[1]; |
|
| 206 | + $n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1).$n[1]; |
|
| 207 | 207 | } |
| 208 | 208 | analyser_dtd($n[1], $n[0], $dtc); |
| 209 | 209 | } |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | if ($dtc->macros[$m[1]] == 'INCLUDE') { |
| 230 | - $retour = $r[1] . substr($m[2], strlen($r[0])); |
|
| 230 | + $retour = $r[1].substr($m[2], strlen($r[0])); |
|
| 231 | 231 | } else { |
| 232 | 232 | $retour = substr($m[2], strlen($r[0])); |
| 233 | 233 | } |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | spip_log("redefinition de l'entite $nom"); |
| 261 | 261 | } |
| 262 | 262 | if ($k6) { |
| 263 | - return $k6 . $dtd; |
|
| 263 | + return $k6.$dtd; |
|
| 264 | 264 | } // cas du synonyme complet |
| 265 | 265 | $val = expanserEntite(($k2 ? $k3 : ($k4 ? $k5 : $k6)), $dtc->macros); |
| 266 | 266 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+([^\s']*)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) { |
| 367 | 367 | foreach ($r2 as $m2) { |
| 368 | 368 | $v = preg_match('/^\w+$/', $m2[2]) ? $m2[2] |
| 369 | - : ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/'); |
|
| 369 | + : ('/^'.preg_replace('/\s+/', '', $m2[2]).'$/'); |
|
| 370 | 370 | $m21 = expanserEntite($m2[1], $dtc->macros); |
| 371 | 371 | $m25 = expanserEntite($m2[5], $dtc->macros); |
| 372 | 372 | $dtc->attributs[$nom][$m21] = array($v, $m25); |
@@ -11,59 +11,59 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('xml/interfaces'); |
| 18 | 18 | |
| 19 | 19 | // https://code.spip.net/@charger_dtd |
| 20 | 20 | function charger_dtd($grammaire, $avail, $rotlvl) { |
| 21 | - static $dtd = array(); # cache bien utile pour le validateur en boucle |
|
| 22 | - |
|
| 23 | - if (isset($dtd[$grammaire])) { |
|
| 24 | - return $dtd[$grammaire]; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - if ($avail == 'SYSTEM') { |
|
| 28 | - $grammaire = find_in_path($grammaire); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - $file = _DIR_CACHE_XML . preg_replace('/[^\w.]/', '_', $rotlvl) . '.gz'; |
|
| 32 | - |
|
| 33 | - if (lire_fichier($file, $r)) { |
|
| 34 | - if (!$grammaire) { |
|
| 35 | - return array(); |
|
| 36 | - } |
|
| 37 | - if (($avail == 'SYSTEM') and filemtime($file) < filemtime($grammaire)) { |
|
| 38 | - $r = false; |
|
| 39 | - } |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - if ($r) { |
|
| 43 | - $dtc = unserialize($r); |
|
| 44 | - } else { |
|
| 45 | - spip_timer('dtd'); |
|
| 46 | - $dtc = new DTC; |
|
| 47 | - // L'analyseur retourne un booleen de reussite et modifie $dtc. |
|
| 48 | - // Retourner vide en cas d'echec |
|
| 49 | - if (!analyser_dtd($grammaire, $avail, $dtc)) { |
|
| 50 | - $dtc = array(); |
|
| 51 | - } else { |
|
| 52 | - // tri final pour presenter les suggestions de corrections |
|
| 53 | - foreach ($dtc->peres as $k => $v) { |
|
| 54 | - asort($v); |
|
| 55 | - $dtc->peres[$k] = $v; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - spip_log("Analyser DTD $avail $grammaire (" . spip_timer('dtd') . ") " . count($dtc->macros) . ' macros, ' . count($dtc->elements) . ' elements, ' . count($dtc->attributs) . " listes d'attributs, " . count($dtc->entites) . " entites"); |
|
| 59 | - # $r = $dtc->regles; ksort($r);foreach($r as $l => $v) {$t=array_keys($dtc->attributs[$l]);echo "<b>$l</b> '$v' ", count($t), " attributs: ", join (', ',$t);$t=$dtc->peres[$l];echo "<br />",count($t), " peres: ", @join (', ',$t), "<br />\n";}exit; |
|
| 60 | - ecrire_fichier($file, serialize($dtc), true); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - } |
|
| 64 | - $dtd[$grammaire] = $dtc; |
|
| 65 | - |
|
| 66 | - return $dtc; |
|
| 21 | + static $dtd = array(); # cache bien utile pour le validateur en boucle |
|
| 22 | + |
|
| 23 | + if (isset($dtd[$grammaire])) { |
|
| 24 | + return $dtd[$grammaire]; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + if ($avail == 'SYSTEM') { |
|
| 28 | + $grammaire = find_in_path($grammaire); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + $file = _DIR_CACHE_XML . preg_replace('/[^\w.]/', '_', $rotlvl) . '.gz'; |
|
| 32 | + |
|
| 33 | + if (lire_fichier($file, $r)) { |
|
| 34 | + if (!$grammaire) { |
|
| 35 | + return array(); |
|
| 36 | + } |
|
| 37 | + if (($avail == 'SYSTEM') and filemtime($file) < filemtime($grammaire)) { |
|
| 38 | + $r = false; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + if ($r) { |
|
| 43 | + $dtc = unserialize($r); |
|
| 44 | + } else { |
|
| 45 | + spip_timer('dtd'); |
|
| 46 | + $dtc = new DTC; |
|
| 47 | + // L'analyseur retourne un booleen de reussite et modifie $dtc. |
|
| 48 | + // Retourner vide en cas d'echec |
|
| 49 | + if (!analyser_dtd($grammaire, $avail, $dtc)) { |
|
| 50 | + $dtc = array(); |
|
| 51 | + } else { |
|
| 52 | + // tri final pour presenter les suggestions de corrections |
|
| 53 | + foreach ($dtc->peres as $k => $v) { |
|
| 54 | + asort($v); |
|
| 55 | + $dtc->peres[$k] = $v; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + spip_log("Analyser DTD $avail $grammaire (" . spip_timer('dtd') . ") " . count($dtc->macros) . ' macros, ' . count($dtc->elements) . ' elements, ' . count($dtc->attributs) . " listes d'attributs, " . count($dtc->entites) . " entites"); |
|
| 59 | + # $r = $dtc->regles; ksort($r);foreach($r as $l => $v) {$t=array_keys($dtc->attributs[$l]);echo "<b>$l</b> '$v' ", count($t), " attributs: ", join (', ',$t);$t=$dtc->peres[$l];echo "<br />",count($t), " peres: ", @join (', ',$t), "<br />\n";}exit; |
|
| 60 | + ecrire_fichier($file, serialize($dtc), true); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + } |
|
| 64 | + $dtd[$grammaire] = $dtc; |
|
| 65 | + |
|
| 66 | + return $dtc; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // Compiler une regle de production en une Regexp qu'on appliquera sur la |
@@ -76,141 +76,141 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | // https://code.spip.net/@compilerRegle |
| 78 | 78 | function compilerRegle($val) { |
| 79 | - $x = str_replace('()', '', |
|
| 80 | - preg_replace('/\s*,\s*/', '', |
|
| 81 | - preg_replace('/(\w+)\s*/', '(?:\1 )', |
|
| 82 | - preg_replace('/\s*\)/', ')', |
|
| 83 | - preg_replace('/\s*([(+*|?])\s*/', '\1', |
|
| 84 | - preg_replace('/\s*#\w+\s*[,|]?\s*/', '', $val)))))); |
|
| 85 | - |
|
| 86 | - return $x; |
|
| 79 | + $x = str_replace('()', '', |
|
| 80 | + preg_replace('/\s*,\s*/', '', |
|
| 81 | + preg_replace('/(\w+)\s*/', '(?:\1 )', |
|
| 82 | + preg_replace('/\s*\)/', ')', |
|
| 83 | + preg_replace('/\s*([(+*|?])\s*/', '\1', |
|
| 84 | + preg_replace('/\s*#\w+\s*[,|]?\s*/', '', $val)))))); |
|
| 85 | + |
|
| 86 | + return $x; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | |
| 90 | 90 | // https://code.spip.net/@analyser_dtd |
| 91 | 91 | function analyser_dtd($loc, $avail, &$dtc) { |
| 92 | - // creer le repertoire de cache si ce n'est fait |
|
| 93 | - // (utile aussi pour le resultat de la compil) |
|
| 94 | - $file = sous_repertoire(_DIR_CACHE_XML); |
|
| 95 | - // si DTD locale, ignorer ce repertoire pour le moment |
|
| 96 | - if ($avail == 'SYSTEM') { |
|
| 97 | - $file = $loc; |
|
| 98 | - if (_DIR_RACINE and strncmp($file, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 99 | - $file = substr($file, strlen(_DIR_RACINE)); |
|
| 100 | - } |
|
| 101 | - $file = find_in_path($file); |
|
| 102 | - } else { |
|
| 103 | - $file .= preg_replace('/[^\w.]/', '_', $loc); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $dtd = ''; |
|
| 107 | - if (@is_readable($file)) { |
|
| 108 | - lire_fichier($file, $dtd); |
|
| 109 | - } else { |
|
| 110 | - if ($avail == 'PUBLIC') { |
|
| 111 | - include_spip('inc/distant'); |
|
| 112 | - $dtd = recuperer_url($loc); |
|
| 113 | - $dtd = trim($dtd['page'] ?? ''); |
|
| 114 | - if ($dtd) { |
|
| 115 | - ecrire_fichier($file, $dtd, true); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $dtd = ltrim($dtd); |
|
| 121 | - if (!$dtd) { |
|
| 122 | - spip_log("DTD '$loc' ($file) inaccessible"); |
|
| 123 | - |
|
| 124 | - return false; |
|
| 125 | - } else { |
|
| 126 | - spip_log("analyse de la DTD $loc "); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - while ($dtd) { |
|
| 130 | - if ($dtd[0] != '<') { |
|
| 131 | - $r = analyser_dtd_lexeme($dtd, $dtc, $loc); |
|
| 132 | - } elseif ($dtd[1] != '!') { |
|
| 133 | - $r = analyser_dtd_pi($dtd, $dtc, $loc); |
|
| 134 | - } elseif ($dtd[2] == '[') { |
|
| 135 | - $r = analyser_dtd_data($dtd, $dtc, $loc); |
|
| 136 | - } else { |
|
| 137 | - switch ($dtd[3]) { |
|
| 138 | - case '%' : |
|
| 139 | - $r = analyser_dtd_data($dtd, $dtc, $loc); |
|
| 140 | - break; |
|
| 141 | - case 'T' : |
|
| 142 | - $r = analyser_dtd_attlist($dtd, $dtc, $loc); |
|
| 143 | - break; |
|
| 144 | - case 'L' : |
|
| 145 | - $r = analyser_dtd_element($dtd, $dtc, $loc); |
|
| 146 | - break; |
|
| 147 | - case 'N' : |
|
| 148 | - $r = analyser_dtd_entity($dtd, $dtc, $loc); |
|
| 149 | - break; |
|
| 150 | - case 'O' : |
|
| 151 | - $r = analyser_dtd_notation($dtd, $dtc, $loc); |
|
| 152 | - break; |
|
| 153 | - case '-' : |
|
| 154 | - $r = analyser_dtd_comment($dtd, $dtc, $loc); |
|
| 155 | - break; |
|
| 156 | - default: |
|
| 157 | - $r = -1; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - if (!is_string($r)) { |
|
| 161 | - spip_log("erreur $r dans la DTD " . substr($dtd, 0, 80) . "....."); |
|
| 162 | - |
|
| 163 | - return false; |
|
| 164 | - } |
|
| 165 | - $dtd = $r; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - return true; |
|
| 92 | + // creer le repertoire de cache si ce n'est fait |
|
| 93 | + // (utile aussi pour le resultat de la compil) |
|
| 94 | + $file = sous_repertoire(_DIR_CACHE_XML); |
|
| 95 | + // si DTD locale, ignorer ce repertoire pour le moment |
|
| 96 | + if ($avail == 'SYSTEM') { |
|
| 97 | + $file = $loc; |
|
| 98 | + if (_DIR_RACINE and strncmp($file, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 99 | + $file = substr($file, strlen(_DIR_RACINE)); |
|
| 100 | + } |
|
| 101 | + $file = find_in_path($file); |
|
| 102 | + } else { |
|
| 103 | + $file .= preg_replace('/[^\w.]/', '_', $loc); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $dtd = ''; |
|
| 107 | + if (@is_readable($file)) { |
|
| 108 | + lire_fichier($file, $dtd); |
|
| 109 | + } else { |
|
| 110 | + if ($avail == 'PUBLIC') { |
|
| 111 | + include_spip('inc/distant'); |
|
| 112 | + $dtd = recuperer_url($loc); |
|
| 113 | + $dtd = trim($dtd['page'] ?? ''); |
|
| 114 | + if ($dtd) { |
|
| 115 | + ecrire_fichier($file, $dtd, true); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $dtd = ltrim($dtd); |
|
| 121 | + if (!$dtd) { |
|
| 122 | + spip_log("DTD '$loc' ($file) inaccessible"); |
|
| 123 | + |
|
| 124 | + return false; |
|
| 125 | + } else { |
|
| 126 | + spip_log("analyse de la DTD $loc "); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + while ($dtd) { |
|
| 130 | + if ($dtd[0] != '<') { |
|
| 131 | + $r = analyser_dtd_lexeme($dtd, $dtc, $loc); |
|
| 132 | + } elseif ($dtd[1] != '!') { |
|
| 133 | + $r = analyser_dtd_pi($dtd, $dtc, $loc); |
|
| 134 | + } elseif ($dtd[2] == '[') { |
|
| 135 | + $r = analyser_dtd_data($dtd, $dtc, $loc); |
|
| 136 | + } else { |
|
| 137 | + switch ($dtd[3]) { |
|
| 138 | + case '%' : |
|
| 139 | + $r = analyser_dtd_data($dtd, $dtc, $loc); |
|
| 140 | + break; |
|
| 141 | + case 'T' : |
|
| 142 | + $r = analyser_dtd_attlist($dtd, $dtc, $loc); |
|
| 143 | + break; |
|
| 144 | + case 'L' : |
|
| 145 | + $r = analyser_dtd_element($dtd, $dtc, $loc); |
|
| 146 | + break; |
|
| 147 | + case 'N' : |
|
| 148 | + $r = analyser_dtd_entity($dtd, $dtc, $loc); |
|
| 149 | + break; |
|
| 150 | + case 'O' : |
|
| 151 | + $r = analyser_dtd_notation($dtd, $dtc, $loc); |
|
| 152 | + break; |
|
| 153 | + case '-' : |
|
| 154 | + $r = analyser_dtd_comment($dtd, $dtc, $loc); |
|
| 155 | + break; |
|
| 156 | + default: |
|
| 157 | + $r = -1; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + if (!is_string($r)) { |
|
| 161 | + spip_log("erreur $r dans la DTD " . substr($dtd, 0, 80) . "....."); |
|
| 162 | + |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 165 | + $dtd = $r; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + return true; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // https://code.spip.net/@analyser_dtd_comment |
| 172 | 172 | function analyser_dtd_comment($dtd, &$dtc, $grammaire) { |
| 173 | - // ejecter les commentaires, surtout quand ils contiennent du code. |
|
| 174 | - // Option /s car sur plusieurs lignes parfois |
|
| 173 | + // ejecter les commentaires, surtout quand ils contiennent du code. |
|
| 174 | + // Option /s car sur plusieurs lignes parfois |
|
| 175 | 175 | |
| 176 | - if (!preg_match('/^<!--.*?-->\s*(.*)$/s', $dtd, $m)) { |
|
| 177 | - return -6; |
|
| 178 | - } |
|
| 176 | + if (!preg_match('/^<!--.*?-->\s*(.*)$/s', $dtd, $m)) { |
|
| 177 | + return -6; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - return $m[1]; |
|
| 180 | + return $m[1]; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // https://code.spip.net/@analyser_dtd_pi |
| 184 | 184 | function analyser_dtd_pi($dtd, &$dtc, $grammaire) { |
| 185 | - if (!preg_match('/^<\?.*?>\s*(.*)$/s', $dtd, $m)) { |
|
| 186 | - return -10; |
|
| 187 | - } |
|
| 185 | + if (!preg_match('/^<\?.*?>\s*(.*)$/s', $dtd, $m)) { |
|
| 186 | + return -10; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - return $m[1]; |
|
| 189 | + return $m[1]; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // https://code.spip.net/@analyser_dtd_lexeme |
| 193 | 193 | function analyser_dtd_lexeme($dtd, &$dtc, $grammaire) { |
| 194 | 194 | |
| 195 | - if (!preg_match(_REGEXP_ENTITY_DEF, $dtd, $m)) { |
|
| 196 | - return -9; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - list(, $s) = $m; |
|
| 200 | - $n = $dtc->macros[$s]; |
|
| 201 | - |
|
| 202 | - if (is_array($n)) { |
|
| 203 | - // en cas d'inclusion, l'espace de nom est le meme |
|
| 204 | - // mais gaffe aux DTD dont l'URL est relative a l'engloblante |
|
| 205 | - if (($n[0] == 'PUBLIC') |
|
| 206 | - and !tester_url_absolue($n[1]) |
|
| 207 | - ) { |
|
| 208 | - $n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1) . $n[1]; |
|
| 209 | - } |
|
| 210 | - analyser_dtd($n[1], $n[0], $dtc); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - return ltrim(substr($dtd, strlen($m[0]))); |
|
| 195 | + if (!preg_match(_REGEXP_ENTITY_DEF, $dtd, $m)) { |
|
| 196 | + return -9; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + list(, $s) = $m; |
|
| 200 | + $n = $dtc->macros[$s]; |
|
| 201 | + |
|
| 202 | + if (is_array($n)) { |
|
| 203 | + // en cas d'inclusion, l'espace de nom est le meme |
|
| 204 | + // mais gaffe aux DTD dont l'URL est relative a l'engloblante |
|
| 205 | + if (($n[0] == 'PUBLIC') |
|
| 206 | + and !tester_url_absolue($n[1]) |
|
| 207 | + ) { |
|
| 208 | + $n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1) . $n[1]; |
|
| 209 | + } |
|
| 210 | + analyser_dtd($n[1], $n[0], $dtc); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + return ltrim(substr($dtd, strlen($m[0]))); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // il faudrait gerer plus proprement les niveaux d'inclusion: |
@@ -219,80 +219,80 @@ discard block |
||
| 219 | 219 | // https://code.spip.net/@analyser_dtd_data |
| 220 | 220 | function analyser_dtd_data($dtd, &$dtc, $grammaire) { |
| 221 | 221 | |
| 222 | - if (!preg_match(_REGEXP_INCLUDE_USE, $dtd, $m)) { |
|
| 223 | - return -11; |
|
| 224 | - } |
|
| 225 | - if (!preg_match('/^((\s*<!(\[\s*%\s*[^;]*;\s*\[([^]<]*<[^>]*>)*[^]<]*\]\]>)|([^]>]*>))*[^]<]*)\]\]>\s*/s', $m[2], |
|
| 226 | - $r) |
|
| 227 | - ) { |
|
| 228 | - return -12; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - if ($dtc->macros[$m[1]] == 'INCLUDE') { |
|
| 232 | - $retour = $r[1] . substr($m[2], strlen($r[0])); |
|
| 233 | - } else { |
|
| 234 | - $retour = substr($m[2], strlen($r[0])); |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - return $retour; |
|
| 222 | + if (!preg_match(_REGEXP_INCLUDE_USE, $dtd, $m)) { |
|
| 223 | + return -11; |
|
| 224 | + } |
|
| 225 | + if (!preg_match('/^((\s*<!(\[\s*%\s*[^;]*;\s*\[([^]<]*<[^>]*>)*[^]<]*\]\]>)|([^]>]*>))*[^]<]*)\]\]>\s*/s', $m[2], |
|
| 226 | + $r) |
|
| 227 | + ) { |
|
| 228 | + return -12; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + if ($dtc->macros[$m[1]] == 'INCLUDE') { |
|
| 232 | + $retour = $r[1] . substr($m[2], strlen($r[0])); |
|
| 233 | + } else { |
|
| 234 | + $retour = substr($m[2], strlen($r[0])); |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + return $retour; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // https://code.spip.net/@analyser_dtd_notation |
| 241 | 241 | function analyser_dtd_notation($dtd, &$dtc, $grammaire) { |
| 242 | - if (!preg_match('/^<!NOTATION.*?>\s*(.*)$/s', $dtd, $m)) { |
|
| 243 | - return -8; |
|
| 244 | - } |
|
| 245 | - spip_log("analyser_dtd_notation a ecrire"); |
|
| 242 | + if (!preg_match('/^<!NOTATION.*?>\s*(.*)$/s', $dtd, $m)) { |
|
| 243 | + return -8; |
|
| 244 | + } |
|
| 245 | + spip_log("analyser_dtd_notation a ecrire"); |
|
| 246 | 246 | |
| 247 | - return $m[1]; |
|
| 247 | + return $m[1]; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | // https://code.spip.net/@analyser_dtd_entity |
| 251 | 251 | function analyser_dtd_entity($dtd, &$dtc, $grammaire) { |
| 252 | - if (!preg_match(_REGEXP_ENTITY_DECL, $dtd, $m)) { |
|
| 253 | - return -2; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - list($t, $term, $nom, $type, $k1, $k2, $k3, $k4, $k5, $k6, $c, $q, $alt, $dtd) = $m; |
|
| 257 | - |
|
| 258 | - if (isset($dtc->macros[$nom]) and $dtc->macros[$nom]) { |
|
| 259 | - return $dtd; |
|
| 260 | - } |
|
| 261 | - if (isset($dtc->entites[$nom])) { |
|
| 262 | - spip_log("redefinition de l'entite $nom"); |
|
| 263 | - } |
|
| 264 | - if ($k6) { |
|
| 265 | - return $k6 . $dtd; |
|
| 266 | - } // cas du synonyme complet |
|
| 267 | - $val = expanserEntite(($k2 ? $k3 : ($k4 ? $k5 : $k6)), $dtc->macros); |
|
| 268 | - |
|
| 269 | - // cas particulier double evaluation: 'PUBLIC "..." "...."' |
|
| 270 | - if (preg_match('/(PUBLIC|SYSTEM)\s+"([^"]*)"\s*("([^"]*)")?\s*$/s', $val, $r)) { |
|
| 271 | - list($t, $type, $val, $q, $alt) = $r; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - if (!$term) { |
|
| 275 | - $dtc->entites[$nom] = $val; |
|
| 276 | - } elseif (!$type) { |
|
| 277 | - $dtc->macros[$nom] = $val; |
|
| 278 | - } else { |
|
| 279 | - if (($type == 'SYSTEM') and !$alt) { |
|
| 280 | - $alt = $val; |
|
| 281 | - } |
|
| 282 | - if (!$alt) { |
|
| 283 | - $dtc->macros[$nom] = $val; |
|
| 284 | - } else { |
|
| 285 | - if (($type == 'PUBLIC') |
|
| 286 | - and (strpos($alt, '/') === false) |
|
| 287 | - ) { |
|
| 288 | - $alt = preg_replace(',/[^/]+$,', '/', $grammaire) |
|
| 289 | - . $alt; |
|
| 290 | - } |
|
| 291 | - $dtc->macros[$nom] = array($type, $alt); |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - return $dtd; |
|
| 252 | + if (!preg_match(_REGEXP_ENTITY_DECL, $dtd, $m)) { |
|
| 253 | + return -2; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + list($t, $term, $nom, $type, $k1, $k2, $k3, $k4, $k5, $k6, $c, $q, $alt, $dtd) = $m; |
|
| 257 | + |
|
| 258 | + if (isset($dtc->macros[$nom]) and $dtc->macros[$nom]) { |
|
| 259 | + return $dtd; |
|
| 260 | + } |
|
| 261 | + if (isset($dtc->entites[$nom])) { |
|
| 262 | + spip_log("redefinition de l'entite $nom"); |
|
| 263 | + } |
|
| 264 | + if ($k6) { |
|
| 265 | + return $k6 . $dtd; |
|
| 266 | + } // cas du synonyme complet |
|
| 267 | + $val = expanserEntite(($k2 ? $k3 : ($k4 ? $k5 : $k6)), $dtc->macros); |
|
| 268 | + |
|
| 269 | + // cas particulier double evaluation: 'PUBLIC "..." "...."' |
|
| 270 | + if (preg_match('/(PUBLIC|SYSTEM)\s+"([^"]*)"\s*("([^"]*)")?\s*$/s', $val, $r)) { |
|
| 271 | + list($t, $type, $val, $q, $alt) = $r; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + if (!$term) { |
|
| 275 | + $dtc->entites[$nom] = $val; |
|
| 276 | + } elseif (!$type) { |
|
| 277 | + $dtc->macros[$nom] = $val; |
|
| 278 | + } else { |
|
| 279 | + if (($type == 'SYSTEM') and !$alt) { |
|
| 280 | + $alt = $val; |
|
| 281 | + } |
|
| 282 | + if (!$alt) { |
|
| 283 | + $dtc->macros[$nom] = $val; |
|
| 284 | + } else { |
|
| 285 | + if (($type == 'PUBLIC') |
|
| 286 | + and (strpos($alt, '/') === false) |
|
| 287 | + ) { |
|
| 288 | + $alt = preg_replace(',/[^/]+$,', '/', $grammaire) |
|
| 289 | + . $alt; |
|
| 290 | + } |
|
| 291 | + $dtc->macros[$nom] = array($type, $alt); |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + return $dtd; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | // Dresser le tableau des filles potentielles de l'element |
@@ -306,76 +306,76 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | // https://code.spip.net/@analyser_dtd_element |
| 308 | 308 | function analyser_dtd_element($dtd, &$dtc, $grammaire) { |
| 309 | - if (!preg_match('/^<!ELEMENT\s+([^>\s]+)([^>]*)>\s*(.*)$/s', $dtd, $m)) { |
|
| 310 | - return -3; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - list(, $nom, $contenu, $dtd) = $m; |
|
| 314 | - $nom = expanserEntite($nom, $dtc->macros); |
|
| 315 | - |
|
| 316 | - if (isset($dtc->elements[$nom])) { |
|
| 317 | - spip_log("redefinition de l'element $nom dans la DTD"); |
|
| 318 | - |
|
| 319 | - return -4; |
|
| 320 | - } |
|
| 321 | - $filles = array(); |
|
| 322 | - $contenu = expanserEntite($contenu, $dtc->macros); |
|
| 323 | - $val = $contenu ? compilerRegle($contenu) : '(?:EMPTY )'; |
|
| 324 | - if ($val == '(?:EMPTY )') { |
|
| 325 | - $dtc->regles[$nom] = 'EMPTY'; |
|
| 326 | - } elseif ($val == '(?:ANY )') { |
|
| 327 | - $dtc->regles[$nom] = 'ANY'; |
|
| 328 | - } else { |
|
| 329 | - $last = substr($val, -1); |
|
| 330 | - if (preg_match('/ \w/', $val) |
|
| 331 | - or (!empty($last) and strpos('*+?', $last) === false) |
|
| 332 | - ) { |
|
| 333 | - $dtc->regles[$nom] = "/^$val$/"; |
|
| 334 | - } else { |
|
| 335 | - $dtc->regles[$nom] = $last; |
|
| 336 | - } |
|
| 337 | - $filles = array_values(preg_split('/\W+/', $val, -1, PREG_SPLIT_NO_EMPTY)); |
|
| 338 | - |
|
| 339 | - foreach ($filles as $k) { |
|
| 340 | - if (!isset($dtc->peres[$k])) { |
|
| 341 | - $dtc->peres[$k] = array(); |
|
| 342 | - } |
|
| 343 | - if (!in_array($nom, $dtc->peres[$k])) { |
|
| 344 | - $dtc->peres[$k][] = $nom; |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - $dtc->pcdata[$nom] = (strpos($contenu, '#PCDATA') === false); |
|
| 349 | - $dtc->elements[$nom] = $filles; |
|
| 350 | - |
|
| 351 | - return $dtd; |
|
| 309 | + if (!preg_match('/^<!ELEMENT\s+([^>\s]+)([^>]*)>\s*(.*)$/s', $dtd, $m)) { |
|
| 310 | + return -3; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + list(, $nom, $contenu, $dtd) = $m; |
|
| 314 | + $nom = expanserEntite($nom, $dtc->macros); |
|
| 315 | + |
|
| 316 | + if (isset($dtc->elements[$nom])) { |
|
| 317 | + spip_log("redefinition de l'element $nom dans la DTD"); |
|
| 318 | + |
|
| 319 | + return -4; |
|
| 320 | + } |
|
| 321 | + $filles = array(); |
|
| 322 | + $contenu = expanserEntite($contenu, $dtc->macros); |
|
| 323 | + $val = $contenu ? compilerRegle($contenu) : '(?:EMPTY )'; |
|
| 324 | + if ($val == '(?:EMPTY )') { |
|
| 325 | + $dtc->regles[$nom] = 'EMPTY'; |
|
| 326 | + } elseif ($val == '(?:ANY )') { |
|
| 327 | + $dtc->regles[$nom] = 'ANY'; |
|
| 328 | + } else { |
|
| 329 | + $last = substr($val, -1); |
|
| 330 | + if (preg_match('/ \w/', $val) |
|
| 331 | + or (!empty($last) and strpos('*+?', $last) === false) |
|
| 332 | + ) { |
|
| 333 | + $dtc->regles[$nom] = "/^$val$/"; |
|
| 334 | + } else { |
|
| 335 | + $dtc->regles[$nom] = $last; |
|
| 336 | + } |
|
| 337 | + $filles = array_values(preg_split('/\W+/', $val, -1, PREG_SPLIT_NO_EMPTY)); |
|
| 338 | + |
|
| 339 | + foreach ($filles as $k) { |
|
| 340 | + if (!isset($dtc->peres[$k])) { |
|
| 341 | + $dtc->peres[$k] = array(); |
|
| 342 | + } |
|
| 343 | + if (!in_array($nom, $dtc->peres[$k])) { |
|
| 344 | + $dtc->peres[$k][] = $nom; |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + $dtc->pcdata[$nom] = (strpos($contenu, '#PCDATA') === false); |
|
| 349 | + $dtc->elements[$nom] = $filles; |
|
| 350 | + |
|
| 351 | + return $dtd; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | |
| 355 | 355 | // https://code.spip.net/@analyser_dtd_attlist |
| 356 | 356 | function analyser_dtd_attlist($dtd, &$dtc, $grammaire) { |
| 357 | - if (!preg_match('/^<!ATTLIST\s+(\S+)\s+([^>]*)>\s*(.*)/s', $dtd, $m)) { |
|
| 358 | - return -5; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - list(, $nom, $val, $dtd) = $m; |
|
| 362 | - $nom = expanserEntite($nom, $dtc->macros); |
|
| 363 | - $val = expanserEntite($val, $dtc->macros); |
|
| 364 | - if (!isset($dtc->attributs[$nom])) { |
|
| 365 | - $dtc->attributs[$nom] = array(); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+([^\s']*)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) { |
|
| 369 | - foreach ($r2 as $m2) { |
|
| 370 | - $v = preg_match('/^\w+$/', $m2[2]) ? $m2[2] |
|
| 371 | - : ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/'); |
|
| 372 | - $m21 = expanserEntite($m2[1], $dtc->macros); |
|
| 373 | - $m25 = expanserEntite($m2[5], $dtc->macros); |
|
| 374 | - $dtc->attributs[$nom][$m21] = array($v, $m25); |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - return $dtd; |
|
| 357 | + if (!preg_match('/^<!ATTLIST\s+(\S+)\s+([^>]*)>\s*(.*)/s', $dtd, $m)) { |
|
| 358 | + return -5; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + list(, $nom, $val, $dtd) = $m; |
|
| 362 | + $nom = expanserEntite($nom, $dtc->macros); |
|
| 363 | + $val = expanserEntite($val, $dtc->macros); |
|
| 364 | + if (!isset($dtc->attributs[$nom])) { |
|
| 365 | + $dtc->attributs[$nom] = array(); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+([^\s']*)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) { |
|
| 369 | + foreach ($r2 as $m2) { |
|
| 370 | + $v = preg_match('/^\w+$/', $m2[2]) ? $m2[2] |
|
| 371 | + : ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/'); |
|
| 372 | + $m21 = expanserEntite($m2[1], $dtc->macros); |
|
| 373 | + $m25 = expanserEntite($m2[5], $dtc->macros); |
|
| 374 | + $dtc->attributs[$nom][$m21] = array($v, $m25); |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + return $dtd; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | |
@@ -391,26 +391,26 @@ discard block |
||
| 391 | 391 | * @return string|array |
| 392 | 392 | **/ |
| 393 | 393 | function expanserEntite($val, $macros = array()) { |
| 394 | - static $vu = array(); |
|
| 395 | - if (!is_string($val)) { |
|
| 396 | - return $vu; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - if (preg_match_all(_REGEXP_ENTITY_USE, $val, $r, PREG_SET_ORDER)) { |
|
| 400 | - foreach ($r as $m) { |
|
| 401 | - $ent = $m[1]; |
|
| 402 | - // il peut valoir "" |
|
| 403 | - if (!isset($macros[$ent])) { |
|
| 404 | - spip_log("Entite $ent inconnu"); |
|
| 405 | - } else { |
|
| 406 | - if (!isset($vu[$ent])) { |
|
| 407 | - $vu[$ent] = 0; |
|
| 408 | - } |
|
| 409 | - ++$vu[$ent]; |
|
| 410 | - $val = str_replace($m[0], $macros[$ent], $val); |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - return trim(preg_replace('/\s+/', ' ', $val)); |
|
| 394 | + static $vu = array(); |
|
| 395 | + if (!is_string($val)) { |
|
| 396 | + return $vu; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + if (preg_match_all(_REGEXP_ENTITY_USE, $val, $r, PREG_SET_ORDER)) { |
|
| 400 | + foreach ($r as $m) { |
|
| 401 | + $ent = $m[1]; |
|
| 402 | + // il peut valoir "" |
|
| 403 | + if (!isset($macros[$ent])) { |
|
| 404 | + spip_log("Entite $ent inconnu"); |
|
| 405 | + } else { |
|
| 406 | + if (!isset($vu[$ent])) { |
|
| 407 | + $vu[$ent] = 0; |
|
| 408 | + } |
|
| 409 | + ++$vu[$ent]; |
|
| 410 | + $val = str_replace($m[0], $macros[$ent], $val); |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + return trim(preg_replace('/\s+/', ' ', $val)); |
|
| 416 | 416 | } |