@@ -16,212 +16,212 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | include_spip('inc/charsets'); |
| 22 | 22 | include_spip('inc/texte'); |
| 23 | 23 | include_spip('inc/plugin'); // pour plugin_est_installe |
| 24 | 24 | |
| 25 | 25 | function plugins_afficher_plugin_dist( |
| 26 | - $url_page, |
|
| 27 | - $plug_file, |
|
| 28 | - $checked, |
|
| 29 | - $actif, |
|
| 30 | - $expose = false, |
|
| 31 | - $class_li = 'item', |
|
| 32 | - $dir_plugins = _DIR_PLUGINS |
|
| 26 | + $url_page, |
|
| 27 | + $plug_file, |
|
| 28 | + $checked, |
|
| 29 | + $actif, |
|
| 30 | + $expose = false, |
|
| 31 | + $class_li = 'item', |
|
| 32 | + $dir_plugins = _DIR_PLUGINS |
|
| 33 | 33 | ) { |
| 34 | 34 | |
| 35 | - static $id_input = 0; |
|
| 36 | - static $versions = []; |
|
| 37 | - |
|
| 38 | - $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 39 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 40 | - $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 41 | - $prefix = $info['prefix']; |
|
| 42 | - $cfg = ''; |
|
| 43 | - $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 44 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 45 | - $erreur = ''; |
|
| 46 | - |
|
| 47 | - if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 48 | - $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 49 | - $erreur = http_img_pack( |
|
| 50 | - 'plugin-dis-32.png', |
|
| 51 | - _T('plugin_info_non_compatible_spip'), |
|
| 52 | - " class='picto_err'", |
|
| 53 | - _T('plugin_info_non_compatible_spip') |
|
| 54 | - ); |
|
| 55 | - $class_li .= ' disabled'; |
|
| 56 | - $checkable = false; |
|
| 57 | - } elseif (isset($info['erreur'])) { |
|
| 58 | - $class_li .= ' error'; |
|
| 59 | - $erreur = http_img_pack( |
|
| 60 | - 'plugin-err-32.png', |
|
| 61 | - _T('plugin_info_erreur_xml'), |
|
| 62 | - " class='picto_err'", |
|
| 63 | - _T('plugin_info_erreur_xml') |
|
| 64 | - ) |
|
| 65 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 66 | - $checkable = false; |
|
| 67 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 68 | - $class_li .= ' error'; |
|
| 69 | - $erreur = http_img_pack( |
|
| 70 | - 'plugin-err-32.png', |
|
| 71 | - _T('plugin_impossible_activer', ['plugin' => $nom]), |
|
| 72 | - " class='picto_err'", |
|
| 73 | - _T('plugin_impossible_activer', ['plugin' => $nom]) |
|
| 74 | - ) |
|
| 75 | - . "<div class='erreur'>" . implode( |
|
| 76 | - '<br />', |
|
| 77 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 78 | - ) . '</div>'; |
|
| 79 | - } else { |
|
| 80 | - $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
|
| 81 | - if (defined('_DEV_VERSION_SPIP_COMPAT') && !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
|
| 82 | - //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 83 | - $erreur = http_img_pack( |
|
| 84 | - 'plugin-dis-32.png', |
|
| 85 | - _T('plugin_info_non_compatible_spip'), |
|
| 86 | - " class='picto_err picto_compat_forcee'", |
|
| 87 | - _L('Version incompatible : compatibilité forcée') |
|
| 88 | - ); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // numerotons les occurrences d'un meme prefix |
|
| 93 | - $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 94 | - |
|
| 95 | - $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 96 | - |
|
| 97 | - return "<li id='$prefix$id' class='$class_li'>" |
|
| 98 | - . ((!$checkable && !$checked) |
|
| 99 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 100 | - . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 101 | - . $cfg |
|
| 102 | - . $erreur |
|
| 103 | - . (($dir_plugins !== _DIR_PLUGINS_DIST && plugin_est_installe($plug_file)) |
|
| 104 | - ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 105 | - . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 106 | - . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 107 | - . '</div>' |
|
| 108 | - . '</li>'; |
|
| 35 | + static $id_input = 0; |
|
| 36 | + static $versions = []; |
|
| 37 | + |
|
| 38 | + $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 39 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 40 | + $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 41 | + $prefix = $info['prefix']; |
|
| 42 | + $cfg = ''; |
|
| 43 | + $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 44 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 45 | + $erreur = ''; |
|
| 46 | + |
|
| 47 | + if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 48 | + $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 49 | + $erreur = http_img_pack( |
|
| 50 | + 'plugin-dis-32.png', |
|
| 51 | + _T('plugin_info_non_compatible_spip'), |
|
| 52 | + " class='picto_err'", |
|
| 53 | + _T('plugin_info_non_compatible_spip') |
|
| 54 | + ); |
|
| 55 | + $class_li .= ' disabled'; |
|
| 56 | + $checkable = false; |
|
| 57 | + } elseif (isset($info['erreur'])) { |
|
| 58 | + $class_li .= ' error'; |
|
| 59 | + $erreur = http_img_pack( |
|
| 60 | + 'plugin-err-32.png', |
|
| 61 | + _T('plugin_info_erreur_xml'), |
|
| 62 | + " class='picto_err'", |
|
| 63 | + _T('plugin_info_erreur_xml') |
|
| 64 | + ) |
|
| 65 | + . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 66 | + $checkable = false; |
|
| 67 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 68 | + $class_li .= ' error'; |
|
| 69 | + $erreur = http_img_pack( |
|
| 70 | + 'plugin-err-32.png', |
|
| 71 | + _T('plugin_impossible_activer', ['plugin' => $nom]), |
|
| 72 | + " class='picto_err'", |
|
| 73 | + _T('plugin_impossible_activer', ['plugin' => $nom]) |
|
| 74 | + ) |
|
| 75 | + . "<div class='erreur'>" . implode( |
|
| 76 | + '<br />', |
|
| 77 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 78 | + ) . '</div>'; |
|
| 79 | + } else { |
|
| 80 | + $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
|
| 81 | + if (defined('_DEV_VERSION_SPIP_COMPAT') && !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
|
| 82 | + //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 83 | + $erreur = http_img_pack( |
|
| 84 | + 'plugin-dis-32.png', |
|
| 85 | + _T('plugin_info_non_compatible_spip'), |
|
| 86 | + " class='picto_err picto_compat_forcee'", |
|
| 87 | + _L('Version incompatible : compatibilité forcée') |
|
| 88 | + ); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // numerotons les occurrences d'un meme prefix |
|
| 93 | + $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 94 | + |
|
| 95 | + $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 96 | + |
|
| 97 | + return "<li id='$prefix$id' class='$class_li'>" |
|
| 98 | + . ((!$checkable && !$checked) |
|
| 99 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 100 | + . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 101 | + . $cfg |
|
| 102 | + . $erreur |
|
| 103 | + . (($dir_plugins !== _DIR_PLUGINS_DIST && plugin_est_installe($plug_file)) |
|
| 104 | + ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 105 | + . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 106 | + . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 107 | + . '</div>' |
|
| 108 | + . '</li>'; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | function plugin_bouton_config($nom, $infos, $dir) { |
| 112 | - // la verification se base sur le filesystem |
|
| 113 | - // il faut donc n'utiliser que des minuscules, par convention |
|
| 114 | - $prefix = strtolower($infos['prefix']); |
|
| 115 | - // si paquet.xml fournit un squelette, le prendre |
|
| 116 | - if (isset($infos['config']) && $infos['config']) { |
|
| 117 | - return recuperer_fond( |
|
| 118 | - "$dir$nom/" . $infos['config'], |
|
| 119 | - [ |
|
| 120 | - 'script' => 'configurer_' . $prefix, |
|
| 121 | - 'nom' => $nom |
|
| 122 | - ] |
|
| 123 | - ); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // sinon prendre le squelette std sur le nom std |
|
| 127 | - return recuperer_fond( |
|
| 128 | - 'prive/squelettes/inclure/cfg', |
|
| 129 | - [ |
|
| 130 | - 'script' => 'configurer_' . $prefix, |
|
| 131 | - 'nom' => $nom |
|
| 132 | - ] |
|
| 133 | - ); |
|
| 112 | + // la verification se base sur le filesystem |
|
| 113 | + // il faut donc n'utiliser que des minuscules, par convention |
|
| 114 | + $prefix = strtolower($infos['prefix']); |
|
| 115 | + // si paquet.xml fournit un squelette, le prendre |
|
| 116 | + if (isset($infos['config']) && $infos['config']) { |
|
| 117 | + return recuperer_fond( |
|
| 118 | + "$dir$nom/" . $infos['config'], |
|
| 119 | + [ |
|
| 120 | + 'script' => 'configurer_' . $prefix, |
|
| 121 | + 'nom' => $nom |
|
| 122 | + ] |
|
| 123 | + ); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // sinon prendre le squelette std sur le nom std |
|
| 127 | + return recuperer_fond( |
|
| 128 | + 'prive/squelettes/inclure/cfg', |
|
| 129 | + [ |
|
| 130 | + 'script' => 'configurer_' . $prefix, |
|
| 131 | + 'nom' => $nom |
|
| 132 | + ] |
|
| 133 | + ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // checkbox pour activer ou desactiver |
| 137 | 137 | // si ce n'est pas une extension |
| 138 | 138 | |
| 139 | 139 | function plugin_checkbox($id_input, $file, $actif) { |
| 140 | - $name = substr(md5($file), 0, 16); |
|
| 141 | - |
|
| 142 | - return "<div class='check'>\n" |
|
| 143 | - . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 144 | - . ($actif ? " checked='checked'" : '') |
|
| 145 | - . " class='checkbox' value='O' />" |
|
| 146 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 147 | - . '</div>'; |
|
| 140 | + $name = substr(md5($file), 0, 16); |
|
| 141 | + |
|
| 142 | + return "<div class='check'>\n" |
|
| 143 | + . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 144 | + . ($actif ? " checked='checked'" : '') |
|
| 145 | + . " class='checkbox' value='O' />" |
|
| 146 | + . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 147 | + . '</div>'; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | function plugin_nom($info, $dir_plugins, $plug_file) { |
| 151 | - $prefix = $info['prefix']; |
|
| 152 | - $dir = "$dir_plugins$plug_file"; |
|
| 153 | - // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 154 | - if ($info['dtd'] == 'paquet') { |
|
| 155 | - $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 156 | - if (!$nom) { |
|
| 157 | - $nom = typo($info['nom']); |
|
| 158 | - } |
|
| 159 | - } else { |
|
| 160 | - $nom = typo(attribut_html($info['nom'])); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - return trim($nom); |
|
| 151 | + $prefix = $info['prefix']; |
|
| 152 | + $dir = "$dir_plugins$plug_file"; |
|
| 153 | + // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 154 | + if ($info['dtd'] == 'paquet') { |
|
| 155 | + $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 156 | + if (!$nom) { |
|
| 157 | + $nom = typo($info['nom']); |
|
| 158 | + } |
|
| 159 | + } else { |
|
| 160 | + $nom = typo(attribut_html($info['nom'])); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + return trim($nom); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Cartouche Resume |
| 167 | 167 | function plugin_resume($info, $dir_plugins, $plug_file, $url_page) { |
| 168 | - $prefix = $info['prefix']; |
|
| 169 | - $dir = "$dir_plugins$plug_file"; |
|
| 170 | - $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 171 | - // une seule ligne dans le slogan : couper si besoin |
|
| 172 | - if (($p = strpos($slogan, '<br />')) !== false) { |
|
| 173 | - $slogan = substr($slogan, 0, $p); |
|
| 174 | - } |
|
| 175 | - // couper par securite |
|
| 176 | - $slogan = couper($slogan, 80); |
|
| 177 | - |
|
| 178 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 179 | - |
|
| 180 | - $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE))); |
|
| 181 | - |
|
| 182 | - $icon_class = 'icon'; |
|
| 183 | - $img = ''; |
|
| 184 | - if (isset($info['logo']) && ($i = trim($info['logo']))) { |
|
| 185 | - $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 186 | - if (!extraire_attribut($img, 'src')) { |
|
| 187 | - $img = ''; |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - if (!$img) { |
|
| 191 | - $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'"); |
|
| 192 | - $icon_class .= ' no-logo'; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 196 | - |
|
| 197 | - return "<div class='resume'>" |
|
| 198 | - . "<h3><a href='$url' rel='info'>" |
|
| 199 | - . $nom |
|
| 200 | - . '</a></h3>' |
|
| 201 | - . " <span class='version'>" . $info['version'] . '</span>' |
|
| 202 | - . " <span class='etat'> - " |
|
| 203 | - . plugin_etat_en_clair($info['etat']) |
|
| 204 | - . '</span>' |
|
| 205 | - . "<div class='short'>" . $slogan . '</div>' |
|
| 206 | - . $i |
|
| 207 | - . '</div>'; |
|
| 168 | + $prefix = $info['prefix']; |
|
| 169 | + $dir = "$dir_plugins$plug_file"; |
|
| 170 | + $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 171 | + // une seule ligne dans le slogan : couper si besoin |
|
| 172 | + if (($p = strpos($slogan, '<br />')) !== false) { |
|
| 173 | + $slogan = substr($slogan, 0, $p); |
|
| 174 | + } |
|
| 175 | + // couper par securite |
|
| 176 | + $slogan = couper($slogan, 80); |
|
| 177 | + |
|
| 178 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 179 | + |
|
| 180 | + $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE))); |
|
| 181 | + |
|
| 182 | + $icon_class = 'icon'; |
|
| 183 | + $img = ''; |
|
| 184 | + if (isset($info['logo']) && ($i = trim($info['logo']))) { |
|
| 185 | + $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 186 | + if (!extraire_attribut($img, 'src')) { |
|
| 187 | + $img = ''; |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + if (!$img) { |
|
| 191 | + $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'"); |
|
| 192 | + $icon_class .= ' no-logo'; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 196 | + |
|
| 197 | + return "<div class='resume'>" |
|
| 198 | + . "<h3><a href='$url' rel='info'>" |
|
| 199 | + . $nom |
|
| 200 | + . '</a></h3>' |
|
| 201 | + . " <span class='version'>" . $info['version'] . '</span>' |
|
| 202 | + . " <span class='etat'> - " |
|
| 203 | + . plugin_etat_en_clair($info['etat']) |
|
| 204 | + . '</span>' |
|
| 205 | + . "<div class='short'>" . $slogan . '</div>' |
|
| 206 | + . $i |
|
| 207 | + . '</div>'; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | function plugin_desintalle($plug_file, $nom, $dir_plugins = null) { |
| 211 | - if (!$dir_plugins) { |
|
| 212 | - $dir_plugins = _DIR_PLUGINS; |
|
| 213 | - } |
|
| 211 | + if (!$dir_plugins) { |
|
| 212 | + $dir_plugins = _DIR_PLUGINS; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 216 | - $text = _T('bouton_desinstaller'); |
|
| 217 | - $text2 = _T('info_desinstaller_plugin'); |
|
| 218 | - $file = basename($plug_file); |
|
| 215 | + $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 216 | + $text = _T('bouton_desinstaller'); |
|
| 217 | + $text2 = _T('info_desinstaller_plugin'); |
|
| 218 | + $file = basename($plug_file); |
|
| 219 | 219 | |
| 220 | - return "<div class='actions'>[" . |
|
| 221 | - "<a href='$action' |
|
| 220 | + return "<div class='actions'>[" . |
|
| 221 | + "<a href='$action' |
|
| 222 | 222 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 223 | - . $text |
|
| 224 | - . '</a>]</div>'; |
|
| 223 | + . $text |
|
| 224 | + . '</a>]</div>'; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -235,143 +235,143 @@ discard block |
||
| 235 | 235 | * Traduction de l'état dans la langue en cours |
| 236 | 236 | **/ |
| 237 | 237 | function plugin_etat_en_clair($etat) { |
| 238 | - if (!in_array($etat, ['stable', 'test', 'experimental'])) { |
|
| 239 | - $etat = 'developpement'; |
|
| 240 | - } |
|
| 238 | + if (!in_array($etat, ['stable', 'test', 'experimental'])) { |
|
| 239 | + $etat = 'developpement'; |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - return _T('plugin_etat_' . $etat); |
|
| 242 | + return _T('plugin_etat_' . $etat); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | function plugin_propre($texte, $module = '', $propre = 'propre') { |
| 246 | - // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 247 | - if (_DIR_RACINE && str_starts_with($module, _DIR_RACINE)) { |
|
| 248 | - $module = substr($module, strlen(_DIR_RACINE)); |
|
| 249 | - } |
|
| 250 | - if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
|
| 251 | - $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - return $propre($texte); |
|
| 246 | + // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 247 | + if (_DIR_RACINE && str_starts_with($module, _DIR_RACINE)) { |
|
| 248 | + $module = substr($module, strlen(_DIR_RACINE)); |
|
| 249 | + } |
|
| 250 | + if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
|
| 251 | + $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + return $propre($texte); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | function plugin_typo($texte, $module = '') { |
| 258 | - return plugin_propre($texte, $module, 'typo'); |
|
| 258 | + return plugin_propre($texte, $module, 'typo'); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) { |
| 263 | - $log = null; |
|
| 264 | - if (!$dir_plugins) { |
|
| 265 | - $dir_plugins = _DIR_PLUGINS; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - $prefix = $info['prefix']; |
|
| 269 | - $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 270 | - |
|
| 271 | - $s = ''; |
|
| 272 | - // TODO: le traiter_multi ici n'est pas beau |
|
| 273 | - // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 274 | - // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 275 | - $description = ''; |
|
| 276 | - if (isset($info['description'])) { |
|
| 277 | - $description = plugin_propre($info['description'], $dir); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - if ( |
|
| 281 | - isset($info['documentation']) && ($lien = $info['documentation']) |
|
| 282 | - ) { |
|
| 283 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 284 | - } |
|
| 285 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 286 | - |
|
| 287 | - if (isset($info['auteur'])) { |
|
| 288 | - if (is_array($info['auteur'])) { |
|
| 289 | - $a = formater_credits($info['auteur'], ', '); |
|
| 290 | - } // pour compat mais ne doit plus arriver |
|
| 291 | - else { |
|
| 292 | - $a = trim($info['auteur']); |
|
| 293 | - } |
|
| 294 | - if ($a) { |
|
| 295 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 296 | - $a, |
|
| 297 | - $dir |
|
| 298 | - )) . "</dd>\n"; |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - if (isset($info['credit'])) { |
|
| 303 | - if ($a = formater_credits($info['credit'], ', ')) { |
|
| 304 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 305 | - $a, |
|
| 306 | - $dir |
|
| 307 | - )) . "</dd>\n"; |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - if (isset($info['licence'])) { |
|
| 312 | - if (is_array($info['licence'])) { |
|
| 313 | - $a = formater_credits($info['licence'], ', '); |
|
| 314 | - } // pour compat mais ne doit plus arriver |
|
| 315 | - else { |
|
| 316 | - $a = trim($info['licence']); |
|
| 317 | - } |
|
| 318 | - if ($a) { |
|
| 319 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 320 | - $a, |
|
| 321 | - $dir |
|
| 322 | - )) . "</dd>\n"; |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - $s = "<dl class='description'>$s</dl>"; |
|
| 327 | - |
|
| 328 | - // |
|
| 329 | - // Ajouter les infos techniques |
|
| 330 | - // |
|
| 331 | - $infotech = []; |
|
| 332 | - |
|
| 333 | - $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 334 | - // Version VCS |
|
| 335 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 336 | - $version .= ' ' . $vcs; |
|
| 337 | - } |
|
| 338 | - $version .= '</dd>'; |
|
| 339 | - $infotech[] = $version; |
|
| 340 | - $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 341 | - // source zip le cas echeant |
|
| 342 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) && preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 343 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 344 | - : ''; |
|
| 345 | - |
|
| 346 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 347 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 348 | - ' ', |
|
| 349 | - array_map('array_shift', $info['necessite']) |
|
| 350 | - ) . '</dd>'); |
|
| 351 | - |
|
| 352 | - $s .= "<dl class='tech'>" |
|
| 353 | - . join('', $infotech) |
|
| 354 | - . '</dl>'; |
|
| 355 | - |
|
| 356 | - |
|
| 357 | - return $s; |
|
| 263 | + $log = null; |
|
| 264 | + if (!$dir_plugins) { |
|
| 265 | + $dir_plugins = _DIR_PLUGINS; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + $prefix = $info['prefix']; |
|
| 269 | + $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 270 | + |
|
| 271 | + $s = ''; |
|
| 272 | + // TODO: le traiter_multi ici n'est pas beau |
|
| 273 | + // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 274 | + // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 275 | + $description = ''; |
|
| 276 | + if (isset($info['description'])) { |
|
| 277 | + $description = plugin_propre($info['description'], $dir); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + if ( |
|
| 281 | + isset($info['documentation']) && ($lien = $info['documentation']) |
|
| 282 | + ) { |
|
| 283 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 284 | + } |
|
| 285 | + $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 286 | + |
|
| 287 | + if (isset($info['auteur'])) { |
|
| 288 | + if (is_array($info['auteur'])) { |
|
| 289 | + $a = formater_credits($info['auteur'], ', '); |
|
| 290 | + } // pour compat mais ne doit plus arriver |
|
| 291 | + else { |
|
| 292 | + $a = trim($info['auteur']); |
|
| 293 | + } |
|
| 294 | + if ($a) { |
|
| 295 | + $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 296 | + $a, |
|
| 297 | + $dir |
|
| 298 | + )) . "</dd>\n"; |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + if (isset($info['credit'])) { |
|
| 303 | + if ($a = formater_credits($info['credit'], ', ')) { |
|
| 304 | + $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 305 | + $a, |
|
| 306 | + $dir |
|
| 307 | + )) . "</dd>\n"; |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + if (isset($info['licence'])) { |
|
| 312 | + if (is_array($info['licence'])) { |
|
| 313 | + $a = formater_credits($info['licence'], ', '); |
|
| 314 | + } // pour compat mais ne doit plus arriver |
|
| 315 | + else { |
|
| 316 | + $a = trim($info['licence']); |
|
| 317 | + } |
|
| 318 | + if ($a) { |
|
| 319 | + $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 320 | + $a, |
|
| 321 | + $dir |
|
| 322 | + )) . "</dd>\n"; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + $s = "<dl class='description'>$s</dl>"; |
|
| 327 | + |
|
| 328 | + // |
|
| 329 | + // Ajouter les infos techniques |
|
| 330 | + // |
|
| 331 | + $infotech = []; |
|
| 332 | + |
|
| 333 | + $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 334 | + // Version VCS |
|
| 335 | + if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 336 | + $version .= ' ' . $vcs; |
|
| 337 | + } |
|
| 338 | + $version .= '</dd>'; |
|
| 339 | + $infotech[] = $version; |
|
| 340 | + $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 341 | + // source zip le cas echeant |
|
| 342 | + $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) && preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 343 | + ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 344 | + : ''; |
|
| 345 | + |
|
| 346 | + $infotech[] = !$info['necessite'] ? '' : |
|
| 347 | + ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 348 | + ' ', |
|
| 349 | + array_map('array_shift', $info['necessite']) |
|
| 350 | + ) . '</dd>'); |
|
| 351 | + |
|
| 352 | + $s .= "<dl class='tech'>" |
|
| 353 | + . join('', $infotech) |
|
| 354 | + . '</dl>'; |
|
| 355 | + |
|
| 356 | + |
|
| 357 | + return $s; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | function formater_credits($infos, $sep = ', ') { |
| 361 | - $texte = ''; |
|
| 362 | - |
|
| 363 | - foreach ($infos as $_credit) { |
|
| 364 | - if ($texte) { |
|
| 365 | - $texte .= $sep; |
|
| 366 | - } |
|
| 367 | - // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 368 | - $texte .= |
|
| 369 | - (!is_array($_credit)) |
|
| 370 | - ? PtoBR(propre($_credit)) |
|
| 371 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 372 | - $_credit['nom'] . |
|
| 373 | - ($_credit['url'] ? '</a>' : ''); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - return $texte; |
|
| 361 | + $texte = ''; |
|
| 362 | + |
|
| 363 | + foreach ($infos as $_credit) { |
|
| 364 | + if ($texte) { |
|
| 365 | + $texte .= $sep; |
|
| 366 | + } |
|
| 367 | + // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 368 | + $texte .= |
|
| 369 | + (!is_array($_credit)) |
|
| 370 | + ? PtoBR(propre($_credit)) |
|
| 371 | + : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 372 | + $_credit['nom'] . |
|
| 373 | + ($_credit['url'] ? '</a>' : ''); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + return $texte; |
|
| 377 | 377 | } |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | " class='picto_err'", |
| 63 | 63 | _T('plugin_info_erreur_xml') |
| 64 | 64 | ) |
| 65 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 65 | + . "<div class='erreur'>".join('<br >', $info['erreur']).'</div>'; |
|
| 66 | 66 | $checkable = false; |
| 67 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 67 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file])) { |
|
| 68 | 68 | $class_li .= ' error'; |
| 69 | 69 | $erreur = http_img_pack( |
| 70 | 70 | 'plugin-err-32.png', |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | " class='picto_err'", |
| 73 | 73 | _T('plugin_impossible_activer', ['plugin' => $nom]) |
| 74 | 74 | ) |
| 75 | - . "<div class='erreur'>" . implode( |
|
| 75 | + . "<div class='erreur'>".implode( |
|
| 76 | 76 | '<br />', |
| 77 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 78 | - ) . '</div>'; |
|
| 77 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file] |
|
| 78 | + ).'</div>'; |
|
| 79 | 79 | } else { |
| 80 | 80 | $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
| 81 | 81 | if (defined('_DEV_VERSION_SPIP_COMPAT') && !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | // numerotons les occurrences d'un meme prefix |
| 93 | 93 | $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
| 94 | 94 | |
| 95 | - $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 95 | + $class_li .= ($actif ? ' actif' : '').($expose ? ' on' : ''); |
|
| 96 | 96 | |
| 97 | 97 | return "<li id='$prefix$id' class='$class_li'>" |
| 98 | 98 | . ((!$checkable && !$checked) |
| 99 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 99 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins.$plug_file, $checked)) |
|
| 100 | 100 | . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
| 101 | 101 | . $cfg |
| 102 | 102 | . $erreur |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | // si paquet.xml fournit un squelette, le prendre |
| 116 | 116 | if (isset($infos['config']) && $infos['config']) { |
| 117 | 117 | return recuperer_fond( |
| 118 | - "$dir$nom/" . $infos['config'], |
|
| 118 | + "$dir$nom/".$infos['config'], |
|
| 119 | 119 | [ |
| 120 | - 'script' => 'configurer_' . $prefix, |
|
| 120 | + 'script' => 'configurer_'.$prefix, |
|
| 121 | 121 | 'nom' => $nom |
| 122 | 122 | ] |
| 123 | 123 | ); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | return recuperer_fond( |
| 128 | 128 | 'prive/squelettes/inclure/cfg', |
| 129 | 129 | [ |
| 130 | - 'script' => 'configurer_' . $prefix, |
|
| 130 | + 'script' => 'configurer_'.$prefix, |
|
| 131 | 131 | 'nom' => $nom |
| 132 | 132 | ] |
| 133 | 133 | ); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | . "<input type='checkbox' name='s$name' id='label_$id_input'" |
| 144 | 144 | . ($actif ? " checked='checked'" : '') |
| 145 | 145 | . " class='checkbox' value='O' />" |
| 146 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 146 | + . "\n<label for='label_$id_input'>"._T('activer_plugin').'</label>' |
|
| 147 | 147 | . '</div>'; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -198,11 +198,11 @@ discard block |
||
| 198 | 198 | . "<h3><a href='$url' rel='info'>" |
| 199 | 199 | . $nom |
| 200 | 200 | . '</a></h3>' |
| 201 | - . " <span class='version'>" . $info['version'] . '</span>' |
|
| 201 | + . " <span class='version'>".$info['version'].'</span>' |
|
| 202 | 202 | . " <span class='etat'> - " |
| 203 | 203 | . plugin_etat_en_clair($info['etat']) |
| 204 | 204 | . '</span>' |
| 205 | - . "<div class='short'>" . $slogan . '</div>' |
|
| 205 | + . "<div class='short'>".$slogan.'</div>' |
|
| 206 | 206 | . $i |
| 207 | 207 | . '</div>'; |
| 208 | 208 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $text2 = _T('info_desinstaller_plugin'); |
| 218 | 218 | $file = basename($plug_file); |
| 219 | 219 | |
| 220 | - return "<div class='actions'>[" . |
|
| 220 | + return "<div class='actions'>[". |
|
| 221 | 221 | "<a href='$action' |
| 222 | 222 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 223 | 223 | . $text |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $etat = 'developpement'; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - return _T('plugin_etat_' . $etat); |
|
| 242 | + return _T('plugin_etat_'.$etat); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | function plugin_propre($texte, $module = '', $propre = 'propre') { |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | $module = substr($module, strlen(_DIR_RACINE)); |
| 249 | 249 | } |
| 250 | 250 | if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
| 251 | - $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 251 | + $texte = _T(($module ? "$module:" : '').$texte, [], ['force' => false]); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $propre($texte); |
@@ -280,9 +280,9 @@ discard block |
||
| 280 | 280 | if ( |
| 281 | 281 | isset($info['documentation']) && ($lien = $info['documentation']) |
| 282 | 282 | ) { |
| 283 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 283 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>"._T('en_savoir_plus').'</a></em></p>'; |
|
| 284 | 284 | } |
| 285 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 285 | + $s .= "<dd class='desc'>".$description."</dd>\n"; |
|
| 286 | 286 | |
| 287 | 287 | if (isset($info['auteur'])) { |
| 288 | 288 | if (is_array($info['auteur'])) { |
@@ -292,19 +292,19 @@ discard block |
||
| 292 | 292 | $a = trim($info['auteur']); |
| 293 | 293 | } |
| 294 | 294 | if ($a) { |
| 295 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 295 | + $s .= "<dt class='auteurs'>"._T('public:par_auteur')."</dt><dd class='auteurs'>".PtoBR(propre( |
|
| 296 | 296 | $a, |
| 297 | 297 | $dir |
| 298 | - )) . "</dd>\n"; |
|
| 298 | + ))."</dd>\n"; |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | if (isset($info['credit'])) { |
| 303 | 303 | if ($a = formater_credits($info['credit'], ', ')) { |
| 304 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 304 | + $s .= "<dt class='credits'>"._T('plugin_info_credit')."</dt><dd class='credits'>".PtoBR(propre( |
|
| 305 | 305 | $a, |
| 306 | 306 | $dir |
| 307 | - )) . "</dd>\n"; |
|
| 307 | + ))."</dd>\n"; |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | $a = trim($info['licence']); |
| 317 | 317 | } |
| 318 | 318 | if ($a) { |
| 319 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 319 | + $s .= "<dt class='licence'>"._T('intitule_licence')."</dt><dd class='licence'>".PtoBR(propre( |
|
| 320 | 320 | $a, |
| 321 | 321 | $dir |
| 322 | - )) . "</dd>\n"; |
|
| 322 | + ))."</dd>\n"; |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
@@ -330,24 +330,23 @@ discard block |
||
| 330 | 330 | // |
| 331 | 331 | $infotech = []; |
| 332 | 332 | |
| 333 | - $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 333 | + $version = '<dt>'._T('version').'</dt><dd>'.$info['version']; |
|
| 334 | 334 | // Version VCS |
| 335 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 336 | - $version .= ' ' . $vcs; |
|
| 335 | + if ($vcs = version_vcs_courante($dir_plugins.$plug_file)) { |
|
| 336 | + $version .= ' '.$vcs; |
|
| 337 | 337 | } |
| 338 | 338 | $version .= '</dd>'; |
| 339 | 339 | $infotech[] = $version; |
| 340 | - $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 340 | + $infotech[] = '<dt>'._T('repertoire_plugins').'</dt><dd>'.joli_repertoire("$dir_plugins$plug_file").'</dd>'; |
|
| 341 | 341 | // source zip le cas echeant |
| 342 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) && preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 343 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 342 | + $infotech[] = (lire_fichier($dir_plugins.$plug_file.'/install.log', $log) && preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 343 | + ? '<dt>'._T('plugin_source').'</dt><dd>'.trim($r[1]).'</dd>' |
|
| 344 | 344 | : ''; |
| 345 | 345 | |
| 346 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 347 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 346 | + $infotech[] = !$info['necessite'] ? '' : ('<dt>'._T('plugin_info_necessite').'</dt><dd>'.join( |
|
| 348 | 347 | ' ', |
| 349 | 348 | array_map('array_shift', $info['necessite']) |
| 350 | - ) . '</dd>'); |
|
| 349 | + ).'</dd>'); |
|
| 351 | 350 | |
| 352 | 351 | $s .= "<dl class='tech'>" |
| 353 | 352 | . join('', $infotech) |
@@ -368,8 +367,8 @@ discard block |
||
| 368 | 367 | $texte .= |
| 369 | 368 | (!is_array($_credit)) |
| 370 | 369 | ? PtoBR(propre($_credit)) |
| 371 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 372 | - $_credit['nom'] . |
|
| 370 | + : ($_credit['url'] ? '<a href="'.$_credit['url'].'">' : ''). |
|
| 371 | + $_credit['nom']. |
|
| 373 | 372 | ($_credit['url'] ? '</a>' : ''); |
| 374 | 373 | } |
| 375 | 374 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -36,45 +36,45 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | function install_etape_1_dist() { |
| 38 | 38 | |
| 39 | - $minipage = new Installation(); |
|
| 40 | - echo $minipage->installDebutPage(); |
|
| 39 | + $minipage = new Installation(); |
|
| 40 | + echo $minipage->installDebutPage(); |
|
| 41 | 41 | |
| 42 | - // stopper en cas de grosse incompatibilite de l'hebergement |
|
| 43 | - tester_compatibilite_hebergement(); |
|
| 42 | + // stopper en cas de grosse incompatibilite de l'hebergement |
|
| 43 | + tester_compatibilite_hebergement(); |
|
| 44 | 44 | |
| 45 | - // Recuperer les anciennes donnees pour plus de facilite (si presentes) |
|
| 46 | - $s = @is_readable(_FILE_CONNECT_TMP) ? analyse_fichier_connection(_FILE_CONNECT_TMP) : ''; |
|
| 45 | + // Recuperer les anciennes donnees pour plus de facilite (si presentes) |
|
| 46 | + $s = @is_readable(_FILE_CONNECT_TMP) ? analyse_fichier_connection(_FILE_CONNECT_TMP) : ''; |
|
| 47 | 47 | |
| 48 | - [$adresse_db, $login_db] = $s ?: ['localhost', '']; |
|
| 48 | + [$adresse_db, $login_db] = $s ?: ['localhost', '']; |
|
| 49 | 49 | |
| 50 | - $chmod = (isset($_GET['chmod']) && preg_match(',^\d+$,', (string) $_GET['chmod'])) ? |
|
| 51 | - sprintf('%04o', $_GET['chmod']) : '0777'; |
|
| 50 | + $chmod = (isset($_GET['chmod']) && preg_match(',^\d+$,', (string) $_GET['chmod'])) ? |
|
| 51 | + sprintf('%04o', $_GET['chmod']) : '0777'; |
|
| 52 | 52 | |
| 53 | - if (@is_readable(_FILE_CHMOD_TMP)) { |
|
| 54 | - $s = @implode('', @file(_FILE_CHMOD_TMP)); |
|
| 55 | - if (preg_match("#define\('_SPIP_CHMOD', (.*)\)#", $s, $regs)) { |
|
| 56 | - $chmod = $regs[1]; |
|
| 57 | - } |
|
| 58 | - } |
|
| 53 | + if (@is_readable(_FILE_CHMOD_TMP)) { |
|
| 54 | + $s = @implode('', @file(_FILE_CHMOD_TMP)); |
|
| 55 | + if (preg_match("#define\('_SPIP_CHMOD', (.*)\)#", $s, $regs)) { |
|
| 56 | + $chmod = $regs[1]; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | - $db = [$adresse_db, _T('entree_base_donnee_2')]; |
|
| 62 | - $login = [$login_db, _T('entree_login_connexion_2')]; |
|
| 63 | - $pass = ['', _T('entree_mot_passe_2')]; |
|
| 61 | + $db = [$adresse_db, _T('entree_base_donnee_2')]; |
|
| 62 | + $login = [$login_db, _T('entree_login_connexion_2')]; |
|
| 63 | + $pass = ['', _T('entree_mot_passe_2')]; |
|
| 64 | 64 | |
| 65 | - $predef = [ |
|
| 66 | - defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : '', |
|
| 67 | - defined('_INSTALL_HOST_DB'), |
|
| 68 | - defined('_INSTALL_USER_DB'), |
|
| 69 | - defined('_INSTALL_PASS_DB') |
|
| 70 | - ]; |
|
| 65 | + $predef = [ |
|
| 66 | + defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : '', |
|
| 67 | + defined('_INSTALL_HOST_DB'), |
|
| 68 | + defined('_INSTALL_USER_DB'), |
|
| 69 | + defined('_INSTALL_PASS_DB') |
|
| 70 | + ]; |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - echo info_progression_etape(1, 'etape_', 'install/'); |
|
| 73 | + echo info_progression_etape(1, 'etape_', 'install/'); |
|
| 74 | 74 | |
| 75 | - // ces deux chaines de langues doivent etre reecrites |
|
| 75 | + // ces deux chaines de langues doivent etre reecrites |
|
| 76 | 76 | # echo info_etape(_T('info_connexion_mysql'), _T('texte_connexion_mysql').aide ("install1", true)); |
| 77 | - echo info_etape(_T('info_connexion_base_donnee')); |
|
| 78 | - echo install_connexion_form($db, $login, $pass, $predef, "\n<input type='hidden' name='chmod' value='$chmod' />", 2); |
|
| 79 | - echo $minipage->installFinPage(); |
|
| 77 | + echo info_etape(_T('info_connexion_base_donnee')); |
|
| 78 | + echo install_connexion_form($db, $login, $pass, $predef, "\n<input type='hidden' name='chmod' value='$chmod' />", 2); |
|
| 79 | + echo $minipage->installFinPage(); |
|
| 80 | 80 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | // creer le repertoire cache, qui sert partout ! |
| 40 | 40 | // deja fait en etape 4 en principe, on garde au cas ou |
| 41 | 41 | if (!@file_exists(_DIR_CACHE)) { |
| 42 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 42 | + $rep = preg_replace(','._DIR_TMP.',', '', (string) _DIR_CACHE); |
|
| 43 | 43 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $cible = _T('public:accueil_site'); |
| 51 | 51 | $cible = generer_form_ecrire('accueil', '', '', $cible); |
| 52 | 52 | $minipage = new Installation(); |
| 53 | - echo $minipage->page($msg . $cible); |
|
| 53 | + echo $minipage->page($msg.$cible); |
|
| 54 | 54 | // ok, deboucher dans l'espace prive |
| 55 | 55 | } else { |
| 56 | 56 | redirige_url_ecrire('accueil'); |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | $averti = _T( |
| 72 | 72 | 'htaccess_a_simuler', |
| 73 | 73 | [ |
| 74 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 74 | + 'htaccess' => '<tt>'._ACCESS_FILE_NAME.'</tt>', |
|
| 75 | 75 | 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
| 76 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 76 | + 'document_root' => '<tt>'.$_SERVER['DOCUMENT_ROOT'].'</tt>' |
|
| 77 | 77 | ] |
| 78 | 78 | ); |
| 79 | 79 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | include_spip('inc/headers'); |
@@ -21,61 +21,61 @@ discard block |
||
| 21 | 21 | // Mise en place des fichiers de configuration si ce n'est fait |
| 22 | 22 | |
| 23 | 23 | function install_etape_fin_dist() { |
| 24 | - ecrire_acces(); |
|
| 24 | + ecrire_acces(); |
|
| 25 | 25 | |
| 26 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CHMOD_TMP); |
|
| 27 | - if (file_exists(_FILE_CHMOD_TMP) && !@rename(_FILE_CHMOD_TMP, $f) && @copy(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | - spip_unlink(_FILE_CHMOD_TMP); |
|
| 29 | - } |
|
| 26 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CHMOD_TMP); |
|
| 27 | + if (file_exists(_FILE_CHMOD_TMP) && !@rename(_FILE_CHMOD_TMP, $f) && @copy(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | + spip_unlink(_FILE_CHMOD_TMP); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CONNECT_TMP); |
|
| 32 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 33 | - spip_logger()->info("renomme $f"); |
|
| 34 | - if (!@rename(_FILE_CONNECT_TMP, $f) && @copy(_FILE_CONNECT_TMP, $f)) { |
|
| 35 | - @spip_unlink(_FILE_CONNECT_TMP); |
|
| 36 | - } |
|
| 37 | - } |
|
| 31 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CONNECT_TMP); |
|
| 32 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 33 | + spip_logger()->info("renomme $f"); |
|
| 34 | + if (!@rename(_FILE_CONNECT_TMP, $f) && @copy(_FILE_CONNECT_TMP, $f)) { |
|
| 35 | + @spip_unlink(_FILE_CONNECT_TMP); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - // creer le repertoire cache, qui sert partout ! |
|
| 40 | - // deja fait en etape 4 en principe, on garde au cas ou |
|
| 41 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 42 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 43 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 44 | - } |
|
| 39 | + // creer le repertoire cache, qui sert partout ! |
|
| 40 | + // deja fait en etape 4 en principe, on garde au cas ou |
|
| 41 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 42 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 43 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // Verifier la securite des htaccess |
|
| 47 | - // Si elle ne fonctionne pas, prevenir |
|
| 48 | - $msg = install_verifier_htaccess(); |
|
| 49 | - if ($msg) { |
|
| 50 | - $cible = _T('public:accueil_site'); |
|
| 51 | - $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 52 | - $minipage = new Installation(); |
|
| 53 | - echo $minipage->page($msg . $cible); |
|
| 54 | - // ok, deboucher dans l'espace prive |
|
| 55 | - } else { |
|
| 56 | - redirige_url_ecrire('accueil'); |
|
| 57 | - } |
|
| 46 | + // Verifier la securite des htaccess |
|
| 47 | + // Si elle ne fonctionne pas, prevenir |
|
| 48 | + $msg = install_verifier_htaccess(); |
|
| 49 | + if ($msg) { |
|
| 50 | + $cible = _T('public:accueil_site'); |
|
| 51 | + $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 52 | + $minipage = new Installation(); |
|
| 53 | + echo $minipage->page($msg . $cible); |
|
| 54 | + // ok, deboucher dans l'espace prive |
|
| 55 | + } else { |
|
| 56 | + redirige_url_ecrire('accueil'); |
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function install_verifier_htaccess() { |
| 61 | - if ( |
|
| 62 | - verifier_htaccess(_DIR_TMP, true) |
|
| 63 | - && verifier_htaccess(_DIR_CONNECT, true) |
|
| 64 | - && verifier_htaccess(_DIR_VENDOR, true) |
|
| 65 | - ) { |
|
| 66 | - return ''; |
|
| 67 | - } |
|
| 61 | + if ( |
|
| 62 | + verifier_htaccess(_DIR_TMP, true) |
|
| 63 | + && verifier_htaccess(_DIR_CONNECT, true) |
|
| 64 | + && verifier_htaccess(_DIR_VENDOR, true) |
|
| 65 | + ) { |
|
| 66 | + return ''; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $titre = _T('htaccess_inoperant'); |
|
| 69 | + $titre = _T('htaccess_inoperant'); |
|
| 70 | 70 | |
| 71 | - $averti = _T( |
|
| 72 | - 'htaccess_a_simuler', |
|
| 73 | - [ |
|
| 74 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 75 | - 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 76 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 77 | - ] |
|
| 78 | - ); |
|
| 71 | + $averti = _T( |
|
| 72 | + 'htaccess_a_simuler', |
|
| 73 | + [ |
|
| 74 | + 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 75 | + 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 76 | + 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 77 | + ] |
|
| 78 | + ); |
|
| 79 | 79 | |
| 80 | - return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 80 | + return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 81 | 81 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | * @uses info_copyright() |
| 28 | 28 | **/ |
| 29 | 29 | function install_etape__dist() { |
| 30 | - utiliser_langue_visiteur(); |
|
| 31 | - $menu_langues = menu_langues('var_lang_ecrire'); |
|
| 32 | - if (!$menu_langues) { |
|
| 33 | - redirige_url_ecrire('install', 'etape=chmod'); |
|
| 34 | - } else { |
|
| 35 | - include_spip('inc/presentation'); // pour info_copyright |
|
| 30 | + utiliser_langue_visiteur(); |
|
| 31 | + $menu_langues = menu_langues('var_lang_ecrire'); |
|
| 32 | + if (!$menu_langues) { |
|
| 33 | + redirige_url_ecrire('install', 'etape=chmod'); |
|
| 34 | + } else { |
|
| 35 | + include_spip('inc/presentation'); // pour info_copyright |
|
| 36 | 36 | |
| 37 | - $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 38 | - "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 39 | - '<p>' . _T('install_select_langue') . '</p>' . |
|
| 40 | - '<div>' . $menu_langues . "</div>\n" . |
|
| 41 | - generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 37 | + $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 38 | + "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 39 | + '<p>' . _T('install_select_langue') . '</p>' . |
|
| 40 | + '<div>' . $menu_langues . "</div>\n" . |
|
| 41 | + generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 42 | 42 | |
| 43 | - $minipage = new Installation(); |
|
| 44 | - echo $minipage->page($res); |
|
| 45 | - } |
|
| 43 | + $minipage = new Installation(); |
|
| 44 | + echo $minipage->page($res); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -34,11 +34,11 @@ |
||
| 34 | 34 | } else { |
| 35 | 35 | include_spip('inc/presentation'); // pour info_copyright |
| 36 | 36 | |
| 37 | - $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 38 | - "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 39 | - '<p>' . _T('install_select_langue') . '</p>' . |
|
| 40 | - '<div>' . $menu_langues . "</div>\n" . |
|
| 41 | - generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 37 | + $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='".chemin_image('logo-spip.png')."' />\n". |
|
| 38 | + "<p class='small'>".info_copyright()."</p></div>\n". |
|
| 39 | + '<p>'._T('install_select_langue').'</p>'. |
|
| 40 | + '<div>'.$menu_langues."</div>\n". |
|
| 41 | + generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />".bouton_suivant()); |
|
| 42 | 42 | |
| 43 | 43 | $minipage = new Installation(); |
| 44 | 44 | echo $minipage->page($res); |
@@ -12,167 +12,167 @@ |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | include_spip('base/abstract_sql'); |
| 19 | 19 | |
| 20 | 20 | function install_etape_2_dist() { |
| 21 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 22 | - ? _INSTALL_HOST_DB |
|
| 23 | - : _request('adresse_db'); |
|
| 21 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 22 | + ? _INSTALL_HOST_DB |
|
| 23 | + : _request('adresse_db'); |
|
| 24 | 24 | |
| 25 | - if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 26 | - [, $adresse_db, $port] = $r; |
|
| 27 | - } else { |
|
| 28 | - $port = ''; |
|
| 29 | - } |
|
| 25 | + if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 26 | + [, $adresse_db, $port] = $r; |
|
| 27 | + } else { |
|
| 28 | + $port = ''; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 32 | - ? _INSTALL_USER_DB |
|
| 33 | - : _request('login_db'); |
|
| 31 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 32 | + ? _INSTALL_USER_DB |
|
| 33 | + : _request('login_db'); |
|
| 34 | 34 | |
| 35 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 36 | - ? _INSTALL_PASS_DB |
|
| 37 | - : _request('pass_db'); |
|
| 35 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 36 | + ? _INSTALL_PASS_DB |
|
| 37 | + : _request('pass_db'); |
|
| 38 | 38 | |
| 39 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 40 | - ? _INSTALL_SERVER_DB |
|
| 41 | - : _request('server_db'); |
|
| 39 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 40 | + ? _INSTALL_SERVER_DB |
|
| 41 | + : _request('server_db'); |
|
| 42 | 42 | |
| 43 | - $name_db = defined('_INSTALL_NAME_DB') |
|
| 44 | - ? _INSTALL_NAME_DB |
|
| 45 | - : ''; |
|
| 43 | + $name_db = defined('_INSTALL_NAME_DB') |
|
| 44 | + ? _INSTALL_NAME_DB |
|
| 45 | + : ''; |
|
| 46 | 46 | |
| 47 | - $chmod = _request('chmod'); |
|
| 47 | + $chmod = _request('chmod'); |
|
| 48 | 48 | |
| 49 | - $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 50 | - $GLOBALS['connexions'][$server_db] = $link; |
|
| 49 | + $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 50 | + $GLOBALS['connexions'][$server_db] = $link; |
|
| 51 | 51 | |
| 52 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 53 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 52 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 53 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 54 | 54 | |
| 55 | - $minipage = new Installation(); |
|
| 56 | - echo $minipage->installDebutPage(); |
|
| 55 | + $minipage = new Installation(); |
|
| 56 | + echo $minipage->installDebutPage(); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | // prenons toutes les dispositions possibles pour que rien ne s'affiche ! |
| 60 | 60 | |
| 61 | - /* |
|
| 61 | + /* |
|
| 62 | 62 | * /!\ sqlite3/PDO : erreur sur join(', ', $link) |
| 63 | 63 | * L'objet PDO ne peut pas etre transformee en chaine |
| 64 | 64 | * Un echo $link ne fonctionne pas non plus |
| 65 | 65 | * Il faut utiliser par exemple print_r($link) |
| 66 | 66 | */ |
| 67 | - //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 68 | - $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 69 | - //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 70 | - //echo "\n-->\n"; |
|
| 67 | + //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 68 | + $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 69 | + //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 70 | + //echo "\n-->\n"; |
|
| 71 | 71 | |
| 72 | - if (($db_connect == '0') && $link) { |
|
| 73 | - echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 74 | - echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 72 | + if (($db_connect == '0') && $link) { |
|
| 73 | + echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 74 | + echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 75 | 75 | |
| 76 | - echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 76 | + echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 77 | 77 | |
| 78 | - echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 79 | - [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 78 | + echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 79 | + [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 80 | 80 | |
| 81 | - $hidden = (defined('_SPIP_CHMOD') |
|
| 82 | - ? '' |
|
| 83 | - : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 84 | - . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 81 | + $hidden = (defined('_SPIP_CHMOD') |
|
| 82 | + ? '' |
|
| 83 | + : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 84 | + . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 85 | 85 | |
| 86 | - echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 87 | - } else { |
|
| 88 | - echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 86 | + echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 87 | + } else { |
|
| 88 | + echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 89 | 89 | |
| 90 | - echo "<div class='error'>"; |
|
| 91 | - echo info_etape(_T('info_connexion_base')); |
|
| 92 | - echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 93 | - echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 90 | + echo "<div class='error'>"; |
|
| 91 | + echo info_etape(_T('info_connexion_base')); |
|
| 92 | + echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 93 | + echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 94 | 94 | |
| 95 | - echo "<p style='font-size: small;'>", |
|
| 96 | - _T('avis_connexion_echec_3'), |
|
| 97 | - '</p></div>'; |
|
| 98 | - } |
|
| 95 | + echo "<p style='font-size: small;'>", |
|
| 96 | + _T('avis_connexion_echec_3'), |
|
| 97 | + '</p></div>'; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - echo $minipage->installFinPage(); |
|
| 100 | + echo $minipage->installFinPage(); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Liste les bases accessibles, |
| 104 | 104 | // avec une heuristique pour preselectionner la plus probable |
| 105 | 105 | |
| 106 | 106 | function install_etape_2_bases($login_db, $server_db) { |
| 107 | - $res = install_etape_liste_bases($server_db, $login_db); |
|
| 108 | - if ($res) { |
|
| 109 | - [$checked, $bases] = $res; |
|
| 110 | - |
|
| 111 | - return [ |
|
| 112 | - $checked, |
|
| 113 | - "<label for='choix_db'><b>" |
|
| 114 | - . _T('texte_choix_base_2') |
|
| 115 | - . '</b><br />' |
|
| 116 | - . _T('texte_choix_base_3') |
|
| 117 | - . '</label>' |
|
| 118 | - . "<ul>\n<li>" |
|
| 119 | - . implode("</li>\n<li>", $bases) |
|
| 120 | - . "</li>\n</ul><p>" |
|
| 121 | - . _T('info_ou') |
|
| 122 | - . ' ' |
|
| 123 | - ]; |
|
| 124 | - } |
|
| 125 | - $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 107 | + $res = install_etape_liste_bases($server_db, $login_db); |
|
| 108 | + if ($res) { |
|
| 109 | + [$checked, $bases] = $res; |
|
| 110 | + |
|
| 111 | + return [ |
|
| 112 | + $checked, |
|
| 113 | + "<label for='choix_db'><b>" |
|
| 114 | + . _T('texte_choix_base_2') |
|
| 115 | + . '</b><br />' |
|
| 116 | + . _T('texte_choix_base_3') |
|
| 117 | + . '</label>' |
|
| 118 | + . "<ul>\n<li>" |
|
| 119 | + . implode("</li>\n<li>", $bases) |
|
| 120 | + . "</li>\n</ul><p>" |
|
| 121 | + . _T('info_ou') |
|
| 122 | + . ' ' |
|
| 123 | + ]; |
|
| 124 | + } |
|
| 125 | + $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 126 | 126 | ' . _T('avis_lecture_noms_bases_2') . '<p>'; |
| 127 | 127 | |
| 128 | - $checked = false; |
|
| 129 | - if ($login_db) { |
|
| 130 | - // Si un login comporte un point, le nom de la base est plus |
|
| 131 | - // probablement le login sans le point -- testons pour savoir |
|
| 132 | - $test_base = $login_db; |
|
| 133 | - $ok = sql_selectdb($test_base, $server_db); |
|
| 134 | - $test_base2 = str_replace('.', '_', (string) $test_base); |
|
| 135 | - if (sql_selectdb($test_base2, $server_db)) { |
|
| 136 | - $test_base = $test_base2; |
|
| 137 | - $ok = true; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - if ($ok) { |
|
| 141 | - $res .= _T('avis_lecture_noms_bases_3') |
|
| 142 | - . '<ul>' |
|
| 143 | - . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 144 | - . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 145 | - . '</ul>' |
|
| 146 | - . '<p>' . _T('info_ou') . ' '; |
|
| 147 | - $checked = true; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return [$checked, $res]; |
|
| 128 | + $checked = false; |
|
| 129 | + if ($login_db) { |
|
| 130 | + // Si un login comporte un point, le nom de la base est plus |
|
| 131 | + // probablement le login sans le point -- testons pour savoir |
|
| 132 | + $test_base = $login_db; |
|
| 133 | + $ok = sql_selectdb($test_base, $server_db); |
|
| 134 | + $test_base2 = str_replace('.', '_', (string) $test_base); |
|
| 135 | + if (sql_selectdb($test_base2, $server_db)) { |
|
| 136 | + $test_base = $test_base2; |
|
| 137 | + $ok = true; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + if ($ok) { |
|
| 141 | + $res .= _T('avis_lecture_noms_bases_3') |
|
| 142 | + . '<ul>' |
|
| 143 | + . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 144 | + . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 145 | + . '</ul>' |
|
| 146 | + . '<p>' . _T('info_ou') . ' '; |
|
| 147 | + $checked = true; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + return [$checked, $res]; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | function install_etape_2_form($hidden, $checked, $res, $etape) { |
| 155 | - return generer_form_ecrire('install', ( |
|
| 156 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 157 | - . $hidden |
|
| 158 | - . (defined('_INSTALL_NAME_DB') |
|
| 159 | - ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 160 | - : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 161 | - . $res |
|
| 162 | - . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 163 | - . ($checked ? '' : " checked='checked'") |
|
| 164 | - . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 165 | - . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 166 | - ) |
|
| 167 | - |
|
| 168 | - . ((defined('_INSTALL_TABLE_PREFIX') || $GLOBALS['table_prefix'] != 'spip') |
|
| 169 | - ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 170 | - : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 171 | - . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 172 | - . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 173 | - . 'spip' # valeur par defaut |
|
| 174 | - . "' size='20' /></p></fieldset>" |
|
| 175 | - ) |
|
| 176 | - |
|
| 177 | - . bouton_suivant())); |
|
| 155 | + return generer_form_ecrire('install', ( |
|
| 156 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 157 | + . $hidden |
|
| 158 | + . (defined('_INSTALL_NAME_DB') |
|
| 159 | + ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 160 | + : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 161 | + . $res |
|
| 162 | + . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 163 | + . ($checked ? '' : " checked='checked'") |
|
| 164 | + . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 165 | + . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 166 | + ) |
|
| 167 | + |
|
| 168 | + . ((defined('_INSTALL_TABLE_PREFIX') || $GLOBALS['table_prefix'] != 'spip') |
|
| 169 | + ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 170 | + : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 171 | + . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 172 | + . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 173 | + . 'spip' # valeur par defaut |
|
| 174 | + . "' size='20' /></p></fieldset>" |
|
| 175 | + ) |
|
| 176 | + |
|
| 177 | + . bouton_suivant())); |
|
| 178 | 178 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $GLOBALS['connexions'][$server_db] = $link; |
| 51 | 51 | |
| 52 | 52 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 53 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 53 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 54 | 54 | |
| 55 | 55 | $minipage = new Installation(); |
| 56 | 56 | echo $minipage->installDebutPage(); |
@@ -70,18 +70,18 @@ discard block |
||
| 70 | 70 | //echo "\n-->\n"; |
| 71 | 71 | |
| 72 | 72 | if (($db_connect == '0') && $link) { |
| 73 | - echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 73 | + echo "<div class='success'><b>"._T('info_connexion_ok').'</b></div>'; |
|
| 74 | 74 | echo info_progression_etape(2, 'etape_', 'install/'); |
| 75 | 75 | |
| 76 | - echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 76 | + echo info_etape(_T('menu_aide_installation_choix_base').aider('install2', true)); |
|
| 77 | 77 | |
| 78 | 78 | echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
| 79 | 79 | [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
| 80 | 80 | |
| 81 | 81 | $hidden = (defined('_SPIP_CHMOD') |
| 82 | 82 | ? '' |
| 83 | - : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 84 | - . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 83 | + : ("\n<input type='hidden' name='chmod' value='".spip_htmlspecialchars($chmod)."' />")) |
|
| 84 | + . predef_ou_cache($adresse_db.($port ? ':'.$port : ''), $login_db, $pass_db, $server_db); |
|
| 85 | 85 | |
| 86 | 86 | echo install_etape_2_form($hidden, $checked, $res, 3); |
| 87 | 87 | } else { |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | echo "<div class='error'>"; |
| 91 | 91 | echo info_etape(_T('info_connexion_base')); |
| 92 | - echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 93 | - echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 92 | + echo '<h3>'._T('avis_connexion_echec_1').'</h3>'; |
|
| 93 | + echo '<p>'._T('avis_connexion_echec_2').'</p>'; |
|
| 94 | 94 | |
| 95 | 95 | echo "<p style='font-size: small;'>", |
| 96 | 96 | _T('avis_connexion_echec_3'), |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | . ' ' |
| 123 | 123 | ]; |
| 124 | 124 | } |
| 125 | - $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 126 | - ' . _T('avis_lecture_noms_bases_2') . '<p>'; |
|
| 125 | + $res = '<b>'._T('avis_lecture_noms_bases_1').'</b> |
|
| 126 | + ' . _T('avis_lecture_noms_bases_2').'<p>'; |
|
| 127 | 127 | |
| 128 | 128 | $checked = false; |
| 129 | 129 | if ($login_db) { |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | if ($ok) { |
| 141 | 141 | $res .= _T('avis_lecture_noms_bases_3') |
| 142 | 142 | . '<ul>' |
| 143 | - . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 144 | - . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 143 | + . '<li><input name="choix_db" value="'.$test_base."\" type='radio' id='stand' checked='checked' />" |
|
| 144 | + . "<label for='stand'>".$test_base."</label></li>\n" |
|
| 145 | 145 | . '</ul>' |
| 146 | - . '<p>' . _T('info_ou') . ' '; |
|
| 146 | + . '<p>'._T('info_ou').' '; |
|
| 147 | 147 | $checked = true; |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -156,19 +156,19 @@ discard block |
||
| 156 | 156 | "\n<input type='hidden' name='etape' value='$etape' />" |
| 157 | 157 | . $hidden |
| 158 | 158 | . (defined('_INSTALL_NAME_DB') |
| 159 | - ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 160 | - : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 159 | + ? '<h3>'._T('install_nom_base_hebergeur').' <tt>'._INSTALL_NAME_DB.'</tt>'.'</h3>' |
|
| 160 | + : "\n<fieldset><legend>"._T('texte_choix_base_1')."</legend>\n" |
|
| 161 | 161 | . $res |
| 162 | 162 | . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
| 163 | 163 | . ($checked ? '' : " checked='checked'") |
| 164 | - . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 164 | + . " />\n<label for='nou'>"._T('info_creer_base')."</label></p>\n<p>" |
|
| 165 | 165 | . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
| 166 | 166 | ) |
| 167 | 167 | |
| 168 | 168 | . ((defined('_INSTALL_TABLE_PREFIX') || $GLOBALS['table_prefix'] != 'spip') |
| 169 | - ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 170 | - : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 171 | - . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 169 | + ? '<h3>'._T('install_table_prefix_hebergeur').' <tt>'.$GLOBALS['table_prefix'].'</tt>'.'</h3>' |
|
| 170 | + : '<fieldset><legend>'._T('texte_choix_table_prefix')."</legend>\n" |
|
| 171 | + . "<p><label for='table_prefix'>"._T('info_table_prefix').'</label></p><p>' |
|
| 172 | 172 | . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
| 173 | 173 | . 'spip' # valeur par defaut |
| 174 | 174 | . "' size='20' /></p></fieldset>" |
@@ -17,210 +17,210 @@ |
||
| 17 | 17 | * @see extraire_balises() |
| 18 | 18 | */ |
| 19 | 19 | class HtmlTag extends AbstractCollecteur { |
| 20 | - protected static string $markPrefix = 'HTMLTAG'; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * La preg pour découper et collecter les modèles |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - protected string $preg_openingtag; |
|
| 27 | - protected string $preg_closingtag; |
|
| 28 | - protected string $tag; |
|
| 29 | - |
|
| 30 | - public static array $listeBalisesAProteger = ['html', 'pre', 'code', 'cadre', 'frame', 'script', 'style']; |
|
| 31 | - |
|
| 32 | - public function __construct(string $tag, ?string $preg_openingtag = null, ?string $preg_closingtag = null) { |
|
| 33 | - |
|
| 34 | - $tag = strtolower($tag); |
|
| 35 | - $this->tag = $tag; |
|
| 36 | - $this->preg_openingtag = ($preg_openingtag ?: "@<{$tag}\b([^>]*?)(/?)>@isS"); |
|
| 37 | - $this->preg_closingtag = ($preg_closingtag ?? "@</{$tag}\b[^>]*>@isS"); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @param string $texte |
|
| 42 | - * @param array $options |
|
| 43 | - * bool $detecter_presence |
|
| 44 | - * bool $nb_max |
|
| 45 | - * int $profondeur |
|
| 46 | - * @return array |
|
| 47 | - */ |
|
| 48 | - public function collecter(string $texte, array $options = []): array { |
|
| 49 | - if (!$texte) { |
|
| 50 | - return []; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - $upperTag = strtoupper($this->tag); |
|
| 54 | - $hasUpperCaseTags = ($upperTag !== $this->tag && (str_contains($texte, '<' . $upperTag) || str_contains($texte, '</' . $upperTag))); |
|
| 55 | - |
|
| 56 | - // collecter les balises ouvrantes |
|
| 57 | - $opening = static::collecteur($texte, '', $hasUpperCaseTags ? '<' : '<' . $this->tag, $this->preg_openingtag, empty($options['detecter_presence']) ? 0 : 1); |
|
| 58 | - if (!$opening) { |
|
| 59 | - return []; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // si c'est un tag autofermant ou vide qui se repère avec une seule regexp, on va plus vite |
|
| 63 | - if (!$this->preg_closingtag) { |
|
| 64 | - return $opening; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - // collecter les balises fermantes |
|
| 68 | - $closing = static::collecteur($texte, '', $hasUpperCaseTags ? '</' : '</' . $this->tag, $this->preg_closingtag); |
|
| 69 | - |
|
| 70 | - $profondeur = ($options['profondeur'] ?? 1); |
|
| 71 | - $tags = []; |
|
| 72 | - while (!empty($opening)) { |
|
| 73 | - $first_opening = array_shift($opening); |
|
| 74 | - // self closing ? |
|
| 75 | - if (str_contains($first_opening['raw'], '/>')) { |
|
| 76 | - $tag = $first_opening; |
|
| 77 | - $tag['opening'] = $tag['raw']; |
|
| 78 | - $tag['closing'] = ''; |
|
| 79 | - $tag['innerHtml'] = ''; |
|
| 80 | - $tag['attributs'] = trim(substr($tag['opening'], strlen($this->tag) + 1, -2)); |
|
| 81 | - $tags[] = $tag; |
|
| 82 | - } |
|
| 83 | - else { |
|
| 84 | - // enlever les closing qui sont avant le premier opening, car ils n'ont pas de sens |
|
| 85 | - while ( |
|
| 86 | - !empty($closing) |
|
| 87 | - && ($first_closing = reset($closing)) |
|
| 88 | - && $first_closing['pos'] < $first_opening['pos'] |
|
| 89 | - ) { |
|
| 90 | - array_shift($closing); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $need_closing = 0; |
|
| 94 | - $next_closing = reset($closing); |
|
| 95 | - $next_opening = reset($opening); |
|
| 96 | - // certaines balises comme <code> neutralisent le contenant, donc tout ce qui est avant le prochain closing doit etre ignoré |
|
| 97 | - if (in_array($this->tag, ['code'])) { |
|
| 98 | - while ($next_opening && $next_closing && $next_opening['pos'] < $next_closing['pos']) { |
|
| 99 | - array_shift($opening); |
|
| 100 | - $next_opening = reset($opening); |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - else { |
|
| 104 | - while ($next_opening && $next_closing && $next_opening['pos'] < $next_closing['pos']) { |
|
| 105 | - while ($next_opening && $next_opening['pos'] < $next_closing['pos']) { |
|
| 106 | - // si pas self closing, il faut un closing de plus |
|
| 107 | - if (!str_contains($next_opening['raw'], '/>')) { |
|
| 108 | - $need_closing++; |
|
| 109 | - } |
|
| 110 | - array_shift($opening); |
|
| 111 | - $next_opening = reset($opening); |
|
| 112 | - } |
|
| 113 | - // il faut depiler les balises fermantes autant de fois que nécessaire et tant qu'on a pas une nouvelle balise ouvrante |
|
| 114 | - while ($need_closing && $next_closing && (!$next_opening || $next_closing['pos'] < $next_opening['pos'])) { |
|
| 115 | - array_shift($closing); |
|
| 116 | - $need_closing--; |
|
| 117 | - $next_closing = reset($closing); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - // si pas de fermeture, c'est une autofermante mal fermée... |
|
| 122 | - if (!$next_closing || $need_closing) { |
|
| 123 | - $tag = $first_opening; |
|
| 124 | - $tag['opening'] = $tag['raw']; |
|
| 125 | - $tag['closing'] = ''; |
|
| 126 | - $tag['innerHtml'] = ''; |
|
| 127 | - $tag['attributs'] = trim(substr($tag['opening'], strlen($this->tag) + 1, -1)); |
|
| 128 | - $tags[] = $tag; |
|
| 129 | - } |
|
| 130 | - else { |
|
| 131 | - $tag = $first_opening; |
|
| 132 | - $next_closing = array_shift($closing); |
|
| 133 | - $innerHtml = substr($texte, $tag['pos'] + $tag['length'], $next_closing['pos'] - $tag['pos'] - $tag['length']); |
|
| 134 | - $tag['length'] = $next_closing['pos'] - $tag['pos'] + $next_closing['length']; |
|
| 135 | - $tag['opening'] = $tag['raw']; |
|
| 136 | - $tag['raw'] = substr($texte, $tag['pos'], $tag['length']); |
|
| 137 | - $tag['innerHtml'] = $innerHtml; |
|
| 138 | - $tag['closing'] = $next_closing['raw']; |
|
| 139 | - $tag['attributs'] = trim(substr($tag['opening'], strlen($this->tag) + 1, -1)); |
|
| 140 | - $tags[] = $tag; |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - if ((!empty($options['detecter_presence']) && count($tags))) { |
|
| 144 | - return $tags; |
|
| 145 | - } |
|
| 146 | - if (($profondeur == 1 && !empty($options['nb_max']) && count($tags) >= $options['nb_max'])) { |
|
| 147 | - break; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - while (--$profondeur > 0) { |
|
| 152 | - $outerTags = $tags; |
|
| 153 | - $tags = []; |
|
| 154 | - $options['profondeur'] = 1; |
|
| 155 | - foreach ($outerTags as $outerTag) { |
|
| 156 | - if (!empty($outerTag['innerHtml'])) { |
|
| 157 | - $offsetPos = $outerTag['pos'] + strlen($outerTag['opening']); |
|
| 158 | - $innerTags = $this->collecter($outerTag['innerHtml'], $options); |
|
| 159 | - if (!empty($innerTags)) { |
|
| 160 | - foreach ($innerTags as $tag) { |
|
| 161 | - $tag['pos'] += $offsetPos; |
|
| 162 | - $tags[] = $tag; |
|
| 163 | - } |
|
| 164 | - if (($profondeur == 1 && !empty($options['nb_max']) && count($tags) >= $options['nb_max'])) { |
|
| 165 | - return $tags; |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - return $tags; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @param callable|null $callback_function |
|
| 178 | - */ |
|
| 179 | - public function echapper_enHtmlBase64(string $texte, string $source = '', $callback_function = null, array $callback_options = []): string { |
|
| 180 | - if ($callback_function) { |
|
| 181 | - $legacy_callback = $callback_function; |
|
| 182 | - // si on est dans un cas evident de preg perso, ne pas essayer de mapper le match car on ne sait pas ce qu'il contient |
|
| 183 | - // et on aura pas non plus de innerHtml si pas de preg_closingtag |
|
| 184 | - if ($this->preg_closingtag) { |
|
| 185 | - $tag = $this->tag; |
|
| 186 | - $legacy_callback = function ($c, $options) use ($tag, $callback_function) { |
|
| 187 | - // legacy : renseigner les infos correspondantes aux matchs de l'ancienne regexp |
|
| 188 | - $regs = [ |
|
| 189 | - 0 => $c['raw'], |
|
| 190 | - 1 => $tag, |
|
| 191 | - 2 => $c['match'][1] . $c['match'][2], |
|
| 192 | - 3 => $c['innerHtml'], |
|
| 193 | - 'tag' => $this->tag, |
|
| 194 | - ] + $c; |
|
| 195 | - return $callback_function($regs, $options); |
|
| 196 | - }; |
|
| 197 | - } |
|
| 198 | - } |
|
| 199 | - return parent::echapper_enHtmlBase64($texte, $source, $callback_function ? $legacy_callback : null, $callback_options); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * pour $source voir commentaire infra (echappe_retour) |
|
| 205 | - * pour $no_transform voir le filtre post_autobr dans inc/filtres |
|
| 206 | - */ |
|
| 207 | - public static function proteger_balisesHtml(string $texte, string $source = '', ?array $html_tags = null, array $callbacks_function = [], array $callback_options = []): string { |
|
| 208 | - if ($texte === '') { |
|
| 209 | - return ''; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $html_tags = $html_tags ?: self::$listeBalisesAProteger; |
|
| 213 | - |
|
| 214 | - $tags_todo = $html_tags; |
|
| 215 | - while ( |
|
| 216 | - !empty($tags_todo) |
|
| 217 | - && ($tag = array_shift($tags_todo)) |
|
| 218 | - && str_contains($texte, '<') |
|
| 219 | - ) { |
|
| 220 | - $htmlTagCollecteur = new self($tag); |
|
| 221 | - $texte = $htmlTagCollecteur->echapper_enHtmlBase64($texte, $source, $callbacks_function[$tag] ?? null, $callback_options); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - return $texte; |
|
| 225 | - } |
|
| 20 | + protected static string $markPrefix = 'HTMLTAG'; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * La preg pour découper et collecter les modèles |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + protected string $preg_openingtag; |
|
| 27 | + protected string $preg_closingtag; |
|
| 28 | + protected string $tag; |
|
| 29 | + |
|
| 30 | + public static array $listeBalisesAProteger = ['html', 'pre', 'code', 'cadre', 'frame', 'script', 'style']; |
|
| 31 | + |
|
| 32 | + public function __construct(string $tag, ?string $preg_openingtag = null, ?string $preg_closingtag = null) { |
|
| 33 | + |
|
| 34 | + $tag = strtolower($tag); |
|
| 35 | + $this->tag = $tag; |
|
| 36 | + $this->preg_openingtag = ($preg_openingtag ?: "@<{$tag}\b([^>]*?)(/?)>@isS"); |
|
| 37 | + $this->preg_closingtag = ($preg_closingtag ?? "@</{$tag}\b[^>]*>@isS"); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param string $texte |
|
| 42 | + * @param array $options |
|
| 43 | + * bool $detecter_presence |
|
| 44 | + * bool $nb_max |
|
| 45 | + * int $profondeur |
|
| 46 | + * @return array |
|
| 47 | + */ |
|
| 48 | + public function collecter(string $texte, array $options = []): array { |
|
| 49 | + if (!$texte) { |
|
| 50 | + return []; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + $upperTag = strtoupper($this->tag); |
|
| 54 | + $hasUpperCaseTags = ($upperTag !== $this->tag && (str_contains($texte, '<' . $upperTag) || str_contains($texte, '</' . $upperTag))); |
|
| 55 | + |
|
| 56 | + // collecter les balises ouvrantes |
|
| 57 | + $opening = static::collecteur($texte, '', $hasUpperCaseTags ? '<' : '<' . $this->tag, $this->preg_openingtag, empty($options['detecter_presence']) ? 0 : 1); |
|
| 58 | + if (!$opening) { |
|
| 59 | + return []; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // si c'est un tag autofermant ou vide qui se repère avec une seule regexp, on va plus vite |
|
| 63 | + if (!$this->preg_closingtag) { |
|
| 64 | + return $opening; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + // collecter les balises fermantes |
|
| 68 | + $closing = static::collecteur($texte, '', $hasUpperCaseTags ? '</' : '</' . $this->tag, $this->preg_closingtag); |
|
| 69 | + |
|
| 70 | + $profondeur = ($options['profondeur'] ?? 1); |
|
| 71 | + $tags = []; |
|
| 72 | + while (!empty($opening)) { |
|
| 73 | + $first_opening = array_shift($opening); |
|
| 74 | + // self closing ? |
|
| 75 | + if (str_contains($first_opening['raw'], '/>')) { |
|
| 76 | + $tag = $first_opening; |
|
| 77 | + $tag['opening'] = $tag['raw']; |
|
| 78 | + $tag['closing'] = ''; |
|
| 79 | + $tag['innerHtml'] = ''; |
|
| 80 | + $tag['attributs'] = trim(substr($tag['opening'], strlen($this->tag) + 1, -2)); |
|
| 81 | + $tags[] = $tag; |
|
| 82 | + } |
|
| 83 | + else { |
|
| 84 | + // enlever les closing qui sont avant le premier opening, car ils n'ont pas de sens |
|
| 85 | + while ( |
|
| 86 | + !empty($closing) |
|
| 87 | + && ($first_closing = reset($closing)) |
|
| 88 | + && $first_closing['pos'] < $first_opening['pos'] |
|
| 89 | + ) { |
|
| 90 | + array_shift($closing); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $need_closing = 0; |
|
| 94 | + $next_closing = reset($closing); |
|
| 95 | + $next_opening = reset($opening); |
|
| 96 | + // certaines balises comme <code> neutralisent le contenant, donc tout ce qui est avant le prochain closing doit etre ignoré |
|
| 97 | + if (in_array($this->tag, ['code'])) { |
|
| 98 | + while ($next_opening && $next_closing && $next_opening['pos'] < $next_closing['pos']) { |
|
| 99 | + array_shift($opening); |
|
| 100 | + $next_opening = reset($opening); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + else { |
|
| 104 | + while ($next_opening && $next_closing && $next_opening['pos'] < $next_closing['pos']) { |
|
| 105 | + while ($next_opening && $next_opening['pos'] < $next_closing['pos']) { |
|
| 106 | + // si pas self closing, il faut un closing de plus |
|
| 107 | + if (!str_contains($next_opening['raw'], '/>')) { |
|
| 108 | + $need_closing++; |
|
| 109 | + } |
|
| 110 | + array_shift($opening); |
|
| 111 | + $next_opening = reset($opening); |
|
| 112 | + } |
|
| 113 | + // il faut depiler les balises fermantes autant de fois que nécessaire et tant qu'on a pas une nouvelle balise ouvrante |
|
| 114 | + while ($need_closing && $next_closing && (!$next_opening || $next_closing['pos'] < $next_opening['pos'])) { |
|
| 115 | + array_shift($closing); |
|
| 116 | + $need_closing--; |
|
| 117 | + $next_closing = reset($closing); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + // si pas de fermeture, c'est une autofermante mal fermée... |
|
| 122 | + if (!$next_closing || $need_closing) { |
|
| 123 | + $tag = $first_opening; |
|
| 124 | + $tag['opening'] = $tag['raw']; |
|
| 125 | + $tag['closing'] = ''; |
|
| 126 | + $tag['innerHtml'] = ''; |
|
| 127 | + $tag['attributs'] = trim(substr($tag['opening'], strlen($this->tag) + 1, -1)); |
|
| 128 | + $tags[] = $tag; |
|
| 129 | + } |
|
| 130 | + else { |
|
| 131 | + $tag = $first_opening; |
|
| 132 | + $next_closing = array_shift($closing); |
|
| 133 | + $innerHtml = substr($texte, $tag['pos'] + $tag['length'], $next_closing['pos'] - $tag['pos'] - $tag['length']); |
|
| 134 | + $tag['length'] = $next_closing['pos'] - $tag['pos'] + $next_closing['length']; |
|
| 135 | + $tag['opening'] = $tag['raw']; |
|
| 136 | + $tag['raw'] = substr($texte, $tag['pos'], $tag['length']); |
|
| 137 | + $tag['innerHtml'] = $innerHtml; |
|
| 138 | + $tag['closing'] = $next_closing['raw']; |
|
| 139 | + $tag['attributs'] = trim(substr($tag['opening'], strlen($this->tag) + 1, -1)); |
|
| 140 | + $tags[] = $tag; |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + if ((!empty($options['detecter_presence']) && count($tags))) { |
|
| 144 | + return $tags; |
|
| 145 | + } |
|
| 146 | + if (($profondeur == 1 && !empty($options['nb_max']) && count($tags) >= $options['nb_max'])) { |
|
| 147 | + break; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + while (--$profondeur > 0) { |
|
| 152 | + $outerTags = $tags; |
|
| 153 | + $tags = []; |
|
| 154 | + $options['profondeur'] = 1; |
|
| 155 | + foreach ($outerTags as $outerTag) { |
|
| 156 | + if (!empty($outerTag['innerHtml'])) { |
|
| 157 | + $offsetPos = $outerTag['pos'] + strlen($outerTag['opening']); |
|
| 158 | + $innerTags = $this->collecter($outerTag['innerHtml'], $options); |
|
| 159 | + if (!empty($innerTags)) { |
|
| 160 | + foreach ($innerTags as $tag) { |
|
| 161 | + $tag['pos'] += $offsetPos; |
|
| 162 | + $tags[] = $tag; |
|
| 163 | + } |
|
| 164 | + if (($profondeur == 1 && !empty($options['nb_max']) && count($tags) >= $options['nb_max'])) { |
|
| 165 | + return $tags; |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + return $tags; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @param callable|null $callback_function |
|
| 178 | + */ |
|
| 179 | + public function echapper_enHtmlBase64(string $texte, string $source = '', $callback_function = null, array $callback_options = []): string { |
|
| 180 | + if ($callback_function) { |
|
| 181 | + $legacy_callback = $callback_function; |
|
| 182 | + // si on est dans un cas evident de preg perso, ne pas essayer de mapper le match car on ne sait pas ce qu'il contient |
|
| 183 | + // et on aura pas non plus de innerHtml si pas de preg_closingtag |
|
| 184 | + if ($this->preg_closingtag) { |
|
| 185 | + $tag = $this->tag; |
|
| 186 | + $legacy_callback = function ($c, $options) use ($tag, $callback_function) { |
|
| 187 | + // legacy : renseigner les infos correspondantes aux matchs de l'ancienne regexp |
|
| 188 | + $regs = [ |
|
| 189 | + 0 => $c['raw'], |
|
| 190 | + 1 => $tag, |
|
| 191 | + 2 => $c['match'][1] . $c['match'][2], |
|
| 192 | + 3 => $c['innerHtml'], |
|
| 193 | + 'tag' => $this->tag, |
|
| 194 | + ] + $c; |
|
| 195 | + return $callback_function($regs, $options); |
|
| 196 | + }; |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | + return parent::echapper_enHtmlBase64($texte, $source, $callback_function ? $legacy_callback : null, $callback_options); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * pour $source voir commentaire infra (echappe_retour) |
|
| 205 | + * pour $no_transform voir le filtre post_autobr dans inc/filtres |
|
| 206 | + */ |
|
| 207 | + public static function proteger_balisesHtml(string $texte, string $source = '', ?array $html_tags = null, array $callbacks_function = [], array $callback_options = []): string { |
|
| 208 | + if ($texte === '') { |
|
| 209 | + return ''; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $html_tags = $html_tags ?: self::$listeBalisesAProteger; |
|
| 213 | + |
|
| 214 | + $tags_todo = $html_tags; |
|
| 215 | + while ( |
|
| 216 | + !empty($tags_todo) |
|
| 217 | + && ($tag = array_shift($tags_todo)) |
|
| 218 | + && str_contains($texte, '<') |
|
| 219 | + ) { |
|
| 220 | + $htmlTagCollecteur = new self($tag); |
|
| 221 | + $texte = $htmlTagCollecteur->echapper_enHtmlBase64($texte, $source, $callbacks_function[$tag] ?? null, $callback_options); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + return $texte; |
|
| 225 | + } |
|
| 226 | 226 | } |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $upperTag = strtoupper($this->tag); |
| 54 | - $hasUpperCaseTags = ($upperTag !== $this->tag && (str_contains($texte, '<' . $upperTag) || str_contains($texte, '</' . $upperTag))); |
|
| 54 | + $hasUpperCaseTags = ($upperTag !== $this->tag && (str_contains($texte, '<'.$upperTag) || str_contains($texte, '</'.$upperTag))); |
|
| 55 | 55 | |
| 56 | 56 | // collecter les balises ouvrantes |
| 57 | - $opening = static::collecteur($texte, '', $hasUpperCaseTags ? '<' : '<' . $this->tag, $this->preg_openingtag, empty($options['detecter_presence']) ? 0 : 1); |
|
| 57 | + $opening = static::collecteur($texte, '', $hasUpperCaseTags ? '<' : '<'.$this->tag, $this->preg_openingtag, empty($options['detecter_presence']) ? 0 : 1); |
|
| 58 | 58 | if (!$opening) { |
| 59 | 59 | return []; |
| 60 | 60 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // collecter les balises fermantes |
| 68 | - $closing = static::collecteur($texte, '', $hasUpperCaseTags ? '</' : '</' . $this->tag, $this->preg_closingtag); |
|
| 68 | + $closing = static::collecteur($texte, '', $hasUpperCaseTags ? '</' : '</'.$this->tag, $this->preg_closingtag); |
|
| 69 | 69 | |
| 70 | 70 | $profondeur = ($options['profondeur'] ?? 1); |
| 71 | 71 | $tags = []; |
@@ -183,12 +183,12 @@ discard block |
||
| 183 | 183 | // et on aura pas non plus de innerHtml si pas de preg_closingtag |
| 184 | 184 | if ($this->preg_closingtag) { |
| 185 | 185 | $tag = $this->tag; |
| 186 | - $legacy_callback = function ($c, $options) use ($tag, $callback_function) { |
|
| 186 | + $legacy_callback = function($c, $options) use ($tag, $callback_function) { |
|
| 187 | 187 | // legacy : renseigner les infos correspondantes aux matchs de l'ancienne regexp |
| 188 | 188 | $regs = [ |
| 189 | 189 | 0 => $c['raw'], |
| 190 | 190 | 1 => $tag, |
| 191 | - 2 => $c['match'][1] . $c['match'][2], |
|
| 191 | + 2 => $c['match'][1].$c['match'][2], |
|
| 192 | 192 | 3 => $c['innerHtml'], |
| 193 | 193 | 'tag' => $this->tag, |
| 194 | 194 | ] + $c; |
@@ -79,8 +79,7 @@ discard block |
||
| 79 | 79 | $tag['innerHtml'] = ''; |
| 80 | 80 | $tag['attributs'] = trim(substr($tag['opening'], strlen($this->tag) + 1, -2)); |
| 81 | 81 | $tags[] = $tag; |
| 82 | - } |
|
| 83 | - else { |
|
| 82 | + } else { |
|
| 84 | 83 | // enlever les closing qui sont avant le premier opening, car ils n'ont pas de sens |
| 85 | 84 | while ( |
| 86 | 85 | !empty($closing) |
@@ -99,8 +98,7 @@ discard block |
||
| 99 | 98 | array_shift($opening); |
| 100 | 99 | $next_opening = reset($opening); |
| 101 | 100 | } |
| 102 | - } |
|
| 103 | - else { |
|
| 101 | + } else { |
|
| 104 | 102 | while ($next_opening && $next_closing && $next_opening['pos'] < $next_closing['pos']) { |
| 105 | 103 | while ($next_opening && $next_opening['pos'] < $next_closing['pos']) { |
| 106 | 104 | // si pas self closing, il faut un closing de plus |
@@ -126,8 +124,7 @@ discard block |
||
| 126 | 124 | $tag['innerHtml'] = ''; |
| 127 | 125 | $tag['attributs'] = trim(substr($tag['opening'], strlen($this->tag) + 1, -1)); |
| 128 | 126 | $tags[] = $tag; |
| 129 | - } |
|
| 130 | - else { |
|
| 127 | + } else { |
|
| 131 | 128 | $tag = $first_opening; |
| 132 | 129 | $next_closing = array_shift($closing); |
| 133 | 130 | $innerHtml = substr($texte, $tag['pos'] + $tag['length'], $next_closing['pos'] - $tag['pos'] - $tag['length']); |
@@ -51,12 +51,12 @@ |
||
| 51 | 51 | // chercher la classe d'iterateur Iterateur/XXX |
| 52 | 52 | // definie dans le fichier src/Compilateur/Iterateur/xxx.php |
| 53 | 53 | // FIXME: déclarer quelque part les iterateurs supplémentaires |
| 54 | - $class = __NAMESPACE__ . '\\' . ucfirst(strtolower((string) $iterateur)); |
|
| 54 | + $class = __NAMESPACE__.'\\'.ucfirst(strtolower((string) $iterateur)); |
|
| 55 | 55 | if (!class_exists($class)) { |
| 56 | 56 | // historique |
| 57 | 57 | // Chercher IterateurXXX |
| 58 | - include_spip('iterateur/' . strtolower($iterateur)); |
|
| 59 | - $class = 'Iterateur' . $iterateur; |
|
| 58 | + include_spip('iterateur/'.strtolower($iterateur)); |
|
| 59 | + $class = 'Iterateur'.$iterateur; |
|
| 60 | 60 | if (!class_exists($class)) { |
| 61 | 61 | exit("Iterateur {$iterateur} non trouvé"); |
| 62 | 62 | // si l'iterateur n'existe pas, on se rabat sur le generique |
@@ -12,61 +12,61 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Factory |
| 14 | 14 | { |
| 15 | - public static function create($iterateur, $command, $info = null) { |
|
| 16 | - $logger = spip_logger(); // FIXME: inject it. |
|
| 17 | - $iter = null; |
|
| 18 | - // cas des SI {si expression} analises tres tot |
|
| 19 | - // pour eviter le chargement de tout iterateur |
|
| 20 | - if (isset($command['si'])) { |
|
| 21 | - foreach ($command['si'] as $si) { |
|
| 22 | - if (!$si) { |
|
| 23 | - // $command pour boucle SQL peut generer des erreurs de compilation |
|
| 24 | - // s'il est transmis alors qu'on est dans un iterateur vide |
|
| 25 | - return new Decorator(new EmptyIterator(), [], $info); |
|
| 26 | - } |
|
| 27 | - } |
|
| 28 | - } |
|
| 15 | + public static function create($iterateur, $command, $info = null) { |
|
| 16 | + $logger = spip_logger(); // FIXME: inject it. |
|
| 17 | + $iter = null; |
|
| 18 | + // cas des SI {si expression} analises tres tot |
|
| 19 | + // pour eviter le chargement de tout iterateur |
|
| 20 | + if (isset($command['si'])) { |
|
| 21 | + foreach ($command['si'] as $si) { |
|
| 22 | + if (!$si) { |
|
| 23 | + // $command pour boucle SQL peut generer des erreurs de compilation |
|
| 24 | + // s'il est transmis alors qu'on est dans un iterateur vide |
|
| 25 | + return new Decorator(new EmptyIterator(), [], $info); |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - // chercher un iterateur PHP existant (par exemple dans SPL) |
|
| 31 | - // (il faudrait passer l'argument ->sql_serveur |
|
| 32 | - // pour etre certain qu'on est sur un "php:") |
|
| 33 | - if (class_exists($iterateur)) { |
|
| 34 | - $a = $command['args'] ?? []; |
|
| 30 | + // chercher un iterateur PHP existant (par exemple dans SPL) |
|
| 31 | + // (il faudrait passer l'argument ->sql_serveur |
|
| 32 | + // pour etre certain qu'on est sur un "php:") |
|
| 33 | + if (class_exists($iterateur)) { |
|
| 34 | + $a = $command['args'] ?? []; |
|
| 35 | 35 | |
| 36 | - // permettre de passer un Iterateur directement {args #ITERATEUR} : |
|
| 37 | - // si on recoit deja un iterateur en argument, on l'utilise |
|
| 38 | - if ((is_countable($a) ? count($a) : 0) == 1 && is_object($a[0]) && is_subclass_of($a[0], \Iterator::class)) { |
|
| 39 | - $iter = $a[0]; |
|
| 40 | - } else { |
|
| 41 | - // sinon, on cree un iterateur du type donne |
|
| 42 | - // arguments de creation de l'iterateur... |
|
| 43 | - try { |
|
| 44 | - $iter = new $iterateur(...$a); |
|
| 45 | - } catch (Exception $e) { |
|
| 46 | - $logger->info("Erreur de chargement de l'iterateur {$iterateur}"); |
|
| 47 | - $logger->info($e->getMessage()); |
|
| 48 | - $iter = new EmptyIterator(); |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - } else { |
|
| 52 | - // chercher la classe d'iterateur Iterateur/XXX |
|
| 53 | - // definie dans le fichier src/Compilateur/Iterateur/xxx.php |
|
| 54 | - // FIXME: déclarer quelque part les iterateurs supplémentaires |
|
| 55 | - $class = __NAMESPACE__ . '\\' . ucfirst(strtolower((string) $iterateur)); |
|
| 56 | - if (!class_exists($class)) { |
|
| 57 | - // historique |
|
| 58 | - // Chercher IterateurXXX |
|
| 59 | - include_spip('iterateur/' . strtolower($iterateur)); |
|
| 60 | - $class = 'Iterateur' . $iterateur; |
|
| 61 | - if (!class_exists($class)) { |
|
| 62 | - exit("Iterateur {$iterateur} non trouvé"); |
|
| 63 | - // si l'iterateur n'existe pas, on se rabat sur le generique |
|
| 64 | - // $iter = new EmptyIterator(); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - $iter = new $class($command, $info); |
|
| 68 | - } |
|
| 36 | + // permettre de passer un Iterateur directement {args #ITERATEUR} : |
|
| 37 | + // si on recoit deja un iterateur en argument, on l'utilise |
|
| 38 | + if ((is_countable($a) ? count($a) : 0) == 1 && is_object($a[0]) && is_subclass_of($a[0], \Iterator::class)) { |
|
| 39 | + $iter = $a[0]; |
|
| 40 | + } else { |
|
| 41 | + // sinon, on cree un iterateur du type donne |
|
| 42 | + // arguments de creation de l'iterateur... |
|
| 43 | + try { |
|
| 44 | + $iter = new $iterateur(...$a); |
|
| 45 | + } catch (Exception $e) { |
|
| 46 | + $logger->info("Erreur de chargement de l'iterateur {$iterateur}"); |
|
| 47 | + $logger->info($e->getMessage()); |
|
| 48 | + $iter = new EmptyIterator(); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + } else { |
|
| 52 | + // chercher la classe d'iterateur Iterateur/XXX |
|
| 53 | + // definie dans le fichier src/Compilateur/Iterateur/xxx.php |
|
| 54 | + // FIXME: déclarer quelque part les iterateurs supplémentaires |
|
| 55 | + $class = __NAMESPACE__ . '\\' . ucfirst(strtolower((string) $iterateur)); |
|
| 56 | + if (!class_exists($class)) { |
|
| 57 | + // historique |
|
| 58 | + // Chercher IterateurXXX |
|
| 59 | + include_spip('iterateur/' . strtolower($iterateur)); |
|
| 60 | + $class = 'Iterateur' . $iterateur; |
|
| 61 | + if (!class_exists($class)) { |
|
| 62 | + exit("Iterateur {$iterateur} non trouvé"); |
|
| 63 | + // si l'iterateur n'existe pas, on se rabat sur le generique |
|
| 64 | + // $iter = new EmptyIterator(); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + $iter = new $class($command, $info); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - return new Decorator($iter, $command, $info); |
|
| 71 | - } |
|
| 70 | + return new Decorator($iter, $command, $info); |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -11,187 +11,187 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Sql extends AbstractIterateur implements Iterator |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Ressource sql. |
|
| 16 | - * |
|
| 17 | - * @var bool|object |
|
| 18 | - */ |
|
| 19 | - protected $sqlresult = false; |
|
| 14 | + /** |
|
| 15 | + * Ressource sql. |
|
| 16 | + * |
|
| 17 | + * @var bool|object |
|
| 18 | + */ |
|
| 19 | + protected $sqlresult = false; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * row sql courante. |
|
| 23 | - * |
|
| 24 | - * @var null|array |
|
| 25 | - */ |
|
| 26 | - protected $row; |
|
| 21 | + /** |
|
| 22 | + * row sql courante. |
|
| 23 | + * |
|
| 24 | + * @var null|array |
|
| 25 | + */ |
|
| 26 | + protected $row; |
|
| 27 | 27 | |
| 28 | - protected bool $firstseek = false; |
|
| 28 | + protected bool $firstseek = false; |
|
| 29 | 29 | |
| 30 | - protected int $pos = -1; |
|
| 30 | + protected int $pos = -1; |
|
| 31 | 31 | |
| 32 | - /* |
|
| 32 | + /* |
|
| 33 | 33 | * array command: les commandes d'initialisation |
| 34 | 34 | * array info: les infos sur le squelette |
| 35 | 35 | */ |
| 36 | - public function __construct(array $command, array $info = []) { |
|
| 37 | - $this->type = 'SQL'; |
|
| 38 | - parent::__construct($command, $info); |
|
| 39 | - |
|
| 40 | - $this->select(); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Rembobiner. |
|
| 45 | - * |
|
| 46 | - * @return bool |
|
| 47 | - */ |
|
| 48 | - public function rewind(): void { |
|
| 49 | - if ($this->pos > 0) { |
|
| 50 | - $this->seek(0); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Verifier l'etat de l'iterateur. |
|
| 56 | - */ |
|
| 57 | - public function valid(): bool { |
|
| 58 | - if ($this->err) { |
|
| 59 | - return false; |
|
| 60 | - } |
|
| 61 | - if (!$this->firstseek) { |
|
| 62 | - $this->next(); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - return is_array($this->row); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Valeurs sur la position courante. |
|
| 70 | - * |
|
| 71 | - * @return array |
|
| 72 | - */ |
|
| 73 | - public function current(): ?array { |
|
| 74 | - return $this->row; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function key(): int { |
|
| 78 | - return $this->pos; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Sauter a une position absolue. |
|
| 83 | - * |
|
| 84 | - * @param int $n |
|
| 85 | - * @param null|string $continue |
|
| 86 | - */ |
|
| 87 | - public function seek($n = 0, $continue = null): bool { |
|
| 88 | - if (!sql_seek($this->sqlresult, $n, $this->command['connect'], $continue)) { |
|
| 89 | - // SQLite ne sait pas seek(), il faut relancer la query |
|
| 90 | - // si la position courante est apres la position visee |
|
| 91 | - // il faut relancer la requete |
|
| 92 | - if ($this->pos > $n) { |
|
| 93 | - $this->free(); |
|
| 94 | - $this->select(); |
|
| 95 | - $this->valid(); |
|
| 96 | - } |
|
| 97 | - // et utiliser la methode par defaut pour se deplacer au bon endroit |
|
| 98 | - // (sera fait en cas d'echec de cette fonction) |
|
| 99 | - return false; |
|
| 100 | - } |
|
| 101 | - $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
|
| 102 | - $this->pos = min($n, $this->count()); |
|
| 103 | - |
|
| 104 | - return true; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Avancer d'un cran. |
|
| 109 | - */ |
|
| 110 | - public function next(): void { |
|
| 111 | - $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
|
| 112 | - ++$this->pos; |
|
| 113 | - $this->firstseek = true; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Avancer et retourner les donnees pour le nouvel element. |
|
| 118 | - * |
|
| 119 | - * @return null|array|bool |
|
| 120 | - */ |
|
| 121 | - public function fetch() { |
|
| 122 | - if ($this->valid()) { |
|
| 123 | - $r = $this->current(); |
|
| 124 | - $this->next(); |
|
| 125 | - } else { |
|
| 126 | - $r = false; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - return $r; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * liberer les ressources. |
|
| 134 | - * |
|
| 135 | - * @return bool |
|
| 136 | - */ |
|
| 137 | - public function free() { |
|
| 138 | - if (!$this->sqlresult) { |
|
| 139 | - return true; |
|
| 140 | - } |
|
| 141 | - $a = sql_free($this->sqlresult, $this->command['connect']); |
|
| 142 | - $this->sqlresult = null; |
|
| 143 | - |
|
| 144 | - return $a; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * Compter le nombre de resultats. |
|
| 149 | - */ |
|
| 150 | - public function count(): int { |
|
| 151 | - if (is_null($this->total)) { |
|
| 152 | - if (!$this->sqlresult) { |
|
| 153 | - $this->total = 0; |
|
| 154 | - } else { |
|
| 155 | - // cas count(*) |
|
| 156 | - if (in_array('count(*)', $this->command['select'])) { |
|
| 157 | - $this->valid(); |
|
| 158 | - $s = $this->current(); |
|
| 159 | - $this->total = (int) $s['count(*)']; |
|
| 160 | - } else { |
|
| 161 | - $this->total = (int) sql_count($this->sqlresult, $this->command['connect']); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - return $this->total; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * selectionner les donnees, ie faire la requete SQL. |
|
| 171 | - */ |
|
| 172 | - protected function select() { |
|
| 173 | - $this->row = null; |
|
| 174 | - $v = &$this->command; |
|
| 175 | - $this->sqlresult = calculer_select( |
|
| 176 | - $v['select'], |
|
| 177 | - $v['from'], |
|
| 178 | - $v['type'], |
|
| 179 | - $v['where'], |
|
| 180 | - $v['join'], |
|
| 181 | - $v['groupby'], |
|
| 182 | - $v['orderby'], |
|
| 183 | - $v['limit'], |
|
| 184 | - $v['having'], |
|
| 185 | - $v['table'], |
|
| 186 | - $v['id'], |
|
| 187 | - $v['connect'], |
|
| 188 | - $this->info |
|
| 189 | - ); |
|
| 190 | - $this->err = !$this->sqlresult; |
|
| 191 | - $this->firstseek = false; |
|
| 192 | - $this->pos = -1; |
|
| 193 | - |
|
| 194 | - // pas d'init a priori, le calcul ne sera fait qu'en cas de besoin (provoque une double requete souvent inutile en sqlite) |
|
| 195 | - //$this->total = $this->count(); |
|
| 196 | - } |
|
| 36 | + public function __construct(array $command, array $info = []) { |
|
| 37 | + $this->type = 'SQL'; |
|
| 38 | + parent::__construct($command, $info); |
|
| 39 | + |
|
| 40 | + $this->select(); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Rembobiner. |
|
| 45 | + * |
|
| 46 | + * @return bool |
|
| 47 | + */ |
|
| 48 | + public function rewind(): void { |
|
| 49 | + if ($this->pos > 0) { |
|
| 50 | + $this->seek(0); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Verifier l'etat de l'iterateur. |
|
| 56 | + */ |
|
| 57 | + public function valid(): bool { |
|
| 58 | + if ($this->err) { |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 61 | + if (!$this->firstseek) { |
|
| 62 | + $this->next(); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + return is_array($this->row); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Valeurs sur la position courante. |
|
| 70 | + * |
|
| 71 | + * @return array |
|
| 72 | + */ |
|
| 73 | + public function current(): ?array { |
|
| 74 | + return $this->row; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + public function key(): int { |
|
| 78 | + return $this->pos; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Sauter a une position absolue. |
|
| 83 | + * |
|
| 84 | + * @param int $n |
|
| 85 | + * @param null|string $continue |
|
| 86 | + */ |
|
| 87 | + public function seek($n = 0, $continue = null): bool { |
|
| 88 | + if (!sql_seek($this->sqlresult, $n, $this->command['connect'], $continue)) { |
|
| 89 | + // SQLite ne sait pas seek(), il faut relancer la query |
|
| 90 | + // si la position courante est apres la position visee |
|
| 91 | + // il faut relancer la requete |
|
| 92 | + if ($this->pos > $n) { |
|
| 93 | + $this->free(); |
|
| 94 | + $this->select(); |
|
| 95 | + $this->valid(); |
|
| 96 | + } |
|
| 97 | + // et utiliser la methode par defaut pour se deplacer au bon endroit |
|
| 98 | + // (sera fait en cas d'echec de cette fonction) |
|
| 99 | + return false; |
|
| 100 | + } |
|
| 101 | + $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
|
| 102 | + $this->pos = min($n, $this->count()); |
|
| 103 | + |
|
| 104 | + return true; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Avancer d'un cran. |
|
| 109 | + */ |
|
| 110 | + public function next(): void { |
|
| 111 | + $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
|
| 112 | + ++$this->pos; |
|
| 113 | + $this->firstseek = true; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Avancer et retourner les donnees pour le nouvel element. |
|
| 118 | + * |
|
| 119 | + * @return null|array|bool |
|
| 120 | + */ |
|
| 121 | + public function fetch() { |
|
| 122 | + if ($this->valid()) { |
|
| 123 | + $r = $this->current(); |
|
| 124 | + $this->next(); |
|
| 125 | + } else { |
|
| 126 | + $r = false; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + return $r; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * liberer les ressources. |
|
| 134 | + * |
|
| 135 | + * @return bool |
|
| 136 | + */ |
|
| 137 | + public function free() { |
|
| 138 | + if (!$this->sqlresult) { |
|
| 139 | + return true; |
|
| 140 | + } |
|
| 141 | + $a = sql_free($this->sqlresult, $this->command['connect']); |
|
| 142 | + $this->sqlresult = null; |
|
| 143 | + |
|
| 144 | + return $a; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Compter le nombre de resultats. |
|
| 149 | + */ |
|
| 150 | + public function count(): int { |
|
| 151 | + if (is_null($this->total)) { |
|
| 152 | + if (!$this->sqlresult) { |
|
| 153 | + $this->total = 0; |
|
| 154 | + } else { |
|
| 155 | + // cas count(*) |
|
| 156 | + if (in_array('count(*)', $this->command['select'])) { |
|
| 157 | + $this->valid(); |
|
| 158 | + $s = $this->current(); |
|
| 159 | + $this->total = (int) $s['count(*)']; |
|
| 160 | + } else { |
|
| 161 | + $this->total = (int) sql_count($this->sqlresult, $this->command['connect']); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + return $this->total; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * selectionner les donnees, ie faire la requete SQL. |
|
| 171 | + */ |
|
| 172 | + protected function select() { |
|
| 173 | + $this->row = null; |
|
| 174 | + $v = &$this->command; |
|
| 175 | + $this->sqlresult = calculer_select( |
|
| 176 | + $v['select'], |
|
| 177 | + $v['from'], |
|
| 178 | + $v['type'], |
|
| 179 | + $v['where'], |
|
| 180 | + $v['join'], |
|
| 181 | + $v['groupby'], |
|
| 182 | + $v['orderby'], |
|
| 183 | + $v['limit'], |
|
| 184 | + $v['having'], |
|
| 185 | + $v['table'], |
|
| 186 | + $v['id'], |
|
| 187 | + $v['connect'], |
|
| 188 | + $this->info |
|
| 189 | + ); |
|
| 190 | + $this->err = !$this->sqlresult; |
|
| 191 | + $this->firstseek = false; |
|
| 192 | + $this->pos = -1; |
|
| 193 | + |
|
| 194 | + // pas d'init a priori, le calcul ne sera fait qu'en cas de besoin (provoque une double requete souvent inutile en sqlite) |
|
| 195 | + //$this->total = $this->count(); |
|
| 196 | + } |
|
| 197 | 197 | } |
@@ -7,368 +7,368 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Boucle |
| 9 | 9 | { |
| 10 | - /** Type de noeud */ |
|
| 11 | - public string $type = 'boucle'; |
|
| 12 | - |
|
| 13 | - /** Identifiant de la boucle */ |
|
| 14 | - public string $id_boucle; |
|
| 15 | - |
|
| 16 | - /** Identifiant de la boucle parente */ |
|
| 17 | - public string $id_parent = ''; |
|
| 18 | - |
|
| 19 | - /** Un nom explicite qui peut être affecté manuellement à certaines boucles générées */ |
|
| 20 | - public string $nom = ''; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Partie avant toujours affichee |
|
| 24 | - * |
|
| 25 | - * @var string|array |
|
| 26 | - */ |
|
| 27 | - public $preaff = ''; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Partie optionnelle avant |
|
| 31 | - * |
|
| 32 | - * @var string|array |
|
| 33 | - */ |
|
| 34 | - public $avant = ''; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Pour chaque élément |
|
| 38 | - * |
|
| 39 | - * @var string|array |
|
| 40 | - */ |
|
| 41 | - public $milieu = ''; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Partie optionnelle après |
|
| 45 | - * |
|
| 46 | - * @var string|array |
|
| 47 | - */ |
|
| 48 | - public $apres = ''; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Partie alternative, si pas de résultat dans la boucle |
|
| 52 | - * |
|
| 53 | - * @var string|array |
|
| 54 | - */ |
|
| 55 | - public $altern = ''; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Partie apres toujours affichee |
|
| 59 | - * |
|
| 60 | - * @var string|array |
|
| 61 | - */ |
|
| 62 | - public $postaff = ''; |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * La boucle doit-elle sélectionner la langue ? |
|
| 67 | - * |
|
| 68 | - * Valeurs : '', 'oui', 'non' |
|
| 69 | - */ |
|
| 70 | - public string $lang_select = ''; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 74 | - * |
|
| 75 | - * FIXME: un seul typage (string ?) |
|
| 76 | - * |
|
| 77 | - * @var string|false|null |
|
| 78 | - */ |
|
| 79 | - public $type_requete = null; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * La table est elle optionnelle ? |
|
| 83 | - * |
|
| 84 | - * Si oui, aucune erreur ne sera générée si la table demandée n'est pas présente |
|
| 85 | - */ |
|
| 86 | - public bool $table_optionnelle = false; |
|
| 87 | - public string $type_table_optionnelle = ''; |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Nom du fichier de connexion |
|
| 91 | - */ |
|
| 92 | - public string $sql_serveur = ''; |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Paramètres de la boucle |
|
| 96 | - * |
|
| 97 | - * Description des paramètres passés à la boucle, qui servent ensuite |
|
| 98 | - * au calcul des critères |
|
| 99 | - * |
|
| 100 | - * FIXME: type unique. |
|
| 101 | - * @var false|array |
|
| 102 | - * - false: erreur de syntaxe |
|
| 103 | - */ |
|
| 104 | - public $param = []; |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Critères de la boucle |
|
| 108 | - * |
|
| 109 | - * FIXME: type array unique. |
|
| 110 | - * |
|
| 111 | - * @var string|Critere[] |
|
| 112 | - * - string: phrasage (code brut). Il reste si erreur de critère |
|
| 113 | - * - array: analyse correcte des critères... |
|
| 114 | - */ |
|
| 115 | - public $criteres = []; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Textes insérés entre 2 éléments de boucle (critère inter) |
|
| 119 | - * |
|
| 120 | - * @var string[] |
|
| 121 | - */ |
|
| 122 | - public array $separateur = []; |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Liste des jointures possibles avec cette table |
|
| 126 | - * |
|
| 127 | - * Les jointures par défaut de la table sont complétées en priorité |
|
| 128 | - * des jointures déclarées explicitement sur la boucle |
|
| 129 | - * |
|
| 130 | - * @see base_trouver_table_dist() |
|
| 131 | - */ |
|
| 132 | - public array $jointures = []; |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * Jointures explicites avec cette table |
|
| 136 | - * |
|
| 137 | - * Ces jointures sont utilisées en priorité par rapport aux jointures |
|
| 138 | - * normales possibles pour retrouver les colonnes demandées extérieures |
|
| 139 | - * à la boucle. |
|
| 140 | - * |
|
| 141 | - * @var string|bool |
|
| 142 | - */ |
|
| 143 | - public $jointures_explicites = false; |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Nom de la variable PHP stockant le noms de doublons utilisés "$doublons_index" |
|
| 147 | - */ |
|
| 148 | - public string $doublons = ''; |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Code PHP ajouté au début de chaque itération de boucle. |
|
| 152 | - * |
|
| 153 | - * Utilisé entre autre par les critères {pagination}, {n-a,b}, {a/b}... |
|
| 154 | - */ |
|
| 155 | - public string $partie = ''; |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Nombre de divisions de la boucle, d'éléments à afficher, |
|
| 159 | - * ou de soustractions d'éléments à faire |
|
| 160 | - * |
|
| 161 | - * Dans les critères limitant le nombre d'éléments affichés |
|
| 162 | - * {a,b}, {a,n-b}, {a/b}, {pagination b}, b est affecté à total_parties. |
|
| 163 | - */ |
|
| 164 | - public string $total_parties = ''; |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Code PHP ajouté avant l'itération de boucle. |
|
| 168 | - * |
|
| 169 | - * Utilisé entre autre par les critères {pagination}, {a,b}, {a/b} |
|
| 170 | - * pour initialiser les variables de début et de fin d'itération. |
|
| 171 | - */ |
|
| 172 | - public string $mode_partie = ''; |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Identifiant d'une boucle qui appelle celle-ci de manière récursive |
|
| 176 | - * |
|
| 177 | - * Si une boucle est appelée de manière récursive quelque part par |
|
| 178 | - * une autre boucle comme <BOUCLE_rec(boucle_identifiant) />, cette |
|
| 179 | - * boucle (identifiant) reçoit dans cette propriété l'identifiant |
|
| 180 | - * de l'appelant (rec) |
|
| 181 | - */ |
|
| 182 | - public string $externe = ''; |
|
| 183 | - |
|
| 184 | - // champs pour la construction de la requete SQL |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Liste des champs à récupérer par la boucle |
|
| 188 | - * |
|
| 189 | - * Expression 'table.nom_champ' ou calculée 'nom_champ AS x' |
|
| 190 | - * |
|
| 191 | - * @var string[] |
|
| 192 | - */ |
|
| 193 | - public array $select = []; |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Liste des alias / tables SQL utilisées dans la boucle |
|
| 197 | - * |
|
| 198 | - * L'index est un identifiant (xx dans spip_xx assez souvent) qui servira |
|
| 199 | - * d'alias au nom de la table ; la valeur est le nom de la table SQL désirée. |
|
| 200 | - * |
|
| 201 | - * L'index 0 peut définir le type de sources de données de l'itérateur DATA |
|
| 202 | - * |
|
| 203 | - * @var string[] |
|
| 204 | - */ |
|
| 205 | - public array $from = []; |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Liste des alias / type de jointures utilisées dans la boucle |
|
| 209 | - * |
|
| 210 | - * L'index est le nom d'alias (comme pour la propriété $from), et la valeur |
|
| 211 | - * un type de jointure parmi 'INNER', 'LEFT', 'RIGHT', 'OUTER'. |
|
| 212 | - * |
|
| 213 | - * Lorsque le type n'est pas déclaré pour un alias, c'est 'INNER' |
|
| 214 | - * qui sera utilisé par défaut (créant donc un INNER JOIN). |
|
| 215 | - * |
|
| 216 | - * @var string[] |
|
| 217 | - */ |
|
| 218 | - public array $from_type = []; |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Liste des conditions WHERE de la boucle |
|
| 222 | - * |
|
| 223 | - * Permet de restreindre les éléments retournés par une boucle |
|
| 224 | - * en fonctions des conditions transmises dans ce tableau. |
|
| 225 | - * |
|
| 226 | - * Ce tableau peut avoir plusieurs niveaux de profondeur. |
|
| 227 | - * |
|
| 228 | - * Les éléments du premier niveau sont reliés par des AND, donc |
|
| 229 | - * chaque élément ajouté directement au where par |
|
| 230 | - * $boucle->where[] = array(...) ou $boucle->where[] = "'expression'" |
|
| 231 | - * est une condition AND en plus. |
|
| 232 | - * |
|
| 233 | - * Par contre, lorsqu'on indique un tableau, il peut décrire des relations |
|
| 234 | - * internes différentes. Soit $expr un tableau d'expressions quelconques de 3 valeurs : |
|
| 235 | - * $expr = array(operateur, val1, val2) |
|
| 236 | - * |
|
| 237 | - * Ces 3 valeurs sont des expressions PHP. L'index 0 désigne l'opérateur |
|
| 238 | - * à réaliser tel que : |
|
| 239 | - * |
|
| 240 | - * - "'='" , "'>='", "'<'", "'IN'", "'REGEXP'", "'LIKE'", ... : |
|
| 241 | - * val1 et val2 sont des champs et valeurs à utiliser dans la comparaison |
|
| 242 | - * suivant cet ordre : "val1 operateur val2". |
|
| 243 | - * Exemple : $boucle->where[] = array("'='", "'articles.statut'", "'\"publie\"'"); |
|
| 244 | - * - "'AND'", "'OR'", "'NOT'" : |
|
| 245 | - * dans ce cas val1 et val2 sont également des expressions |
|
| 246 | - * de comparaison complètes, et peuvent être eux-même des tableaux comme $expr |
|
| 247 | - * Exemples : |
|
| 248 | - * $boucle->where[] = array("'OR'", $expr1, $expr2); |
|
| 249 | - * $boucle->where[] = array("'NOT'", $expr); // val2 n'existe pas avec NOT |
|
| 250 | - * |
|
| 251 | - * D'autres noms sont possibles pour l'opérateur (le nombre de valeurs diffère) : |
|
| 252 | - * - "'SELF'", "'SUBSELECT'" : indiquent des sous requêtes |
|
| 253 | - * - "'?'" : indique une condition à faire évaluer (val1 ? val2 : val3) |
|
| 254 | - */ |
|
| 255 | - public array $where = []; |
|
| 256 | - |
|
| 257 | - public array $join = []; |
|
| 258 | - public array $having = []; |
|
| 259 | - public $limit = ''; |
|
| 260 | - public array $group = []; |
|
| 261 | - public array $order = []; |
|
| 262 | - public array $default_order = []; |
|
| 263 | - public string $date = 'date'; |
|
| 264 | - public string $hash = ''; |
|
| 265 | - public $in = ''; |
|
| 266 | - public bool $sous_requete = false; |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * Code PHP qui sera ajouté en tout début de la fonction de boucle |
|
| 270 | - * |
|
| 271 | - * Il sert à insérer le code calculant une hierarchie |
|
| 272 | - */ |
|
| 273 | - public string $hierarchie = ''; |
|
| 274 | - |
|
| 275 | - // champs pour la construction du corps PHP |
|
| 276 | - |
|
| 277 | - /** |
|
| 278 | - * Description des sources de données de la boucle |
|
| 279 | - * |
|
| 280 | - * Description des données de la boucle issu de trouver_table |
|
| 281 | - * dans le cadre de l'itérateur SQL et contenant au moins l'index 'field'. |
|
| 282 | - * |
|
| 283 | - * @see base_trouver_table_dist() |
|
| 284 | - */ |
|
| 285 | - public array $show = []; |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * Nom de la table SQL principale de la boucle, sans son préfixe |
|
| 289 | - */ |
|
| 290 | - public string $id_table = ''; |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Nom de la clé primaire de la table SQL principale de la boucle |
|
| 294 | - */ |
|
| 295 | - public string $primary = ''; |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * Code PHP compilé de la boucle |
|
| 299 | - * |
|
| 300 | - * FIXME: un seul type (string ?) |
|
| 301 | - * |
|
| 302 | - * - false: boucle fautive ? |
|
| 303 | - * |
|
| 304 | - * @var string|false |
|
| 305 | - */ |
|
| 306 | - public $return = ''; |
|
| 307 | - |
|
| 308 | - public $numrows = false; |
|
| 309 | - public $cptrows = false; |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * Description du squelette |
|
| 313 | - * |
|
| 314 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 315 | - * |
|
| 316 | - * Peut contenir les index : |
|
| 317 | - * |
|
| 318 | - * - nom : Nom du fichier de cache |
|
| 319 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 320 | - * - sourcefile : Chemin du squelette |
|
| 321 | - * - squelette : Code du squelette |
|
| 322 | - * - id_mere : Identifiant de la boucle parente |
|
| 323 | - * - documents : Pour embed et img dans les textes |
|
| 324 | - * - session : Pour un cache sessionné par auteur |
|
| 325 | - * - niv : Niveau de tabulation |
|
| 326 | - */ |
|
| 327 | - public array $descr = []; |
|
| 328 | - |
|
| 329 | - /** Numéro de ligne dans le code source du squelette */ |
|
| 330 | - public int $ligne = 0; |
|
| 331 | - |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * table pour stocker les modificateurs de boucle tels que tout, plat ..., |
|
| 335 | - * utilisable par les plugins egalement |
|
| 336 | - * |
|
| 337 | - * @var array<string, mixed> |
|
| 338 | - */ |
|
| 339 | - public array $modificateur = []; |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * Type d'itérateur utilisé pour cette boucle |
|
| 343 | - * |
|
| 344 | - * - 'SQL' dans le cadre d'une boucle sur une table SQL |
|
| 345 | - * - 'DATA' pour l'itérateur DATA, ... |
|
| 346 | - * |
|
| 347 | - * @var string |
|
| 348 | - */ |
|
| 349 | - public string $iterateur = ''; // type d'iterateur |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * @var array $debug Textes qui seront insérés dans l’entête de boucle du mode debug |
|
| 353 | - */ |
|
| 354 | - public array $debug = []; |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * Index de la boucle dont le champ présent dans cette boucle est originaire, |
|
| 358 | - * notamment si le champ a été trouve dans une boucle parente |
|
| 359 | - * |
|
| 360 | - * Tableau nom du champ => index de boucle |
|
| 361 | - */ |
|
| 362 | - public array $index_champ = []; |
|
| 363 | - |
|
| 364 | - /** Résultat de la compilation (?) (sert au débusqueur) */ |
|
| 365 | - public string $code = ''; |
|
| 366 | - |
|
| 367 | - /** Source des filtres (compatibilité) (?) */ |
|
| 368 | - public array $fonctions = []; |
|
| 369 | - |
|
| 370 | - // obsoletes, conserves provisoirement pour compatibilite |
|
| 371 | - public $tout = false; |
|
| 372 | - public $plat = false; |
|
| 373 | - public $lien = false; |
|
| 10 | + /** Type de noeud */ |
|
| 11 | + public string $type = 'boucle'; |
|
| 12 | + |
|
| 13 | + /** Identifiant de la boucle */ |
|
| 14 | + public string $id_boucle; |
|
| 15 | + |
|
| 16 | + /** Identifiant de la boucle parente */ |
|
| 17 | + public string $id_parent = ''; |
|
| 18 | + |
|
| 19 | + /** Un nom explicite qui peut être affecté manuellement à certaines boucles générées */ |
|
| 20 | + public string $nom = ''; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Partie avant toujours affichee |
|
| 24 | + * |
|
| 25 | + * @var string|array |
|
| 26 | + */ |
|
| 27 | + public $preaff = ''; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Partie optionnelle avant |
|
| 31 | + * |
|
| 32 | + * @var string|array |
|
| 33 | + */ |
|
| 34 | + public $avant = ''; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Pour chaque élément |
|
| 38 | + * |
|
| 39 | + * @var string|array |
|
| 40 | + */ |
|
| 41 | + public $milieu = ''; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Partie optionnelle après |
|
| 45 | + * |
|
| 46 | + * @var string|array |
|
| 47 | + */ |
|
| 48 | + public $apres = ''; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Partie alternative, si pas de résultat dans la boucle |
|
| 52 | + * |
|
| 53 | + * @var string|array |
|
| 54 | + */ |
|
| 55 | + public $altern = ''; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Partie apres toujours affichee |
|
| 59 | + * |
|
| 60 | + * @var string|array |
|
| 61 | + */ |
|
| 62 | + public $postaff = ''; |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * La boucle doit-elle sélectionner la langue ? |
|
| 67 | + * |
|
| 68 | + * Valeurs : '', 'oui', 'non' |
|
| 69 | + */ |
|
| 70 | + public string $lang_select = ''; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Alias de table d'application de la requête ou nom complet de la table SQL |
|
| 74 | + * |
|
| 75 | + * FIXME: un seul typage (string ?) |
|
| 76 | + * |
|
| 77 | + * @var string|false|null |
|
| 78 | + */ |
|
| 79 | + public $type_requete = null; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * La table est elle optionnelle ? |
|
| 83 | + * |
|
| 84 | + * Si oui, aucune erreur ne sera générée si la table demandée n'est pas présente |
|
| 85 | + */ |
|
| 86 | + public bool $table_optionnelle = false; |
|
| 87 | + public string $type_table_optionnelle = ''; |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Nom du fichier de connexion |
|
| 91 | + */ |
|
| 92 | + public string $sql_serveur = ''; |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Paramètres de la boucle |
|
| 96 | + * |
|
| 97 | + * Description des paramètres passés à la boucle, qui servent ensuite |
|
| 98 | + * au calcul des critères |
|
| 99 | + * |
|
| 100 | + * FIXME: type unique. |
|
| 101 | + * @var false|array |
|
| 102 | + * - false: erreur de syntaxe |
|
| 103 | + */ |
|
| 104 | + public $param = []; |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Critères de la boucle |
|
| 108 | + * |
|
| 109 | + * FIXME: type array unique. |
|
| 110 | + * |
|
| 111 | + * @var string|Critere[] |
|
| 112 | + * - string: phrasage (code brut). Il reste si erreur de critère |
|
| 113 | + * - array: analyse correcte des critères... |
|
| 114 | + */ |
|
| 115 | + public $criteres = []; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Textes insérés entre 2 éléments de boucle (critère inter) |
|
| 119 | + * |
|
| 120 | + * @var string[] |
|
| 121 | + */ |
|
| 122 | + public array $separateur = []; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Liste des jointures possibles avec cette table |
|
| 126 | + * |
|
| 127 | + * Les jointures par défaut de la table sont complétées en priorité |
|
| 128 | + * des jointures déclarées explicitement sur la boucle |
|
| 129 | + * |
|
| 130 | + * @see base_trouver_table_dist() |
|
| 131 | + */ |
|
| 132 | + public array $jointures = []; |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * Jointures explicites avec cette table |
|
| 136 | + * |
|
| 137 | + * Ces jointures sont utilisées en priorité par rapport aux jointures |
|
| 138 | + * normales possibles pour retrouver les colonnes demandées extérieures |
|
| 139 | + * à la boucle. |
|
| 140 | + * |
|
| 141 | + * @var string|bool |
|
| 142 | + */ |
|
| 143 | + public $jointures_explicites = false; |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Nom de la variable PHP stockant le noms de doublons utilisés "$doublons_index" |
|
| 147 | + */ |
|
| 148 | + public string $doublons = ''; |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Code PHP ajouté au début de chaque itération de boucle. |
|
| 152 | + * |
|
| 153 | + * Utilisé entre autre par les critères {pagination}, {n-a,b}, {a/b}... |
|
| 154 | + */ |
|
| 155 | + public string $partie = ''; |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Nombre de divisions de la boucle, d'éléments à afficher, |
|
| 159 | + * ou de soustractions d'éléments à faire |
|
| 160 | + * |
|
| 161 | + * Dans les critères limitant le nombre d'éléments affichés |
|
| 162 | + * {a,b}, {a,n-b}, {a/b}, {pagination b}, b est affecté à total_parties. |
|
| 163 | + */ |
|
| 164 | + public string $total_parties = ''; |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Code PHP ajouté avant l'itération de boucle. |
|
| 168 | + * |
|
| 169 | + * Utilisé entre autre par les critères {pagination}, {a,b}, {a/b} |
|
| 170 | + * pour initialiser les variables de début et de fin d'itération. |
|
| 171 | + */ |
|
| 172 | + public string $mode_partie = ''; |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Identifiant d'une boucle qui appelle celle-ci de manière récursive |
|
| 176 | + * |
|
| 177 | + * Si une boucle est appelée de manière récursive quelque part par |
|
| 178 | + * une autre boucle comme <BOUCLE_rec(boucle_identifiant) />, cette |
|
| 179 | + * boucle (identifiant) reçoit dans cette propriété l'identifiant |
|
| 180 | + * de l'appelant (rec) |
|
| 181 | + */ |
|
| 182 | + public string $externe = ''; |
|
| 183 | + |
|
| 184 | + // champs pour la construction de la requete SQL |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Liste des champs à récupérer par la boucle |
|
| 188 | + * |
|
| 189 | + * Expression 'table.nom_champ' ou calculée 'nom_champ AS x' |
|
| 190 | + * |
|
| 191 | + * @var string[] |
|
| 192 | + */ |
|
| 193 | + public array $select = []; |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Liste des alias / tables SQL utilisées dans la boucle |
|
| 197 | + * |
|
| 198 | + * L'index est un identifiant (xx dans spip_xx assez souvent) qui servira |
|
| 199 | + * d'alias au nom de la table ; la valeur est le nom de la table SQL désirée. |
|
| 200 | + * |
|
| 201 | + * L'index 0 peut définir le type de sources de données de l'itérateur DATA |
|
| 202 | + * |
|
| 203 | + * @var string[] |
|
| 204 | + */ |
|
| 205 | + public array $from = []; |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Liste des alias / type de jointures utilisées dans la boucle |
|
| 209 | + * |
|
| 210 | + * L'index est le nom d'alias (comme pour la propriété $from), et la valeur |
|
| 211 | + * un type de jointure parmi 'INNER', 'LEFT', 'RIGHT', 'OUTER'. |
|
| 212 | + * |
|
| 213 | + * Lorsque le type n'est pas déclaré pour un alias, c'est 'INNER' |
|
| 214 | + * qui sera utilisé par défaut (créant donc un INNER JOIN). |
|
| 215 | + * |
|
| 216 | + * @var string[] |
|
| 217 | + */ |
|
| 218 | + public array $from_type = []; |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Liste des conditions WHERE de la boucle |
|
| 222 | + * |
|
| 223 | + * Permet de restreindre les éléments retournés par une boucle |
|
| 224 | + * en fonctions des conditions transmises dans ce tableau. |
|
| 225 | + * |
|
| 226 | + * Ce tableau peut avoir plusieurs niveaux de profondeur. |
|
| 227 | + * |
|
| 228 | + * Les éléments du premier niveau sont reliés par des AND, donc |
|
| 229 | + * chaque élément ajouté directement au where par |
|
| 230 | + * $boucle->where[] = array(...) ou $boucle->where[] = "'expression'" |
|
| 231 | + * est une condition AND en plus. |
|
| 232 | + * |
|
| 233 | + * Par contre, lorsqu'on indique un tableau, il peut décrire des relations |
|
| 234 | + * internes différentes. Soit $expr un tableau d'expressions quelconques de 3 valeurs : |
|
| 235 | + * $expr = array(operateur, val1, val2) |
|
| 236 | + * |
|
| 237 | + * Ces 3 valeurs sont des expressions PHP. L'index 0 désigne l'opérateur |
|
| 238 | + * à réaliser tel que : |
|
| 239 | + * |
|
| 240 | + * - "'='" , "'>='", "'<'", "'IN'", "'REGEXP'", "'LIKE'", ... : |
|
| 241 | + * val1 et val2 sont des champs et valeurs à utiliser dans la comparaison |
|
| 242 | + * suivant cet ordre : "val1 operateur val2". |
|
| 243 | + * Exemple : $boucle->where[] = array("'='", "'articles.statut'", "'\"publie\"'"); |
|
| 244 | + * - "'AND'", "'OR'", "'NOT'" : |
|
| 245 | + * dans ce cas val1 et val2 sont également des expressions |
|
| 246 | + * de comparaison complètes, et peuvent être eux-même des tableaux comme $expr |
|
| 247 | + * Exemples : |
|
| 248 | + * $boucle->where[] = array("'OR'", $expr1, $expr2); |
|
| 249 | + * $boucle->where[] = array("'NOT'", $expr); // val2 n'existe pas avec NOT |
|
| 250 | + * |
|
| 251 | + * D'autres noms sont possibles pour l'opérateur (le nombre de valeurs diffère) : |
|
| 252 | + * - "'SELF'", "'SUBSELECT'" : indiquent des sous requêtes |
|
| 253 | + * - "'?'" : indique une condition à faire évaluer (val1 ? val2 : val3) |
|
| 254 | + */ |
|
| 255 | + public array $where = []; |
|
| 256 | + |
|
| 257 | + public array $join = []; |
|
| 258 | + public array $having = []; |
|
| 259 | + public $limit = ''; |
|
| 260 | + public array $group = []; |
|
| 261 | + public array $order = []; |
|
| 262 | + public array $default_order = []; |
|
| 263 | + public string $date = 'date'; |
|
| 264 | + public string $hash = ''; |
|
| 265 | + public $in = ''; |
|
| 266 | + public bool $sous_requete = false; |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * Code PHP qui sera ajouté en tout début de la fonction de boucle |
|
| 270 | + * |
|
| 271 | + * Il sert à insérer le code calculant une hierarchie |
|
| 272 | + */ |
|
| 273 | + public string $hierarchie = ''; |
|
| 274 | + |
|
| 275 | + // champs pour la construction du corps PHP |
|
| 276 | + |
|
| 277 | + /** |
|
| 278 | + * Description des sources de données de la boucle |
|
| 279 | + * |
|
| 280 | + * Description des données de la boucle issu de trouver_table |
|
| 281 | + * dans le cadre de l'itérateur SQL et contenant au moins l'index 'field'. |
|
| 282 | + * |
|
| 283 | + * @see base_trouver_table_dist() |
|
| 284 | + */ |
|
| 285 | + public array $show = []; |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * Nom de la table SQL principale de la boucle, sans son préfixe |
|
| 289 | + */ |
|
| 290 | + public string $id_table = ''; |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Nom de la clé primaire de la table SQL principale de la boucle |
|
| 294 | + */ |
|
| 295 | + public string $primary = ''; |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * Code PHP compilé de la boucle |
|
| 299 | + * |
|
| 300 | + * FIXME: un seul type (string ?) |
|
| 301 | + * |
|
| 302 | + * - false: boucle fautive ? |
|
| 303 | + * |
|
| 304 | + * @var string|false |
|
| 305 | + */ |
|
| 306 | + public $return = ''; |
|
| 307 | + |
|
| 308 | + public $numrows = false; |
|
| 309 | + public $cptrows = false; |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * Description du squelette |
|
| 313 | + * |
|
| 314 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 315 | + * |
|
| 316 | + * Peut contenir les index : |
|
| 317 | + * |
|
| 318 | + * - nom : Nom du fichier de cache |
|
| 319 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 320 | + * - sourcefile : Chemin du squelette |
|
| 321 | + * - squelette : Code du squelette |
|
| 322 | + * - id_mere : Identifiant de la boucle parente |
|
| 323 | + * - documents : Pour embed et img dans les textes |
|
| 324 | + * - session : Pour un cache sessionné par auteur |
|
| 325 | + * - niv : Niveau de tabulation |
|
| 326 | + */ |
|
| 327 | + public array $descr = []; |
|
| 328 | + |
|
| 329 | + /** Numéro de ligne dans le code source du squelette */ |
|
| 330 | + public int $ligne = 0; |
|
| 331 | + |
|
| 332 | + |
|
| 333 | + /** |
|
| 334 | + * table pour stocker les modificateurs de boucle tels que tout, plat ..., |
|
| 335 | + * utilisable par les plugins egalement |
|
| 336 | + * |
|
| 337 | + * @var array<string, mixed> |
|
| 338 | + */ |
|
| 339 | + public array $modificateur = []; |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * Type d'itérateur utilisé pour cette boucle |
|
| 343 | + * |
|
| 344 | + * - 'SQL' dans le cadre d'une boucle sur une table SQL |
|
| 345 | + * - 'DATA' pour l'itérateur DATA, ... |
|
| 346 | + * |
|
| 347 | + * @var string |
|
| 348 | + */ |
|
| 349 | + public string $iterateur = ''; // type d'iterateur |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * @var array $debug Textes qui seront insérés dans l’entête de boucle du mode debug |
|
| 353 | + */ |
|
| 354 | + public array $debug = []; |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * Index de la boucle dont le champ présent dans cette boucle est originaire, |
|
| 358 | + * notamment si le champ a été trouve dans une boucle parente |
|
| 359 | + * |
|
| 360 | + * Tableau nom du champ => index de boucle |
|
| 361 | + */ |
|
| 362 | + public array $index_champ = []; |
|
| 363 | + |
|
| 364 | + /** Résultat de la compilation (?) (sert au débusqueur) */ |
|
| 365 | + public string $code = ''; |
|
| 366 | + |
|
| 367 | + /** Source des filtres (compatibilité) (?) */ |
|
| 368 | + public array $fonctions = []; |
|
| 369 | + |
|
| 370 | + // obsoletes, conserves provisoirement pour compatibilite |
|
| 371 | + public $tout = false; |
|
| 372 | + public $plat = false; |
|
| 373 | + public $lien = false; |
|
| 374 | 374 | } |