@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('public/decompiler'); |
@@ -68,133 +68,133 @@ discard block |
||
| 68 | 68 | * - true si $opt 'erreurs' = 'reset' |
| 69 | 69 | **/ |
| 70 | 70 | function public_debusquer_dist($message = '', $lieu = '', $opt = []) { |
| 71 | - static $should_log; |
|
| 72 | - static $tableau_des_erreurs = []; |
|
| 73 | - |
|
| 74 | - // Pour des tests unitaires, pouvoir récupérer les erreurs générées |
|
| 75 | - if (isset($opt['erreurs'])) { |
|
| 76 | - if ($opt['erreurs'] == 'get') { |
|
| 77 | - return $tableau_des_erreurs; |
|
| 78 | - } |
|
| 79 | - if ($opt['erreurs'] == 'reset') { |
|
| 80 | - $tableau_des_erreurs = []; |
|
| 81 | - |
|
| 82 | - return true; |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - if (is_null($should_log)) { |
|
| 87 | - $should_log = (empty($GLOBALS['visiteur_session']) || !include_spip('inc/autoriser') || !autoriser('debug')); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - // Erreur ou appel final ? |
|
| 91 | - if ($message) { |
|
| 92 | - $message = debusquer_compose_message($message); |
|
| 93 | - $tableau_des_erreurs[] = [$message, $lieu]; |
|
| 94 | - set_request('var_mode', 'debug'); |
|
| 95 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 96 | - // Permettre a la compil de continuer |
|
| 97 | - if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) { |
|
| 98 | - $lieu->code = "''"; |
|
| 99 | - } |
|
| 100 | - // loger si personne ne verra l'erreur |
|
| 101 | - if ($should_log) { |
|
| 102 | - debusquer_loger_erreur($message, $lieu); |
|
| 103 | - } |
|
| 104 | - // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 105 | - $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 106 | - if (!$urgence) { |
|
| 107 | - return; |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - if (empty($GLOBALS['debug_objets']['principal'])) { |
|
| 111 | - // espace public ? |
|
| 112 | - if (isset($GLOBALS['fond'])) { |
|
| 113 | - $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - include_spip('inc/autoriser'); |
|
| 118 | - if (!autoriser('debug')) { |
|
| 119 | - return; |
|
| 120 | - } |
|
| 121 | - include_spip('inc/headers'); |
|
| 122 | - include_spip('inc/filtres'); |
|
| 123 | - |
|
| 124 | - lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 125 | - $fonc = preg_replace(',\W,', '_', _request('var_mode_objet') ?? ''); |
|
| 126 | - $mode = preg_replace(',\W,', '_', _request('var_mode_affiche') ?? ''); |
|
| 127 | - |
|
| 128 | - $self = str_replace("\\'", ''', self()); |
|
| 129 | - $self = parametre_url($self, 'var_mode', 'debug'); |
|
| 130 | - |
|
| 131 | - $res = debusquer_bandeau($tableau_des_erreurs) |
|
| 132 | - . '<br />' |
|
| 133 | - . debusquer_squelette($fonc, $mode, $self); |
|
| 134 | - |
|
| 135 | - if (!_DIR_RESTREINT or headers_sent()) { |
|
| 136 | - return $res; |
|
| 137 | - } |
|
| 138 | - if ($tableau_des_erreurs) { |
|
| 139 | - http_response_code(503); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - http_no_cache(); |
|
| 143 | - if (isset($_GET['var_profile'])) { |
|
| 144 | - $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', ''); |
|
| 145 | - $titre = parametre_url($titre, 'var_mode', ''); |
|
| 146 | - } else { |
|
| 147 | - if (!$fonc) { |
|
| 148 | - $fonc = $GLOBALS['debug_objets']['principal']; |
|
| 149 | - } |
|
| 150 | - $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 151 | - } |
|
| 152 | - if ($message === false) { |
|
| 153 | - lang_select(); |
|
| 154 | - |
|
| 155 | - return debusquer_entete($titre, $res); |
|
| 156 | - } else { |
|
| 157 | - echo debusquer_entete($titre, $res); |
|
| 158 | - } |
|
| 159 | - exit; |
|
| 71 | + static $should_log; |
|
| 72 | + static $tableau_des_erreurs = []; |
|
| 73 | + |
|
| 74 | + // Pour des tests unitaires, pouvoir récupérer les erreurs générées |
|
| 75 | + if (isset($opt['erreurs'])) { |
|
| 76 | + if ($opt['erreurs'] == 'get') { |
|
| 77 | + return $tableau_des_erreurs; |
|
| 78 | + } |
|
| 79 | + if ($opt['erreurs'] == 'reset') { |
|
| 80 | + $tableau_des_erreurs = []; |
|
| 81 | + |
|
| 82 | + return true; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + if (is_null($should_log)) { |
|
| 87 | + $should_log = (empty($GLOBALS['visiteur_session']) || !include_spip('inc/autoriser') || !autoriser('debug')); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + // Erreur ou appel final ? |
|
| 91 | + if ($message) { |
|
| 92 | + $message = debusquer_compose_message($message); |
|
| 93 | + $tableau_des_erreurs[] = [$message, $lieu]; |
|
| 94 | + set_request('var_mode', 'debug'); |
|
| 95 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 96 | + // Permettre a la compil de continuer |
|
| 97 | + if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) { |
|
| 98 | + $lieu->code = "''"; |
|
| 99 | + } |
|
| 100 | + // loger si personne ne verra l'erreur |
|
| 101 | + if ($should_log) { |
|
| 102 | + debusquer_loger_erreur($message, $lieu); |
|
| 103 | + } |
|
| 104 | + // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 105 | + $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 106 | + if (!$urgence) { |
|
| 107 | + return; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + if (empty($GLOBALS['debug_objets']['principal'])) { |
|
| 111 | + // espace public ? |
|
| 112 | + if (isset($GLOBALS['fond'])) { |
|
| 113 | + $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + include_spip('inc/autoriser'); |
|
| 118 | + if (!autoriser('debug')) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 121 | + include_spip('inc/headers'); |
|
| 122 | + include_spip('inc/filtres'); |
|
| 123 | + |
|
| 124 | + lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 125 | + $fonc = preg_replace(',\W,', '_', _request('var_mode_objet') ?? ''); |
|
| 126 | + $mode = preg_replace(',\W,', '_', _request('var_mode_affiche') ?? ''); |
|
| 127 | + |
|
| 128 | + $self = str_replace("\\'", ''', self()); |
|
| 129 | + $self = parametre_url($self, 'var_mode', 'debug'); |
|
| 130 | + |
|
| 131 | + $res = debusquer_bandeau($tableau_des_erreurs) |
|
| 132 | + . '<br />' |
|
| 133 | + . debusquer_squelette($fonc, $mode, $self); |
|
| 134 | + |
|
| 135 | + if (!_DIR_RESTREINT or headers_sent()) { |
|
| 136 | + return $res; |
|
| 137 | + } |
|
| 138 | + if ($tableau_des_erreurs) { |
|
| 139 | + http_response_code(503); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + http_no_cache(); |
|
| 143 | + if (isset($_GET['var_profile'])) { |
|
| 144 | + $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', ''); |
|
| 145 | + $titre = parametre_url($titre, 'var_mode', ''); |
|
| 146 | + } else { |
|
| 147 | + if (!$fonc) { |
|
| 148 | + $fonc = $GLOBALS['debug_objets']['principal']; |
|
| 149 | + } |
|
| 150 | + $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 151 | + } |
|
| 152 | + if ($message === false) { |
|
| 153 | + lang_select(); |
|
| 154 | + |
|
| 155 | + return debusquer_entete($titre, $res); |
|
| 156 | + } else { |
|
| 157 | + echo debusquer_entete($titre, $res); |
|
| 158 | + } |
|
| 159 | + exit; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | function debusquer_compose_message($msg) { |
| 163 | - if (is_array($msg)) { |
|
| 164 | - // si c'est un texte, c'est une traduction a faire, mais |
|
| 165 | - // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments) |
|
| 166 | - if (!is_numeric($msg[0]) and count($msg) == 2) { |
|
| 167 | - // message avec argument: instancier |
|
| 168 | - $msg = _T($msg[0], $msg[1], 'spip-debug-arg'); |
|
| 169 | - } else { |
|
| 170 | - // message SQL: interpreter |
|
| 171 | - $msg = debusquer_requete($msg); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - // FIXME: le fond n'est pas la si on n'est pas dans un squelette |
|
| 175 | - // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur |
|
| 176 | - $fond = $GLOBALS['fond'] ?? ''; |
|
| 177 | - // une erreur critique sort $message en array |
|
| 178 | - $debug = is_array($msg) ? $msg[1] : $msg; |
|
| 179 | - spip_log('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 180 | - |
|
| 181 | - return $msg; |
|
| 163 | + if (is_array($msg)) { |
|
| 164 | + // si c'est un texte, c'est une traduction a faire, mais |
|
| 165 | + // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments) |
|
| 166 | + if (!is_numeric($msg[0]) and count($msg) == 2) { |
|
| 167 | + // message avec argument: instancier |
|
| 168 | + $msg = _T($msg[0], $msg[1], 'spip-debug-arg'); |
|
| 169 | + } else { |
|
| 170 | + // message SQL: interpreter |
|
| 171 | + $msg = debusquer_requete($msg); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + // FIXME: le fond n'est pas la si on n'est pas dans un squelette |
|
| 175 | + // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur |
|
| 176 | + $fond = $GLOBALS['fond'] ?? ''; |
|
| 177 | + // une erreur critique sort $message en array |
|
| 178 | + $debug = is_array($msg) ? $msg[1] : $msg; |
|
| 179 | + spip_log('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 180 | + |
|
| 181 | + return $msg; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | function debusquer_bandeau($erreurs) { |
| 185 | 185 | |
| 186 | - if (!empty($erreurs)) { |
|
| 187 | - $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 186 | + if (!empty($erreurs)) { |
|
| 187 | + $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 188 | 188 | |
| 189 | - return debusquer_navigation($erreurs, $n); |
|
| 190 | - } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
|
| 191 | - include_spip('public/tracer'); |
|
| 192 | - [$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']); |
|
| 189 | + return debusquer_navigation($erreurs, $n); |
|
| 190 | + } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
|
| 191 | + include_spip('public/tracer'); |
|
| 192 | + [$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']); |
|
| 193 | 193 | |
| 194 | - return debusquer_navigation($temps, $nav, 'debug-profile'); |
|
| 195 | - } else { |
|
| 196 | - return ''; |
|
| 197 | - } |
|
| 194 | + return debusquer_navigation($temps, $nav, 'debug-profile'); |
|
| 195 | + } else { |
|
| 196 | + return ''; |
|
| 197 | + } |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -204,63 +204,63 @@ discard block |
||
| 204 | 204 | * @return string Code HTML |
| 205 | 205 | **/ |
| 206 | 206 | function debusquer_contexte($env) { |
| 207 | - if (is_string($env) and is_array($env_tab = @unserialize($env))) { |
|
| 208 | - $env = $env_tab; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - if (!$env) { |
|
| 212 | - return ''; |
|
| 213 | - } |
|
| 214 | - $res = ''; |
|
| 215 | - foreach ($env as $nom => $valeur) { |
|
| 216 | - if (is_array($valeur)) { |
|
| 217 | - $valeur_simple = []; |
|
| 218 | - foreach ($valeur as $v) { |
|
| 219 | - if (is_array($v)) { |
|
| 220 | - $valeur_simple[] = 'array:' . count($v); |
|
| 221 | - } elseif (is_object($v)) { |
|
| 222 | - $valeur_simple[] = get_class($v); |
|
| 223 | - } elseif (is_string($v)) { |
|
| 224 | - $valeur_simple[] = "'" . $v . "'"; |
|
| 225 | - } else { |
|
| 226 | - $valeur_simple[] = $v; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - $n = count($valeur); |
|
| 230 | - $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 231 | - $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 232 | - } elseif (is_object($valeur)) { |
|
| 233 | - $valeur = get_class($valeur); |
|
| 234 | - } elseif (is_string($valeur)) { |
|
| 235 | - $valeur = "'" . $valeur . "'"; |
|
| 236 | - } |
|
| 237 | - $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 238 | - . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 239 | - . "</td></tr>\n"; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 207 | + if (is_string($env) and is_array($env_tab = @unserialize($env))) { |
|
| 208 | + $env = $env_tab; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + if (!$env) { |
|
| 212 | + return ''; |
|
| 213 | + } |
|
| 214 | + $res = ''; |
|
| 215 | + foreach ($env as $nom => $valeur) { |
|
| 216 | + if (is_array($valeur)) { |
|
| 217 | + $valeur_simple = []; |
|
| 218 | + foreach ($valeur as $v) { |
|
| 219 | + if (is_array($v)) { |
|
| 220 | + $valeur_simple[] = 'array:' . count($v); |
|
| 221 | + } elseif (is_object($v)) { |
|
| 222 | + $valeur_simple[] = get_class($v); |
|
| 223 | + } elseif (is_string($v)) { |
|
| 224 | + $valeur_simple[] = "'" . $v . "'"; |
|
| 225 | + } else { |
|
| 226 | + $valeur_simple[] = $v; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + $n = count($valeur); |
|
| 230 | + $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 231 | + $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 232 | + } elseif (is_object($valeur)) { |
|
| 233 | + $valeur = get_class($valeur); |
|
| 234 | + } elseif (is_string($valeur)) { |
|
| 235 | + $valeur = "'" . $valeur . "'"; |
|
| 236 | + } |
|
| 237 | + $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 238 | + . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 239 | + . "</td></tr>\n"; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | function debusquer_loger_erreur($msg, $lieu) { |
| 247 | - $boucle = $ligne = $skel = ''; |
|
| 248 | - if (is_object($lieu)) { |
|
| 249 | - $ligne = ($lieu->ligne ?? ''); |
|
| 250 | - $boucle = ($lieu->id_boucle ?? ''); |
|
| 251 | - $skel = ($lieu->descr['sourcefile'] ?? ''); |
|
| 252 | - } |
|
| 253 | - $msg = (is_array($msg) ? implode('', $msg) : $msg); |
|
| 254 | - if ($skel) { |
|
| 255 | - $msg .= " Squelette $skel"; |
|
| 256 | - } |
|
| 257 | - if ($boucle) { |
|
| 258 | - $msg .= " Boucle $boucle"; |
|
| 259 | - } |
|
| 260 | - if ($ligne) { |
|
| 261 | - $msg .= " L$ligne"; |
|
| 262 | - } |
|
| 263 | - spip_log($msg, "debusquer" . _LOG_ERREUR); |
|
| 247 | + $boucle = $ligne = $skel = ''; |
|
| 248 | + if (is_object($lieu)) { |
|
| 249 | + $ligne = ($lieu->ligne ?? ''); |
|
| 250 | + $boucle = ($lieu->id_boucle ?? ''); |
|
| 251 | + $skel = ($lieu->descr['sourcefile'] ?? ''); |
|
| 252 | + } |
|
| 253 | + $msg = (is_array($msg) ? implode('', $msg) : $msg); |
|
| 254 | + if ($skel) { |
|
| 255 | + $msg .= " Squelette $skel"; |
|
| 256 | + } |
|
| 257 | + if ($boucle) { |
|
| 258 | + $msg .= " Boucle $boucle"; |
|
| 259 | + } |
|
| 260 | + if ($ligne) { |
|
| 261 | + $msg .= " L$ligne"; |
|
| 262 | + } |
|
| 263 | + spip_log($msg, "debusquer" . _LOG_ERREUR); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
@@ -269,66 +269,66 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | function debusquer_navigation($tableau, $caption = [], $id = 'debug-nav') { |
| 271 | 271 | |
| 272 | - if (_request('exec') == 'valider_xml') { |
|
| 273 | - return ''; |
|
| 274 | - } |
|
| 275 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 276 | - $res = ''; |
|
| 277 | - $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 278 | - foreach ($tableau as $i => $err) { |
|
| 279 | - $boucle = $ligne = $skel = ''; |
|
| 280 | - [$msg, $lieu] = $err; |
|
| 281 | - if (is_object($lieu)) { |
|
| 282 | - $ligne = $lieu->ligne; |
|
| 283 | - $boucle = !empty($lieu->id_boucle) ? $lieu->id_boucle : ''; |
|
| 284 | - if (isset($lieu->descr['nom'])) { |
|
| 285 | - $nom_code = $lieu->descr['nom']; |
|
| 286 | - $skel = $lieu->descr['sourcefile']; |
|
| 287 | - $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 288 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 289 | - $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 290 | - if ($boucle) { |
|
| 291 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 292 | - $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - $j = ($i + 1); |
|
| 298 | - $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 299 | - . $j |
|
| 300 | - . " </td><td style='text-align: left'>" |
|
| 301 | - . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 302 | - . "</td><td style='text-align: left'>" |
|
| 303 | - . ($skel ?: ' / ') |
|
| 304 | - . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 305 | - . ($boucle ?: ' / ') |
|
| 306 | - . "</td><td style='text-align: right'>" |
|
| 307 | - . $ligne |
|
| 308 | - . "</td></tr>\n"; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - return "\n<table id='$id'>" |
|
| 312 | - . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 313 | - . $caption[0] |
|
| 272 | + if (_request('exec') == 'valider_xml') { |
|
| 273 | + return ''; |
|
| 274 | + } |
|
| 275 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 276 | + $res = ''; |
|
| 277 | + $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 278 | + foreach ($tableau as $i => $err) { |
|
| 279 | + $boucle = $ligne = $skel = ''; |
|
| 280 | + [$msg, $lieu] = $err; |
|
| 281 | + if (is_object($lieu)) { |
|
| 282 | + $ligne = $lieu->ligne; |
|
| 283 | + $boucle = !empty($lieu->id_boucle) ? $lieu->id_boucle : ''; |
|
| 284 | + if (isset($lieu->descr['nom'])) { |
|
| 285 | + $nom_code = $lieu->descr['nom']; |
|
| 286 | + $skel = $lieu->descr['sourcefile']; |
|
| 287 | + $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 288 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 289 | + $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 290 | + if ($boucle) { |
|
| 291 | + $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 292 | + $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + $j = ($i + 1); |
|
| 298 | + $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 299 | + . $j |
|
| 300 | + . " </td><td style='text-align: left'>" |
|
| 301 | + . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 302 | + . "</td><td style='text-align: left'>" |
|
| 303 | + . ($skel ?: ' / ') |
|
| 304 | + . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 305 | + . ($boucle ?: ' / ') |
|
| 306 | + . "</td><td style='text-align: right'>" |
|
| 307 | + . $ligne |
|
| 308 | + . "</td></tr>\n"; |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + return "\n<table id='$id'>" |
|
| 312 | + . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 313 | + . $caption[0] |
|
| 314 | 314 | ## aide locale courte a ecrire, avec lien vers une grosse page de documentation |
| 315 | 315 | # aider('erreur_compilation'), |
| 316 | - . '</caption>' |
|
| 317 | - // fausse caption du chrono (mais vraie nav) |
|
| 318 | - . (!empty($caption[1]) ? $caption[1] : '') |
|
| 319 | - . '<tr><th>' |
|
| 320 | - . _T('numero') |
|
| 321 | - . '</th><th>' |
|
| 322 | - . _T('public:message') |
|
| 323 | - . '</th><th>' |
|
| 324 | - . _T('squelette') |
|
| 325 | - . '</th><th>' |
|
| 326 | - . _T('zbug_boucle') |
|
| 327 | - . '</th><th>' |
|
| 328 | - . _T('ligne') |
|
| 329 | - . '</th></tr>' |
|
| 330 | - . $res |
|
| 331 | - . '</table>'; |
|
| 316 | + . '</caption>' |
|
| 317 | + // fausse caption du chrono (mais vraie nav) |
|
| 318 | + . (!empty($caption[1]) ? $caption[1] : '') |
|
| 319 | + . '<tr><th>' |
|
| 320 | + . _T('numero') |
|
| 321 | + . '</th><th>' |
|
| 322 | + . _T('public:message') |
|
| 323 | + . '</th><th>' |
|
| 324 | + . _T('squelette') |
|
| 325 | + . '</th><th>' |
|
| 326 | + . _T('zbug_boucle') |
|
| 327 | + . '</th><th>' |
|
| 328 | + . _T('ligne') |
|
| 329 | + . '</th></tr>' |
|
| 330 | + . $res |
|
| 331 | + . '</table>'; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | |
@@ -348,514 +348,514 @@ discard block |
||
| 348 | 348 | * ou un tableau si l'erreur est critique |
| 349 | 349 | **/ |
| 350 | 350 | function debusquer_requete($message) { |
| 351 | - [$errno, $msg, $query] = $message; |
|
| 352 | - |
|
| 353 | - // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 354 | - // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 355 | - if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) { |
|
| 356 | - $errno = $regs[2]; |
|
| 357 | - } elseif ( |
|
| 358 | - is_numeric($errno) and ($errno == 1030 or $errno <= 1026) |
|
| 359 | - and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs) |
|
| 360 | - ) { |
|
| 361 | - $errno = $regs[1]; |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - // Erreur systeme |
|
| 365 | - if (is_numeric($errno) and $errno > 0 and $errno < 200) { |
|
| 366 | - $retour = '<tt><br /><br /><blink>' |
|
| 367 | - . _T('info_erreur_systeme', ['errsys' => $errno]) |
|
| 368 | - . "</blink><br />\n<b>" |
|
| 369 | - . _T( |
|
| 370 | - 'info_erreur_systeme2', |
|
| 371 | - ['script' => generer_url_ecrire('base_repair')] |
|
| 372 | - ) |
|
| 373 | - . '</b><br />'; |
|
| 374 | - spip_log("Erreur systeme $errno"); |
|
| 375 | - |
|
| 376 | - return [$retour, '']; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - // Requete erronee |
|
| 380 | - $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 381 | - . spip_htmlspecialchars($msg) |
|
| 382 | - . "\n<br /><span style='color: red'><b>" |
|
| 383 | - . spip_htmlspecialchars($query) |
|
| 384 | - . '</b></span></tt><br />'; |
|
| 385 | - |
|
| 386 | - //. aider('erreur_mysql'); |
|
| 387 | - |
|
| 388 | - return $err; |
|
| 351 | + [$errno, $msg, $query] = $message; |
|
| 352 | + |
|
| 353 | + // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 354 | + // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 355 | + if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) { |
|
| 356 | + $errno = $regs[2]; |
|
| 357 | + } elseif ( |
|
| 358 | + is_numeric($errno) and ($errno == 1030 or $errno <= 1026) |
|
| 359 | + and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs) |
|
| 360 | + ) { |
|
| 361 | + $errno = $regs[1]; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + // Erreur systeme |
|
| 365 | + if (is_numeric($errno) and $errno > 0 and $errno < 200) { |
|
| 366 | + $retour = '<tt><br /><br /><blink>' |
|
| 367 | + . _T('info_erreur_systeme', ['errsys' => $errno]) |
|
| 368 | + . "</blink><br />\n<b>" |
|
| 369 | + . _T( |
|
| 370 | + 'info_erreur_systeme2', |
|
| 371 | + ['script' => generer_url_ecrire('base_repair')] |
|
| 372 | + ) |
|
| 373 | + . '</b><br />'; |
|
| 374 | + spip_log("Erreur systeme $errno"); |
|
| 375 | + |
|
| 376 | + return [$retour, '']; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + // Requete erronee |
|
| 380 | + $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 381 | + . spip_htmlspecialchars($msg) |
|
| 382 | + . "\n<br /><span style='color: red'><b>" |
|
| 383 | + . spip_htmlspecialchars($query) |
|
| 384 | + . '</b></span></tt><br />'; |
|
| 385 | + |
|
| 386 | + //. aider('erreur_mysql'); |
|
| 387 | + |
|
| 388 | + return $err; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | |
| 392 | 392 | function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = '') { |
| 393 | 393 | |
| 394 | - $id = $nom . $boucle; |
|
| 395 | - if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 396 | - foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 397 | - if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
|
| 398 | - $y = substr_count($v[0], "\n"); |
|
| 399 | - } else { |
|
| 400 | - if ($v[1][0] == '#') { // balise dynamique |
|
| 401 | - $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 402 | - } else // inclusion |
|
| 403 | - { |
|
| 404 | - $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 405 | - } |
|
| 406 | - $y = substr_count($incl, "\n") |
|
| 407 | - + substr_count($r[1], "\n") |
|
| 408 | - + substr_count($r[3], "\n"); |
|
| 409 | - } |
|
| 410 | - if ($n <= ($y + $debut)) { |
|
| 411 | - if ($v[1][0] == '?') { |
|
| 412 | - return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1)); |
|
| 413 | - } elseif ($v[1][0] == '!') { |
|
| 414 | - if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 415 | - return trouve_boucle_debug($n, $incl, $debut); |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - return [$nom, $boucle, $v[2] - 1 + $n - $debut]; |
|
| 420 | - } |
|
| 421 | - $debut += $y; |
|
| 422 | - } |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - return [$nom, $boucle, $n - $debut]; |
|
| 394 | + $id = $nom . $boucle; |
|
| 395 | + if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 396 | + foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 397 | + if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
|
| 398 | + $y = substr_count($v[0], "\n"); |
|
| 399 | + } else { |
|
| 400 | + if ($v[1][0] == '#') { // balise dynamique |
|
| 401 | + $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 402 | + } else // inclusion |
|
| 403 | + { |
|
| 404 | + $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 405 | + } |
|
| 406 | + $y = substr_count($incl, "\n") |
|
| 407 | + + substr_count($r[1], "\n") |
|
| 408 | + + substr_count($r[3], "\n"); |
|
| 409 | + } |
|
| 410 | + if ($n <= ($y + $debut)) { |
|
| 411 | + if ($v[1][0] == '?') { |
|
| 412 | + return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1)); |
|
| 413 | + } elseif ($v[1][0] == '!') { |
|
| 414 | + if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 415 | + return trouve_boucle_debug($n, $incl, $debut); |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + return [$nom, $boucle, $v[2] - 1 + $n - $debut]; |
|
| 420 | + } |
|
| 421 | + $debut += $y; |
|
| 422 | + } |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + return [$nom, $boucle, $n - $debut]; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | function trouve_squelette_inclus($script) { |
| 429 | 429 | |
| 430 | - preg_match('/include\(.(.*).php3?.\);/', $script, $reg); |
|
| 431 | - // si le script X.php n'est pas ecrire/public.php |
|
| 432 | - // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 433 | - if ($reg[1] == 'ecrire/public') { // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 434 | - if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) { // a defaut on cherche le param 'page' |
|
| 435 | - if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) { |
|
| 436 | - $reg[1] = 'inconnu'; |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 441 | - |
|
| 442 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 443 | - if (preg_match($incl, $v)) { |
|
| 444 | - return $k; |
|
| 445 | - } |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - return ''; |
|
| 430 | + preg_match('/include\(.(.*).php3?.\);/', $script, $reg); |
|
| 431 | + // si le script X.php n'est pas ecrire/public.php |
|
| 432 | + // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 433 | + if ($reg[1] == 'ecrire/public') { // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 434 | + if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) { // a defaut on cherche le param 'page' |
|
| 435 | + if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) { |
|
| 436 | + $reg[1] = 'inconnu'; |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 441 | + |
|
| 442 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 443 | + if (preg_match($incl, $v)) { |
|
| 444 | + return $k; |
|
| 445 | + } |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + return ''; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | function reference_boucle_debug($n, $nom, $self) { |
| 452 | - [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
|
| 453 | - |
|
| 454 | - if (!$boucle) { |
|
| 455 | - return !$ligne ? '' : |
|
| 456 | - (' (' . |
|
| 457 | - (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 458 | - _T('squelette_ligne')) . |
|
| 459 | - " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
|
| 460 | - } else { |
|
| 461 | - $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 462 | - |
|
| 463 | - return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 464 | - " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 465 | - } |
|
| 452 | + [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
|
| 453 | + |
|
| 454 | + if (!$boucle) { |
|
| 455 | + return !$ligne ? '' : |
|
| 456 | + (' (' . |
|
| 457 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 458 | + _T('squelette_ligne')) . |
|
| 459 | + " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
|
| 460 | + } else { |
|
| 461 | + $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 462 | + |
|
| 463 | + return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 464 | + " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 465 | + } |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // affiche un texte avec numero de ligne et ancre. |
| 469 | 469 | |
| 470 | 470 | function ancre_texte($texte, $fautifs = [], $nocpt = false) { |
| 471 | 471 | |
| 472 | - $var_mode_ligne = _request('var_mode_ligne'); |
|
| 473 | - if ($var_mode_ligne) { |
|
| 474 | - $fautifs[] = [$var_mode_ligne]; |
|
| 475 | - } |
|
| 476 | - $res = ''; |
|
| 477 | - |
|
| 478 | - $s = highlight_string($texte, true); |
|
| 479 | - if (substr($s, 0, 6) == '<code>') { |
|
| 480 | - $s = substr($s, 6); |
|
| 481 | - $res = '<code>'; |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - $s = preg_replace( |
|
| 485 | - ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 486 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 487 | - $s |
|
| 488 | - ); |
|
| 489 | - |
|
| 490 | - |
|
| 491 | - $tableau = explode('<br />', $s); |
|
| 492 | - |
|
| 493 | - $format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n"; |
|
| 494 | - |
|
| 495 | - $format10 = str_replace('white', 'lightgrey', $format); |
|
| 496 | - $formaterr = 'color: red;'; |
|
| 497 | - $i = 1; |
|
| 498 | - $flignes = []; |
|
| 499 | - $loc = [0, 0]; |
|
| 500 | - foreach ($fautifs as $lc) { |
|
| 501 | - if (is_array($lc)) { |
|
| 502 | - $l = array_shift($lc); |
|
| 503 | - $flignes[$l] = $lc; |
|
| 504 | - } else { |
|
| 505 | - $flignes[$lc] = $loc; |
|
| 506 | - } |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - $ancre = md5($texte); |
|
| 510 | - foreach ($tableau as $ligne) { |
|
| 511 | - if (isset($flignes[$i])) { |
|
| 512 | - $ligne = str_replace(' ', ' ', $ligne); |
|
| 513 | - $indexmesg = $flignes[$i][1]; |
|
| 514 | - $err = textebrut($flignes[$i][2]); |
|
| 515 | - // tentative de pointer sur la colonne fautive; |
|
| 516 | - // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 517 | - // $m = $flignes[$i][0]; |
|
| 518 | - // $ligne = substr($ligne, 0, $m-1) . |
|
| 519 | - // sprintf($formaterr, substr($ligne,$m)); |
|
| 520 | - $bg = $formaterr; |
|
| 521 | - } else { |
|
| 522 | - $indexmesg = $ancre; |
|
| 523 | - $err = $bg = ''; |
|
| 524 | - } |
|
| 525 | - $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 526 | - $i++; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return "<div id='T$ancre'>" |
|
| 530 | - . '<div onclick="' |
|
| 531 | - . "jQuery(this).parent().find('a').toggle();" |
|
| 532 | - . '" title="' |
|
| 533 | - . _T('masquer_colonne') |
|
| 534 | - . '" style="cursor: pointer;">' |
|
| 535 | - . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 536 | - . '</div> |
|
| 472 | + $var_mode_ligne = _request('var_mode_ligne'); |
|
| 473 | + if ($var_mode_ligne) { |
|
| 474 | + $fautifs[] = [$var_mode_ligne]; |
|
| 475 | + } |
|
| 476 | + $res = ''; |
|
| 477 | + |
|
| 478 | + $s = highlight_string($texte, true); |
|
| 479 | + if (substr($s, 0, 6) == '<code>') { |
|
| 480 | + $s = substr($s, 6); |
|
| 481 | + $res = '<code>'; |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + $s = preg_replace( |
|
| 485 | + ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 486 | + '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 487 | + $s |
|
| 488 | + ); |
|
| 489 | + |
|
| 490 | + |
|
| 491 | + $tableau = explode('<br />', $s); |
|
| 492 | + |
|
| 493 | + $format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n"; |
|
| 494 | + |
|
| 495 | + $format10 = str_replace('white', 'lightgrey', $format); |
|
| 496 | + $formaterr = 'color: red;'; |
|
| 497 | + $i = 1; |
|
| 498 | + $flignes = []; |
|
| 499 | + $loc = [0, 0]; |
|
| 500 | + foreach ($fautifs as $lc) { |
|
| 501 | + if (is_array($lc)) { |
|
| 502 | + $l = array_shift($lc); |
|
| 503 | + $flignes[$l] = $lc; |
|
| 504 | + } else { |
|
| 505 | + $flignes[$lc] = $loc; |
|
| 506 | + } |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + $ancre = md5($texte); |
|
| 510 | + foreach ($tableau as $ligne) { |
|
| 511 | + if (isset($flignes[$i])) { |
|
| 512 | + $ligne = str_replace(' ', ' ', $ligne); |
|
| 513 | + $indexmesg = $flignes[$i][1]; |
|
| 514 | + $err = textebrut($flignes[$i][2]); |
|
| 515 | + // tentative de pointer sur la colonne fautive; |
|
| 516 | + // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 517 | + // $m = $flignes[$i][0]; |
|
| 518 | + // $ligne = substr($ligne, 0, $m-1) . |
|
| 519 | + // sprintf($formaterr, substr($ligne,$m)); |
|
| 520 | + $bg = $formaterr; |
|
| 521 | + } else { |
|
| 522 | + $indexmesg = $ancre; |
|
| 523 | + $err = $bg = ''; |
|
| 524 | + } |
|
| 525 | + $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 526 | + $i++; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return "<div id='T$ancre'>" |
|
| 530 | + . '<div onclick="' |
|
| 531 | + . "jQuery(this).parent().find('a').toggle();" |
|
| 532 | + . '" title="' |
|
| 533 | + . _T('masquer_colonne') |
|
| 534 | + . '" style="cursor: pointer;">' |
|
| 535 | + . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 536 | + . '</div> |
|
| 537 | 537 | ' . $res . "</div>\n"; |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | // l'environnement graphique du debuggueur |
| 541 | 541 | |
| 542 | 542 | function debusquer_squelette($fonc, $mode, $self) { |
| 543 | - $legend = null; |
|
| 544 | - $texte = ''; |
|
| 545 | - |
|
| 546 | - if ($mode !== 'validation') { |
|
| 547 | - if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) { |
|
| 548 | - $res = "<div id='spip-boucles'>\n" |
|
| 549 | - . debusquer_navigation_squelettes($self) |
|
| 550 | - . '</div>'; |
|
| 551 | - } else { |
|
| 552 | - $res = ''; |
|
| 553 | - } |
|
| 554 | - if ($fonc) { |
|
| 555 | - $id = " id='$fonc'"; |
|
| 556 | - if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 557 | - [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
|
| 558 | - $texte .= $res2; |
|
| 559 | - } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 560 | - $legend = _T('zbug_' . $mode); |
|
| 561 | - $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 562 | - $texte = ancre_texte($texte, ['', '']); |
|
| 563 | - } |
|
| 564 | - } else { |
|
| 565 | - if (strlen(trim($res))) { |
|
| 566 | - return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 567 | - } else { |
|
| 568 | - // cas de l'appel sur erreur: montre la page |
|
| 569 | - return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
|
| 570 | - } |
|
| 571 | - } |
|
| 572 | - } else { |
|
| 573 | - $valider = charger_fonction('valider', 'xml'); |
|
| 574 | - $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 575 | - // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 576 | - $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 577 | - [$texte, $err] = emboite_texte($val, $fonc, $self); |
|
| 578 | - if ($err === false) { |
|
| 579 | - $err = _T('impossible'); |
|
| 580 | - } elseif ($err === true) { |
|
| 581 | - $err = _T('correcte'); |
|
| 582 | - } else { |
|
| 583 | - $err = ": $err"; |
|
| 584 | - } |
|
| 585 | - $legend = _T('validation') . ' ' . $err; |
|
| 586 | - $res = $id = ''; |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - return !trim($texte) ? '' : ( |
|
| 590 | - "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 591 | - . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 592 | - . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> ↑ " |
|
| 593 | - . ($legend ?: $mode) |
|
| 594 | - . '</a></legend>' |
|
| 595 | - . $texte |
|
| 596 | - . '</fieldset></div>' |
|
| 597 | - . '</div>'); |
|
| 543 | + $legend = null; |
|
| 544 | + $texte = ''; |
|
| 545 | + |
|
| 546 | + if ($mode !== 'validation') { |
|
| 547 | + if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) { |
|
| 548 | + $res = "<div id='spip-boucles'>\n" |
|
| 549 | + . debusquer_navigation_squelettes($self) |
|
| 550 | + . '</div>'; |
|
| 551 | + } else { |
|
| 552 | + $res = ''; |
|
| 553 | + } |
|
| 554 | + if ($fonc) { |
|
| 555 | + $id = " id='$fonc'"; |
|
| 556 | + if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 557 | + [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
|
| 558 | + $texte .= $res2; |
|
| 559 | + } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 560 | + $legend = _T('zbug_' . $mode); |
|
| 561 | + $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 562 | + $texte = ancre_texte($texte, ['', '']); |
|
| 563 | + } |
|
| 564 | + } else { |
|
| 565 | + if (strlen(trim($res))) { |
|
| 566 | + return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 567 | + } else { |
|
| 568 | + // cas de l'appel sur erreur: montre la page |
|
| 569 | + return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
|
| 570 | + } |
|
| 571 | + } |
|
| 572 | + } else { |
|
| 573 | + $valider = charger_fonction('valider', 'xml'); |
|
| 574 | + $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 575 | + // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 576 | + $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 577 | + [$texte, $err] = emboite_texte($val, $fonc, $self); |
|
| 578 | + if ($err === false) { |
|
| 579 | + $err = _T('impossible'); |
|
| 580 | + } elseif ($err === true) { |
|
| 581 | + $err = _T('correcte'); |
|
| 582 | + } else { |
|
| 583 | + $err = ": $err"; |
|
| 584 | + } |
|
| 585 | + $legend = _T('validation') . ' ' . $err; |
|
| 586 | + $res = $id = ''; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + return !trim($texte) ? '' : ( |
|
| 590 | + "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 591 | + . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 592 | + . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> ↑ " |
|
| 593 | + . ($legend ?: $mode) |
|
| 594 | + . '</a></legend>' |
|
| 595 | + . $texte |
|
| 596 | + . '</fieldset></div>' |
|
| 597 | + . '</div>'); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | |
| 601 | 601 | function emboite_texte($res, $fonc = '', $self = '') { |
| 602 | - $errs = $res->err; |
|
| 603 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 604 | - |
|
| 605 | - if (!$texte and !$errs) { |
|
| 606 | - return [ancre_texte('', ['', '']), false]; |
|
| 607 | - } |
|
| 608 | - if (!$errs) { |
|
| 609 | - return [ancre_texte($texte, ['', '']), true]; |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - if (!isset($GLOBALS['debug_objets'])) { |
|
| 613 | - $colors = ['#e0e0f0', '#f8f8ff']; |
|
| 614 | - $encore = count_occ($errs); |
|
| 615 | - $encore2 = []; |
|
| 616 | - $fautifs = []; |
|
| 617 | - |
|
| 618 | - $err = '<tr><th>' |
|
| 619 | - . _T('numero') |
|
| 620 | - . '</th><th>' |
|
| 621 | - . _T('occurence') |
|
| 622 | - . '</th><th>' |
|
| 623 | - . _T('ligne') |
|
| 624 | - . '</th><th>' |
|
| 625 | - . _T('colonne') |
|
| 626 | - . '</th><th>' |
|
| 627 | - . _T('erreur') |
|
| 628 | - . '</th></tr>'; |
|
| 629 | - |
|
| 630 | - $i = 0; |
|
| 631 | - $style = "style='text-align: right; padding-right: 5px'"; |
|
| 632 | - foreach ($errs as $r) { |
|
| 633 | - $i++; |
|
| 634 | - [$msg, $ligne, $col] = $r; |
|
| 635 | - #spip_log("$r = list($msg, $ligne, $col"); |
|
| 636 | - if (isset($encore2[$msg])) { |
|
| 637 | - $ref = ++$encore2[$msg]; |
|
| 638 | - } else { |
|
| 639 | - $encore2[$msg] = $ref = 1; |
|
| 640 | - } |
|
| 641 | - $err .= "<tr style='background-color: " |
|
| 642 | - . $colors[$i % 2] |
|
| 643 | - . "'><td $style><a href='#debut_err'>" |
|
| 644 | - . $i |
|
| 645 | - . "</a></td><td $style>" |
|
| 646 | - . "$ref/$encore[$msg]</td>" |
|
| 647 | - . "<td $style><a href='#L" |
|
| 648 | - . $ligne |
|
| 649 | - . "' id='T$i'>" |
|
| 650 | - . $ligne |
|
| 651 | - . "</a></td><td $style>" |
|
| 652 | - . $col |
|
| 653 | - . "</td><td>$msg</td></tr>\n"; |
|
| 654 | - $fautifs[] = [$ligne, $col, $i, $msg]; |
|
| 655 | - } |
|
| 656 | - $err = "<h2 style='text-align: center'>" |
|
| 657 | - . $i |
|
| 658 | - . "<a href='#fin_err'>" |
|
| 659 | - . ' ' . _T('erreur_texte') |
|
| 660 | - . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 661 | - . $err |
|
| 662 | - . " </table><a id='fin_err'></a>"; |
|
| 663 | - |
|
| 664 | - return [ancre_texte($texte, $fautifs), $err]; |
|
| 665 | - } else { |
|
| 666 | - [$msg, $fermant, $ouvrant] = $errs[0]; |
|
| 667 | - $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 668 | - $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 669 | - $err = $msg . |
|
| 670 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 671 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 672 | - |
|
| 673 | - return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
|
| 674 | - } |
|
| 602 | + $errs = $res->err; |
|
| 603 | + $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 604 | + |
|
| 605 | + if (!$texte and !$errs) { |
|
| 606 | + return [ancre_texte('', ['', '']), false]; |
|
| 607 | + } |
|
| 608 | + if (!$errs) { |
|
| 609 | + return [ancre_texte($texte, ['', '']), true]; |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + if (!isset($GLOBALS['debug_objets'])) { |
|
| 613 | + $colors = ['#e0e0f0', '#f8f8ff']; |
|
| 614 | + $encore = count_occ($errs); |
|
| 615 | + $encore2 = []; |
|
| 616 | + $fautifs = []; |
|
| 617 | + |
|
| 618 | + $err = '<tr><th>' |
|
| 619 | + . _T('numero') |
|
| 620 | + . '</th><th>' |
|
| 621 | + . _T('occurence') |
|
| 622 | + . '</th><th>' |
|
| 623 | + . _T('ligne') |
|
| 624 | + . '</th><th>' |
|
| 625 | + . _T('colonne') |
|
| 626 | + . '</th><th>' |
|
| 627 | + . _T('erreur') |
|
| 628 | + . '</th></tr>'; |
|
| 629 | + |
|
| 630 | + $i = 0; |
|
| 631 | + $style = "style='text-align: right; padding-right: 5px'"; |
|
| 632 | + foreach ($errs as $r) { |
|
| 633 | + $i++; |
|
| 634 | + [$msg, $ligne, $col] = $r; |
|
| 635 | + #spip_log("$r = list($msg, $ligne, $col"); |
|
| 636 | + if (isset($encore2[$msg])) { |
|
| 637 | + $ref = ++$encore2[$msg]; |
|
| 638 | + } else { |
|
| 639 | + $encore2[$msg] = $ref = 1; |
|
| 640 | + } |
|
| 641 | + $err .= "<tr style='background-color: " |
|
| 642 | + . $colors[$i % 2] |
|
| 643 | + . "'><td $style><a href='#debut_err'>" |
|
| 644 | + . $i |
|
| 645 | + . "</a></td><td $style>" |
|
| 646 | + . "$ref/$encore[$msg]</td>" |
|
| 647 | + . "<td $style><a href='#L" |
|
| 648 | + . $ligne |
|
| 649 | + . "' id='T$i'>" |
|
| 650 | + . $ligne |
|
| 651 | + . "</a></td><td $style>" |
|
| 652 | + . $col |
|
| 653 | + . "</td><td>$msg</td></tr>\n"; |
|
| 654 | + $fautifs[] = [$ligne, $col, $i, $msg]; |
|
| 655 | + } |
|
| 656 | + $err = "<h2 style='text-align: center'>" |
|
| 657 | + . $i |
|
| 658 | + . "<a href='#fin_err'>" |
|
| 659 | + . ' ' . _T('erreur_texte') |
|
| 660 | + . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 661 | + . $err |
|
| 662 | + . " </table><a id='fin_err'></a>"; |
|
| 663 | + |
|
| 664 | + return [ancre_texte($texte, $fautifs), $err]; |
|
| 665 | + } else { |
|
| 666 | + [$msg, $fermant, $ouvrant] = $errs[0]; |
|
| 667 | + $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 668 | + $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 669 | + $err = $msg . |
|
| 670 | + "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 671 | + "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 672 | + |
|
| 673 | + return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
|
| 674 | + } |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | function count_occ($regs) { |
| 678 | - $encore = []; |
|
| 679 | - foreach ($regs as $r) { |
|
| 680 | - if (isset($encore[$r[0]])) { |
|
| 681 | - $encore[$r[0]]++; |
|
| 682 | - } else { |
|
| 683 | - $encore[$r[0]] = 1; |
|
| 684 | - } |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - return $encore; |
|
| 678 | + $encore = []; |
|
| 679 | + foreach ($regs as $r) { |
|
| 680 | + if (isset($encore[$r[0]])) { |
|
| 681 | + $encore[$r[0]]++; |
|
| 682 | + } else { |
|
| 683 | + $encore[$r[0]] = 1; |
|
| 684 | + } |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + return $encore; |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | function debusquer_navigation_squelettes($self) { |
| 691 | 691 | |
| 692 | - $res = ''; |
|
| 693 | - $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : ''; |
|
| 694 | - $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 695 | - $t_skel = _T('squelette'); |
|
| 696 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 697 | - $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 698 | - $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile); |
|
| 699 | - $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T( |
|
| 700 | - 'zbug_profile', |
|
| 701 | - ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
|
| 702 | - ); |
|
| 703 | - |
|
| 704 | - $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 705 | - . $t_skel |
|
| 706 | - . ' ' |
|
| 707 | - . $sourcefile |
|
| 708 | - . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 709 | - . $t_skel |
|
| 710 | - . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 711 | - . _T('zbug_resultat') |
|
| 712 | - . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 713 | - . _T('zbug_code') |
|
| 714 | - . "</a>\n<a href='" |
|
| 715 | - . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', $self) |
|
| 716 | - . "'>" |
|
| 717 | - . _T('zbug_calcul') |
|
| 718 | - . '</a></legend>' |
|
| 719 | - . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 720 | - . debusquer_contexte($contexte[$sourcefile]) |
|
| 721 | - . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
|
| 722 | - . "</fieldset>\n"; |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - return $res; |
|
| 692 | + $res = ''; |
|
| 693 | + $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : ''; |
|
| 694 | + $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 695 | + $t_skel = _T('squelette'); |
|
| 696 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 697 | + $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 698 | + $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile); |
|
| 699 | + $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T( |
|
| 700 | + 'zbug_profile', |
|
| 701 | + ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
|
| 702 | + ); |
|
| 703 | + |
|
| 704 | + $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 705 | + . $t_skel |
|
| 706 | + . ' ' |
|
| 707 | + . $sourcefile |
|
| 708 | + . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 709 | + . $t_skel |
|
| 710 | + . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 711 | + . _T('zbug_resultat') |
|
| 712 | + . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 713 | + . _T('zbug_code') |
|
| 714 | + . "</a>\n<a href='" |
|
| 715 | + . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', $self) |
|
| 716 | + . "'>" |
|
| 717 | + . _T('zbug_calcul') |
|
| 718 | + . '</a></legend>' |
|
| 719 | + . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 720 | + . debusquer_contexte($contexte[$sourcefile]) |
|
| 721 | + . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
|
| 722 | + . "</fieldset>\n"; |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + return $res; |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source) { |
| 729 | - $i = 0; |
|
| 730 | - $res = ''; |
|
| 731 | - $var_mode_objet = _request('var_mode_objet'); |
|
| 732 | - $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : ''; |
|
| 733 | - |
|
| 734 | - foreach ($boucles as $objet => $boucle) { |
|
| 735 | - if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) { |
|
| 736 | - $i++; |
|
| 737 | - $nom = $boucle->id_boucle; |
|
| 738 | - $req = $boucle->type_requete; |
|
| 739 | - $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 740 | - $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 741 | - |
|
| 742 | - $res .= "\n<tr style='background-color: " . |
|
| 743 | - ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 744 | - "'><td align='right'>$i</td><td>\n" . |
|
| 745 | - "<a class='debug_link_boucle' href='" . |
|
| 746 | - $self2 . |
|
| 747 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 748 | - _T('zbug_boucle') . |
|
| 749 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 750 | - $self2 . |
|
| 751 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 752 | - _T('zbug_resultat') . |
|
| 753 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 754 | - $self2 . |
|
| 755 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 756 | - _T('zbug_code') . |
|
| 757 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 758 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 759 | - "'>" . |
|
| 760 | - _T('zbug_calcul') . |
|
| 761 | - "</a></td><td>\n" . |
|
| 762 | - (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 763 | - "</td><td>\n" . |
|
| 764 | - $req . |
|
| 765 | - "</td><td>\n" . |
|
| 766 | - spip_htmlspecialchars($crit) . |
|
| 767 | - '</td></tr>'; |
|
| 768 | - } |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - return $res; |
|
| 729 | + $i = 0; |
|
| 730 | + $res = ''; |
|
| 731 | + $var_mode_objet = _request('var_mode_objet'); |
|
| 732 | + $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : ''; |
|
| 733 | + |
|
| 734 | + foreach ($boucles as $objet => $boucle) { |
|
| 735 | + if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) { |
|
| 736 | + $i++; |
|
| 737 | + $nom = $boucle->id_boucle; |
|
| 738 | + $req = $boucle->type_requete; |
|
| 739 | + $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 740 | + $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 741 | + |
|
| 742 | + $res .= "\n<tr style='background-color: " . |
|
| 743 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 744 | + "'><td align='right'>$i</td><td>\n" . |
|
| 745 | + "<a class='debug_link_boucle' href='" . |
|
| 746 | + $self2 . |
|
| 747 | + "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 748 | + _T('zbug_boucle') . |
|
| 749 | + "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 750 | + $self2 . |
|
| 751 | + "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 752 | + _T('zbug_resultat') . |
|
| 753 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 754 | + $self2 . |
|
| 755 | + "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 756 | + _T('zbug_code') . |
|
| 757 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 758 | + str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 759 | + "'>" . |
|
| 760 | + _T('zbug_calcul') . |
|
| 761 | + "</a></td><td>\n" . |
|
| 762 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 763 | + "</td><td>\n" . |
|
| 764 | + $req . |
|
| 765 | + "</td><td>\n" . |
|
| 766 | + spip_htmlspecialchars($crit) . |
|
| 767 | + '</td></tr>'; |
|
| 768 | + } |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + return $res; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | function debusquer_source($objet, $affiche) { |
| 775 | - $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 776 | - if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 777 | - $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 778 | - } else { |
|
| 779 | - $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 780 | - } |
|
| 781 | - $res2 = ''; |
|
| 782 | - |
|
| 783 | - if ($affiche == 'resultat') { |
|
| 784 | - $legend = $nom; |
|
| 785 | - $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 786 | - if (function_exists('_mysql_traite_query')) { |
|
| 787 | - $c = strtolower(_request('connect') ?? ''); |
|
| 788 | - $c = $GLOBALS['connexions'][$c ?: 0]['prefixe']; |
|
| 789 | - $req = _mysql_traite_query($req, '', $c); |
|
| 790 | - } |
|
| 791 | - // permettre le copier/coller facile |
|
| 792 | - // $res = ancre_texte($req, array(), true); |
|
| 793 | - $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 794 | - // formatage et affichage des resultats bruts de la requete |
|
| 795 | - $ress_req = spip_query($req); |
|
| 796 | - $brut_sql = ''; |
|
| 797 | - $num = 1; |
|
| 798 | - // eviter l'affichage de milliers de lignes |
|
| 799 | - // personnalisation possible dans mes_options |
|
| 800 | - $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 801 | - while ($retours_sql = sql_fetch($ress_req)) { |
|
| 802 | - if ($num <= $max_aff) { |
|
| 803 | - $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 804 | - $brut_sql .= '<p>'; |
|
| 805 | - foreach ($retours_sql as $key => $val) { |
|
| 806 | - $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 807 | - } |
|
| 808 | - $brut_sql .= '</p>'; |
|
| 809 | - } |
|
| 810 | - $num++; |
|
| 811 | - } |
|
| 812 | - $res2 = interdire_scripts($brut_sql); |
|
| 813 | - foreach ($quoi as $view) { |
|
| 814 | - // ne pas afficher les $contexte_inclus |
|
| 815 | - $view = preg_replace(',<\?php.+\?[>],Uims', '', $view); |
|
| 816 | - if ($view) { |
|
| 817 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 818 | - } |
|
| 819 | - } |
|
| 820 | - } elseif ($affiche == 'code') { |
|
| 821 | - $legend = $nom; |
|
| 822 | - $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 823 | - } elseif ($affiche == 'boucle') { |
|
| 824 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 825 | - // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 826 | - $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
|
| 827 | - $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 828 | - } elseif ($affiche == 'squelette') { |
|
| 829 | - $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 830 | - $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 831 | - } |
|
| 832 | - |
|
| 833 | - return [$legend, $res, $res2]; |
|
| 775 | + $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 776 | + if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 777 | + $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 778 | + } else { |
|
| 779 | + $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 780 | + } |
|
| 781 | + $res2 = ''; |
|
| 782 | + |
|
| 783 | + if ($affiche == 'resultat') { |
|
| 784 | + $legend = $nom; |
|
| 785 | + $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 786 | + if (function_exists('_mysql_traite_query')) { |
|
| 787 | + $c = strtolower(_request('connect') ?? ''); |
|
| 788 | + $c = $GLOBALS['connexions'][$c ?: 0]['prefixe']; |
|
| 789 | + $req = _mysql_traite_query($req, '', $c); |
|
| 790 | + } |
|
| 791 | + // permettre le copier/coller facile |
|
| 792 | + // $res = ancre_texte($req, array(), true); |
|
| 793 | + $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 794 | + // formatage et affichage des resultats bruts de la requete |
|
| 795 | + $ress_req = spip_query($req); |
|
| 796 | + $brut_sql = ''; |
|
| 797 | + $num = 1; |
|
| 798 | + // eviter l'affichage de milliers de lignes |
|
| 799 | + // personnalisation possible dans mes_options |
|
| 800 | + $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 801 | + while ($retours_sql = sql_fetch($ress_req)) { |
|
| 802 | + if ($num <= $max_aff) { |
|
| 803 | + $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 804 | + $brut_sql .= '<p>'; |
|
| 805 | + foreach ($retours_sql as $key => $val) { |
|
| 806 | + $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 807 | + } |
|
| 808 | + $brut_sql .= '</p>'; |
|
| 809 | + } |
|
| 810 | + $num++; |
|
| 811 | + } |
|
| 812 | + $res2 = interdire_scripts($brut_sql); |
|
| 813 | + foreach ($quoi as $view) { |
|
| 814 | + // ne pas afficher les $contexte_inclus |
|
| 815 | + $view = preg_replace(',<\?php.+\?[>],Uims', '', $view); |
|
| 816 | + if ($view) { |
|
| 817 | + $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 818 | + } |
|
| 819 | + } |
|
| 820 | + } elseif ($affiche == 'code') { |
|
| 821 | + $legend = $nom; |
|
| 822 | + $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 823 | + } elseif ($affiche == 'boucle') { |
|
| 824 | + $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 825 | + // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 826 | + $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
|
| 827 | + $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 828 | + } elseif ($affiche == 'squelette') { |
|
| 829 | + $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 830 | + $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + return [$legend, $res, $res2]; |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | function debusquer_entete($titre, $corps) { |
| 837 | 837 | |
| 838 | - include_spip('balise/formulaire_admin'); |
|
| 839 | - include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 840 | - include_spip('inc/texte'); // pour corriger_typo |
|
| 841 | - |
|
| 842 | - return _DOCTYPE_ECRIRE . |
|
| 843 | - html_lang_attributes() . |
|
| 844 | - "<head>\n<title>" . |
|
| 845 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 846 | - _T('admin_debug') . ' ' . spip_htmlspecialchars($titre) . ' (' . |
|
| 847 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 848 | - ")</title>\n" . |
|
| 849 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 850 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 851 | - "' />\n" . |
|
| 852 | - http_script('', 'jquery.js') |
|
| 853 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 854 | - . "' type='text/css' />" . |
|
| 855 | - "</head>\n" . |
|
| 856 | - "<body style='margin:0 10px;'>\n" . |
|
| 857 | - "<div id='spip-debug-header'>" . |
|
| 858 | - $corps . |
|
| 859 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 860 | - '</div></body></html>'; |
|
| 838 | + include_spip('balise/formulaire_admin'); |
|
| 839 | + include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 840 | + include_spip('inc/texte'); // pour corriger_typo |
|
| 841 | + |
|
| 842 | + return _DOCTYPE_ECRIRE . |
|
| 843 | + html_lang_attributes() . |
|
| 844 | + "<head>\n<title>" . |
|
| 845 | + ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 846 | + _T('admin_debug') . ' ' . spip_htmlspecialchars($titre) . ' (' . |
|
| 847 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 848 | + ")</title>\n" . |
|
| 849 | + "<meta http-equiv='Content-Type' content='text/html" . |
|
| 850 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 851 | + "' />\n" . |
|
| 852 | + http_script('', 'jquery.js') |
|
| 853 | + . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 854 | + . "' type='text/css' />" . |
|
| 855 | + "</head>\n" . |
|
| 856 | + "<body style='margin:0 10px;'>\n" . |
|
| 857 | + "<div id='spip-debug-header'>" . |
|
| 858 | + $corps . |
|
| 859 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 860 | + '</div></body></html>'; |
|
| 861 | 861 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | if (!$fonc) { |
| 148 | 148 | $fonc = $GLOBALS['debug_objets']['principal']; |
| 149 | 149 | } |
| 150 | - $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 150 | + $titre = !$mode ? $fonc : ($mode.(isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' '.$GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 151 | 151 | } |
| 152 | 152 | if ($message === false) { |
| 153 | 153 | lang_select(); |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | $fond = $GLOBALS['fond'] ?? ''; |
| 177 | 177 | // une erreur critique sort $message en array |
| 178 | 178 | $debug = is_array($msg) ? $msg[1] : $msg; |
| 179 | - spip_log('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 179 | + spip_log('Debug: '.$debug.' ('.$fond.')'); |
|
| 180 | 180 | |
| 181 | 181 | return $msg; |
| 182 | 182 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | function debusquer_bandeau($erreurs) { |
| 185 | 185 | |
| 186 | 186 | if (!empty($erreurs)) { |
| 187 | - $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 187 | + $n = [(is_countable($erreurs) ? count($erreurs) : 0).' '._T('zbug_erreur_squelette')]; |
|
| 188 | 188 | |
| 189 | 189 | return debusquer_navigation($erreurs, $n); |
| 190 | 190 | } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
@@ -217,25 +217,25 @@ discard block |
||
| 217 | 217 | $valeur_simple = []; |
| 218 | 218 | foreach ($valeur as $v) { |
| 219 | 219 | if (is_array($v)) { |
| 220 | - $valeur_simple[] = 'array:' . count($v); |
|
| 220 | + $valeur_simple[] = 'array:'.count($v); |
|
| 221 | 221 | } elseif (is_object($v)) { |
| 222 | 222 | $valeur_simple[] = get_class($v); |
| 223 | 223 | } elseif (is_string($v)) { |
| 224 | - $valeur_simple[] = "'" . $v . "'"; |
|
| 224 | + $valeur_simple[] = "'".$v."'"; |
|
| 225 | 225 | } else { |
| 226 | 226 | $valeur_simple[] = $v; |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | $n = count($valeur); |
| 230 | - $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 231 | - $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 230 | + $valeur = (($n > 3) ? 'array:'.$n.' ' : ''); |
|
| 231 | + $valeur .= '['.join(', ', $valeur_simple).']'; |
|
| 232 | 232 | } elseif (is_object($valeur)) { |
| 233 | 233 | $valeur = get_class($valeur); |
| 234 | 234 | } elseif (is_string($valeur)) { |
| 235 | - $valeur = "'" . $valeur . "'"; |
|
| 235 | + $valeur = "'".$valeur."'"; |
|
| 236 | 236 | } |
| 237 | - $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 238 | - . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 237 | + $res .= "\n<tr><td><strong>".nl2br((string) entites_html($nom)) |
|
| 238 | + . '</strong></td><td>: '.nl2br((string) entites_html($valeur)) |
|
| 239 | 239 | . "</td></tr>\n"; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | if ($ligne) { |
| 261 | 261 | $msg .= " L$ligne"; |
| 262 | 262 | } |
| 263 | - spip_log($msg, "debusquer" . _LOG_ERREUR); |
|
| 263 | + spip_log($msg, "debusquer"._LOG_ERREUR); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | $nom_code = $lieu->descr['nom']; |
| 286 | 286 | $skel = $lieu->descr['sourcefile']; |
| 287 | 287 | $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
| 288 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 288 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette').'#L'.$ligne; |
|
| 289 | 289 | $skel = "<a href='$h3'><b>$skel</b></a>"; |
| 290 | 290 | if ($boucle) { |
| 291 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 291 | + $h3 = parametre_url($h2.$boucle, 'var_mode_affiche', 'boucle'); |
|
| 292 | 292 | $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
| 293 | 293 | } |
| 294 | 294 | } |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Requete erronee |
| 380 | - $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 380 | + $err = '<b>'._T('avis_erreur_mysql')." $errno</b><br /><tt>\n" |
|
| 381 | 381 | . spip_htmlspecialchars($msg) |
| 382 | 382 | . "\n<br /><span style='color: red'><b>" |
| 383 | 383 | . spip_htmlspecialchars($query) |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = '') { |
| 393 | 393 | |
| 394 | - $id = $nom . $boucle; |
|
| 394 | + $id = $nom.$boucle; |
|
| 395 | 395 | if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
| 396 | 396 | foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
| 397 | 397 | if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 440 | + $incl = ','.$reg[1].'[.]\w$,'; |
|
| 441 | 441 | |
| 442 | 442 | foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
| 443 | 443 | if (preg_match($incl, $v)) { |
@@ -452,16 +452,13 @@ discard block |
||
| 452 | 452 | [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
| 453 | 453 | |
| 454 | 454 | if (!$boucle) { |
| 455 | - return !$ligne ? '' : |
|
| 456 | - (' (' . |
|
| 457 | - (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 458 | - _T('squelette_ligne')) . |
|
| 455 | + return !$ligne ? '' : (' ('. |
|
| 456 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : _T('squelette_ligne')). |
|
| 459 | 457 | " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
| 460 | 458 | } else { |
| 461 | 459 | $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
| 462 | 460 | |
| 463 | - return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 464 | - " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 461 | + return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 465 | 462 | } |
| 466 | 463 | } |
| 467 | 464 | |
@@ -483,14 +480,14 @@ discard block |
||
| 483 | 480 | |
| 484 | 481 | $s = preg_replace( |
| 485 | 482 | ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
| 486 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 483 | + '<\1>\2</\1><br />'."\n".'<\1>\3</\1>', |
|
| 487 | 484 | $s |
| 488 | 485 | ); |
| 489 | 486 | |
| 490 | 487 | |
| 491 | 488 | $tableau = explode('<br />', $s); |
| 492 | 489 | |
| 493 | - $format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: " . ($nocpt ? 'hidden' : 'visible') . ";%s' href='#T%s' title=\"%s\">%0" . strval(@strlen(count($tableau))) . "d</a></span> %s<br />\n"; |
|
| 490 | + $format = "<span style='float:left;display:block;width:50px;height:1px'><a id='L%d' style='background-color: white; visibility: ".($nocpt ? 'hidden' : 'visible').";%s' href='#T%s' title=\"%s\">%0".strval(@strlen(count($tableau)))."d</a></span> %s<br />\n"; |
|
| 494 | 491 | |
| 495 | 492 | $format10 = str_replace('white', 'lightgrey', $format); |
| 496 | 493 | $formaterr = 'color: red;'; |
@@ -534,7 +531,7 @@ discard block |
||
| 534 | 531 | . '" style="cursor: pointer;">' |
| 535 | 532 | . ($nocpt ? '' : _T('info_numero_abbreviation')) |
| 536 | 533 | . '</div> |
| 537 | - ' . $res . "</div>\n"; |
|
| 534 | + ' . $res."</div>\n"; |
|
| 538 | 535 | } |
| 539 | 536 | |
| 540 | 537 | // l'environnement graphique du debuggueur |
@@ -556,14 +553,14 @@ discard block |
||
| 556 | 553 | if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
| 557 | 554 | [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
| 558 | 555 | $texte .= $res2; |
| 559 | - } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 560 | - $legend = _T('zbug_' . $mode); |
|
| 561 | - $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 556 | + } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc.'tout'])) { |
|
| 557 | + $legend = _T('zbug_'.$mode); |
|
| 558 | + $texte = $GLOBALS['debug_objets'][$mode][$fonc.'tout']; |
|
| 562 | 559 | $texte = ancre_texte($texte, ['', '']); |
| 563 | 560 | } |
| 564 | 561 | } else { |
| 565 | 562 | if (strlen(trim($res))) { |
| 566 | - return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 563 | + return "<img src='".chemin_image('debug-xx.svg')."' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 567 | 564 | } else { |
| 568 | 565 | // cas de l'appel sur erreur: montre la page |
| 569 | 566 | return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
@@ -571,7 +568,7 @@ discard block |
||
| 571 | 568 | } |
| 572 | 569 | } else { |
| 573 | 570 | $valider = charger_fonction('valider', 'xml'); |
| 574 | - $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 571 | + $val = $valider($GLOBALS['debug_objets']['validation'][$fonc.'tout']); |
|
| 575 | 572 | // Si erreur, signaler leur nombre dans le formulaire admin |
| 576 | 573 | $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
| 577 | 574 | [$texte, $err] = emboite_texte($val, $fonc, $self); |
@@ -582,14 +579,14 @@ discard block |
||
| 582 | 579 | } else { |
| 583 | 580 | $err = ": $err"; |
| 584 | 581 | } |
| 585 | - $legend = _T('validation') . ' ' . $err; |
|
| 582 | + $legend = _T('validation').' '.$err; |
|
| 586 | 583 | $res = $id = ''; |
| 587 | 584 | } |
| 588 | 585 | |
| 589 | 586 | return !trim($texte) ? '' : ( |
| 590 | - "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 587 | + "<img src='".chemin_image('debug-xx.svg')."' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 591 | 588 | . "<div id='debug_boucle'><fieldset$id><legend>" |
| 592 | - . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> ↑ " |
|
| 589 | + . "<a href='".$self.'#f_'.substr($fonc, 0, 37)."'> ↑ " |
|
| 593 | 590 | . ($legend ?: $mode) |
| 594 | 591 | . '</a></legend>' |
| 595 | 592 | . $texte |
@@ -600,7 +597,7 @@ discard block |
||
| 600 | 597 | |
| 601 | 598 | function emboite_texte($res, $fonc = '', $self = '') { |
| 602 | 599 | $errs = $res->err; |
| 603 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 600 | + $texte = $res->entete.($errs ? '' : $res->page); |
|
| 604 | 601 | |
| 605 | 602 | if (!$texte and !$errs) { |
| 606 | 603 | return [ancre_texte('', ['', '']), false]; |
@@ -656,7 +653,7 @@ discard block |
||
| 656 | 653 | $err = "<h2 style='text-align: center'>" |
| 657 | 654 | . $i |
| 658 | 655 | . "<a href='#fin_err'>" |
| 659 | - . ' ' . _T('erreur_texte') |
|
| 656 | + . ' '._T('erreur_texte') |
|
| 660 | 657 | . "</a></h2><table id='debut_err' style='width: 100%'>" |
| 661 | 658 | . $err |
| 662 | 659 | . " </table><a id='fin_err'></a>"; |
@@ -666,9 +663,9 @@ discard block |
||
| 666 | 663 | [$msg, $fermant, $ouvrant] = $errs[0]; |
| 667 | 664 | $rf = reference_boucle_debug($fermant, $fonc, $self); |
| 668 | 665 | $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
| 669 | - $err = $msg . |
|
| 670 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 671 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 666 | + $err = $msg. |
|
| 667 | + "<a href='#L".$fermant."'>$fermant</a>$rf<br />". |
|
| 668 | + "<a href='#L".$ouvrant."'>$ouvrant</a>$ro"; |
|
| 672 | 669 | |
| 673 | 670 | return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
| 674 | 671 | } |
@@ -701,7 +698,7 @@ discard block |
||
| 701 | 698 | ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
| 702 | 699 | ); |
| 703 | 700 | |
| 704 | - $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 701 | + $res .= "<fieldset id='f_".$nom."'><legend>" |
|
| 705 | 702 | . $t_skel |
| 706 | 703 | . ' ' |
| 707 | 704 | . $sourcefile |
@@ -716,7 +713,7 @@ discard block |
||
| 716 | 713 | . "'>" |
| 717 | 714 | . _T('zbug_calcul') |
| 718 | 715 | . '</a></legend>' |
| 719 | - . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 716 | + . (!$temps ? '' : ("\n<span style='display:block;float:".$GLOBALS['spip_lang_right']."'>$temps</span><br />")) |
|
| 720 | 717 | . debusquer_contexte($contexte[$sourcefile]) |
| 721 | 718 | . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
| 722 | 719 | . "</fieldset>\n"; |
@@ -737,33 +734,33 @@ discard block |
||
| 737 | 734 | $nom = $boucle->id_boucle; |
| 738 | 735 | $req = $boucle->type_requete; |
| 739 | 736 | $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
| 740 | - $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 741 | - |
|
| 742 | - $res .= "\n<tr style='background-color: " . |
|
| 743 | - ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 744 | - "'><td align='right'>$i</td><td>\n" . |
|
| 745 | - "<a class='debug_link_boucle' href='" . |
|
| 746 | - $self2 . |
|
| 747 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 748 | - _T('zbug_boucle') . |
|
| 749 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 750 | - $self2 . |
|
| 751 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 752 | - _T('zbug_resultat') . |
|
| 753 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 754 | - $self2 . |
|
| 755 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 756 | - _T('zbug_code') . |
|
| 757 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 758 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 759 | - "'>" . |
|
| 760 | - _T('zbug_calcul') . |
|
| 761 | - "</a></td><td>\n" . |
|
| 762 | - (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 763 | - "</td><td>\n" . |
|
| 764 | - $req . |
|
| 765 | - "</td><td>\n" . |
|
| 766 | - spip_htmlspecialchars($crit) . |
|
| 737 | + $self2 = $self.'&var_mode_objet='.$objet; |
|
| 738 | + |
|
| 739 | + $res .= "\n<tr style='background-color: ". |
|
| 740 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff'). |
|
| 741 | + "'><td align='right'>$i</td><td>\n". |
|
| 742 | + "<a class='debug_link_boucle' href='". |
|
| 743 | + $self2. |
|
| 744 | + "&var_mode_affiche=boucle#f_$nom_skel'>". |
|
| 745 | + _T('zbug_boucle'). |
|
| 746 | + "</a></td><td>\n<a class='debug_link_boucle' href='". |
|
| 747 | + $self2. |
|
| 748 | + "&var_mode_affiche=resultat#f_$nom_skel'>". |
|
| 749 | + _T('zbug_resultat'). |
|
| 750 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 751 | + $self2. |
|
| 752 | + "&var_mode_affiche=code#f_$nom_skel'>". |
|
| 753 | + _T('zbug_code'). |
|
| 754 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 755 | + str_replace('var_mode=', 'var_profile=', $self2). |
|
| 756 | + "'>". |
|
| 757 | + _T('zbug_calcul'). |
|
| 758 | + "</a></td><td>\n". |
|
| 759 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom). |
|
| 760 | + "</td><td>\n". |
|
| 761 | + $req. |
|
| 762 | + "</td><td>\n". |
|
| 763 | + spip_htmlspecialchars($crit). |
|
| 767 | 764 | '</td></tr>'; |
| 768 | 765 | } |
| 769 | 766 | } |
@@ -790,7 +787,7 @@ discard block |
||
| 790 | 787 | } |
| 791 | 788 | // permettre le copier/coller facile |
| 792 | 789 | // $res = ancre_texte($req, array(), true); |
| 793 | - $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 790 | + $res = "<div id='T".md5($req)."'>\n<pre>\n".$req."</pre>\n</div>\n"; |
|
| 794 | 791 | // formatage et affichage des resultats bruts de la requete |
| 795 | 792 | $ress_req = spip_query($req); |
| 796 | 793 | $brut_sql = ''; |
@@ -800,10 +797,10 @@ discard block |
||
| 800 | 797 | $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
| 801 | 798 | while ($retours_sql = sql_fetch($ress_req)) { |
| 802 | 799 | if ($num <= $max_aff) { |
| 803 | - $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 800 | + $brut_sql .= '<h3>'.($num == 1 ? $num.' sur '.sql_count($ress_req) : $num).'</h3>'; |
|
| 804 | 801 | $brut_sql .= '<p>'; |
| 805 | 802 | foreach ($retours_sql as $key => $val) { |
| 806 | - $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 803 | + $brut_sql .= '<strong>'.$key.'</strong> => '.spip_htmlspecialchars(couper($val, 150))."<br />\n"; |
|
| 807 | 804 | } |
| 808 | 805 | $brut_sql .= '</p>'; |
| 809 | 806 | } |
@@ -814,14 +811,14 @@ discard block |
||
| 814 | 811 | // ne pas afficher les $contexte_inclus |
| 815 | 812 | $view = preg_replace(',<\?php.+\?[>],Uims', '', $view); |
| 816 | 813 | if ($view) { |
| 817 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 814 | + $res2 .= "\n<br /><fieldset>".interdire_scripts($view).'</fieldset>'; |
|
| 818 | 815 | } |
| 819 | 816 | } |
| 820 | 817 | } elseif ($affiche == 'code') { |
| 821 | 818 | $legend = $nom; |
| 822 | - $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 819 | + $res = ancre_texte('<'."?php\n".$quoi."\n?".'>'); |
|
| 823 | 820 | } elseif ($affiche == 'boucle') { |
| 824 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 821 | + $legend = _T('zbug_boucle').' '.$nom; |
|
| 825 | 822 | // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
| 826 | 823 | $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
| 827 | 824 | $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
@@ -839,23 +836,23 @@ discard block |
||
| 839 | 836 | include_spip('public/assembler'); // pour inclure_balise_dynamique |
| 840 | 837 | include_spip('inc/texte'); // pour corriger_typo |
| 841 | 838 | |
| 842 | - return _DOCTYPE_ECRIRE . |
|
| 843 | - html_lang_attributes() . |
|
| 844 | - "<head>\n<title>" . |
|
| 845 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 846 | - _T('admin_debug') . ' ' . spip_htmlspecialchars($titre) . ' (' . |
|
| 847 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 848 | - ")</title>\n" . |
|
| 849 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 850 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 851 | - "' />\n" . |
|
| 839 | + return _DOCTYPE_ECRIRE. |
|
| 840 | + html_lang_attributes(). |
|
| 841 | + "<head>\n<title>". |
|
| 842 | + ('SPIP '.$GLOBALS['spip_version_affichee'].' '. |
|
| 843 | + _T('admin_debug').' '.spip_htmlspecialchars($titre).' ('. |
|
| 844 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))). |
|
| 845 | + ")</title>\n". |
|
| 846 | + "<meta http-equiv='Content-Type' content='text/html". |
|
| 847 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : ''). |
|
| 848 | + "' />\n". |
|
| 852 | 849 | http_script('', 'jquery.js') |
| 853 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 854 | - . "' type='text/css' />" . |
|
| 855 | - "</head>\n" . |
|
| 856 | - "<body style='margin:0 10px;'>\n" . |
|
| 857 | - "<div id='spip-debug-header'>" . |
|
| 858 | - $corps . |
|
| 859 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 850 | + . "<link rel='stylesheet' href='".url_absolue(find_in_path('spip_admin.css')) |
|
| 851 | + . "' type='text/css' />". |
|
| 852 | + "</head>\n". |
|
| 853 | + "<body style='margin:0 10px;'>\n". |
|
| 854 | + "<div id='spip-debug-header'>". |
|
| 855 | + $corps. |
|
| 856 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false). |
|
| 860 | 857 | '</div></body></html>'; |
| 861 | 858 | } |