@@ -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'); |
@@ -66,135 +66,135 @@ discard block |
||
| 66 | 66 | * - string si $message à false. |
| 67 | 67 | **/ |
| 68 | 68 | function public_debusquer_dist($message = '', $lieu = '', $opt = array()) { |
| 69 | - static $tableau_des_erreurs = array(); |
|
| 70 | - |
|
| 71 | - // Pour des tests unitaires, pouvoir récupérer les erreurs générées |
|
| 72 | - if (isset($opt['erreurs'])) { |
|
| 73 | - if ($opt['erreurs'] == 'get') { |
|
| 74 | - return $tableau_des_erreurs; |
|
| 75 | - } |
|
| 76 | - if ($opt['erreurs'] == 'reset') { |
|
| 77 | - $tableau_des_erreurs = array(); |
|
| 78 | - |
|
| 79 | - return true; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - // Erreur ou appel final ? |
|
| 84 | - if ($message) { |
|
| 85 | - $message = debusquer_compose_message($message); |
|
| 86 | - $tableau_des_erreurs[] = array($message, $lieu); |
|
| 87 | - set_request('var_mode', 'debug'); |
|
| 88 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 89 | - // Permettre a la compil de continuer |
|
| 90 | - if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) { |
|
| 91 | - $lieu->code = "''"; |
|
| 92 | - } |
|
| 93 | - // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 94 | - $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and count($tableau_des_erreurs) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 95 | - if (!$urgence) { |
|
| 96 | - return; |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - if (empty($GLOBALS['debug_objets']['principal'])) { |
|
| 100 | - // espace public ? |
|
| 101 | - if (isset($GLOBALS['fond'])) { |
|
| 102 | - $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - include_spip('inc/autoriser'); |
|
| 107 | - if (!autoriser('debug')) { |
|
| 108 | - return; |
|
| 109 | - } |
|
| 110 | - include_spip('inc/headers'); |
|
| 111 | - include_spip('inc/filtres'); |
|
| 112 | - |
|
| 113 | - // en cas de squelette inclus, virer le code de l'incluant: |
|
| 114 | - // - il contient souvent une Div restreignant la largeur a 3 fois rien |
|
| 115 | - // - ca fait 2 headers ! |
|
| 116 | - // sauf si l'on se trouve deja dans un flux compresse (plugin compresseur |
|
| 117 | - // actif par exemple) |
|
| 118 | - if (ob_get_length() |
|
| 119 | - and |
|
| 120 | - !in_array('ob_gzhandler', ob_get_status()) |
|
| 121 | - ) { |
|
| 122 | - ob_end_clean(); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 126 | - $fonc = _request('var_mode_objet'); |
|
| 127 | - $mode = _request('var_mode_affiche'); |
|
| 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_status(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; |
|
| 69 | + static $tableau_des_erreurs = array(); |
|
| 70 | + |
|
| 71 | + // Pour des tests unitaires, pouvoir récupérer les erreurs générées |
|
| 72 | + if (isset($opt['erreurs'])) { |
|
| 73 | + if ($opt['erreurs'] == 'get') { |
|
| 74 | + return $tableau_des_erreurs; |
|
| 75 | + } |
|
| 76 | + if ($opt['erreurs'] == 'reset') { |
|
| 77 | + $tableau_des_erreurs = array(); |
|
| 78 | + |
|
| 79 | + return true; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + // Erreur ou appel final ? |
|
| 84 | + if ($message) { |
|
| 85 | + $message = debusquer_compose_message($message); |
|
| 86 | + $tableau_des_erreurs[] = array($message, $lieu); |
|
| 87 | + set_request('var_mode', 'debug'); |
|
| 88 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 89 | + // Permettre a la compil de continuer |
|
| 90 | + if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) { |
|
| 91 | + $lieu->code = "''"; |
|
| 92 | + } |
|
| 93 | + // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 94 | + $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and count($tableau_des_erreurs) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 95 | + if (!$urgence) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + if (empty($GLOBALS['debug_objets']['principal'])) { |
|
| 100 | + // espace public ? |
|
| 101 | + if (isset($GLOBALS['fond'])) { |
|
| 102 | + $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + include_spip('inc/autoriser'); |
|
| 107 | + if (!autoriser('debug')) { |
|
| 108 | + return; |
|
| 109 | + } |
|
| 110 | + include_spip('inc/headers'); |
|
| 111 | + include_spip('inc/filtres'); |
|
| 112 | + |
|
| 113 | + // en cas de squelette inclus, virer le code de l'incluant: |
|
| 114 | + // - il contient souvent une Div restreignant la largeur a 3 fois rien |
|
| 115 | + // - ca fait 2 headers ! |
|
| 116 | + // sauf si l'on se trouve deja dans un flux compresse (plugin compresseur |
|
| 117 | + // actif par exemple) |
|
| 118 | + if (ob_get_length() |
|
| 119 | + and |
|
| 120 | + !in_array('ob_gzhandler', ob_get_status()) |
|
| 121 | + ) { |
|
| 122 | + ob_end_clean(); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 126 | + $fonc = _request('var_mode_objet'); |
|
| 127 | + $mode = _request('var_mode_affiche'); |
|
| 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_status(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 = isset($GLOBALS['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 = isset($GLOBALS['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 = array(count($erreurs) . ' ' . _T('zbug_erreur_squelette')); |
|
| 186 | + if (!empty($erreurs)) { |
|
| 187 | + $n = array(count($erreurs) . ' ' . _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 | - list($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 | + list($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 | /** |
@@ -205,42 +205,42 @@ discard block |
||
| 205 | 205 | **/ |
| 206 | 206 | function debusquer_contexte($env) { |
| 207 | 207 | |
| 208 | - if (is_array($env_tab = @unserialize($env))) { |
|
| 209 | - $env = $env_tab; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - if (!$env) { |
|
| 213 | - return ''; |
|
| 214 | - } |
|
| 215 | - $res = ""; |
|
| 216 | - foreach ($env as $nom => $valeur) { |
|
| 217 | - if (is_array($valeur)) { |
|
| 218 | - $valeur_simple = array(); |
|
| 219 | - foreach ($valeur as $v) { |
|
| 220 | - if (is_array($v)) { |
|
| 221 | - $valeur_simple[] = 'array:' . count($v); |
|
| 222 | - } elseif (is_object($v)) { |
|
| 223 | - $valeur_simple[] = get_class($v); |
|
| 224 | - } elseif (is_string($v)) { |
|
| 225 | - $valeur_simple[] = "'" . $v . "'"; |
|
| 226 | - } else { |
|
| 227 | - $valeur_simple[] = $v; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - $n = count($valeur); |
|
| 231 | - $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 232 | - $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 233 | - } elseif (is_object($valeur)) { |
|
| 234 | - $valeur = get_class($valeur); |
|
| 235 | - } elseif (is_string($valeur)) { |
|
| 236 | - $valeur = "'" . $valeur . "'"; |
|
| 237 | - } |
|
| 238 | - $res .= "\n<tr><td><strong>" . nl2br(entites_html($nom)) |
|
| 239 | - . "</strong></td><td>: " . nl2br(entites_html($valeur)) |
|
| 240 | - . "</td></tr>\n"; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - return "<div class='spip-env'><fieldset><legend>#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 208 | + if (is_array($env_tab = @unserialize($env))) { |
|
| 209 | + $env = $env_tab; |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + if (!$env) { |
|
| 213 | + return ''; |
|
| 214 | + } |
|
| 215 | + $res = ""; |
|
| 216 | + foreach ($env as $nom => $valeur) { |
|
| 217 | + if (is_array($valeur)) { |
|
| 218 | + $valeur_simple = array(); |
|
| 219 | + foreach ($valeur as $v) { |
|
| 220 | + if (is_array($v)) { |
|
| 221 | + $valeur_simple[] = 'array:' . count($v); |
|
| 222 | + } elseif (is_object($v)) { |
|
| 223 | + $valeur_simple[] = get_class($v); |
|
| 224 | + } elseif (is_string($v)) { |
|
| 225 | + $valeur_simple[] = "'" . $v . "'"; |
|
| 226 | + } else { |
|
| 227 | + $valeur_simple[] = $v; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + $n = count($valeur); |
|
| 231 | + $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 232 | + $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 233 | + } elseif (is_object($valeur)) { |
|
| 234 | + $valeur = get_class($valeur); |
|
| 235 | + } elseif (is_string($valeur)) { |
|
| 236 | + $valeur = "'" . $valeur . "'"; |
|
| 237 | + } |
|
| 238 | + $res .= "\n<tr><td><strong>" . nl2br(entites_html($nom)) |
|
| 239 | + . "</strong></td><td>: " . nl2br(entites_html($valeur)) |
|
| 240 | + . "</td></tr>\n"; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + return "<div class='spip-env'><fieldset><legend>#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | // Affichage du tableau des erreurs ou des temps de calcul |
@@ -248,67 +248,67 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | function debusquer_navigation($tableau, $caption = array(), $id = 'debug-nav') { |
| 250 | 250 | |
| 251 | - if (_request('exec') == 'valider_xml') { |
|
| 252 | - return ''; |
|
| 253 | - } |
|
| 254 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 255 | - $res = ''; |
|
| 256 | - $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 257 | - foreach ($tableau as $i => $err) { |
|
| 258 | - $boucle = $ligne = $skel = ''; |
|
| 259 | - list($msg, $lieu) = $err; |
|
| 260 | - if (is_object($lieu)) { |
|
| 261 | - $ligne = $lieu->ligne; |
|
| 262 | - $boucle = $lieu->id_boucle ? $lieu->id_boucle : ''; |
|
| 263 | - if (isset($lieu->descr['nom'])) { |
|
| 264 | - $nom_code = $lieu->descr['nom']; |
|
| 265 | - $skel = $lieu->descr['sourcefile']; |
|
| 266 | - $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 267 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 268 | - $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 269 | - if ($boucle) { |
|
| 270 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 271 | - $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - $j = ($i + 1); |
|
| 277 | - $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 278 | - . $j |
|
| 279 | - . " </td><td style='text-align: left'>" |
|
| 280 | - . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 281 | - . "</td><td style='text-align: left'>" |
|
| 282 | - . ($skel ? $skel : " / ") |
|
| 283 | - . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 284 | - . ($boucle ? $boucle : " / ") |
|
| 285 | - . "</td><td style='text-align: right'>" |
|
| 286 | - . $ligne |
|
| 287 | - . "</td></tr>\n"; |
|
| 288 | - |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return "\n<table id='$id'>" |
|
| 292 | - . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 293 | - . $caption[0] |
|
| 251 | + if (_request('exec') == 'valider_xml') { |
|
| 252 | + return ''; |
|
| 253 | + } |
|
| 254 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 255 | + $res = ''; |
|
| 256 | + $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 257 | + foreach ($tableau as $i => $err) { |
|
| 258 | + $boucle = $ligne = $skel = ''; |
|
| 259 | + list($msg, $lieu) = $err; |
|
| 260 | + if (is_object($lieu)) { |
|
| 261 | + $ligne = $lieu->ligne; |
|
| 262 | + $boucle = $lieu->id_boucle ? $lieu->id_boucle : ''; |
|
| 263 | + if (isset($lieu->descr['nom'])) { |
|
| 264 | + $nom_code = $lieu->descr['nom']; |
|
| 265 | + $skel = $lieu->descr['sourcefile']; |
|
| 266 | + $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 267 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 268 | + $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 269 | + if ($boucle) { |
|
| 270 | + $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 271 | + $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + $j = ($i + 1); |
|
| 277 | + $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 278 | + . $j |
|
| 279 | + . " </td><td style='text-align: left'>" |
|
| 280 | + . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 281 | + . "</td><td style='text-align: left'>" |
|
| 282 | + . ($skel ? $skel : " / ") |
|
| 283 | + . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 284 | + . ($boucle ? $boucle : " / ") |
|
| 285 | + . "</td><td style='text-align: right'>" |
|
| 286 | + . $ligne |
|
| 287 | + . "</td></tr>\n"; |
|
| 288 | + |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return "\n<table id='$id'>" |
|
| 292 | + . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 293 | + . $caption[0] |
|
| 294 | 294 | ## aide locale courte a ecrire, avec lien vers une grosse page de documentation |
| 295 | 295 | # aider('erreur_compilation'), |
| 296 | - . "</caption>" |
|
| 297 | - // fausse caption du chrono (mais vraie nav) |
|
| 298 | - . (!empty($caption[1]) ? $caption[1] : '') |
|
| 299 | - . "<tr><th>" |
|
| 300 | - . _T('numero') |
|
| 301 | - . "</th><th>" |
|
| 302 | - . _T('public:message') |
|
| 303 | - . "</th><th>" |
|
| 304 | - . _T('squelette') |
|
| 305 | - . "</th><th>" |
|
| 306 | - . _T('zbug_boucle') |
|
| 307 | - . "</th><th>" |
|
| 308 | - . _T('ligne') |
|
| 309 | - . "</th></tr>" |
|
| 310 | - . $res |
|
| 311 | - . "</table>"; |
|
| 296 | + . "</caption>" |
|
| 297 | + // fausse caption du chrono (mais vraie nav) |
|
| 298 | + . (!empty($caption[1]) ? $caption[1] : '') |
|
| 299 | + . "<tr><th>" |
|
| 300 | + . _T('numero') |
|
| 301 | + . "</th><th>" |
|
| 302 | + . _T('public:message') |
|
| 303 | + . "</th><th>" |
|
| 304 | + . _T('squelette') |
|
| 305 | + . "</th><th>" |
|
| 306 | + . _T('zbug_boucle') |
|
| 307 | + . "</th><th>" |
|
| 308 | + . _T('ligne') |
|
| 309 | + . "</th></tr>" |
|
| 310 | + . $res |
|
| 311 | + . "</table>"; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
@@ -328,125 +328,125 @@ discard block |
||
| 328 | 328 | * ou un tableau si l'erreur est critique |
| 329 | 329 | **/ |
| 330 | 330 | function debusquer_requete($message) { |
| 331 | - list($errno, $msg, $query) = $message; |
|
| 332 | - |
|
| 333 | - // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 334 | - // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 335 | - if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) { |
|
| 336 | - $errno = $regs[2]; |
|
| 337 | - } elseif (is_numeric($errno) and ($errno == 1030 or $errno <= 1026) |
|
| 338 | - and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs) |
|
| 339 | - ) { |
|
| 340 | - $errno = $regs[1]; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - // Erreur systeme |
|
| 344 | - if (is_numeric($errno) and $errno > 0 and $errno < 200) { |
|
| 345 | - $retour = "<tt><br /><br /><blink>" |
|
| 346 | - . _T('info_erreur_systeme', array('errsys' => $errno)) |
|
| 347 | - . "</blink><br />\n<b>" |
|
| 348 | - . _T('info_erreur_systeme2', |
|
| 349 | - array('script' => generer_url_ecrire('base_repair'))) |
|
| 350 | - . '</b><br />'; |
|
| 351 | - spip_log("Erreur systeme $errno"); |
|
| 352 | - |
|
| 353 | - return array($retour, ''); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - // Requete erronee |
|
| 357 | - $err = "<b>" . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 358 | - . spip_htmlspecialchars($msg) |
|
| 359 | - . "\n<br /><span style='color: red'><b>" |
|
| 360 | - . spip_htmlspecialchars($query) |
|
| 361 | - . "</b></span></tt><br />"; |
|
| 362 | - |
|
| 363 | - //. aider('erreur_mysql'); |
|
| 364 | - |
|
| 365 | - return $err; |
|
| 331 | + list($errno, $msg, $query) = $message; |
|
| 332 | + |
|
| 333 | + // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 334 | + // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 335 | + if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) { |
|
| 336 | + $errno = $regs[2]; |
|
| 337 | + } elseif (is_numeric($errno) and ($errno == 1030 or $errno <= 1026) |
|
| 338 | + and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs) |
|
| 339 | + ) { |
|
| 340 | + $errno = $regs[1]; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + // Erreur systeme |
|
| 344 | + if (is_numeric($errno) and $errno > 0 and $errno < 200) { |
|
| 345 | + $retour = "<tt><br /><br /><blink>" |
|
| 346 | + . _T('info_erreur_systeme', array('errsys' => $errno)) |
|
| 347 | + . "</blink><br />\n<b>" |
|
| 348 | + . _T('info_erreur_systeme2', |
|
| 349 | + array('script' => generer_url_ecrire('base_repair'))) |
|
| 350 | + . '</b><br />'; |
|
| 351 | + spip_log("Erreur systeme $errno"); |
|
| 352 | + |
|
| 353 | + return array($retour, ''); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + // Requete erronee |
|
| 357 | + $err = "<b>" . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 358 | + . spip_htmlspecialchars($msg) |
|
| 359 | + . "\n<br /><span style='color: red'><b>" |
|
| 360 | + . spip_htmlspecialchars($query) |
|
| 361 | + . "</b></span></tt><br />"; |
|
| 362 | + |
|
| 363 | + //. aider('erreur_mysql'); |
|
| 364 | + |
|
| 365 | + return $err; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | |
| 369 | 369 | // http://code.spip.net/@trouve_boucle_debug |
| 370 | 370 | function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = "") { |
| 371 | 371 | |
| 372 | - $id = $nom . $boucle; |
|
| 373 | - if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 374 | - foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 375 | - |
|
| 376 | - if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
|
| 377 | - $y = substr_count($v[0], "\n"); |
|
| 378 | - } else { |
|
| 379 | - if ($v[1][0] == '#') // balise dynamique |
|
| 380 | - { |
|
| 381 | - $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 382 | - } else // inclusion |
|
| 383 | - { |
|
| 384 | - $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 385 | - } |
|
| 386 | - $y = substr_count($incl, "\n") |
|
| 387 | - + substr_count($r[1], "\n") |
|
| 388 | - + substr_count($r[3], "\n"); |
|
| 389 | - } |
|
| 390 | - if ($n <= ($y + $debut)) { |
|
| 391 | - if ($v[1][0] == '?') { |
|
| 392 | - return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1)); |
|
| 393 | - } elseif ($v[1][0] == '!') { |
|
| 394 | - if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 395 | - return trouve_boucle_debug($n, $incl, $debut); |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - return array($nom, $boucle, $v[2] - 1 + $n - $debut); |
|
| 400 | - } |
|
| 401 | - $debut += $y; |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - return array($nom, $boucle, $n - $debut); |
|
| 372 | + $id = $nom . $boucle; |
|
| 373 | + if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 374 | + foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 375 | + |
|
| 376 | + if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
|
| 377 | + $y = substr_count($v[0], "\n"); |
|
| 378 | + } else { |
|
| 379 | + if ($v[1][0] == '#') // balise dynamique |
|
| 380 | + { |
|
| 381 | + $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 382 | + } else // inclusion |
|
| 383 | + { |
|
| 384 | + $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 385 | + } |
|
| 386 | + $y = substr_count($incl, "\n") |
|
| 387 | + + substr_count($r[1], "\n") |
|
| 388 | + + substr_count($r[3], "\n"); |
|
| 389 | + } |
|
| 390 | + if ($n <= ($y + $debut)) { |
|
| 391 | + if ($v[1][0] == '?') { |
|
| 392 | + return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1)); |
|
| 393 | + } elseif ($v[1][0] == '!') { |
|
| 394 | + if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 395 | + return trouve_boucle_debug($n, $incl, $debut); |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + return array($nom, $boucle, $v[2] - 1 + $n - $debut); |
|
| 400 | + } |
|
| 401 | + $debut += $y; |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + return array($nom, $boucle, $n - $debut); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // http://code.spip.net/@trouve_squelette_inclus |
| 409 | 409 | function trouve_squelette_inclus($script) { |
| 410 | 410 | |
| 411 | - preg_match('/include\(.(.*).php3?.\);/', $script, $reg); |
|
| 412 | - // si le script X.php n'est pas ecrire/public.php |
|
| 413 | - // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 414 | - if ($reg[1] == 'ecrire/public') // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 415 | - { |
|
| 416 | - if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) // a defaut on cherche le param 'page' |
|
| 417 | - { |
|
| 418 | - if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) { |
|
| 419 | - $reg[1] = "inconnu"; |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - } |
|
| 423 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 424 | - |
|
| 425 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 426 | - if (preg_match($incl, $v)) { |
|
| 427 | - return $k; |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - return ""; |
|
| 411 | + preg_match('/include\(.(.*).php3?.\);/', $script, $reg); |
|
| 412 | + // si le script X.php n'est pas ecrire/public.php |
|
| 413 | + // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 414 | + if ($reg[1] == 'ecrire/public') // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 415 | + { |
|
| 416 | + if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) // a defaut on cherche le param 'page' |
|
| 417 | + { |
|
| 418 | + if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) { |
|
| 419 | + $reg[1] = "inconnu"; |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + } |
|
| 423 | + $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 424 | + |
|
| 425 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 426 | + if (preg_match($incl, $v)) { |
|
| 427 | + return $k; |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + return ""; |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | // http://code.spip.net/@reference_boucle_debug |
| 435 | 435 | function reference_boucle_debug($n, $nom, $self) { |
| 436 | - list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom); |
|
| 437 | - |
|
| 438 | - if (!$boucle) { |
|
| 439 | - return !$ligne ? "" : |
|
| 440 | - (" (" . |
|
| 441 | - (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 442 | - _T('squelette_ligne')) . |
|
| 443 | - " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
|
| 444 | - } else { |
|
| 445 | - $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 446 | - |
|
| 447 | - return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 448 | - " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 449 | - } |
|
| 436 | + list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom); |
|
| 437 | + |
|
| 438 | + if (!$boucle) { |
|
| 439 | + return !$ligne ? "" : |
|
| 440 | + (" (" . |
|
| 441 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 442 | + _T('squelette_ligne')) . |
|
| 443 | + " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
|
| 444 | + } else { |
|
| 445 | + $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 446 | + |
|
| 447 | + return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 448 | + " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 449 | + } |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | // affiche un texte avec numero de ligne et ancre. |
@@ -454,395 +454,395 @@ discard block |
||
| 454 | 454 | // http://code.spip.net/@ancre_texte |
| 455 | 455 | function ancre_texte($texte, $fautifs = array(), $nocpt = false) { |
| 456 | 456 | |
| 457 | - $var_mode_ligne = _request('var_mode_ligne'); |
|
| 458 | - if ($var_mode_ligne) { |
|
| 459 | - $fautifs[] = array($var_mode_ligne); |
|
| 460 | - } |
|
| 461 | - $res = ''; |
|
| 462 | - |
|
| 463 | - $s = highlight_string($texte, true); |
|
| 464 | - if (substr($s, 0, 6) == '<code>') { |
|
| 465 | - $s = substr($s, 6); |
|
| 466 | - $res = '<code>'; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - $s = preg_replace(',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 470 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 471 | - $s); |
|
| 472 | - |
|
| 473 | - |
|
| 474 | - $tableau = explode("<br />", $s); |
|
| 475 | - |
|
| 476 | - $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"; |
|
| 477 | - |
|
| 478 | - $format10 = str_replace('white', 'lightgrey', $format); |
|
| 479 | - $formaterr = "color: red;"; |
|
| 480 | - $i = 1; |
|
| 481 | - $flignes = array(); |
|
| 482 | - $loc = array(0, 0); |
|
| 483 | - foreach ($fautifs as $lc) { |
|
| 484 | - if (is_array($lc)) { |
|
| 485 | - $l = array_shift($lc); |
|
| 486 | - $flignes[$l] = $lc; |
|
| 487 | - } else { |
|
| 488 | - $flignes[$lc] = $loc; |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - $ancre = md5($texte); |
|
| 493 | - foreach ($tableau as $ligne) { |
|
| 494 | - if (isset($flignes[$i])) { |
|
| 495 | - $ligne = str_replace(' ', ' ', $ligne); |
|
| 496 | - $indexmesg = $flignes[$i][1]; |
|
| 497 | - $err = textebrut($flignes[$i][2]); |
|
| 498 | - // tentative de pointer sur la colonne fautive; |
|
| 499 | - // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 500 | - // $m = $flignes[$i][0]; |
|
| 501 | - // $ligne = substr($ligne, 0, $m-1) . |
|
| 502 | - // sprintf($formaterr, substr($ligne,$m)); |
|
| 503 | - $bg = $formaterr; |
|
| 504 | - } else { |
|
| 505 | - $indexmesg = $ancre; |
|
| 506 | - $err = $bg = ''; |
|
| 507 | - } |
|
| 508 | - $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 509 | - $i++; |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - return "<div id='T$ancre'>" |
|
| 513 | - . '<div onclick="' |
|
| 514 | - . "jQuery(this).parent().find('a').toggle();" |
|
| 515 | - . '" title="' |
|
| 516 | - . _T('masquer_colonne') |
|
| 517 | - . '" style="cursor: pointer;">' |
|
| 518 | - . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 519 | - . "</div> |
|
| 457 | + $var_mode_ligne = _request('var_mode_ligne'); |
|
| 458 | + if ($var_mode_ligne) { |
|
| 459 | + $fautifs[] = array($var_mode_ligne); |
|
| 460 | + } |
|
| 461 | + $res = ''; |
|
| 462 | + |
|
| 463 | + $s = highlight_string($texte, true); |
|
| 464 | + if (substr($s, 0, 6) == '<code>') { |
|
| 465 | + $s = substr($s, 6); |
|
| 466 | + $res = '<code>'; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + $s = preg_replace(',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 470 | + '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 471 | + $s); |
|
| 472 | + |
|
| 473 | + |
|
| 474 | + $tableau = explode("<br />", $s); |
|
| 475 | + |
|
| 476 | + $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"; |
|
| 477 | + |
|
| 478 | + $format10 = str_replace('white', 'lightgrey', $format); |
|
| 479 | + $formaterr = "color: red;"; |
|
| 480 | + $i = 1; |
|
| 481 | + $flignes = array(); |
|
| 482 | + $loc = array(0, 0); |
|
| 483 | + foreach ($fautifs as $lc) { |
|
| 484 | + if (is_array($lc)) { |
|
| 485 | + $l = array_shift($lc); |
|
| 486 | + $flignes[$l] = $lc; |
|
| 487 | + } else { |
|
| 488 | + $flignes[$lc] = $loc; |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + $ancre = md5($texte); |
|
| 493 | + foreach ($tableau as $ligne) { |
|
| 494 | + if (isset($flignes[$i])) { |
|
| 495 | + $ligne = str_replace(' ', ' ', $ligne); |
|
| 496 | + $indexmesg = $flignes[$i][1]; |
|
| 497 | + $err = textebrut($flignes[$i][2]); |
|
| 498 | + // tentative de pointer sur la colonne fautive; |
|
| 499 | + // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 500 | + // $m = $flignes[$i][0]; |
|
| 501 | + // $ligne = substr($ligne, 0, $m-1) . |
|
| 502 | + // sprintf($formaterr, substr($ligne,$m)); |
|
| 503 | + $bg = $formaterr; |
|
| 504 | + } else { |
|
| 505 | + $indexmesg = $ancre; |
|
| 506 | + $err = $bg = ''; |
|
| 507 | + } |
|
| 508 | + $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 509 | + $i++; |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + return "<div id='T$ancre'>" |
|
| 513 | + . '<div onclick="' |
|
| 514 | + . "jQuery(this).parent().find('a').toggle();" |
|
| 515 | + . '" title="' |
|
| 516 | + . _T('masquer_colonne') |
|
| 517 | + . '" style="cursor: pointer;">' |
|
| 518 | + . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 519 | + . "</div> |
|
| 520 | 520 | " . $res . "</div>\n"; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | // l'environnement graphique du debuggueur |
| 524 | 524 | |
| 525 | 525 | function debusquer_squelette($fonc, $mode, $self) { |
| 526 | - $texte = ''; |
|
| 527 | - |
|
| 528 | - if ($mode !== 'validation') { |
|
| 529 | - if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) { |
|
| 530 | - $res = "<div id='spip-boucles'>\n" |
|
| 531 | - . debusquer_navigation_squelettes($self) |
|
| 532 | - . "</div>"; |
|
| 533 | - } else { |
|
| 534 | - $res = ''; |
|
| 535 | - } |
|
| 536 | - if ($fonc) { |
|
| 537 | - $id = " id='$fonc'"; |
|
| 538 | - if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 539 | - list($legend, $texte, $res2) = debusquer_source($fonc, $mode); |
|
| 540 | - $texte .= $res2; |
|
| 541 | - } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 542 | - $legend = _T('zbug_' . $mode); |
|
| 543 | - $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 544 | - $texte = ancre_texte($texte, array('', '')); |
|
| 545 | - } |
|
| 546 | - } else { |
|
| 547 | - if (strlen(trim($res))) { |
|
| 548 | - return "<img src='" . chemin_image('compat-16.png') . "' 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>"; |
|
| 549 | - } else { |
|
| 550 | - // cas de l'appel sur erreur: montre la page |
|
| 551 | - return isset($GLOBALS['debug_objets']['resultat']['tout']) |
|
| 552 | - ? $GLOBALS['debug_objets']['resultat']['tout'] |
|
| 553 | - : ''; |
|
| 554 | - } |
|
| 555 | - } |
|
| 556 | - } else { |
|
| 557 | - $valider = charger_fonction('valider', 'xml'); |
|
| 558 | - $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 559 | - // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 560 | - $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 561 | - list($texte, $err) = emboite_texte($val, $fonc, $self); |
|
| 562 | - if ($err === false) { |
|
| 563 | - $err = _T('impossible'); |
|
| 564 | - } elseif ($err === true) { |
|
| 565 | - $err = _T('correcte'); |
|
| 566 | - } else { |
|
| 567 | - $err = ": $err"; |
|
| 568 | - } |
|
| 569 | - $legend = _T('validation') . ' ' . $err; |
|
| 570 | - $res = $id = ''; |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - return !trim($texte) ? '' : ( |
|
| 574 | - "<img src='" . chemin_image('compat-16.png') . "' 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" |
|
| 575 | - . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 576 | - . "<a href='" . $self . "#f_" . substr($fonc, 0, 37) . "'> ↑ " |
|
| 577 | - . ($legend ? $legend : $mode) |
|
| 578 | - . "</a></legend>" |
|
| 579 | - . $texte |
|
| 580 | - . "</fieldset></div>" |
|
| 581 | - . "</div>"); |
|
| 526 | + $texte = ''; |
|
| 527 | + |
|
| 528 | + if ($mode !== 'validation') { |
|
| 529 | + if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) { |
|
| 530 | + $res = "<div id='spip-boucles'>\n" |
|
| 531 | + . debusquer_navigation_squelettes($self) |
|
| 532 | + . "</div>"; |
|
| 533 | + } else { |
|
| 534 | + $res = ''; |
|
| 535 | + } |
|
| 536 | + if ($fonc) { |
|
| 537 | + $id = " id='$fonc'"; |
|
| 538 | + if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 539 | + list($legend, $texte, $res2) = debusquer_source($fonc, $mode); |
|
| 540 | + $texte .= $res2; |
|
| 541 | + } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 542 | + $legend = _T('zbug_' . $mode); |
|
| 543 | + $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 544 | + $texte = ancre_texte($texte, array('', '')); |
|
| 545 | + } |
|
| 546 | + } else { |
|
| 547 | + if (strlen(trim($res))) { |
|
| 548 | + return "<img src='" . chemin_image('compat-16.png') . "' 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>"; |
|
| 549 | + } else { |
|
| 550 | + // cas de l'appel sur erreur: montre la page |
|
| 551 | + return isset($GLOBALS['debug_objets']['resultat']['tout']) |
|
| 552 | + ? $GLOBALS['debug_objets']['resultat']['tout'] |
|
| 553 | + : ''; |
|
| 554 | + } |
|
| 555 | + } |
|
| 556 | + } else { |
|
| 557 | + $valider = charger_fonction('valider', 'xml'); |
|
| 558 | + $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 559 | + // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 560 | + $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 561 | + list($texte, $err) = emboite_texte($val, $fonc, $self); |
|
| 562 | + if ($err === false) { |
|
| 563 | + $err = _T('impossible'); |
|
| 564 | + } elseif ($err === true) { |
|
| 565 | + $err = _T('correcte'); |
|
| 566 | + } else { |
|
| 567 | + $err = ": $err"; |
|
| 568 | + } |
|
| 569 | + $legend = _T('validation') . ' ' . $err; |
|
| 570 | + $res = $id = ''; |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + return !trim($texte) ? '' : ( |
|
| 574 | + "<img src='" . chemin_image('compat-16.png') . "' 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" |
|
| 575 | + . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 576 | + . "<a href='" . $self . "#f_" . substr($fonc, 0, 37) . "'> ↑ " |
|
| 577 | + . ($legend ? $legend : $mode) |
|
| 578 | + . "</a></legend>" |
|
| 579 | + . $texte |
|
| 580 | + . "</fieldset></div>" |
|
| 581 | + . "</div>"); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | |
| 585 | 585 | // http://code.spip.net/@emboite_texte |
| 586 | 586 | function emboite_texte($res, $fonc = '', $self = '') { |
| 587 | - $errs = $res->err; |
|
| 588 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 589 | - |
|
| 590 | - if (!$texte and !$errs) { |
|
| 591 | - return array(ancre_texte('', array('', '')), false); |
|
| 592 | - } |
|
| 593 | - if (!$errs) { |
|
| 594 | - return array(ancre_texte($texte, array('', '')), true); |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - if (!isset($GLOBALS['debug_objets'])) { |
|
| 598 | - |
|
| 599 | - $colors = array('#e0e0f0', '#f8f8ff'); |
|
| 600 | - $encore = count_occ($errs); |
|
| 601 | - $encore2 = array(); |
|
| 602 | - $fautifs = array(); |
|
| 603 | - |
|
| 604 | - $err = '<tr><th>' |
|
| 605 | - . _T('numero') |
|
| 606 | - . "</th><th>" |
|
| 607 | - . _T('occurence') |
|
| 608 | - . "</th><th>" |
|
| 609 | - . _T('ligne') |
|
| 610 | - . "</th><th>" |
|
| 611 | - . _T('colonne') |
|
| 612 | - . "</th><th>" |
|
| 613 | - . _T('erreur') |
|
| 614 | - . "</th></tr>"; |
|
| 615 | - |
|
| 616 | - $i = 0; |
|
| 617 | - $style = "style='text-align: right; padding-right: 5px'"; |
|
| 618 | - foreach ($errs as $r) { |
|
| 619 | - $i++; |
|
| 620 | - list($msg, $ligne, $col) = $r; |
|
| 621 | - #spip_log("$r = list($msg, $ligne, $col"); |
|
| 622 | - if (isset($encore2[$msg])) { |
|
| 623 | - $ref = ++$encore2[$msg]; |
|
| 624 | - } else { |
|
| 625 | - $encore2[$msg] = $ref = 1; |
|
| 626 | - } |
|
| 627 | - $err .= "<tr style='background-color: " |
|
| 628 | - . $colors[$i % 2] |
|
| 629 | - . "'><td $style><a href='#debut_err'>" |
|
| 630 | - . $i |
|
| 631 | - . "</a></td><td $style>" |
|
| 632 | - . "$ref/$encore[$msg]</td>" |
|
| 633 | - . "<td $style><a href='#L" |
|
| 634 | - . $ligne |
|
| 635 | - . "' id='T$i'>" |
|
| 636 | - . $ligne |
|
| 637 | - . "</a></td><td $style>" |
|
| 638 | - . $col |
|
| 639 | - . "</td><td>$msg</td></tr>\n"; |
|
| 640 | - $fautifs[] = array($ligne, $col, $i, $msg); |
|
| 641 | - } |
|
| 642 | - $err = "<h2 style='text-align: center'>" |
|
| 643 | - . $i |
|
| 644 | - . "<a href='#fin_err'>" |
|
| 645 | - . " " . _T('erreur_texte') |
|
| 646 | - . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 647 | - . $err |
|
| 648 | - . " </table><a id='fin_err'></a>"; |
|
| 649 | - |
|
| 650 | - return array(ancre_texte($texte, $fautifs), $err); |
|
| 651 | - } else { |
|
| 652 | - list($msg, $fermant, $ouvrant) = $errs[0]; |
|
| 653 | - $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 654 | - $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 655 | - $err = $msg . |
|
| 656 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 657 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 658 | - |
|
| 659 | - return array(ancre_texte($texte, array(array($ouvrant), array($fermant))), $err); |
|
| 660 | - } |
|
| 587 | + $errs = $res->err; |
|
| 588 | + $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 589 | + |
|
| 590 | + if (!$texte and !$errs) { |
|
| 591 | + return array(ancre_texte('', array('', '')), false); |
|
| 592 | + } |
|
| 593 | + if (!$errs) { |
|
| 594 | + return array(ancre_texte($texte, array('', '')), true); |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + if (!isset($GLOBALS['debug_objets'])) { |
|
| 598 | + |
|
| 599 | + $colors = array('#e0e0f0', '#f8f8ff'); |
|
| 600 | + $encore = count_occ($errs); |
|
| 601 | + $encore2 = array(); |
|
| 602 | + $fautifs = array(); |
|
| 603 | + |
|
| 604 | + $err = '<tr><th>' |
|
| 605 | + . _T('numero') |
|
| 606 | + . "</th><th>" |
|
| 607 | + . _T('occurence') |
|
| 608 | + . "</th><th>" |
|
| 609 | + . _T('ligne') |
|
| 610 | + . "</th><th>" |
|
| 611 | + . _T('colonne') |
|
| 612 | + . "</th><th>" |
|
| 613 | + . _T('erreur') |
|
| 614 | + . "</th></tr>"; |
|
| 615 | + |
|
| 616 | + $i = 0; |
|
| 617 | + $style = "style='text-align: right; padding-right: 5px'"; |
|
| 618 | + foreach ($errs as $r) { |
|
| 619 | + $i++; |
|
| 620 | + list($msg, $ligne, $col) = $r; |
|
| 621 | + #spip_log("$r = list($msg, $ligne, $col"); |
|
| 622 | + if (isset($encore2[$msg])) { |
|
| 623 | + $ref = ++$encore2[$msg]; |
|
| 624 | + } else { |
|
| 625 | + $encore2[$msg] = $ref = 1; |
|
| 626 | + } |
|
| 627 | + $err .= "<tr style='background-color: " |
|
| 628 | + . $colors[$i % 2] |
|
| 629 | + . "'><td $style><a href='#debut_err'>" |
|
| 630 | + . $i |
|
| 631 | + . "</a></td><td $style>" |
|
| 632 | + . "$ref/$encore[$msg]</td>" |
|
| 633 | + . "<td $style><a href='#L" |
|
| 634 | + . $ligne |
|
| 635 | + . "' id='T$i'>" |
|
| 636 | + . $ligne |
|
| 637 | + . "</a></td><td $style>" |
|
| 638 | + . $col |
|
| 639 | + . "</td><td>$msg</td></tr>\n"; |
|
| 640 | + $fautifs[] = array($ligne, $col, $i, $msg); |
|
| 641 | + } |
|
| 642 | + $err = "<h2 style='text-align: center'>" |
|
| 643 | + . $i |
|
| 644 | + . "<a href='#fin_err'>" |
|
| 645 | + . " " . _T('erreur_texte') |
|
| 646 | + . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 647 | + . $err |
|
| 648 | + . " </table><a id='fin_err'></a>"; |
|
| 649 | + |
|
| 650 | + return array(ancre_texte($texte, $fautifs), $err); |
|
| 651 | + } else { |
|
| 652 | + list($msg, $fermant, $ouvrant) = $errs[0]; |
|
| 653 | + $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 654 | + $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 655 | + $err = $msg . |
|
| 656 | + "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 657 | + "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 658 | + |
|
| 659 | + return array(ancre_texte($texte, array(array($ouvrant), array($fermant))), $err); |
|
| 660 | + } |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | // http://code.spip.net/@count_occ |
| 664 | 664 | function count_occ($regs) { |
| 665 | - $encore = array(); |
|
| 666 | - foreach ($regs as $r) { |
|
| 667 | - if (isset($encore[$r[0]])) { |
|
| 668 | - $encore[$r[0]]++; |
|
| 669 | - } else { |
|
| 670 | - $encore[$r[0]] = 1; |
|
| 671 | - } |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - return $encore; |
|
| 665 | + $encore = array(); |
|
| 666 | + foreach ($regs as $r) { |
|
| 667 | + if (isset($encore[$r[0]])) { |
|
| 668 | + $encore[$r[0]]++; |
|
| 669 | + } else { |
|
| 670 | + $encore[$r[0]] = 1; |
|
| 671 | + } |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + return $encore; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | function debusquer_navigation_squelettes($self) { |
| 678 | 678 | |
| 679 | - $res = ''; |
|
| 680 | - $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : ''; |
|
| 681 | - $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 682 | - $t_skel = _T('squelette'); |
|
| 683 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 684 | - $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 685 | - $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile); |
|
| 686 | - $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T('zbug_profile', |
|
| 687 | - array('time' => $GLOBALS['debug_objets']['profile'][$sourcefile])); |
|
| 688 | - |
|
| 689 | - $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 690 | - . $t_skel |
|
| 691 | - . ' ' |
|
| 692 | - . $sourcefile |
|
| 693 | - . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 694 | - . $t_skel |
|
| 695 | - . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 696 | - . _T('zbug_resultat') |
|
| 697 | - . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 698 | - . _T('zbug_code') |
|
| 699 | - . "</a>\n<a href='" |
|
| 700 | - . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', $self) |
|
| 701 | - . "'>" |
|
| 702 | - . _T('zbug_calcul') |
|
| 703 | - . "</a></legend>" |
|
| 704 | - . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 705 | - . debusquer_contexte($contexte[$sourcefile]) |
|
| 706 | - . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
|
| 707 | - . "</fieldset>\n"; |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - return $res; |
|
| 679 | + $res = ''; |
|
| 680 | + $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : ''; |
|
| 681 | + $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 682 | + $t_skel = _T('squelette'); |
|
| 683 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 684 | + $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 685 | + $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile); |
|
| 686 | + $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T('zbug_profile', |
|
| 687 | + array('time' => $GLOBALS['debug_objets']['profile'][$sourcefile])); |
|
| 688 | + |
|
| 689 | + $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 690 | + . $t_skel |
|
| 691 | + . ' ' |
|
| 692 | + . $sourcefile |
|
| 693 | + . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 694 | + . $t_skel |
|
| 695 | + . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 696 | + . _T('zbug_resultat') |
|
| 697 | + . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 698 | + . _T('zbug_code') |
|
| 699 | + . "</a>\n<a href='" |
|
| 700 | + . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', $self) |
|
| 701 | + . "'>" |
|
| 702 | + . _T('zbug_calcul') |
|
| 703 | + . "</a></legend>" |
|
| 704 | + . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 705 | + . debusquer_contexte($contexte[$sourcefile]) |
|
| 706 | + . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
|
| 707 | + . "</fieldset>\n"; |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + return $res; |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source) { |
| 714 | - $i = 0; |
|
| 715 | - $res = ''; |
|
| 716 | - $var_mode_objet = _request('var_mode_objet'); |
|
| 717 | - $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : ''; |
|
| 718 | - |
|
| 719 | - foreach ($boucles as $objet => $boucle) { |
|
| 720 | - if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) { |
|
| 721 | - $i++; |
|
| 722 | - $nom = $boucle->id_boucle; |
|
| 723 | - $req = $boucle->type_requete; |
|
| 724 | - $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 725 | - $self2 = $self . "&var_mode_objet=" . $objet; |
|
| 726 | - |
|
| 727 | - $res .= "\n<tr style='background-color: " . |
|
| 728 | - ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 729 | - "'><td align='right'>$i</td><td>\n" . |
|
| 730 | - "<a class='debug_link_boucle' href='" . |
|
| 731 | - $self2 . |
|
| 732 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 733 | - _T('zbug_boucle') . |
|
| 734 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 735 | - $self2 . |
|
| 736 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 737 | - _T('zbug_resultat') . |
|
| 738 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 739 | - $self2 . |
|
| 740 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 741 | - _T('zbug_code') . |
|
| 742 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 743 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 744 | - "'>" . |
|
| 745 | - _T('zbug_calcul') . |
|
| 746 | - "</a></td><td>\n" . |
|
| 747 | - (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 748 | - "</td><td>\n" . |
|
| 749 | - $req . |
|
| 750 | - "</td><td>\n" . |
|
| 751 | - spip_htmlspecialchars($crit) . |
|
| 752 | - "</td></tr>"; |
|
| 753 | - } |
|
| 754 | - } |
|
| 755 | - |
|
| 756 | - return $res; |
|
| 714 | + $i = 0; |
|
| 715 | + $res = ''; |
|
| 716 | + $var_mode_objet = _request('var_mode_objet'); |
|
| 717 | + $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : ''; |
|
| 718 | + |
|
| 719 | + foreach ($boucles as $objet => $boucle) { |
|
| 720 | + if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) { |
|
| 721 | + $i++; |
|
| 722 | + $nom = $boucle->id_boucle; |
|
| 723 | + $req = $boucle->type_requete; |
|
| 724 | + $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 725 | + $self2 = $self . "&var_mode_objet=" . $objet; |
|
| 726 | + |
|
| 727 | + $res .= "\n<tr style='background-color: " . |
|
| 728 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 729 | + "'><td align='right'>$i</td><td>\n" . |
|
| 730 | + "<a class='debug_link_boucle' href='" . |
|
| 731 | + $self2 . |
|
| 732 | + "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 733 | + _T('zbug_boucle') . |
|
| 734 | + "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 735 | + $self2 . |
|
| 736 | + "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 737 | + _T('zbug_resultat') . |
|
| 738 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 739 | + $self2 . |
|
| 740 | + "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 741 | + _T('zbug_code') . |
|
| 742 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 743 | + str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 744 | + "'>" . |
|
| 745 | + _T('zbug_calcul') . |
|
| 746 | + "</a></td><td>\n" . |
|
| 747 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 748 | + "</td><td>\n" . |
|
| 749 | + $req . |
|
| 750 | + "</td><td>\n" . |
|
| 751 | + spip_htmlspecialchars($crit) . |
|
| 752 | + "</td></tr>"; |
|
| 753 | + } |
|
| 754 | + } |
|
| 755 | + |
|
| 756 | + return $res; |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | function debusquer_source($objet, $affiche) { |
| 760 | - $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 761 | - if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 762 | - $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 763 | - } else { |
|
| 764 | - $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 765 | - } |
|
| 766 | - $res2 = ""; |
|
| 767 | - |
|
| 768 | - if ($affiche == 'resultat') { |
|
| 769 | - $legend = $nom; |
|
| 770 | - $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 771 | - if (function_exists('_mysql_traite_query')) { |
|
| 772 | - $c = strtolower(_request('connect')); |
|
| 773 | - $c = $GLOBALS['connexions'][$c ? $c : 0]['prefixe']; |
|
| 774 | - $req = _mysql_traite_query($req, '', $c); |
|
| 775 | - } |
|
| 776 | - // permettre le copier/coller facile |
|
| 777 | - // $res = ancre_texte($req, array(), true); |
|
| 778 | - $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 779 | - // formatage et affichage des resultats bruts de la requete |
|
| 780 | - $ress_req = spip_query($req); |
|
| 781 | - $brut_sql = ''; |
|
| 782 | - $num = 1; |
|
| 783 | - // eviter l'affichage de milliers de lignes |
|
| 784 | - // personnalisation possible dans mes_options |
|
| 785 | - $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 786 | - while ($retours_sql = sql_fetch($ress_req)) { |
|
| 787 | - if ($num <= $max_aff) { |
|
| 788 | - $brut_sql .= "<h3>" . ($num == 1 ? $num . " sur " . sql_count($ress_req) : $num) . "</h3>"; |
|
| 789 | - $brut_sql .= "<p>"; |
|
| 790 | - foreach ($retours_sql as $key => $val) { |
|
| 791 | - $brut_sql .= "<strong>" . $key . "</strong> => " . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 792 | - } |
|
| 793 | - $brut_sql .= "</p>"; |
|
| 794 | - } |
|
| 795 | - $num++; |
|
| 796 | - } |
|
| 797 | - $res2 = interdire_scripts($brut_sql); |
|
| 798 | - foreach ($quoi as $view) { |
|
| 799 | - // ne pas afficher les $contexte_inclus |
|
| 800 | - $view = preg_replace(",<\?php.+\?[>],Uims", "", $view); |
|
| 801 | - if ($view) { |
|
| 802 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . "</fieldset>"; |
|
| 803 | - } |
|
| 804 | - } |
|
| 805 | - |
|
| 806 | - } elseif ($affiche == 'code') { |
|
| 807 | - $legend = $nom; |
|
| 808 | - $res = ancre_texte("<" . "?php\n" . $quoi . "\n?" . ">"); |
|
| 809 | - } elseif ($affiche == 'boucle') { |
|
| 810 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 811 | - // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 812 | - $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
|
| 813 | - $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 814 | - } elseif ($affiche == 'squelette') { |
|
| 815 | - $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 816 | - $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 817 | - } |
|
| 818 | - |
|
| 819 | - return array($legend, $res, $res2); |
|
| 760 | + $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 761 | + if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 762 | + $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 763 | + } else { |
|
| 764 | + $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 765 | + } |
|
| 766 | + $res2 = ""; |
|
| 767 | + |
|
| 768 | + if ($affiche == 'resultat') { |
|
| 769 | + $legend = $nom; |
|
| 770 | + $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 771 | + if (function_exists('_mysql_traite_query')) { |
|
| 772 | + $c = strtolower(_request('connect')); |
|
| 773 | + $c = $GLOBALS['connexions'][$c ? $c : 0]['prefixe']; |
|
| 774 | + $req = _mysql_traite_query($req, '', $c); |
|
| 775 | + } |
|
| 776 | + // permettre le copier/coller facile |
|
| 777 | + // $res = ancre_texte($req, array(), true); |
|
| 778 | + $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 779 | + // formatage et affichage des resultats bruts de la requete |
|
| 780 | + $ress_req = spip_query($req); |
|
| 781 | + $brut_sql = ''; |
|
| 782 | + $num = 1; |
|
| 783 | + // eviter l'affichage de milliers de lignes |
|
| 784 | + // personnalisation possible dans mes_options |
|
| 785 | + $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 786 | + while ($retours_sql = sql_fetch($ress_req)) { |
|
| 787 | + if ($num <= $max_aff) { |
|
| 788 | + $brut_sql .= "<h3>" . ($num == 1 ? $num . " sur " . sql_count($ress_req) : $num) . "</h3>"; |
|
| 789 | + $brut_sql .= "<p>"; |
|
| 790 | + foreach ($retours_sql as $key => $val) { |
|
| 791 | + $brut_sql .= "<strong>" . $key . "</strong> => " . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 792 | + } |
|
| 793 | + $brut_sql .= "</p>"; |
|
| 794 | + } |
|
| 795 | + $num++; |
|
| 796 | + } |
|
| 797 | + $res2 = interdire_scripts($brut_sql); |
|
| 798 | + foreach ($quoi as $view) { |
|
| 799 | + // ne pas afficher les $contexte_inclus |
|
| 800 | + $view = preg_replace(",<\?php.+\?[>],Uims", "", $view); |
|
| 801 | + if ($view) { |
|
| 802 | + $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . "</fieldset>"; |
|
| 803 | + } |
|
| 804 | + } |
|
| 805 | + |
|
| 806 | + } elseif ($affiche == 'code') { |
|
| 807 | + $legend = $nom; |
|
| 808 | + $res = ancre_texte("<" . "?php\n" . $quoi . "\n?" . ">"); |
|
| 809 | + } elseif ($affiche == 'boucle') { |
|
| 810 | + $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 811 | + // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 812 | + $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
|
| 813 | + $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 814 | + } elseif ($affiche == 'squelette') { |
|
| 815 | + $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 816 | + $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 817 | + } |
|
| 818 | + |
|
| 819 | + return array($legend, $res, $res2); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | // http://code.spip.net/@debusquer_entete |
| 823 | 823 | function debusquer_entete($titre, $corps) { |
| 824 | 824 | |
| 825 | - include_spip('balise/formulaire_admin'); |
|
| 826 | - include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 827 | - include_spip('inc/texte'); // pour corriger_typo |
|
| 828 | - |
|
| 829 | - return _DOCTYPE_ECRIRE . |
|
| 830 | - html_lang_attributes() . |
|
| 831 | - "<head>\n<title>" . |
|
| 832 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 833 | - _T('admin_debug') . ' ' . $titre . ' (' . |
|
| 834 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 835 | - ")</title>\n" . |
|
| 836 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 837 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 838 | - "' />\n" . |
|
| 839 | - http_script('', 'jquery.js') |
|
| 840 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 841 | - . "' type='text/css' />" . |
|
| 842 | - "</head>\n" . |
|
| 843 | - "<body style='margin:0 10px;'>\n" . |
|
| 844 | - "<div id='spip-debug-header'>" . |
|
| 845 | - $corps . |
|
| 846 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 847 | - '</div></body></html>'; |
|
| 825 | + include_spip('balise/formulaire_admin'); |
|
| 826 | + include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 827 | + include_spip('inc/texte'); // pour corriger_typo |
|
| 828 | + |
|
| 829 | + return _DOCTYPE_ECRIRE . |
|
| 830 | + html_lang_attributes() . |
|
| 831 | + "<head>\n<title>" . |
|
| 832 | + ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 833 | + _T('admin_debug') . ' ' . $titre . ' (' . |
|
| 834 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 835 | + ")</title>\n" . |
|
| 836 | + "<meta http-equiv='Content-Type' content='text/html" . |
|
| 837 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 838 | + "' />\n" . |
|
| 839 | + http_script('', 'jquery.js') |
|
| 840 | + . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 841 | + . "' type='text/css' />" . |
|
| 842 | + "</head>\n" . |
|
| 843 | + "<body style='margin:0 10px;'>\n" . |
|
| 844 | + "<div id='spip-debug-header'>" . |
|
| 845 | + $corps . |
|
| 846 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 847 | + '</div></body></html>'; |
|
| 848 | 848 | } |
@@ -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 = isset($GLOBALS['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 = array(count($erreurs) . ' ' . _T('zbug_erreur_squelette')); |
|
| 187 | + $n = array(count($erreurs).' '._T('zbug_erreur_squelette')); |
|
| 188 | 188 | |
| 189 | 189 | return debusquer_navigation($erreurs, $n); |
| 190 | 190 | } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
@@ -218,25 +218,25 @@ discard block |
||
| 218 | 218 | $valeur_simple = array(); |
| 219 | 219 | foreach ($valeur as $v) { |
| 220 | 220 | if (is_array($v)) { |
| 221 | - $valeur_simple[] = 'array:' . count($v); |
|
| 221 | + $valeur_simple[] = 'array:'.count($v); |
|
| 222 | 222 | } elseif (is_object($v)) { |
| 223 | 223 | $valeur_simple[] = get_class($v); |
| 224 | 224 | } elseif (is_string($v)) { |
| 225 | - $valeur_simple[] = "'" . $v . "'"; |
|
| 225 | + $valeur_simple[] = "'".$v."'"; |
|
| 226 | 226 | } else { |
| 227 | 227 | $valeur_simple[] = $v; |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | $n = count($valeur); |
| 231 | - $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 232 | - $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 231 | + $valeur = (($n > 3) ? 'array:'.$n.' ' : ''); |
|
| 232 | + $valeur .= '['.join(', ', $valeur_simple).']'; |
|
| 233 | 233 | } elseif (is_object($valeur)) { |
| 234 | 234 | $valeur = get_class($valeur); |
| 235 | 235 | } elseif (is_string($valeur)) { |
| 236 | - $valeur = "'" . $valeur . "'"; |
|
| 236 | + $valeur = "'".$valeur."'"; |
|
| 237 | 237 | } |
| 238 | - $res .= "\n<tr><td><strong>" . nl2br(entites_html($nom)) |
|
| 239 | - . "</strong></td><td>: " . nl2br(entites_html($valeur)) |
|
| 238 | + $res .= "\n<tr><td><strong>".nl2br(entites_html($nom)) |
|
| 239 | + . "</strong></td><td>: ".nl2br(entites_html($valeur)) |
|
| 240 | 240 | . "</td></tr>\n"; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -264,10 +264,10 @@ discard block |
||
| 264 | 264 | $nom_code = $lieu->descr['nom']; |
| 265 | 265 | $skel = $lieu->descr['sourcefile']; |
| 266 | 266 | $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
| 267 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 267 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette').'#L'.$ligne; |
|
| 268 | 268 | $skel = "<a href='$h3'><b>$skel</b></a>"; |
| 269 | 269 | if ($boucle) { |
| 270 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 270 | + $h3 = parametre_url($h2.$boucle, 'var_mode_affiche', 'boucle'); |
|
| 271 | 271 | $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // Requete erronee |
| 357 | - $err = "<b>" . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 357 | + $err = "<b>"._T('avis_erreur_mysql')." $errno</b><br /><tt>\n" |
|
| 358 | 358 | . spip_htmlspecialchars($msg) |
| 359 | 359 | . "\n<br /><span style='color: red'><b>" |
| 360 | 360 | . spip_htmlspecialchars($query) |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | // http://code.spip.net/@trouve_boucle_debug |
| 370 | 370 | function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = "") { |
| 371 | 371 | |
| 372 | - $id = $nom . $boucle; |
|
| 372 | + $id = $nom.$boucle; |
|
| 373 | 373 | if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
| 374 | 374 | foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
| 375 | 375 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 423 | + $incl = ','.$reg[1].'[.]\w$,'; |
|
| 424 | 424 | |
| 425 | 425 | foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
| 426 | 426 | if (preg_match($incl, $v)) { |
@@ -436,16 +436,13 @@ discard block |
||
| 436 | 436 | list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom); |
| 437 | 437 | |
| 438 | 438 | if (!$boucle) { |
| 439 | - return !$ligne ? "" : |
|
| 440 | - (" (" . |
|
| 441 | - (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 442 | - _T('squelette_ligne')) . |
|
| 439 | + return !$ligne ? "" : (" (". |
|
| 440 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : _T('squelette_ligne')). |
|
| 443 | 441 | " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
| 444 | 442 | } else { |
| 445 | 443 | $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
| 446 | 444 | |
| 447 | - return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 448 | - " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 445 | + 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>)"; |
|
| 449 | 446 | } |
| 450 | 447 | } |
| 451 | 448 | |
@@ -467,13 +464,13 @@ discard block |
||
| 467 | 464 | } |
| 468 | 465 | |
| 469 | 466 | $s = preg_replace(',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
| 470 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 467 | + '<\1>\2</\1><br />'."\n".'<\1>\3</\1>', |
|
| 471 | 468 | $s); |
| 472 | 469 | |
| 473 | 470 | |
| 474 | 471 | $tableau = explode("<br />", $s); |
| 475 | 472 | |
| 476 | - $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"; |
|
| 473 | + $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"; |
|
| 477 | 474 | |
| 478 | 475 | $format10 = str_replace('white', 'lightgrey', $format); |
| 479 | 476 | $formaterr = "color: red;"; |
@@ -517,7 +514,7 @@ discard block |
||
| 517 | 514 | . '" style="cursor: pointer;">' |
| 518 | 515 | . ($nocpt ? '' : _T('info_numero_abbreviation')) |
| 519 | 516 | . "</div> |
| 520 | - " . $res . "</div>\n"; |
|
| 517 | + " . $res."</div>\n"; |
|
| 521 | 518 | } |
| 522 | 519 | |
| 523 | 520 | // l'environnement graphique du debuggueur |
@@ -538,14 +535,14 @@ discard block |
||
| 538 | 535 | if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
| 539 | 536 | list($legend, $texte, $res2) = debusquer_source($fonc, $mode); |
| 540 | 537 | $texte .= $res2; |
| 541 | - } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 542 | - $legend = _T('zbug_' . $mode); |
|
| 543 | - $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 538 | + } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc.'tout'])) { |
|
| 539 | + $legend = _T('zbug_'.$mode); |
|
| 540 | + $texte = $GLOBALS['debug_objets'][$mode][$fonc.'tout']; |
|
| 544 | 541 | $texte = ancre_texte($texte, array('', '')); |
| 545 | 542 | } |
| 546 | 543 | } else { |
| 547 | 544 | if (strlen(trim($res))) { |
| 548 | - return "<img src='" . chemin_image('compat-16.png') . "' 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>"; |
|
| 545 | + return "<img src='".chemin_image('compat-16.png')."' 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>"; |
|
| 549 | 546 | } else { |
| 550 | 547 | // cas de l'appel sur erreur: montre la page |
| 551 | 548 | return isset($GLOBALS['debug_objets']['resultat']['tout']) |
@@ -555,7 +552,7 @@ discard block |
||
| 555 | 552 | } |
| 556 | 553 | } else { |
| 557 | 554 | $valider = charger_fonction('valider', 'xml'); |
| 558 | - $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 555 | + $val = $valider($GLOBALS['debug_objets']['validation'][$fonc.'tout']); |
|
| 559 | 556 | // Si erreur, signaler leur nombre dans le formulaire admin |
| 560 | 557 | $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
| 561 | 558 | list($texte, $err) = emboite_texte($val, $fonc, $self); |
@@ -566,14 +563,14 @@ discard block |
||
| 566 | 563 | } else { |
| 567 | 564 | $err = ": $err"; |
| 568 | 565 | } |
| 569 | - $legend = _T('validation') . ' ' . $err; |
|
| 566 | + $legend = _T('validation').' '.$err; |
|
| 570 | 567 | $res = $id = ''; |
| 571 | 568 | } |
| 572 | 569 | |
| 573 | 570 | return !trim($texte) ? '' : ( |
| 574 | - "<img src='" . chemin_image('compat-16.png') . "' 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" |
|
| 571 | + "<img src='".chemin_image('compat-16.png')."' 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" |
|
| 575 | 572 | . "<div id='debug_boucle'><fieldset$id><legend>" |
| 576 | - . "<a href='" . $self . "#f_" . substr($fonc, 0, 37) . "'> ↑ " |
|
| 573 | + . "<a href='".$self."#f_".substr($fonc, 0, 37)."'> ↑ " |
|
| 577 | 574 | . ($legend ? $legend : $mode) |
| 578 | 575 | . "</a></legend>" |
| 579 | 576 | . $texte |
@@ -585,7 +582,7 @@ discard block |
||
| 585 | 582 | // http://code.spip.net/@emboite_texte |
| 586 | 583 | function emboite_texte($res, $fonc = '', $self = '') { |
| 587 | 584 | $errs = $res->err; |
| 588 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 585 | + $texte = $res->entete.($errs ? '' : $res->page); |
|
| 589 | 586 | |
| 590 | 587 | if (!$texte and !$errs) { |
| 591 | 588 | return array(ancre_texte('', array('', '')), false); |
@@ -642,7 +639,7 @@ discard block |
||
| 642 | 639 | $err = "<h2 style='text-align: center'>" |
| 643 | 640 | . $i |
| 644 | 641 | . "<a href='#fin_err'>" |
| 645 | - . " " . _T('erreur_texte') |
|
| 642 | + . " "._T('erreur_texte') |
|
| 646 | 643 | . "</a></h2><table id='debut_err' style='width: 100%'>" |
| 647 | 644 | . $err |
| 648 | 645 | . " </table><a id='fin_err'></a>"; |
@@ -652,9 +649,9 @@ discard block |
||
| 652 | 649 | list($msg, $fermant, $ouvrant) = $errs[0]; |
| 653 | 650 | $rf = reference_boucle_debug($fermant, $fonc, $self); |
| 654 | 651 | $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
| 655 | - $err = $msg . |
|
| 656 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 657 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 652 | + $err = $msg. |
|
| 653 | + "<a href='#L".$fermant."'>$fermant</a>$rf<br />". |
|
| 654 | + "<a href='#L".$ouvrant."'>$ouvrant</a>$ro"; |
|
| 658 | 655 | |
| 659 | 656 | return array(ancre_texte($texte, array(array($ouvrant), array($fermant))), $err); |
| 660 | 657 | } |
@@ -686,7 +683,7 @@ discard block |
||
| 686 | 683 | $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T('zbug_profile', |
| 687 | 684 | array('time' => $GLOBALS['debug_objets']['profile'][$sourcefile])); |
| 688 | 685 | |
| 689 | - $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 686 | + $res .= "<fieldset id='f_".$nom."'><legend>" |
|
| 690 | 687 | . $t_skel |
| 691 | 688 | . ' ' |
| 692 | 689 | . $sourcefile |
@@ -701,7 +698,7 @@ discard block |
||
| 701 | 698 | . "'>" |
| 702 | 699 | . _T('zbug_calcul') |
| 703 | 700 | . "</a></legend>" |
| 704 | - . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 701 | + . (!$temps ? '' : ("\n<span style='display:block;float:".$GLOBALS['spip_lang_right']."'>$temps</span><br />")) |
|
| 705 | 702 | . debusquer_contexte($contexte[$sourcefile]) |
| 706 | 703 | . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
| 707 | 704 | . "</fieldset>\n"; |
@@ -722,33 +719,33 @@ discard block |
||
| 722 | 719 | $nom = $boucle->id_boucle; |
| 723 | 720 | $req = $boucle->type_requete; |
| 724 | 721 | $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
| 725 | - $self2 = $self . "&var_mode_objet=" . $objet; |
|
| 726 | - |
|
| 727 | - $res .= "\n<tr style='background-color: " . |
|
| 728 | - ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 729 | - "'><td align='right'>$i</td><td>\n" . |
|
| 730 | - "<a class='debug_link_boucle' href='" . |
|
| 731 | - $self2 . |
|
| 732 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 733 | - _T('zbug_boucle') . |
|
| 734 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 735 | - $self2 . |
|
| 736 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 737 | - _T('zbug_resultat') . |
|
| 738 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 739 | - $self2 . |
|
| 740 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 741 | - _T('zbug_code') . |
|
| 742 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 743 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 744 | - "'>" . |
|
| 745 | - _T('zbug_calcul') . |
|
| 746 | - "</a></td><td>\n" . |
|
| 747 | - (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 748 | - "</td><td>\n" . |
|
| 749 | - $req . |
|
| 750 | - "</td><td>\n" . |
|
| 751 | - spip_htmlspecialchars($crit) . |
|
| 722 | + $self2 = $self."&var_mode_objet=".$objet; |
|
| 723 | + |
|
| 724 | + $res .= "\n<tr style='background-color: ". |
|
| 725 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff'). |
|
| 726 | + "'><td align='right'>$i</td><td>\n". |
|
| 727 | + "<a class='debug_link_boucle' href='". |
|
| 728 | + $self2. |
|
| 729 | + "&var_mode_affiche=boucle#f_$nom_skel'>". |
|
| 730 | + _T('zbug_boucle'). |
|
| 731 | + "</a></td><td>\n<a class='debug_link_boucle' href='". |
|
| 732 | + $self2. |
|
| 733 | + "&var_mode_affiche=resultat#f_$nom_skel'>". |
|
| 734 | + _T('zbug_resultat'). |
|
| 735 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 736 | + $self2. |
|
| 737 | + "&var_mode_affiche=code#f_$nom_skel'>". |
|
| 738 | + _T('zbug_code'). |
|
| 739 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 740 | + str_replace('var_mode=', 'var_profile=', $self2). |
|
| 741 | + "'>". |
|
| 742 | + _T('zbug_calcul'). |
|
| 743 | + "</a></td><td>\n". |
|
| 744 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom). |
|
| 745 | + "</td><td>\n". |
|
| 746 | + $req. |
|
| 747 | + "</td><td>\n". |
|
| 748 | + spip_htmlspecialchars($crit). |
|
| 752 | 749 | "</td></tr>"; |
| 753 | 750 | } |
| 754 | 751 | } |
@@ -775,7 +772,7 @@ discard block |
||
| 775 | 772 | } |
| 776 | 773 | // permettre le copier/coller facile |
| 777 | 774 | // $res = ancre_texte($req, array(), true); |
| 778 | - $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 775 | + $res = "<div id='T".md5($req)."'>\n<pre>\n".$req."</pre>\n</div>\n"; |
|
| 779 | 776 | // formatage et affichage des resultats bruts de la requete |
| 780 | 777 | $ress_req = spip_query($req); |
| 781 | 778 | $brut_sql = ''; |
@@ -785,10 +782,10 @@ discard block |
||
| 785 | 782 | $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
| 786 | 783 | while ($retours_sql = sql_fetch($ress_req)) { |
| 787 | 784 | if ($num <= $max_aff) { |
| 788 | - $brut_sql .= "<h3>" . ($num == 1 ? $num . " sur " . sql_count($ress_req) : $num) . "</h3>"; |
|
| 785 | + $brut_sql .= "<h3>".($num == 1 ? $num." sur ".sql_count($ress_req) : $num)."</h3>"; |
|
| 789 | 786 | $brut_sql .= "<p>"; |
| 790 | 787 | foreach ($retours_sql as $key => $val) { |
| 791 | - $brut_sql .= "<strong>" . $key . "</strong> => " . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 788 | + $brut_sql .= "<strong>".$key."</strong> => ".spip_htmlspecialchars(couper($val, 150))."<br />\n"; |
|
| 792 | 789 | } |
| 793 | 790 | $brut_sql .= "</p>"; |
| 794 | 791 | } |
@@ -799,15 +796,15 @@ discard block |
||
| 799 | 796 | // ne pas afficher les $contexte_inclus |
| 800 | 797 | $view = preg_replace(",<\?php.+\?[>],Uims", "", $view); |
| 801 | 798 | if ($view) { |
| 802 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . "</fieldset>"; |
|
| 799 | + $res2 .= "\n<br /><fieldset>".interdire_scripts($view)."</fieldset>"; |
|
| 803 | 800 | } |
| 804 | 801 | } |
| 805 | 802 | |
| 806 | 803 | } elseif ($affiche == 'code') { |
| 807 | 804 | $legend = $nom; |
| 808 | - $res = ancre_texte("<" . "?php\n" . $quoi . "\n?" . ">"); |
|
| 805 | + $res = ancre_texte("<"."?php\n".$quoi."\n?".">"); |
|
| 809 | 806 | } elseif ($affiche == 'boucle') { |
| 810 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 807 | + $legend = _T('zbug_boucle').' '.$nom; |
|
| 811 | 808 | // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
| 812 | 809 | $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
| 813 | 810 | $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
@@ -826,23 +823,23 @@ discard block |
||
| 826 | 823 | include_spip('public/assembler'); // pour inclure_balise_dynamique |
| 827 | 824 | include_spip('inc/texte'); // pour corriger_typo |
| 828 | 825 | |
| 829 | - return _DOCTYPE_ECRIRE . |
|
| 830 | - html_lang_attributes() . |
|
| 831 | - "<head>\n<title>" . |
|
| 832 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 833 | - _T('admin_debug') . ' ' . $titre . ' (' . |
|
| 834 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 835 | - ")</title>\n" . |
|
| 836 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 837 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 838 | - "' />\n" . |
|
| 826 | + return _DOCTYPE_ECRIRE. |
|
| 827 | + html_lang_attributes(). |
|
| 828 | + "<head>\n<title>". |
|
| 829 | + ('SPIP '.$GLOBALS['spip_version_affichee'].' '. |
|
| 830 | + _T('admin_debug').' '.$titre.' ('. |
|
| 831 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))). |
|
| 832 | + ")</title>\n". |
|
| 833 | + "<meta http-equiv='Content-Type' content='text/html". |
|
| 834 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : ''). |
|
| 835 | + "' />\n". |
|
| 839 | 836 | http_script('', 'jquery.js') |
| 840 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 841 | - . "' type='text/css' />" . |
|
| 842 | - "</head>\n" . |
|
| 843 | - "<body style='margin:0 10px;'>\n" . |
|
| 844 | - "<div id='spip-debug-header'>" . |
|
| 845 | - $corps . |
|
| 846 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 837 | + . "<link rel='stylesheet' href='".url_absolue(find_in_path('spip_admin.css')) |
|
| 838 | + . "' type='text/css' />". |
|
| 839 | + "</head>\n". |
|
| 840 | + "<body style='margin:0 10px;'>\n". |
|
| 841 | + "<div id='spip-debug-header'>". |
|
| 842 | + $corps. |
|
| 843 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false). |
|
| 847 | 844 | '</div></body></html>'; |
| 848 | 845 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/lang'); |
@@ -19,16 +19,16 @@ discard block |
||
| 19 | 19 | // NB: mes_fonctions peut initialiser $dossier_squelettes (old-style) |
| 20 | 20 | // donc il faut l'inclure "en globals" |
| 21 | 21 | if ($f = find_in_path('mes_fonctions.php')) { |
| 22 | - global $dossier_squelettes; |
|
| 23 | - include_once(_ROOT_CWD . $f); |
|
| 22 | + global $dossier_squelettes; |
|
| 23 | + include_once(_ROOT_CWD . $f); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
| 27 | - // chargement optimise precompile |
|
| 28 | - include_once(_CACHE_PLUGINS_FCT); |
|
| 27 | + // chargement optimise precompile |
|
| 28 | + include_once(_CACHE_PLUGINS_FCT); |
|
| 29 | 29 | } |
| 30 | 30 | if (test_espace_prive()) { |
| 31 | - include_spip('inc/filtres_ecrire'); |
|
| 31 | + include_spip('inc/filtres_ecrire'); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | # Determine le squelette associe a une requete |
@@ -46,167 +46,167 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | // http://code.spip.net/@public_parametrer_dist |
| 48 | 48 | function public_parametrer_dist($fond, $contexte = '', $cache = '', $connect = '') { |
| 49 | - static $composer, $styliser, $notes = null; |
|
| 50 | - $page = tester_redirection($fond, $contexte, $connect); |
|
| 51 | - if ($page) { |
|
| 52 | - return $page; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - if (isset($contexte['lang'])) { |
|
| 56 | - $lang = $contexte['lang']; |
|
| 57 | - } elseif (!isset($lang)) { |
|
| 58 | - $lang = $GLOBALS['meta']['langue_site']; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']); |
|
| 62 | - if ($select) { |
|
| 63 | - $select = lang_select($lang); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug'); |
|
| 67 | - |
|
| 68 | - if (!$styliser) { |
|
| 69 | - $styliser = charger_fonction('styliser', 'public'); |
|
| 70 | - } |
|
| 71 | - list($skel, $mime_type, $gram, $sourcefile) = |
|
| 72 | - $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
|
| 73 | - |
|
| 74 | - if ($skel) { |
|
| 75 | - |
|
| 76 | - // sauver le nom de l'eventuel squelette en cours d'execution |
|
| 77 | - // (recursion possible a cause des modeles) |
|
| 78 | - if ($debug) { |
|
| 79 | - $courant = @$GLOBALS['debug_objets']['courant']; |
|
| 80 | - $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - // charger le squelette en specifiant les langages cibles et source |
|
| 84 | - // au cas il faudrait le compiler (source posterieure au resultat) |
|
| 85 | - |
|
| 86 | - if (!$composer) { |
|
| 87 | - $composer = charger_fonction('composer', 'public'); |
|
| 88 | - } |
|
| 89 | - $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect); |
|
| 90 | - } else { |
|
| 91 | - $fonc = ''; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if (!$fonc) { // squelette inconnu (==='') ou faux (===false) |
|
| 95 | - $page = $fonc; |
|
| 96 | - } else { |
|
| 97 | - // Preparer l'appel de la fonction principale du squelette |
|
| 98 | - |
|
| 99 | - spip_timer($a = 'calcul page ' . rand(0, 1000)); |
|
| 100 | - |
|
| 101 | - // On cree un marqueur de notes unique lie a cette composition |
|
| 102 | - // et on enregistre l'etat courant des globales de notes... |
|
| 103 | - if (is_null($notes)) { |
|
| 104 | - $notes = charger_fonction('notes', 'inc', true); |
|
| 105 | - } |
|
| 106 | - if ($notes) { |
|
| 107 | - $notes('', 'empiler'); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - // Rajouter d'office ces deux parametres |
|
| 111 | - // (mais vaudrait mieux que le compilateur sache le simuler |
|
| 112 | - // car ca interdit l'usage de criteres conditionnels dessus). |
|
| 113 | - if (!isset($contexte['date'])) { |
|
| 114 | - $contexte['date'] = date("Y-m-d H:i:s"); |
|
| 115 | - $contexte['date_default'] = true; |
|
| 116 | - } else { |
|
| 117 | - $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - if (!isset($contexte['date_redac'])) { |
|
| 121 | - $contexte['date_redac'] = date("Y-m-d H:i:s"); |
|
| 122 | - $contexte['date_redac_default'] = true; |
|
| 123 | - } else { |
|
| 124 | - $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - // Passer le nom du cache pour produire sa destruction automatique |
|
| 128 | - $page = $fonc(array('cache' => $cache), array($contexte)); |
|
| 129 | - |
|
| 130 | - // Restituer les globales de notes telles qu'elles etaient avant l'appel |
|
| 131 | - // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent* |
|
| 132 | - // etre dans son resultat, autrement elles ne seraient pas prises en |
|
| 133 | - // compte a chaque calcul d'un texte contenant un modele, mais seulement |
|
| 134 | - // quand le modele serait calcule, et on aurait des resultats incoherents) |
|
| 135 | - if ($notes) { |
|
| 136 | - $notes('', 'depiler'); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - // reinjecter en dynamique la pile des notes |
|
| 140 | - // si il y a des inclure dynamiques |
|
| 141 | - // si la pile n'est pas vide |
|
| 142 | - // la generalisation de cette injection permettrait de corriger le point juste au dessus |
|
| 143 | - // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
|
| 144 | - if ($notes) { |
|
| 145 | - $page['notes'] = $notes('', 'sauver_etat'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - // spip_log: un joli contexte |
|
| 149 | - $infos = presenter_contexte(array_filter($contexte)); |
|
| 150 | - |
|
| 151 | - $profile = spip_timer($a); |
|
| 152 | - spip_log("calcul ($profile) [$skel] $infos" |
|
| 153 | - . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 154 | - |
|
| 155 | - if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){ |
|
| 156 | - spip_log("calcul ($profile) [$skel] $infos" |
|
| 157 | - .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - if ($debug) { |
|
| 161 | - // si c'est ce que demande le debusqueur, lui passer la main |
|
| 162 | - $t = strlen($page['texte']) ? $page['texte'] : " "; |
|
| 163 | - $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 164 | - $GLOBALS['debug_objets']['courant'] = $courant; |
|
| 165 | - $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
|
| 166 | - if ($GLOBALS['debug_objets']['sourcefile'] |
|
| 167 | - and (_request('var_mode_objet') == $fonc) |
|
| 168 | - and (_request('var_mode_affiche') == 'resultat') |
|
| 169 | - ) { |
|
| 170 | - erreur_squelette(); |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - // Si #CACHE{} n'etait pas la, le mettre a $delais |
|
| 174 | - if (!isset($page['entetes']['X-Spip-Cache'])) { |
|
| 175 | - // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut |
|
| 176 | - // si aucun #CACHE{} spécifié |
|
| 177 | - // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
|
| 178 | - // entre public et prive |
|
| 179 | - if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) { |
|
| 180 | - $page['entetes']['X-Spip-Cache'] = 0; |
|
| 181 | - } else { |
|
| 182 | - $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : 36000; |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - $page['contexte'] = $contexte; |
|
| 187 | - |
|
| 188 | - // faire remonter le fichier source |
|
| 189 | - static $js_inclus = false; |
|
| 190 | - if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
|
| 191 | - $page['sourcefile'] = $sourcefile; |
|
| 192 | - $page['texte'] = |
|
| 193 | - "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>" |
|
| 194 | - . ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>"); |
|
| 195 | - $js_inclus = true; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // Si un modele contenait #SESSION, on note l'info dans $page |
|
| 199 | - if (isset($GLOBALS['cache_utilise_session'])) { |
|
| 200 | - $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session']; |
|
| 201 | - unset($GLOBALS['cache_utilise_session']); |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - if ($select) { |
|
| 206 | - lang_select(); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - return $page; |
|
| 49 | + static $composer, $styliser, $notes = null; |
|
| 50 | + $page = tester_redirection($fond, $contexte, $connect); |
|
| 51 | + if ($page) { |
|
| 52 | + return $page; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + if (isset($contexte['lang'])) { |
|
| 56 | + $lang = $contexte['lang']; |
|
| 57 | + } elseif (!isset($lang)) { |
|
| 58 | + $lang = $GLOBALS['meta']['langue_site']; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']); |
|
| 62 | + if ($select) { |
|
| 63 | + $select = lang_select($lang); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug'); |
|
| 67 | + |
|
| 68 | + if (!$styliser) { |
|
| 69 | + $styliser = charger_fonction('styliser', 'public'); |
|
| 70 | + } |
|
| 71 | + list($skel, $mime_type, $gram, $sourcefile) = |
|
| 72 | + $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
|
| 73 | + |
|
| 74 | + if ($skel) { |
|
| 75 | + |
|
| 76 | + // sauver le nom de l'eventuel squelette en cours d'execution |
|
| 77 | + // (recursion possible a cause des modeles) |
|
| 78 | + if ($debug) { |
|
| 79 | + $courant = @$GLOBALS['debug_objets']['courant']; |
|
| 80 | + $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + // charger le squelette en specifiant les langages cibles et source |
|
| 84 | + // au cas il faudrait le compiler (source posterieure au resultat) |
|
| 85 | + |
|
| 86 | + if (!$composer) { |
|
| 87 | + $composer = charger_fonction('composer', 'public'); |
|
| 88 | + } |
|
| 89 | + $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect); |
|
| 90 | + } else { |
|
| 91 | + $fonc = ''; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if (!$fonc) { // squelette inconnu (==='') ou faux (===false) |
|
| 95 | + $page = $fonc; |
|
| 96 | + } else { |
|
| 97 | + // Preparer l'appel de la fonction principale du squelette |
|
| 98 | + |
|
| 99 | + spip_timer($a = 'calcul page ' . rand(0, 1000)); |
|
| 100 | + |
|
| 101 | + // On cree un marqueur de notes unique lie a cette composition |
|
| 102 | + // et on enregistre l'etat courant des globales de notes... |
|
| 103 | + if (is_null($notes)) { |
|
| 104 | + $notes = charger_fonction('notes', 'inc', true); |
|
| 105 | + } |
|
| 106 | + if ($notes) { |
|
| 107 | + $notes('', 'empiler'); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + // Rajouter d'office ces deux parametres |
|
| 111 | + // (mais vaudrait mieux que le compilateur sache le simuler |
|
| 112 | + // car ca interdit l'usage de criteres conditionnels dessus). |
|
| 113 | + if (!isset($contexte['date'])) { |
|
| 114 | + $contexte['date'] = date("Y-m-d H:i:s"); |
|
| 115 | + $contexte['date_default'] = true; |
|
| 116 | + } else { |
|
| 117 | + $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + if (!isset($contexte['date_redac'])) { |
|
| 121 | + $contexte['date_redac'] = date("Y-m-d H:i:s"); |
|
| 122 | + $contexte['date_redac_default'] = true; |
|
| 123 | + } else { |
|
| 124 | + $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + // Passer le nom du cache pour produire sa destruction automatique |
|
| 128 | + $page = $fonc(array('cache' => $cache), array($contexte)); |
|
| 129 | + |
|
| 130 | + // Restituer les globales de notes telles qu'elles etaient avant l'appel |
|
| 131 | + // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent* |
|
| 132 | + // etre dans son resultat, autrement elles ne seraient pas prises en |
|
| 133 | + // compte a chaque calcul d'un texte contenant un modele, mais seulement |
|
| 134 | + // quand le modele serait calcule, et on aurait des resultats incoherents) |
|
| 135 | + if ($notes) { |
|
| 136 | + $notes('', 'depiler'); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + // reinjecter en dynamique la pile des notes |
|
| 140 | + // si il y a des inclure dynamiques |
|
| 141 | + // si la pile n'est pas vide |
|
| 142 | + // la generalisation de cette injection permettrait de corriger le point juste au dessus |
|
| 143 | + // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
|
| 144 | + if ($notes) { |
|
| 145 | + $page['notes'] = $notes('', 'sauver_etat'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + // spip_log: un joli contexte |
|
| 149 | + $infos = presenter_contexte(array_filter($contexte)); |
|
| 150 | + |
|
| 151 | + $profile = spip_timer($a); |
|
| 152 | + spip_log("calcul ($profile) [$skel] $infos" |
|
| 153 | + . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 154 | + |
|
| 155 | + if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){ |
|
| 156 | + spip_log("calcul ($profile) [$skel] $infos" |
|
| 157 | + .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + if ($debug) { |
|
| 161 | + // si c'est ce que demande le debusqueur, lui passer la main |
|
| 162 | + $t = strlen($page['texte']) ? $page['texte'] : " "; |
|
| 163 | + $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 164 | + $GLOBALS['debug_objets']['courant'] = $courant; |
|
| 165 | + $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
|
| 166 | + if ($GLOBALS['debug_objets']['sourcefile'] |
|
| 167 | + and (_request('var_mode_objet') == $fonc) |
|
| 168 | + and (_request('var_mode_affiche') == 'resultat') |
|
| 169 | + ) { |
|
| 170 | + erreur_squelette(); |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + // Si #CACHE{} n'etait pas la, le mettre a $delais |
|
| 174 | + if (!isset($page['entetes']['X-Spip-Cache'])) { |
|
| 175 | + // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut |
|
| 176 | + // si aucun #CACHE{} spécifié |
|
| 177 | + // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
|
| 178 | + // entre public et prive |
|
| 179 | + if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) { |
|
| 180 | + $page['entetes']['X-Spip-Cache'] = 0; |
|
| 181 | + } else { |
|
| 182 | + $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : 36000; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + $page['contexte'] = $contexte; |
|
| 187 | + |
|
| 188 | + // faire remonter le fichier source |
|
| 189 | + static $js_inclus = false; |
|
| 190 | + if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
|
| 191 | + $page['sourcefile'] = $sourcefile; |
|
| 192 | + $page['texte'] = |
|
| 193 | + "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>" |
|
| 194 | + . ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>"); |
|
| 195 | + $js_inclus = true; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // Si un modele contenait #SESSION, on note l'info dans $page |
|
| 199 | + if (isset($GLOBALS['cache_utilise_session'])) { |
|
| 200 | + $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session']; |
|
| 201 | + unset($GLOBALS['cache_utilise_session']); |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + if ($select) { |
|
| 206 | + lang_select(); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + return $page; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -215,33 +215,33 @@ discard block |
||
| 215 | 215 | * @return string |
| 216 | 216 | */ |
| 217 | 217 | function presenter_contexte($contexte, $profondeur_max = 1, $max_lines = 0) { |
| 218 | - $infos = array(); |
|
| 219 | - $line = 0; |
|
| 220 | - foreach ($contexte as $var => $val) { |
|
| 221 | - $line++; |
|
| 222 | - if ($max_lines and $max_lines < $line) { |
|
| 223 | - $infos[] = '…'; |
|
| 224 | - break; |
|
| 225 | - } |
|
| 226 | - if (is_array($val)) { |
|
| 227 | - if ($profondeur_max > 0) { |
|
| 228 | - $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 229 | - } else { |
|
| 230 | - $val = 'array:' . count($val); |
|
| 231 | - } |
|
| 232 | - } elseif (is_object($val)) { |
|
| 233 | - $val = get_class($val); |
|
| 234 | - } elseif (strlen("$val") > 30) { |
|
| 235 | - $val = substr("$val", 0, 29) . '…'; |
|
| 236 | - if (strstr($val, ' ')) { |
|
| 237 | - $val = "'$val'"; |
|
| 238 | - } |
|
| 239 | - } elseif (strstr($val, ' ')) { |
|
| 240 | - $val = "'$val'"; |
|
| 241 | - } |
|
| 242 | - $infos[] = $var . '=' . $val; |
|
| 243 | - } |
|
| 244 | - return join(', ', $infos); |
|
| 218 | + $infos = array(); |
|
| 219 | + $line = 0; |
|
| 220 | + foreach ($contexte as $var => $val) { |
|
| 221 | + $line++; |
|
| 222 | + if ($max_lines and $max_lines < $line) { |
|
| 223 | + $infos[] = '…'; |
|
| 224 | + break; |
|
| 225 | + } |
|
| 226 | + if (is_array($val)) { |
|
| 227 | + if ($profondeur_max > 0) { |
|
| 228 | + $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 229 | + } else { |
|
| 230 | + $val = 'array:' . count($val); |
|
| 231 | + } |
|
| 232 | + } elseif (is_object($val)) { |
|
| 233 | + $val = get_class($val); |
|
| 234 | + } elseif (strlen("$val") > 30) { |
|
| 235 | + $val = substr("$val", 0, 29) . '…'; |
|
| 236 | + if (strstr($val, ' ')) { |
|
| 237 | + $val = "'$val'"; |
|
| 238 | + } |
|
| 239 | + } elseif (strstr($val, ' ')) { |
|
| 240 | + $val = "'$val'"; |
|
| 241 | + } |
|
| 242 | + $infos[] = $var . '=' . $val; |
|
| 243 | + } |
|
| 244 | + return join(', ', $infos); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
@@ -258,11 +258,11 @@ discard block |
||
| 258 | 258 | * @return array|bool |
| 259 | 259 | */ |
| 260 | 260 | function tester_redirection($fond, $contexte, $connect) { |
| 261 | - static $tester_redirection = null; |
|
| 262 | - if (is_null($tester_redirection)) { |
|
| 263 | - $tester_redirection = charger_fonction('tester_redirection', 'public'); |
|
| 264 | - } |
|
| 265 | - return $tester_redirection($fond, $contexte, $connect); |
|
| 261 | + static $tester_redirection = null; |
|
| 262 | + if (is_null($tester_redirection)) { |
|
| 263 | + $tester_redirection = charger_fonction('tester_redirection', 'public'); |
|
| 264 | + } |
|
| 265 | + return $tester_redirection($fond, $contexte, $connect); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
@@ -278,40 +278,40 @@ discard block |
||
| 278 | 278 | * @return array|bool |
| 279 | 279 | */ |
| 280 | 280 | function public_tester_redirection_dist($fond, $contexte, $connect) { |
| 281 | - if ($fond == 'article' |
|
| 282 | - and $id_article = intval($contexte['id_article']) |
|
| 283 | - ) { |
|
| 284 | - include_spip('public/quete'); // pour quete_virtuel et ses dependances |
|
| 285 | - $m = quete_virtuel($id_article, $connect); |
|
| 286 | - if (strlen($m)) { |
|
| 287 | - include_spip('inc/texte'); |
|
| 288 | - // les navigateurs pataugent si l'URL est vide |
|
| 289 | - if ($url = virtuel_redirige($m, true)) { |
|
| 290 | - // passer en url absolue car cette redirection pourra |
|
| 291 | - // etre utilisee dans un contexte d'url qui change |
|
| 292 | - // y compris url arbo |
|
| 293 | - $status = 302; |
|
| 294 | - if (defined('_STATUS_REDIRECTION_VIRTUEL')) { |
|
| 295 | - $status = _STATUS_REDIRECTION_VIRTUEL; |
|
| 296 | - } |
|
| 297 | - if (!preg_match(',^\w+:,', $url)) { |
|
| 298 | - include_spip('inc/filtres_mini'); |
|
| 299 | - $url = url_absolue($url); |
|
| 300 | - } |
|
| 301 | - $url = str_replace('&', '&', $url); |
|
| 302 | - |
|
| 303 | - return array( |
|
| 304 | - 'texte' => "<" |
|
| 305 | - . "?php include_spip('inc/headers');redirige_par_entete('" |
|
| 306 | - . texte_script($url) |
|
| 307 | - . "','',$status);" |
|
| 308 | - . "?" . ">", |
|
| 309 | - 'process_ins' => 'php', |
|
| 310 | - 'status' => $status |
|
| 311 | - ); |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - return false; |
|
| 281 | + if ($fond == 'article' |
|
| 282 | + and $id_article = intval($contexte['id_article']) |
|
| 283 | + ) { |
|
| 284 | + include_spip('public/quete'); // pour quete_virtuel et ses dependances |
|
| 285 | + $m = quete_virtuel($id_article, $connect); |
|
| 286 | + if (strlen($m)) { |
|
| 287 | + include_spip('inc/texte'); |
|
| 288 | + // les navigateurs pataugent si l'URL est vide |
|
| 289 | + if ($url = virtuel_redirige($m, true)) { |
|
| 290 | + // passer en url absolue car cette redirection pourra |
|
| 291 | + // etre utilisee dans un contexte d'url qui change |
|
| 292 | + // y compris url arbo |
|
| 293 | + $status = 302; |
|
| 294 | + if (defined('_STATUS_REDIRECTION_VIRTUEL')) { |
|
| 295 | + $status = _STATUS_REDIRECTION_VIRTUEL; |
|
| 296 | + } |
|
| 297 | + if (!preg_match(',^\w+:,', $url)) { |
|
| 298 | + include_spip('inc/filtres_mini'); |
|
| 299 | + $url = url_absolue($url); |
|
| 300 | + } |
|
| 301 | + $url = str_replace('&', '&', $url); |
|
| 302 | + |
|
| 303 | + return array( |
|
| 304 | + 'texte' => "<" |
|
| 305 | + . "?php include_spip('inc/headers');redirige_par_entete('" |
|
| 306 | + . texte_script($url) |
|
| 307 | + . "','',$status);" |
|
| 308 | + . "?" . ">", |
|
| 309 | + 'process_ins' => 'php', |
|
| 310 | + 'status' => $status |
|
| 311 | + ); |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + return false; |
|
| 317 | 317 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | // donc il faut l'inclure "en globals" |
| 21 | 21 | if ($f = find_in_path('mes_fonctions.php')) { |
| 22 | 22 | global $dossier_squelettes; |
| 23 | - include_once(_ROOT_CWD . $f); |
|
| 23 | + include_once(_ROOT_CWD.$f); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | } else { |
| 97 | 97 | // Preparer l'appel de la fonction principale du squelette |
| 98 | 98 | |
| 99 | - spip_timer($a = 'calcul page ' . rand(0, 1000)); |
|
| 99 | + spip_timer($a = 'calcul page '.rand(0, 1000)); |
|
| 100 | 100 | |
| 101 | 101 | // On cree un marqueur de notes unique lie a cette composition |
| 102 | 102 | // et on enregistre l'etat courant des globales de notes... |
@@ -150,17 +150,17 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | $profile = spip_timer($a); |
| 152 | 152 | spip_log("calcul ($profile) [$skel] $infos" |
| 153 | - . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 153 | + . ' ('.strlen($page['texte']).' octets)'); |
|
| 154 | 154 | |
| 155 | - if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){ |
|
| 155 | + if (defined('_CALCUL_PROFILER') AND intval($profile) > _CALCUL_PROFILER) { |
|
| 156 | 156 | spip_log("calcul ($profile) [$skel] $infos" |
| 157 | - .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT); |
|
| 157 | + .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'], "profiler"._LOG_AVERTISSEMENT); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if ($debug) { |
| 161 | 161 | // si c'est ce que demande le debusqueur, lui passer la main |
| 162 | 162 | $t = strlen($page['texte']) ? $page['texte'] : " "; |
| 163 | - $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 163 | + $GLOBALS['debug_objets']['resultat'][$fonc.'tout'] = $t; |
|
| 164 | 164 | $GLOBALS['debug_objets']['courant'] = $courant; |
| 165 | 165 | $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
| 166 | 166 | if ($GLOBALS['debug_objets']['sourcefile'] |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
| 191 | 191 | $page['sourcefile'] = $sourcefile; |
| 192 | 192 | $page['texte'] = |
| 193 | - "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . "</h6>" . $page['texte'] . "</div>" |
|
| 193 | + "<div class='inclure_blocs'><h6>".$page['sourcefile']."</h6>".$page['texte']."</div>" |
|
| 194 | 194 | . ($js_inclus ? "" : "<script type='text/javascript'>jQuery(function(){jQuery('.inclure_blocs > h6:first-child').hover(function(){jQuery(this).parent().addClass('hover')},function(){jQuery(this).parent().removeClass('hover')})});</script>"); |
| 195 | 195 | $js_inclus = true; |
| 196 | 196 | } |
@@ -225,21 +225,21 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | if (is_array($val)) { |
| 227 | 227 | if ($profondeur_max > 0) { |
| 228 | - $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 228 | + $val = 'array:'.count($val).'('.presenter_contexte($val, $profondeur_max - 1, 3).')'; |
|
| 229 | 229 | } else { |
| 230 | - $val = 'array:' . count($val); |
|
| 230 | + $val = 'array:'.count($val); |
|
| 231 | 231 | } |
| 232 | 232 | } elseif (is_object($val)) { |
| 233 | 233 | $val = get_class($val); |
| 234 | 234 | } elseif (strlen("$val") > 30) { |
| 235 | - $val = substr("$val", 0, 29) . '…'; |
|
| 235 | + $val = substr("$val", 0, 29).'…'; |
|
| 236 | 236 | if (strstr($val, ' ')) { |
| 237 | 237 | $val = "'$val'"; |
| 238 | 238 | } |
| 239 | 239 | } elseif (strstr($val, ' ')) { |
| 240 | 240 | $val = "'$val'"; |
| 241 | 241 | } |
| 242 | - $infos[] = $var . '=' . $val; |
|
| 242 | + $infos[] = $var.'='.$val; |
|
| 243 | 243 | } |
| 244 | 244 | return join(', ', $infos); |
| 245 | 245 | } |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | . "?php include_spip('inc/headers');redirige_par_entete('" |
| 306 | 306 | . texte_script($url) |
| 307 | 307 | . "','',$status);" |
| 308 | - . "?" . ">", |
|
| 308 | + . "?".">", |
|
| 309 | 309 | 'process_ins' => 'php', |
| 310 | 310 | 'status' => $status |
| 311 | 311 | ); |
@@ -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 | include_spip('inc/texte'); |
@@ -43,239 +43,239 @@ discard block |
||
| 43 | 43 | // http://code.spip.net/@public_composer_dist |
| 44 | 44 | function public_composer_dist($squelette, $mime_type, $gram, $source, $connect = '') { |
| 45 | 45 | |
| 46 | - $nom = calculer_nom_fonction_squel($squelette, $mime_type, $connect); |
|
| 47 | - |
|
| 48 | - // si deja en memoire (INCLURE a repetition) c'est bon. |
|
| 49 | - if (function_exists($nom)) { |
|
| 50 | - return $nom; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 54 | - $GLOBALS['debug_objets']['courant'] = $nom; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $phpfile = sous_repertoire(_DIR_SKELS, '', false, true) . $nom . '.php'; |
|
| 58 | - |
|
| 59 | - // si squelette est deja compile et perenne, le charger |
|
| 60 | - if (!squelette_obsolete($phpfile, $source)) { |
|
| 61 | - include_once $phpfile; |
|
| 62 | - #if (!squelette_obsolete($phpfile, $source) |
|
| 63 | - # AND lire_fichier ($phpfile, $skel_code, |
|
| 64 | - # array('critique' => 'oui', 'phpcheck' => 'oui'))){ |
|
| 65 | - ## eval('?'.'>'.$skel_code); |
|
| 66 | - # spip_log($skel_code, 'comp') |
|
| 67 | - #} |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if (file_exists($lib = $squelette . '_fonctions' . '.php')) { |
|
| 71 | - include_once $lib; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - // tester si le eval ci-dessus a mis le squelette en memoire |
|
| 75 | - |
|
| 76 | - if (function_exists($nom)) { |
|
| 77 | - return $nom; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // charger le source, si possible, et compiler |
|
| 81 | - $skel_code = ''; |
|
| 82 | - if (lire_fichier($source, $skel)) { |
|
| 83 | - $compiler = charger_fonction('compiler', 'public'); |
|
| 84 | - $skel_code = $compiler($skel, $nom, $gram, $source, $connect); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // Ne plus rien faire si le compilateur n'a pas pu operer. |
|
| 88 | - if (!$skel_code) { |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - foreach ($skel_code as $id => $boucle) { |
|
| 93 | - $f = $boucle->return; |
|
| 94 | - try { |
|
| 95 | - // @todo : a remplacer quand _PHP_MIN >= 7 |
|
| 96 | - // eval("return true; $f ;"); |
|
| 97 | - // PHP 5.x compat |
|
| 98 | - if ($ok = @eval("return true; $f ;") === false) { |
|
| 99 | - // Code syntaxiquement faux (critere etc mal programme') |
|
| 100 | - $msg = _T('zbug_erreur_compilation'); |
|
| 101 | - erreur_squelette($msg, $boucle); |
|
| 102 | - // continuer pour trouver d'autres fautes eventuelles |
|
| 103 | - // mais prevenir que c'est mort |
|
| 104 | - $nom = ''; |
|
| 105 | - } |
|
| 106 | - } catch (\ParseError $e) { |
|
| 107 | - // Code syntaxiquement faux (critere etc mal programme') |
|
| 108 | - $msg = _T('zbug_erreur_compilation') . ' | Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 109 | - erreur_squelette($msg, $boucle); |
|
| 110 | - // continuer pour trouver d'autres fautes eventuelles |
|
| 111 | - // mais prevenir que c'est mort |
|
| 112 | - $nom = ''; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - // Contexte de compil inutile a present |
|
| 116 | - // (mais la derniere valeur de $boucle est utilisee ci-dessous) |
|
| 117 | - $skel_code[$id] = $f; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $code = ''; |
|
| 121 | - if ($nom) { |
|
| 122 | - // Si le code est bon, concatener et mettre en cache |
|
| 123 | - if (function_exists($nom)) { |
|
| 124 | - $code = squelette_traduit($skel, $source, $phpfile, $skel_code); |
|
| 125 | - } else { |
|
| 126 | - // code semantiquement faux: bug du compilateur |
|
| 127 | - // $boucle est en fait ici la fct principale du squelette |
|
| 128 | - $msg = _T('zbug_erreur_compilation'); |
|
| 129 | - erreur_squelette($msg, $boucle); |
|
| 130 | - $nom = ''; |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 135 | - |
|
| 136 | - // Tracer ce qui vient d'etre compile |
|
| 137 | - $GLOBALS['debug_objets']['code'][$nom . 'tout'] = $code; |
|
| 138 | - |
|
| 139 | - // si c'est ce que demande le debusqueur, lui passer la main |
|
| 140 | - if ($GLOBALS['debug_objets']['sourcefile'] |
|
| 141 | - and (_request('var_mode_objet') == $nom) |
|
| 142 | - and (_request('var_mode_affiche') == 'code') |
|
| 143 | - ) { |
|
| 144 | - erreur_squelette(); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - return $nom ? $nom : false; |
|
| 46 | + $nom = calculer_nom_fonction_squel($squelette, $mime_type, $connect); |
|
| 47 | + |
|
| 48 | + // si deja en memoire (INCLURE a repetition) c'est bon. |
|
| 49 | + if (function_exists($nom)) { |
|
| 50 | + return $nom; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 54 | + $GLOBALS['debug_objets']['courant'] = $nom; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $phpfile = sous_repertoire(_DIR_SKELS, '', false, true) . $nom . '.php'; |
|
| 58 | + |
|
| 59 | + // si squelette est deja compile et perenne, le charger |
|
| 60 | + if (!squelette_obsolete($phpfile, $source)) { |
|
| 61 | + include_once $phpfile; |
|
| 62 | + #if (!squelette_obsolete($phpfile, $source) |
|
| 63 | + # AND lire_fichier ($phpfile, $skel_code, |
|
| 64 | + # array('critique' => 'oui', 'phpcheck' => 'oui'))){ |
|
| 65 | + ## eval('?'.'>'.$skel_code); |
|
| 66 | + # spip_log($skel_code, 'comp') |
|
| 67 | + #} |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if (file_exists($lib = $squelette . '_fonctions' . '.php')) { |
|
| 71 | + include_once $lib; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + // tester si le eval ci-dessus a mis le squelette en memoire |
|
| 75 | + |
|
| 76 | + if (function_exists($nom)) { |
|
| 77 | + return $nom; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // charger le source, si possible, et compiler |
|
| 81 | + $skel_code = ''; |
|
| 82 | + if (lire_fichier($source, $skel)) { |
|
| 83 | + $compiler = charger_fonction('compiler', 'public'); |
|
| 84 | + $skel_code = $compiler($skel, $nom, $gram, $source, $connect); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // Ne plus rien faire si le compilateur n'a pas pu operer. |
|
| 88 | + if (!$skel_code) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + foreach ($skel_code as $id => $boucle) { |
|
| 93 | + $f = $boucle->return; |
|
| 94 | + try { |
|
| 95 | + // @todo : a remplacer quand _PHP_MIN >= 7 |
|
| 96 | + // eval("return true; $f ;"); |
|
| 97 | + // PHP 5.x compat |
|
| 98 | + if ($ok = @eval("return true; $f ;") === false) { |
|
| 99 | + // Code syntaxiquement faux (critere etc mal programme') |
|
| 100 | + $msg = _T('zbug_erreur_compilation'); |
|
| 101 | + erreur_squelette($msg, $boucle); |
|
| 102 | + // continuer pour trouver d'autres fautes eventuelles |
|
| 103 | + // mais prevenir que c'est mort |
|
| 104 | + $nom = ''; |
|
| 105 | + } |
|
| 106 | + } catch (\ParseError $e) { |
|
| 107 | + // Code syntaxiquement faux (critere etc mal programme') |
|
| 108 | + $msg = _T('zbug_erreur_compilation') . ' | Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 109 | + erreur_squelette($msg, $boucle); |
|
| 110 | + // continuer pour trouver d'autres fautes eventuelles |
|
| 111 | + // mais prevenir que c'est mort |
|
| 112 | + $nom = ''; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + // Contexte de compil inutile a present |
|
| 116 | + // (mais la derniere valeur de $boucle est utilisee ci-dessous) |
|
| 117 | + $skel_code[$id] = $f; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $code = ''; |
|
| 121 | + if ($nom) { |
|
| 122 | + // Si le code est bon, concatener et mettre en cache |
|
| 123 | + if (function_exists($nom)) { |
|
| 124 | + $code = squelette_traduit($skel, $source, $phpfile, $skel_code); |
|
| 125 | + } else { |
|
| 126 | + // code semantiquement faux: bug du compilateur |
|
| 127 | + // $boucle est en fait ici la fct principale du squelette |
|
| 128 | + $msg = _T('zbug_erreur_compilation'); |
|
| 129 | + erreur_squelette($msg, $boucle); |
|
| 130 | + $nom = ''; |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
|
| 135 | + |
|
| 136 | + // Tracer ce qui vient d'etre compile |
|
| 137 | + $GLOBALS['debug_objets']['code'][$nom . 'tout'] = $code; |
|
| 138 | + |
|
| 139 | + // si c'est ce que demande le debusqueur, lui passer la main |
|
| 140 | + if ($GLOBALS['debug_objets']['sourcefile'] |
|
| 141 | + and (_request('var_mode_objet') == $nom) |
|
| 142 | + and (_request('var_mode_affiche') == 'code') |
|
| 143 | + ) { |
|
| 144 | + erreur_squelette(); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + return $nom ? $nom : false; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | function squelette_traduit($squelette, $sourcefile, $phpfile, $boucles) { |
| 152 | 152 | |
| 153 | - // Le dernier index est '' (fonction principale) |
|
| 154 | - $noms = substr(join(', ', array_keys($boucles)), 0, -2); |
|
| 155 | - if (CODE_COMMENTE) { |
|
| 156 | - $code = " |
|
| 153 | + // Le dernier index est '' (fonction principale) |
|
| 154 | + $noms = substr(join(', ', array_keys($boucles)), 0, -2); |
|
| 155 | + if (CODE_COMMENTE) { |
|
| 156 | + $code = " |
|
| 157 | 157 | /* |
| 158 | 158 | * Squelette : $sourcefile |
| 159 | 159 | * Date : " . gmdate("D, d M Y H:i:s", @filemtime($sourcefile)) . " GMT |
| 160 | 160 | * Compile : " . gmdate("D, d M Y H:i:s", time()) . " GMT |
| 161 | 161 | * " . (!$boucles ? "Pas de boucle" : ("Boucles : " . $noms)) . " |
| 162 | 162 | */ "; |
| 163 | - } |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - $code = '<' . "?php\n" . $code . join('', $boucles) . "\n?" . '>'; |
|
| 166 | - if (!defined('_VAR_NOCACHE') or !_VAR_NOCACHE) { |
|
| 167 | - ecrire_fichier($phpfile, $code); |
|
| 168 | - } |
|
| 165 | + $code = '<' . "?php\n" . $code . join('', $boucles) . "\n?" . '>'; |
|
| 166 | + if (!defined('_VAR_NOCACHE') or !_VAR_NOCACHE) { |
|
| 167 | + ecrire_fichier($phpfile, $code); |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - return $code; |
|
| 170 | + return $code; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Le squelette compile est-il trop vieux ? |
| 174 | 174 | // http://code.spip.net/@squelette_obsolete |
| 175 | 175 | function squelette_obsolete($skel, $squelette) { |
| 176 | - static $date_change = null; |
|
| 177 | - // ne verifier la date de mes_fonctions et mes_options qu'une seule fois |
|
| 178 | - // par hit |
|
| 179 | - if (is_null($date_change)) { |
|
| 180 | - if (@file_exists($fonc = 'mes_fonctions.php')) { |
|
| 181 | - $date_change = @filemtime($fonc); |
|
| 182 | - } # compatibilite |
|
| 183 | - if (defined('_FILE_OPTIONS')) { |
|
| 184 | - $date_change = max($date_change, @filemtime(_FILE_OPTIONS)); |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - return ( |
|
| 189 | - (defined('_VAR_MODE') and in_array(_VAR_MODE, array('recalcul', 'preview', 'debug'))) |
|
| 190 | - or !@file_exists($skel) |
|
| 191 | - or ((@file_exists($squelette) ? @filemtime($squelette) : 0) |
|
| 192 | - > ($date = @filemtime($skel))) |
|
| 193 | - or ($date_change > $date) |
|
| 194 | - ); |
|
| 176 | + static $date_change = null; |
|
| 177 | + // ne verifier la date de mes_fonctions et mes_options qu'une seule fois |
|
| 178 | + // par hit |
|
| 179 | + if (is_null($date_change)) { |
|
| 180 | + if (@file_exists($fonc = 'mes_fonctions.php')) { |
|
| 181 | + $date_change = @filemtime($fonc); |
|
| 182 | + } # compatibilite |
|
| 183 | + if (defined('_FILE_OPTIONS')) { |
|
| 184 | + $date_change = max($date_change, @filemtime(_FILE_OPTIONS)); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + return ( |
|
| 189 | + (defined('_VAR_MODE') and in_array(_VAR_MODE, array('recalcul', 'preview', 'debug'))) |
|
| 190 | + or !@file_exists($skel) |
|
| 191 | + or ((@file_exists($squelette) ? @filemtime($squelette) : 0) |
|
| 192 | + > ($date = @filemtime($skel))) |
|
| 193 | + or ($date_change > $date) |
|
| 194 | + ); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // Activer l'invalideur de session |
| 198 | 198 | // http://code.spip.net/@invalideur_session |
| 199 | 199 | function invalideur_session(&$Cache, $code = null) { |
| 200 | - $Cache['session'] = spip_session(); |
|
| 200 | + $Cache['session'] = spip_session(); |
|
| 201 | 201 | |
| 202 | - return $code; |
|
| 202 | + return $code; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | |
| 206 | 206 | // http://code.spip.net/@analyse_resultat_skel |
| 207 | 207 | function analyse_resultat_skel($nom, $cache, $corps, $source = '') { |
| 208 | - static $filtres = array(); |
|
| 209 | - $headers = array(); |
|
| 210 | - |
|
| 211 | - // Recupere les < ?php header('Xx: y'); ? > pour $page['headers'] |
|
| 212 | - // note: on essaie d'attrapper aussi certains de ces entetes codes |
|
| 213 | - // "a la main" dans les squelettes, mais evidemment sans exhaustivite |
|
| 214 | - if (stripos($corps, 'header') !== false |
|
| 215 | - and preg_match_all( |
|
| 216 | - '/(<[?]php\s+)@?header\s*\(\s*.([^:\'"]*):?\s*([^)]*)[^)]\s*\)\s*[;]?\s*[?]>/ims', |
|
| 217 | - $corps, $regs, PREG_SET_ORDER) |
|
| 218 | - ) { |
|
| 219 | - foreach ($regs as $r) { |
|
| 220 | - $corps = str_replace($r[0], '', $corps); |
|
| 221 | - # $j = Content-Type, et pas content-TYPE. |
|
| 222 | - $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); |
|
| 223 | - |
|
| 224 | - if ($j == 'X-Spip-Filtre' and isset($headers[$j])) { |
|
| 225 | - $headers[$j] .= "|" . $r[3]; |
|
| 226 | - } else { |
|
| 227 | - $headers[$j] = $r[3]; |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - // S'agit-il d'un resultat constant ou contenant du code php |
|
| 232 | - $process_ins = ( |
|
| 233 | - strpos($corps, '<' . '?') === false |
|
| 234 | - or |
|
| 235 | - (strpos($corps, '<' . '?xml') !== false and |
|
| 236 | - strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 237 | - ) |
|
| 238 | - ? 'html' |
|
| 239 | - : 'php'; |
|
| 240 | - |
|
| 241 | - $skel = array( |
|
| 242 | - 'squelette' => $nom, |
|
| 243 | - 'source' => $source, |
|
| 244 | - 'process_ins' => $process_ins, |
|
| 245 | - 'invalideurs' => $cache, |
|
| 246 | - 'entetes' => $headers, |
|
| 247 | - 'duree' => isset($headers['X-Spip-Cache']) ? intval($headers['X-Spip-Cache']) : 0 |
|
| 248 | - ); |
|
| 249 | - |
|
| 250 | - // traiter #FILTRE{} et filtres |
|
| 251 | - if (!isset($filtres[$nom])) { |
|
| 252 | - $filtres[$nom] = pipeline('declarer_filtres_squelettes', array('args' => $skel, 'data' => array())); |
|
| 253 | - } |
|
| 254 | - $filtres_headers = array(); |
|
| 255 | - if (isset($headers['X-Spip-Filtre']) and strlen($headers['X-Spip-Filtre'])) { |
|
| 256 | - $filtres_headers = array_filter(explode('|', $headers['X-Spip-Filtre'])); |
|
| 257 | - unset($headers['X-Spip-Filtre']); |
|
| 258 | - } |
|
| 259 | - if (count($filtres[$nom]) or count($filtres_headers)) { |
|
| 260 | - include_spip('public/sandbox'); |
|
| 261 | - $corps = sandbox_filtrer_squelette($skel, $corps, $filtres_headers, $filtres[$nom]); |
|
| 262 | - |
|
| 263 | - if ($process_ins == 'html') { |
|
| 264 | - $skel['process_ins'] = ( |
|
| 265 | - strpos($corps, '<' . '?') === false |
|
| 266 | - or |
|
| 267 | - (strpos($corps, '<' . '?xml') !== false and |
|
| 268 | - strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 269 | - ) |
|
| 270 | - ? 'html' |
|
| 271 | - : 'php'; |
|
| 272 | - } |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - $skel['entetes'] = $headers; |
|
| 276 | - $skel['texte'] = $corps; |
|
| 277 | - |
|
| 278 | - return $skel; |
|
| 208 | + static $filtres = array(); |
|
| 209 | + $headers = array(); |
|
| 210 | + |
|
| 211 | + // Recupere les < ?php header('Xx: y'); ? > pour $page['headers'] |
|
| 212 | + // note: on essaie d'attrapper aussi certains de ces entetes codes |
|
| 213 | + // "a la main" dans les squelettes, mais evidemment sans exhaustivite |
|
| 214 | + if (stripos($corps, 'header') !== false |
|
| 215 | + and preg_match_all( |
|
| 216 | + '/(<[?]php\s+)@?header\s*\(\s*.([^:\'"]*):?\s*([^)]*)[^)]\s*\)\s*[;]?\s*[?]>/ims', |
|
| 217 | + $corps, $regs, PREG_SET_ORDER) |
|
| 218 | + ) { |
|
| 219 | + foreach ($regs as $r) { |
|
| 220 | + $corps = str_replace($r[0], '', $corps); |
|
| 221 | + # $j = Content-Type, et pas content-TYPE. |
|
| 222 | + $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); |
|
| 223 | + |
|
| 224 | + if ($j == 'X-Spip-Filtre' and isset($headers[$j])) { |
|
| 225 | + $headers[$j] .= "|" . $r[3]; |
|
| 226 | + } else { |
|
| 227 | + $headers[$j] = $r[3]; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + // S'agit-il d'un resultat constant ou contenant du code php |
|
| 232 | + $process_ins = ( |
|
| 233 | + strpos($corps, '<' . '?') === false |
|
| 234 | + or |
|
| 235 | + (strpos($corps, '<' . '?xml') !== false and |
|
| 236 | + strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 237 | + ) |
|
| 238 | + ? 'html' |
|
| 239 | + : 'php'; |
|
| 240 | + |
|
| 241 | + $skel = array( |
|
| 242 | + 'squelette' => $nom, |
|
| 243 | + 'source' => $source, |
|
| 244 | + 'process_ins' => $process_ins, |
|
| 245 | + 'invalideurs' => $cache, |
|
| 246 | + 'entetes' => $headers, |
|
| 247 | + 'duree' => isset($headers['X-Spip-Cache']) ? intval($headers['X-Spip-Cache']) : 0 |
|
| 248 | + ); |
|
| 249 | + |
|
| 250 | + // traiter #FILTRE{} et filtres |
|
| 251 | + if (!isset($filtres[$nom])) { |
|
| 252 | + $filtres[$nom] = pipeline('declarer_filtres_squelettes', array('args' => $skel, 'data' => array())); |
|
| 253 | + } |
|
| 254 | + $filtres_headers = array(); |
|
| 255 | + if (isset($headers['X-Spip-Filtre']) and strlen($headers['X-Spip-Filtre'])) { |
|
| 256 | + $filtres_headers = array_filter(explode('|', $headers['X-Spip-Filtre'])); |
|
| 257 | + unset($headers['X-Spip-Filtre']); |
|
| 258 | + } |
|
| 259 | + if (count($filtres[$nom]) or count($filtres_headers)) { |
|
| 260 | + include_spip('public/sandbox'); |
|
| 261 | + $corps = sandbox_filtrer_squelette($skel, $corps, $filtres_headers, $filtres[$nom]); |
|
| 262 | + |
|
| 263 | + if ($process_ins == 'html') { |
|
| 264 | + $skel['process_ins'] = ( |
|
| 265 | + strpos($corps, '<' . '?') === false |
|
| 266 | + or |
|
| 267 | + (strpos($corps, '<' . '?xml') !== false and |
|
| 268 | + strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 269 | + ) |
|
| 270 | + ? 'html' |
|
| 271 | + : 'php'; |
|
| 272 | + } |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + $skel['entetes'] = $headers; |
|
| 276 | + $skel['texte'] = $corps; |
|
| 277 | + |
|
| 278 | + return $skel; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | inserer_balise_dynamique(balise_%s_dyn(%s), array(%s)); |
| 290 | 290 | if ($lang_select) lang_select(); |
| 291 | 291 | ?' |
| 292 | - . '>'); |
|
| 292 | + . '>'); |
|
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | 295 | * Synthétise une balise dynamique : crée l'appel à l'inclusion |
@@ -309,17 +309,17 @@ discard block |
||
| 309 | 309 | * Code PHP pour inclure le squelette de la balise dynamique |
| 310 | 310 | **/ |
| 311 | 311 | function synthetiser_balise_dynamique($nom, $args, $file, $context_compil) { |
| 312 | - if (strncmp($file, "/", 1) !== 0) { |
|
| 313 | - $file = './" . _DIR_RACINE . "' . $file; |
|
| 314 | - } |
|
| 315 | - $r = sprintf(CODE_INCLURE_BALISE, |
|
| 316 | - $file, |
|
| 317 | - $context_compil[4] ? $context_compil[4] : '', |
|
| 318 | - $nom, |
|
| 319 | - join(', ', array_map('argumenter_squelette', $args)), |
|
| 320 | - join(', ', array_map('_q', $context_compil))); |
|
| 321 | - |
|
| 322 | - return $r; |
|
| 312 | + if (strncmp($file, "/", 1) !== 0) { |
|
| 313 | + $file = './" . _DIR_RACINE . "' . $file; |
|
| 314 | + } |
|
| 315 | + $r = sprintf(CODE_INCLURE_BALISE, |
|
| 316 | + $file, |
|
| 317 | + $context_compil[4] ? $context_compil[4] : '', |
|
| 318 | + $nom, |
|
| 319 | + join(', ', array_map('argumenter_squelette', $args)), |
|
| 320 | + join(', ', array_map('_q', $context_compil))); |
|
| 321 | + |
|
| 322 | + return $r; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -337,21 +337,21 @@ discard block |
||
| 337 | 337 | **/ |
| 338 | 338 | function argumenter_squelette($v) { |
| 339 | 339 | |
| 340 | - if (is_object($v)) { |
|
| 341 | - if (PHP_VERSION_ID < 73000 and $v instanceof \stdClass) { |
|
| 342 | - return "(object) " . var_export((array) $v, true); |
|
| 343 | - } |
|
| 344 | - return var_export($v, true); |
|
| 345 | - } elseif (!is_array($v)) { |
|
| 346 | - return "'" . texte_script($v) . "'"; |
|
| 347 | - } else { |
|
| 348 | - $out = array(); |
|
| 349 | - foreach ($v as $k => $val) { |
|
| 350 | - $out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - return 'array(' . join(", ", $out) . ')'; |
|
| 354 | - } |
|
| 340 | + if (is_object($v)) { |
|
| 341 | + if (PHP_VERSION_ID < 73000 and $v instanceof \stdClass) { |
|
| 342 | + return "(object) " . var_export((array) $v, true); |
|
| 343 | + } |
|
| 344 | + return var_export($v, true); |
|
| 345 | + } elseif (!is_array($v)) { |
|
| 346 | + return "'" . texte_script($v) . "'"; |
|
| 347 | + } else { |
|
| 348 | + $out = array(); |
|
| 349 | + foreach ($v as $k => $val) { |
|
| 350 | + $out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + return 'array(' . join(", ", $out) . ')'; |
|
| 354 | + } |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | |
@@ -382,69 +382,69 @@ discard block |
||
| 382 | 382 | * Code PHP d'exécutant l'inclusion du squelette (ou texte) de la balise dynamique |
| 383 | 383 | **/ |
| 384 | 384 | function executer_balise_dynamique($nom, $args, $context_compil) { |
| 385 | - $nomfonction = $nom; |
|
| 386 | - $nomfonction_generique = ""; |
|
| 387 | - |
|
| 388 | - // Calculer un nom générique (ie. 'formulaire_' dans 'formulaire_editer_article') |
|
| 389 | - if (false !== ($p = strpos($nom, "_"))) { |
|
| 390 | - $nomfonction_generique = substr($nom, 0, $p + 1); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - if (!$fonction_balise = charger_fonction($nomfonction, 'balise', true)) { |
|
| 394 | - if ($nomfonction_generique and $fonction_balise = charger_fonction($nomfonction_generique, 'balise', true)) { |
|
| 395 | - // et injecter en premier arg le nom de la balise |
|
| 396 | - array_unshift($args, $nom); |
|
| 397 | - $nomfonction = $nomfonction_generique; |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - if (!$fonction_balise) { |
|
| 402 | - $msg = array('zbug_balise_inexistante', array('from' => 'CVT', 'balise' => $nom)); |
|
| 403 | - erreur_squelette($msg, $context_compil); |
|
| 404 | - |
|
| 405 | - return ''; |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - // retrouver le fichier qui a déclaré la fonction |
|
| 409 | - // même si la fonction dynamique est déclarée dans un fichier de fonctions. |
|
| 410 | - // Attention sous windows, getFileName() retourne un antislash. |
|
| 411 | - $reflector = new ReflectionFunction($fonction_balise); |
|
| 412 | - $file = str_replace('\\', '/', $reflector->getFileName()); |
|
| 413 | - if (strncmp($file, str_replace('\\', '/', _ROOT_RACINE), strlen(_ROOT_RACINE)) === 0) { |
|
| 414 | - $file = substr($file, strlen(_ROOT_RACINE)); |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - // Y a-t-il une fonction de traitement des arguments ? |
|
| 418 | - $f = 'balise_' . $nomfonction . '_stat'; |
|
| 419 | - |
|
| 420 | - $r = !function_exists($f) ? $args : $f($args, $context_compil); |
|
| 421 | - |
|
| 422 | - if (!is_array($r)) { |
|
| 423 | - return $r; |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - // verifier que la fonction dyn est la, |
|
| 427 | - // sinon se replier sur la generique si elle existe |
|
| 428 | - if (!function_exists('balise_' . $nomfonction . '_dyn')) { |
|
| 429 | - if ($nomfonction_generique |
|
| 430 | - and $file = include_spip("balise/" . strtolower($nomfonction_generique)) |
|
| 431 | - and function_exists('balise_' . $nomfonction_generique . '_dyn') |
|
| 432 | - ) { |
|
| 433 | - // et lui injecter en premier arg le nom de la balise |
|
| 434 | - array_unshift($r, $nom); |
|
| 435 | - $nomfonction = $nomfonction_generique; |
|
| 436 | - if (!_DIR_RESTREINT) { |
|
| 437 | - $file = _DIR_RESTREINT_ABS . $file; |
|
| 438 | - } |
|
| 439 | - } else { |
|
| 440 | - $msg = array('zbug_balise_inexistante', array('from' => 'CVT', 'balise' => $nom)); |
|
| 441 | - erreur_squelette($msg, $context_compil); |
|
| 442 | - |
|
| 443 | - return ''; |
|
| 444 | - } |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - return synthetiser_balise_dynamique($nomfonction, $r, $file, $context_compil); |
|
| 385 | + $nomfonction = $nom; |
|
| 386 | + $nomfonction_generique = ""; |
|
| 387 | + |
|
| 388 | + // Calculer un nom générique (ie. 'formulaire_' dans 'formulaire_editer_article') |
|
| 389 | + if (false !== ($p = strpos($nom, "_"))) { |
|
| 390 | + $nomfonction_generique = substr($nom, 0, $p + 1); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + if (!$fonction_balise = charger_fonction($nomfonction, 'balise', true)) { |
|
| 394 | + if ($nomfonction_generique and $fonction_balise = charger_fonction($nomfonction_generique, 'balise', true)) { |
|
| 395 | + // et injecter en premier arg le nom de la balise |
|
| 396 | + array_unshift($args, $nom); |
|
| 397 | + $nomfonction = $nomfonction_generique; |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if (!$fonction_balise) { |
|
| 402 | + $msg = array('zbug_balise_inexistante', array('from' => 'CVT', 'balise' => $nom)); |
|
| 403 | + erreur_squelette($msg, $context_compil); |
|
| 404 | + |
|
| 405 | + return ''; |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + // retrouver le fichier qui a déclaré la fonction |
|
| 409 | + // même si la fonction dynamique est déclarée dans un fichier de fonctions. |
|
| 410 | + // Attention sous windows, getFileName() retourne un antislash. |
|
| 411 | + $reflector = new ReflectionFunction($fonction_balise); |
|
| 412 | + $file = str_replace('\\', '/', $reflector->getFileName()); |
|
| 413 | + if (strncmp($file, str_replace('\\', '/', _ROOT_RACINE), strlen(_ROOT_RACINE)) === 0) { |
|
| 414 | + $file = substr($file, strlen(_ROOT_RACINE)); |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + // Y a-t-il une fonction de traitement des arguments ? |
|
| 418 | + $f = 'balise_' . $nomfonction . '_stat'; |
|
| 419 | + |
|
| 420 | + $r = !function_exists($f) ? $args : $f($args, $context_compil); |
|
| 421 | + |
|
| 422 | + if (!is_array($r)) { |
|
| 423 | + return $r; |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + // verifier que la fonction dyn est la, |
|
| 427 | + // sinon se replier sur la generique si elle existe |
|
| 428 | + if (!function_exists('balise_' . $nomfonction . '_dyn')) { |
|
| 429 | + if ($nomfonction_generique |
|
| 430 | + and $file = include_spip("balise/" . strtolower($nomfonction_generique)) |
|
| 431 | + and function_exists('balise_' . $nomfonction_generique . '_dyn') |
|
| 432 | + ) { |
|
| 433 | + // et lui injecter en premier arg le nom de la balise |
|
| 434 | + array_unshift($r, $nom); |
|
| 435 | + $nomfonction = $nomfonction_generique; |
|
| 436 | + if (!_DIR_RESTREINT) { |
|
| 437 | + $file = _DIR_RESTREINT_ABS . $file; |
|
| 438 | + } |
|
| 439 | + } else { |
|
| 440 | + $msg = array('zbug_balise_inexistante', array('from' => 'CVT', 'balise' => $nom)); |
|
| 441 | + erreur_squelette($msg, $context_compil); |
|
| 442 | + |
|
| 443 | + return ''; |
|
| 444 | + } |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + return synthetiser_balise_dynamique($nomfonction, $r, $file, $context_compil); |
|
| 448 | 448 | |
| 449 | 449 | } |
| 450 | 450 | |
@@ -469,27 +469,27 @@ discard block |
||
| 469 | 469 | * @return null; |
| 470 | 470 | **/ |
| 471 | 471 | function lang_select_public($lang, $lang_select, $titre = null) { |
| 472 | - // Cas 1. forcer_lang = true et pas de critere {lang_select} |
|
| 473 | - if (isset($GLOBALS['forcer_lang']) and $GLOBALS['forcer_lang'] |
|
| 474 | - and $lang_select !== 'oui' |
|
| 475 | - ) { |
|
| 476 | - $lang = $GLOBALS['spip_lang']; |
|
| 477 | - } // Cas 2. l'objet n'a pas de langue definie (ou definie a '') |
|
| 478 | - elseif (!strlen($lang)) { |
|
| 479 | - $lang = $GLOBALS['spip_lang']; |
|
| 480 | - } // Cas 3. l'objet est multilingue ! |
|
| 481 | - elseif ($lang_select !== 'oui' |
|
| 482 | - and strlen($titre) > 10 |
|
| 483 | - and strpos($titre, '<multi>') !== false |
|
| 484 | - and strpos(echappe_html($titre), '<multi>') !== false |
|
| 485 | - ) { |
|
| 486 | - $lang = $GLOBALS['spip_lang']; |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - // faire un lang_select() eventuellement sur la langue inchangee |
|
| 490 | - lang_select($lang); |
|
| 491 | - |
|
| 492 | - return; |
|
| 472 | + // Cas 1. forcer_lang = true et pas de critere {lang_select} |
|
| 473 | + if (isset($GLOBALS['forcer_lang']) and $GLOBALS['forcer_lang'] |
|
| 474 | + and $lang_select !== 'oui' |
|
| 475 | + ) { |
|
| 476 | + $lang = $GLOBALS['spip_lang']; |
|
| 477 | + } // Cas 2. l'objet n'a pas de langue definie (ou definie a '') |
|
| 478 | + elseif (!strlen($lang)) { |
|
| 479 | + $lang = $GLOBALS['spip_lang']; |
|
| 480 | + } // Cas 3. l'objet est multilingue ! |
|
| 481 | + elseif ($lang_select !== 'oui' |
|
| 482 | + and strlen($titre) > 10 |
|
| 483 | + and strpos($titre, '<multi>') !== false |
|
| 484 | + and strpos(echappe_html($titre), '<multi>') !== false |
|
| 485 | + ) { |
|
| 486 | + $lang = $GLOBALS['spip_lang']; |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + // faire un lang_select() eventuellement sur la langue inchangee |
|
| 490 | + lang_select($lang); |
|
| 491 | + |
|
| 492 | + return; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | |
@@ -497,21 +497,21 @@ discard block |
||
| 497 | 497 | // il faut le nettoyer car il pourrait etre injecte en SQL |
| 498 | 498 | // http://code.spip.net/@nettoyer_env_doublons |
| 499 | 499 | function nettoyer_env_doublons($envd) { |
| 500 | - foreach ($envd as $table => $liste) { |
|
| 501 | - $n = ''; |
|
| 502 | - foreach (explode(',', $liste) as $val) { |
|
| 503 | - if ($a = intval($val) and $val === strval($a)) { |
|
| 504 | - $n .= ',' . $val; |
|
| 505 | - } |
|
| 506 | - } |
|
| 507 | - if (strlen($n)) { |
|
| 508 | - $envd[$table] = $n; |
|
| 509 | - } else { |
|
| 510 | - unset($envd[$table]); |
|
| 511 | - } |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - return $envd; |
|
| 500 | + foreach ($envd as $table => $liste) { |
|
| 501 | + $n = ''; |
|
| 502 | + foreach (explode(',', $liste) as $val) { |
|
| 503 | + if ($a = intval($val) and $val === strval($a)) { |
|
| 504 | + $n .= ',' . $val; |
|
| 505 | + } |
|
| 506 | + } |
|
| 507 | + if (strlen($n)) { |
|
| 508 | + $envd[$table] = $n; |
|
| 509 | + } else { |
|
| 510 | + unset($envd[$table]); |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + return $envd; |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** |
@@ -530,21 +530,21 @@ discard block |
||
| 530 | 530 | * Opérateur trouvé (SELF ou SUBSELECT) sinon false. |
| 531 | 531 | **/ |
| 532 | 532 | function match_self($w) { |
| 533 | - if (is_string($w)) { |
|
| 534 | - return false; |
|
| 535 | - } |
|
| 536 | - if (is_array($w)) { |
|
| 537 | - if (in_array(reset($w), array("SELF", "SUBSELECT"))) { |
|
| 538 | - return $w; |
|
| 539 | - } |
|
| 540 | - foreach (array_filter($w, 'is_array') as $sw) { |
|
| 541 | - if ($m = match_self($sw)) { |
|
| 542 | - return $m; |
|
| 543 | - } |
|
| 544 | - } |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - return false; |
|
| 533 | + if (is_string($w)) { |
|
| 534 | + return false; |
|
| 535 | + } |
|
| 536 | + if (is_array($w)) { |
|
| 537 | + if (in_array(reset($w), array("SELF", "SUBSELECT"))) { |
|
| 538 | + return $w; |
|
| 539 | + } |
|
| 540 | + foreach (array_filter($w, 'is_array') as $sw) { |
|
| 541 | + if ($m = match_self($sw)) { |
|
| 542 | + return $m; |
|
| 543 | + } |
|
| 544 | + } |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + return false; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | /** |
@@ -560,16 +560,16 @@ discard block |
||
| 560 | 560 | * est remplacée par son code. |
| 561 | 561 | **/ |
| 562 | 562 | function remplace_sous_requete($w, $sousrequete) { |
| 563 | - if (is_array($w)) { |
|
| 564 | - if (in_array(reset($w), array("SELF", "SUBSELECT"))) { |
|
| 565 | - return $sousrequete; |
|
| 566 | - } |
|
| 567 | - foreach ($w as $k => $sw) { |
|
| 568 | - $w[$k] = remplace_sous_requete($sw, $sousrequete); |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - return $w; |
|
| 563 | + if (is_array($w)) { |
|
| 564 | + if (in_array(reset($w), array("SELF", "SUBSELECT"))) { |
|
| 565 | + return $sousrequete; |
|
| 566 | + } |
|
| 567 | + foreach ($w as $k => $sw) { |
|
| 568 | + $w[$k] = remplace_sous_requete($sw, $sousrequete); |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + return $w; |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | /** |
@@ -583,17 +583,17 @@ discard block |
||
| 583 | 583 | * - Conditions avec des sous requêtes |
| 584 | 584 | **/ |
| 585 | 585 | function trouver_sous_requetes($where) { |
| 586 | - $where_simples = array(); |
|
| 587 | - $where_sous = array(); |
|
| 588 | - foreach ($where as $k => $w) { |
|
| 589 | - if (match_self($w)) { |
|
| 590 | - $where_sous[$k] = $w; |
|
| 591 | - } else { |
|
| 592 | - $where_simples[$k] = $w; |
|
| 593 | - } |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - return array($where_simples, $where_sous); |
|
| 586 | + $where_simples = array(); |
|
| 587 | + $where_sous = array(); |
|
| 588 | + foreach ($where as $k => $w) { |
|
| 589 | + if (match_self($w)) { |
|
| 590 | + $where_sous[$k] = $w; |
|
| 591 | + } else { |
|
| 592 | + $where_simples[$k] = $w; |
|
| 593 | + } |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + return array($where_simples, $where_sous); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | |
@@ -619,258 +619,258 @@ discard block |
||
| 619 | 619 | * @return resource |
| 620 | 620 | */ |
| 621 | 621 | function calculer_select( |
| 622 | - $select = array(), |
|
| 623 | - $from = array(), |
|
| 624 | - $from_type = array(), |
|
| 625 | - $where = array(), |
|
| 626 | - $join = array(), |
|
| 627 | - $groupby = array(), |
|
| 628 | - $orderby = array(), |
|
| 629 | - $limit = '', |
|
| 630 | - $having = array(), |
|
| 631 | - $table = '', |
|
| 632 | - $id = '', |
|
| 633 | - $serveur = '', |
|
| 634 | - $requeter = true |
|
| 622 | + $select = array(), |
|
| 623 | + $from = array(), |
|
| 624 | + $from_type = array(), |
|
| 625 | + $where = array(), |
|
| 626 | + $join = array(), |
|
| 627 | + $groupby = array(), |
|
| 628 | + $orderby = array(), |
|
| 629 | + $limit = '', |
|
| 630 | + $having = array(), |
|
| 631 | + $table = '', |
|
| 632 | + $id = '', |
|
| 633 | + $serveur = '', |
|
| 634 | + $requeter = true |
|
| 635 | 635 | ) { |
| 636 | 636 | |
| 637 | - // retirer les criteres vides: |
|
| 638 | - // {X ?} avec X absent de l'URL |
|
| 639 | - // {par #ENV{X}} avec X absent de l'URL |
|
| 640 | - // IN sur collection vide (ce dernier devrait pouvoir etre fait a la compil) |
|
| 641 | - $menage = false; |
|
| 642 | - foreach ($where as $k => $v) { |
|
| 643 | - if (is_array($v)) { |
|
| 644 | - if ((count($v) >= 2) && ($v[0] == 'REGEXP') && ($v[2] == "'.*'")) { |
|
| 645 | - $op = false; |
|
| 646 | - } elseif ((count($v) >= 2) && ($v[0] == 'LIKE') && ($v[2] == "'%'")) { |
|
| 647 | - $op = false; |
|
| 648 | - } else { |
|
| 649 | - $op = $v[0] ? $v[0] : $v; |
|
| 650 | - } |
|
| 651 | - } else { |
|
| 652 | - $op = $v; |
|
| 653 | - } |
|
| 654 | - if ((!$op) or ($op == 1) or ($op == '0=0')) { |
|
| 655 | - unset($where[$k]); |
|
| 656 | - $menage = true; |
|
| 657 | - } |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - // evacuer les eventuels groupby vide issus d'un calcul dynamique |
|
| 661 | - $groupby = array_diff($groupby, array('')); |
|
| 662 | - |
|
| 663 | - // remplacer les sous requetes recursives au calcul |
|
| 664 | - list($where_simples, $where_sous) = trouver_sous_requetes($where); |
|
| 665 | - foreach ($where_sous as $k => $w) { |
|
| 666 | - $menage = true; |
|
| 667 | - // on recupere la sous requete |
|
| 668 | - $sous = match_self($w); |
|
| 669 | - if ($sous[0] == 'SELF') { |
|
| 670 | - // c'est une sous requete identique a elle meme sous la forme (SELF,$select,$where) |
|
| 671 | - array_push($where_simples, $sous[2]); |
|
| 672 | - $wheresub = array( |
|
| 673 | - $sous[2], |
|
| 674 | - '0=0' |
|
| 675 | - ); // pour accepter une string et forcer a faire le menage car on a surement simplifie select et where |
|
| 676 | - $jsub = $join; |
|
| 677 | - // trouver les jointures utiles a |
|
| 678 | - // reinjecter dans le where de la sous requete les conditions supplementaires des jointures qui y sont mentionnees |
|
| 679 | - // ie L1.objet='article' |
|
| 680 | - // on construit le where une fois, puis on ajoute les where complentaires si besoin, et on reconstruit le where en fonction |
|
| 681 | - $i = 0; |
|
| 682 | - do { |
|
| 683 | - $where[$k] = remplace_sous_requete($w, "(" . calculer_select( |
|
| 684 | - array($sous[1] . " AS id"), |
|
| 685 | - $from, |
|
| 686 | - $from_type, |
|
| 687 | - $wheresub, |
|
| 688 | - $jsub, |
|
| 689 | - array(), array(), '', |
|
| 690 | - $having, $table, $id, $serveur, false) . ")"); |
|
| 691 | - if (!$i) { |
|
| 692 | - $i = 1; |
|
| 693 | - $wherestring = calculer_where_to_string($where[$k]); |
|
| 694 | - foreach ($join as $cle => $wj) { |
|
| 695 | - if (count($wj) == 4 |
|
| 696 | - and strpos($wherestring, "{$cle}.") !== false |
|
| 697 | - ) { |
|
| 698 | - $i = 0; |
|
| 699 | - $wheresub[] = $wj[3]; |
|
| 700 | - unset($jsub[$cle][3]); |
|
| 701 | - } |
|
| 702 | - } |
|
| 703 | - } |
|
| 704 | - } while ($i++ < 1); |
|
| 705 | - } |
|
| 706 | - if ($sous[0] == 'SUBSELECT') { |
|
| 707 | - // c'est une sous requete explicite sous la forme identique a sql_select : (SUBSELECT,$select,$from,$where,$groupby,$orderby,$limit,$having) |
|
| 708 | - array_push($where_simples, $sous[3]); // est-ce utile dans ce cas ? |
|
| 709 | - $where[$k] = remplace_sous_requete($w, "(" . calculer_select( |
|
| 710 | - $sous[1], # select |
|
| 711 | - $sous[2], #from |
|
| 712 | - array(), #from_type |
|
| 713 | - $sous[3] ? (is_array($sous[3]) ? $sous[3] : array($sous[3])) : array(), |
|
| 714 | - #where, qui peut etre de la forme string comme dans sql_select |
|
| 715 | - array(), #join |
|
| 716 | - $sous[4] ? $sous[4] : array(), #groupby |
|
| 717 | - $sous[5] ? $sous[5] : array(), #orderby |
|
| 718 | - $sous[6], #limit |
|
| 719 | - $sous[7] ? $sous[7] : array(), #having |
|
| 720 | - $table, $id, $serveur, false |
|
| 721 | - ) . ")"); |
|
| 722 | - } |
|
| 723 | - array_pop($where_simples); |
|
| 724 | - } |
|
| 725 | - |
|
| 726 | - foreach ($having as $k => $v) { |
|
| 727 | - if ((!$v) or ($v == 1) or ($v == '0=0')) { |
|
| 728 | - unset($having[$k]); |
|
| 729 | - } |
|
| 730 | - } |
|
| 731 | - |
|
| 732 | - // Installer les jointures. |
|
| 733 | - // Retirer celles seulement utiles aux criteres finalement absents mais |
|
| 734 | - // parcourir de la plus recente a la moins recente pour pouvoir eliminer Ln |
|
| 735 | - // si elle est seulement utile a Ln+1 elle meme inutile |
|
| 736 | - |
|
| 737 | - $afrom = array(); |
|
| 738 | - $equiv = array(); |
|
| 739 | - $k = count($join); |
|
| 740 | - foreach (array_reverse($join, true) as $cledef => $j) { |
|
| 741 | - $cle = $cledef; |
|
| 742 | - // le format de join est : |
|
| 743 | - // array(table depart, cle depart [,cle arrivee[,condition optionnelle and ...]]) |
|
| 744 | - $join[$cle] = array_values($join[$cle]); // recalculer les cles car des unset ont pu perturber |
|
| 745 | - if (count($join[$cle]) == 2) { |
|
| 746 | - $join[$cle][] = $join[$cle][1]; |
|
| 747 | - } |
|
| 748 | - if (count($join[$cle]) == 3) { |
|
| 749 | - $join[$cle][] = ''; |
|
| 750 | - } |
|
| 751 | - list($t, $c, $carr, $and) = $join[$cle]; |
|
| 752 | - // si le nom de la jointure n'a pas ete specifiee, on prend Lx avec x sont rang dans la liste |
|
| 753 | - // pour compat avec ancienne convention |
|
| 754 | - if (is_numeric($cle)) { |
|
| 755 | - $cle = "L$k"; |
|
| 756 | - } |
|
| 757 | - if (!$menage |
|
| 758 | - or isset($afrom[$cle]) |
|
| 759 | - or calculer_jointnul($cle, $select) |
|
| 760 | - or calculer_jointnul($cle, array_diff_key($join, array($cle => $join[$cle]))) |
|
| 761 | - or calculer_jointnul($cle, $having) |
|
| 762 | - or calculer_jointnul($cle, $where_simples) |
|
| 763 | - ) { |
|
| 764 | - // corriger les references non explicites dans select |
|
| 765 | - // ou groupby |
|
| 766 | - foreach ($select as $i => $s) { |
|
| 767 | - if ($s == $c) { |
|
| 768 | - $select[$i] = "$cle.$c AS $c"; |
|
| 769 | - break; |
|
| 770 | - } |
|
| 771 | - } |
|
| 772 | - foreach ($groupby as $i => $g) { |
|
| 773 | - if ($g == $c) { |
|
| 774 | - $groupby[$i] = "$cle.$c"; |
|
| 775 | - break; |
|
| 776 | - } |
|
| 777 | - } |
|
| 778 | - // on garde une ecriture decomposee pour permettre une simplification ulterieure si besoin |
|
| 779 | - // sans recours a preg_match |
|
| 780 | - // un implode(' ',..) est fait dans reinjecte_joint un peu plus bas |
|
| 781 | - $afrom[$t][$cle] = array( |
|
| 782 | - "\n" . |
|
| 783 | - (isset($from_type[$cle]) ? $from_type[$cle] : "INNER") . " JOIN", |
|
| 784 | - $from[$cle], |
|
| 785 | - "AS $cle", |
|
| 786 | - "ON (", |
|
| 787 | - "$cle.$c", |
|
| 788 | - "=", |
|
| 789 | - "$t.$carr", |
|
| 790 | - ($and ? "AND " . $and : "") . |
|
| 791 | - ")" |
|
| 792 | - ); |
|
| 793 | - if (isset($afrom[$cle])) { |
|
| 794 | - $afrom[$t] = $afrom[$t] + $afrom[$cle]; |
|
| 795 | - unset($afrom[$cle]); |
|
| 796 | - } |
|
| 797 | - $equiv[] = $carr; |
|
| 798 | - } else { |
|
| 799 | - unset($join[$cledef]); |
|
| 800 | - } |
|
| 801 | - unset($from[$cle]); |
|
| 802 | - $k--; |
|
| 803 | - } |
|
| 804 | - |
|
| 805 | - if (count($afrom)) { |
|
| 806 | - // Regarder si la table principale ne sert finalement a rien comme dans |
|
| 807 | - //<BOUCLE3(MOTS){id_article}{id_mot}> class='on'</BOUCLE3> |
|
| 808 | - //<BOUCLE2(MOTS){id_article} />#TOTAL_BOUCLE<//B2> |
|
| 809 | - //<BOUCLE5(RUBRIQUES){id_mot}{tout} />#TOTAL_BOUCLE<//B5> |
|
| 810 | - // ou dans |
|
| 811 | - //<BOUCLE8(HIERARCHIE){id_rubrique}{tout}{type='Squelette'}{inverse}{0,1}{lang_select=non} />#TOTAL_BOUCLE<//B8> |
|
| 812 | - // qui comporte plusieurs jointures |
|
| 813 | - // ou dans |
|
| 814 | - // <BOUCLE6(ARTICLES){id_mot=2}{statut==.*} />#TOTAL_BOUCLE<//B6> |
|
| 815 | - // <BOUCLE7(ARTICLES){id_mot>0}{statut?} />#TOTAL_BOUCLE<//B7> |
|
| 816 | - // penser a regarder aussi la clause orderby pour ne pas simplifier abusivement |
|
| 817 | - // <BOUCLE9(ARTICLES){recherche truc}{par titre}>#ID_ARTICLE</BOUCLE9> |
|
| 818 | - // penser a regarder aussi la clause groubpy pour ne pas simplifier abusivement |
|
| 819 | - // <BOUCLE10(EVENEMENTS){id_rubrique} />#TOTAL_BOUCLE<//B10> |
|
| 820 | - |
|
| 821 | - $t = key($from); |
|
| 822 | - $c = current($from); |
|
| 823 | - reset($from); |
|
| 824 | - $e = '/\b(' . "$t\\." . join("|" . $t . '\.', $equiv) . ')\b/'; |
|
| 825 | - if (!(strpos($t, ' ') or // jointure des le depart cf boucle_doc |
|
| 826 | - calculer_jointnul($t, $select, $e) or |
|
| 827 | - calculer_jointnul($t, $join, $e) or |
|
| 828 | - calculer_jointnul($t, $where, $e) or |
|
| 829 | - calculer_jointnul($t, $orderby, $e) or |
|
| 830 | - calculer_jointnul($t, $groupby, $e) or |
|
| 831 | - calculer_jointnul($t, $having, $e)) |
|
| 832 | - && count($afrom[$t]) |
|
| 833 | - ) { |
|
| 834 | - $nfrom = reset($afrom[$t]); |
|
| 835 | - $nt = key($afrom[$t]); |
|
| 836 | - unset($from[$t]); |
|
| 837 | - $from[$nt] = $nfrom[1]; |
|
| 838 | - unset($afrom[$t][$nt]); |
|
| 839 | - $afrom[$nt] = $afrom[$t]; |
|
| 840 | - unset($afrom[$t]); |
|
| 841 | - $e = '/\b' . preg_quote($nfrom[6]) . '\b/'; |
|
| 842 | - $t = $nfrom[4]; |
|
| 843 | - $alias = ""; |
|
| 844 | - // verifier que les deux cles sont homonymes, sinon installer un alias dans le select |
|
| 845 | - $oldcle = explode('.', $nfrom[6]); |
|
| 846 | - $oldcle = end($oldcle); |
|
| 847 | - $newcle = explode('.', $nfrom[4]); |
|
| 848 | - $newcle = end($newcle); |
|
| 849 | - if ($newcle != $oldcle) { |
|
| 850 | - // si l'ancienne cle etait deja dans le select avec un AS |
|
| 851 | - // reprendre simplement ce AS |
|
| 852 | - $as = '/\b' . preg_quote($nfrom[6]) . '\s+(AS\s+\w+)\b/'; |
|
| 853 | - if (preg_match($as, implode(',', $select), $m)) { |
|
| 854 | - $alias = ""; |
|
| 855 | - } else { |
|
| 856 | - $alias = ", " . $nfrom[4] . " AS $oldcle"; |
|
| 857 | - } |
|
| 858 | - } |
|
| 859 | - $select = remplacer_jointnul($t . $alias, $select, $e); |
|
| 860 | - $join = remplacer_jointnul($t, $join, $e); |
|
| 861 | - $where = remplacer_jointnul($t, $where, $e); |
|
| 862 | - $having = remplacer_jointnul($t, $having, $e); |
|
| 863 | - $groupby = remplacer_jointnul($t, $groupby, $e); |
|
| 864 | - $orderby = remplacer_jointnul($t, $orderby, $e); |
|
| 865 | - } |
|
| 866 | - $from = reinjecte_joint($afrom, $from); |
|
| 867 | - } |
|
| 868 | - $GLOBALS['debug']['aucasou'] = array($table, $id, $serveur, $requeter); |
|
| 869 | - $r = sql_select($select, $from, $where, |
|
| 870 | - $groupby, array_filter($orderby), $limit, $having, $serveur, $requeter); |
|
| 871 | - unset($GLOBALS['debug']['aucasou']); |
|
| 872 | - |
|
| 873 | - return $r; |
|
| 637 | + // retirer les criteres vides: |
|
| 638 | + // {X ?} avec X absent de l'URL |
|
| 639 | + // {par #ENV{X}} avec X absent de l'URL |
|
| 640 | + // IN sur collection vide (ce dernier devrait pouvoir etre fait a la compil) |
|
| 641 | + $menage = false; |
|
| 642 | + foreach ($where as $k => $v) { |
|
| 643 | + if (is_array($v)) { |
|
| 644 | + if ((count($v) >= 2) && ($v[0] == 'REGEXP') && ($v[2] == "'.*'")) { |
|
| 645 | + $op = false; |
|
| 646 | + } elseif ((count($v) >= 2) && ($v[0] == 'LIKE') && ($v[2] == "'%'")) { |
|
| 647 | + $op = false; |
|
| 648 | + } else { |
|
| 649 | + $op = $v[0] ? $v[0] : $v; |
|
| 650 | + } |
|
| 651 | + } else { |
|
| 652 | + $op = $v; |
|
| 653 | + } |
|
| 654 | + if ((!$op) or ($op == 1) or ($op == '0=0')) { |
|
| 655 | + unset($where[$k]); |
|
| 656 | + $menage = true; |
|
| 657 | + } |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + // evacuer les eventuels groupby vide issus d'un calcul dynamique |
|
| 661 | + $groupby = array_diff($groupby, array('')); |
|
| 662 | + |
|
| 663 | + // remplacer les sous requetes recursives au calcul |
|
| 664 | + list($where_simples, $where_sous) = trouver_sous_requetes($where); |
|
| 665 | + foreach ($where_sous as $k => $w) { |
|
| 666 | + $menage = true; |
|
| 667 | + // on recupere la sous requete |
|
| 668 | + $sous = match_self($w); |
|
| 669 | + if ($sous[0] == 'SELF') { |
|
| 670 | + // c'est une sous requete identique a elle meme sous la forme (SELF,$select,$where) |
|
| 671 | + array_push($where_simples, $sous[2]); |
|
| 672 | + $wheresub = array( |
|
| 673 | + $sous[2], |
|
| 674 | + '0=0' |
|
| 675 | + ); // pour accepter une string et forcer a faire le menage car on a surement simplifie select et where |
|
| 676 | + $jsub = $join; |
|
| 677 | + // trouver les jointures utiles a |
|
| 678 | + // reinjecter dans le where de la sous requete les conditions supplementaires des jointures qui y sont mentionnees |
|
| 679 | + // ie L1.objet='article' |
|
| 680 | + // on construit le where une fois, puis on ajoute les where complentaires si besoin, et on reconstruit le where en fonction |
|
| 681 | + $i = 0; |
|
| 682 | + do { |
|
| 683 | + $where[$k] = remplace_sous_requete($w, "(" . calculer_select( |
|
| 684 | + array($sous[1] . " AS id"), |
|
| 685 | + $from, |
|
| 686 | + $from_type, |
|
| 687 | + $wheresub, |
|
| 688 | + $jsub, |
|
| 689 | + array(), array(), '', |
|
| 690 | + $having, $table, $id, $serveur, false) . ")"); |
|
| 691 | + if (!$i) { |
|
| 692 | + $i = 1; |
|
| 693 | + $wherestring = calculer_where_to_string($where[$k]); |
|
| 694 | + foreach ($join as $cle => $wj) { |
|
| 695 | + if (count($wj) == 4 |
|
| 696 | + and strpos($wherestring, "{$cle}.") !== false |
|
| 697 | + ) { |
|
| 698 | + $i = 0; |
|
| 699 | + $wheresub[] = $wj[3]; |
|
| 700 | + unset($jsub[$cle][3]); |
|
| 701 | + } |
|
| 702 | + } |
|
| 703 | + } |
|
| 704 | + } while ($i++ < 1); |
|
| 705 | + } |
|
| 706 | + if ($sous[0] == 'SUBSELECT') { |
|
| 707 | + // c'est une sous requete explicite sous la forme identique a sql_select : (SUBSELECT,$select,$from,$where,$groupby,$orderby,$limit,$having) |
|
| 708 | + array_push($where_simples, $sous[3]); // est-ce utile dans ce cas ? |
|
| 709 | + $where[$k] = remplace_sous_requete($w, "(" . calculer_select( |
|
| 710 | + $sous[1], # select |
|
| 711 | + $sous[2], #from |
|
| 712 | + array(), #from_type |
|
| 713 | + $sous[3] ? (is_array($sous[3]) ? $sous[3] : array($sous[3])) : array(), |
|
| 714 | + #where, qui peut etre de la forme string comme dans sql_select |
|
| 715 | + array(), #join |
|
| 716 | + $sous[4] ? $sous[4] : array(), #groupby |
|
| 717 | + $sous[5] ? $sous[5] : array(), #orderby |
|
| 718 | + $sous[6], #limit |
|
| 719 | + $sous[7] ? $sous[7] : array(), #having |
|
| 720 | + $table, $id, $serveur, false |
|
| 721 | + ) . ")"); |
|
| 722 | + } |
|
| 723 | + array_pop($where_simples); |
|
| 724 | + } |
|
| 725 | + |
|
| 726 | + foreach ($having as $k => $v) { |
|
| 727 | + if ((!$v) or ($v == 1) or ($v == '0=0')) { |
|
| 728 | + unset($having[$k]); |
|
| 729 | + } |
|
| 730 | + } |
|
| 731 | + |
|
| 732 | + // Installer les jointures. |
|
| 733 | + // Retirer celles seulement utiles aux criteres finalement absents mais |
|
| 734 | + // parcourir de la plus recente a la moins recente pour pouvoir eliminer Ln |
|
| 735 | + // si elle est seulement utile a Ln+1 elle meme inutile |
|
| 736 | + |
|
| 737 | + $afrom = array(); |
|
| 738 | + $equiv = array(); |
|
| 739 | + $k = count($join); |
|
| 740 | + foreach (array_reverse($join, true) as $cledef => $j) { |
|
| 741 | + $cle = $cledef; |
|
| 742 | + // le format de join est : |
|
| 743 | + // array(table depart, cle depart [,cle arrivee[,condition optionnelle and ...]]) |
|
| 744 | + $join[$cle] = array_values($join[$cle]); // recalculer les cles car des unset ont pu perturber |
|
| 745 | + if (count($join[$cle]) == 2) { |
|
| 746 | + $join[$cle][] = $join[$cle][1]; |
|
| 747 | + } |
|
| 748 | + if (count($join[$cle]) == 3) { |
|
| 749 | + $join[$cle][] = ''; |
|
| 750 | + } |
|
| 751 | + list($t, $c, $carr, $and) = $join[$cle]; |
|
| 752 | + // si le nom de la jointure n'a pas ete specifiee, on prend Lx avec x sont rang dans la liste |
|
| 753 | + // pour compat avec ancienne convention |
|
| 754 | + if (is_numeric($cle)) { |
|
| 755 | + $cle = "L$k"; |
|
| 756 | + } |
|
| 757 | + if (!$menage |
|
| 758 | + or isset($afrom[$cle]) |
|
| 759 | + or calculer_jointnul($cle, $select) |
|
| 760 | + or calculer_jointnul($cle, array_diff_key($join, array($cle => $join[$cle]))) |
|
| 761 | + or calculer_jointnul($cle, $having) |
|
| 762 | + or calculer_jointnul($cle, $where_simples) |
|
| 763 | + ) { |
|
| 764 | + // corriger les references non explicites dans select |
|
| 765 | + // ou groupby |
|
| 766 | + foreach ($select as $i => $s) { |
|
| 767 | + if ($s == $c) { |
|
| 768 | + $select[$i] = "$cle.$c AS $c"; |
|
| 769 | + break; |
|
| 770 | + } |
|
| 771 | + } |
|
| 772 | + foreach ($groupby as $i => $g) { |
|
| 773 | + if ($g == $c) { |
|
| 774 | + $groupby[$i] = "$cle.$c"; |
|
| 775 | + break; |
|
| 776 | + } |
|
| 777 | + } |
|
| 778 | + // on garde une ecriture decomposee pour permettre une simplification ulterieure si besoin |
|
| 779 | + // sans recours a preg_match |
|
| 780 | + // un implode(' ',..) est fait dans reinjecte_joint un peu plus bas |
|
| 781 | + $afrom[$t][$cle] = array( |
|
| 782 | + "\n" . |
|
| 783 | + (isset($from_type[$cle]) ? $from_type[$cle] : "INNER") . " JOIN", |
|
| 784 | + $from[$cle], |
|
| 785 | + "AS $cle", |
|
| 786 | + "ON (", |
|
| 787 | + "$cle.$c", |
|
| 788 | + "=", |
|
| 789 | + "$t.$carr", |
|
| 790 | + ($and ? "AND " . $and : "") . |
|
| 791 | + ")" |
|
| 792 | + ); |
|
| 793 | + if (isset($afrom[$cle])) { |
|
| 794 | + $afrom[$t] = $afrom[$t] + $afrom[$cle]; |
|
| 795 | + unset($afrom[$cle]); |
|
| 796 | + } |
|
| 797 | + $equiv[] = $carr; |
|
| 798 | + } else { |
|
| 799 | + unset($join[$cledef]); |
|
| 800 | + } |
|
| 801 | + unset($from[$cle]); |
|
| 802 | + $k--; |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + if (count($afrom)) { |
|
| 806 | + // Regarder si la table principale ne sert finalement a rien comme dans |
|
| 807 | + //<BOUCLE3(MOTS){id_article}{id_mot}> class='on'</BOUCLE3> |
|
| 808 | + //<BOUCLE2(MOTS){id_article} />#TOTAL_BOUCLE<//B2> |
|
| 809 | + //<BOUCLE5(RUBRIQUES){id_mot}{tout} />#TOTAL_BOUCLE<//B5> |
|
| 810 | + // ou dans |
|
| 811 | + //<BOUCLE8(HIERARCHIE){id_rubrique}{tout}{type='Squelette'}{inverse}{0,1}{lang_select=non} />#TOTAL_BOUCLE<//B8> |
|
| 812 | + // qui comporte plusieurs jointures |
|
| 813 | + // ou dans |
|
| 814 | + // <BOUCLE6(ARTICLES){id_mot=2}{statut==.*} />#TOTAL_BOUCLE<//B6> |
|
| 815 | + // <BOUCLE7(ARTICLES){id_mot>0}{statut?} />#TOTAL_BOUCLE<//B7> |
|
| 816 | + // penser a regarder aussi la clause orderby pour ne pas simplifier abusivement |
|
| 817 | + // <BOUCLE9(ARTICLES){recherche truc}{par titre}>#ID_ARTICLE</BOUCLE9> |
|
| 818 | + // penser a regarder aussi la clause groubpy pour ne pas simplifier abusivement |
|
| 819 | + // <BOUCLE10(EVENEMENTS){id_rubrique} />#TOTAL_BOUCLE<//B10> |
|
| 820 | + |
|
| 821 | + $t = key($from); |
|
| 822 | + $c = current($from); |
|
| 823 | + reset($from); |
|
| 824 | + $e = '/\b(' . "$t\\." . join("|" . $t . '\.', $equiv) . ')\b/'; |
|
| 825 | + if (!(strpos($t, ' ') or // jointure des le depart cf boucle_doc |
|
| 826 | + calculer_jointnul($t, $select, $e) or |
|
| 827 | + calculer_jointnul($t, $join, $e) or |
|
| 828 | + calculer_jointnul($t, $where, $e) or |
|
| 829 | + calculer_jointnul($t, $orderby, $e) or |
|
| 830 | + calculer_jointnul($t, $groupby, $e) or |
|
| 831 | + calculer_jointnul($t, $having, $e)) |
|
| 832 | + && count($afrom[$t]) |
|
| 833 | + ) { |
|
| 834 | + $nfrom = reset($afrom[$t]); |
|
| 835 | + $nt = key($afrom[$t]); |
|
| 836 | + unset($from[$t]); |
|
| 837 | + $from[$nt] = $nfrom[1]; |
|
| 838 | + unset($afrom[$t][$nt]); |
|
| 839 | + $afrom[$nt] = $afrom[$t]; |
|
| 840 | + unset($afrom[$t]); |
|
| 841 | + $e = '/\b' . preg_quote($nfrom[6]) . '\b/'; |
|
| 842 | + $t = $nfrom[4]; |
|
| 843 | + $alias = ""; |
|
| 844 | + // verifier que les deux cles sont homonymes, sinon installer un alias dans le select |
|
| 845 | + $oldcle = explode('.', $nfrom[6]); |
|
| 846 | + $oldcle = end($oldcle); |
|
| 847 | + $newcle = explode('.', $nfrom[4]); |
|
| 848 | + $newcle = end($newcle); |
|
| 849 | + if ($newcle != $oldcle) { |
|
| 850 | + // si l'ancienne cle etait deja dans le select avec un AS |
|
| 851 | + // reprendre simplement ce AS |
|
| 852 | + $as = '/\b' . preg_quote($nfrom[6]) . '\s+(AS\s+\w+)\b/'; |
|
| 853 | + if (preg_match($as, implode(',', $select), $m)) { |
|
| 854 | + $alias = ""; |
|
| 855 | + } else { |
|
| 856 | + $alias = ", " . $nfrom[4] . " AS $oldcle"; |
|
| 857 | + } |
|
| 858 | + } |
|
| 859 | + $select = remplacer_jointnul($t . $alias, $select, $e); |
|
| 860 | + $join = remplacer_jointnul($t, $join, $e); |
|
| 861 | + $where = remplacer_jointnul($t, $where, $e); |
|
| 862 | + $having = remplacer_jointnul($t, $having, $e); |
|
| 863 | + $groupby = remplacer_jointnul($t, $groupby, $e); |
|
| 864 | + $orderby = remplacer_jointnul($t, $orderby, $e); |
|
| 865 | + } |
|
| 866 | + $from = reinjecte_joint($afrom, $from); |
|
| 867 | + } |
|
| 868 | + $GLOBALS['debug']['aucasou'] = array($table, $id, $serveur, $requeter); |
|
| 869 | + $r = sql_select($select, $from, $where, |
|
| 870 | + $groupby, array_filter($orderby), $limit, $having, $serveur, $requeter); |
|
| 871 | + unset($GLOBALS['debug']['aucasou']); |
|
| 872 | + |
|
| 873 | + return $r; |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | /** |
@@ -881,20 +881,20 @@ discard block |
||
| 881 | 881 | * @return string |
| 882 | 882 | */ |
| 883 | 883 | function calculer_where_to_string($v, $join = 'AND') { |
| 884 | - if (empty($v)) { |
|
| 885 | - return ''; |
|
| 886 | - } |
|
| 887 | - |
|
| 888 | - if (!is_array($v)) { |
|
| 889 | - return $v; |
|
| 890 | - } else { |
|
| 891 | - $exp = ""; |
|
| 892 | - if (strtoupper($join) === 'AND') { |
|
| 893 | - return $exp . join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 894 | - } else { |
|
| 895 | - return $exp . join($join, $v); |
|
| 896 | - } |
|
| 897 | - } |
|
| 884 | + if (empty($v)) { |
|
| 885 | + return ''; |
|
| 886 | + } |
|
| 887 | + |
|
| 888 | + if (!is_array($v)) { |
|
| 889 | + return $v; |
|
| 890 | + } else { |
|
| 891 | + $exp = ""; |
|
| 892 | + if (strtoupper($join) === 'AND') { |
|
| 893 | + return $exp . join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 894 | + } else { |
|
| 895 | + return $exp . join($join, $v); |
|
| 896 | + } |
|
| 897 | + } |
|
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | |
@@ -902,62 +902,62 @@ discard block |
||
| 902 | 902 | |
| 903 | 903 | // http://code.spip.net/@calculer_jointnul |
| 904 | 904 | function calculer_jointnul($cle, $exp, $equiv = '') { |
| 905 | - if (!is_array($exp)) { |
|
| 906 | - if ($equiv) { |
|
| 907 | - $exp = preg_replace($equiv, '', $exp); |
|
| 908 | - } |
|
| 909 | - |
|
| 910 | - return preg_match("/\\b$cle\\./", $exp); |
|
| 911 | - } else { |
|
| 912 | - foreach ($exp as $v) { |
|
| 913 | - if (calculer_jointnul($cle, $v, $equiv)) { |
|
| 914 | - return true; |
|
| 915 | - } |
|
| 916 | - } |
|
| 917 | - |
|
| 918 | - return false; |
|
| 919 | - } |
|
| 905 | + if (!is_array($exp)) { |
|
| 906 | + if ($equiv) { |
|
| 907 | + $exp = preg_replace($equiv, '', $exp); |
|
| 908 | + } |
|
| 909 | + |
|
| 910 | + return preg_match("/\\b$cle\\./", $exp); |
|
| 911 | + } else { |
|
| 912 | + foreach ($exp as $v) { |
|
| 913 | + if (calculer_jointnul($cle, $v, $equiv)) { |
|
| 914 | + return true; |
|
| 915 | + } |
|
| 916 | + } |
|
| 917 | + |
|
| 918 | + return false; |
|
| 919 | + } |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | // http://code.spip.net/@reinjecte_joint |
| 923 | 923 | function reinjecte_joint($afrom, $from) { |
| 924 | - $from_synth = array(); |
|
| 925 | - foreach ($from as $k => $v) { |
|
| 926 | - $from_synth[$k] = $from[$k]; |
|
| 927 | - if (isset($afrom[$k])) { |
|
| 928 | - foreach ($afrom[$k] as $kk => $vv) { |
|
| 929 | - $afrom[$k][$kk] = implode(' ', $afrom[$k][$kk]); |
|
| 930 | - } |
|
| 931 | - $from_synth["$k@"] = implode(' ', $afrom[$k]); |
|
| 932 | - unset($afrom[$k]); |
|
| 933 | - } |
|
| 934 | - } |
|
| 935 | - |
|
| 936 | - return $from_synth; |
|
| 924 | + $from_synth = array(); |
|
| 925 | + foreach ($from as $k => $v) { |
|
| 926 | + $from_synth[$k] = $from[$k]; |
|
| 927 | + if (isset($afrom[$k])) { |
|
| 928 | + foreach ($afrom[$k] as $kk => $vv) { |
|
| 929 | + $afrom[$k][$kk] = implode(' ', $afrom[$k][$kk]); |
|
| 930 | + } |
|
| 931 | + $from_synth["$k@"] = implode(' ', $afrom[$k]); |
|
| 932 | + unset($afrom[$k]); |
|
| 933 | + } |
|
| 934 | + } |
|
| 935 | + |
|
| 936 | + return $from_synth; |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | // http://code.spip.net/@remplacer_jointnul |
| 940 | 940 | function remplacer_jointnul($cle, $exp, $equiv = '') { |
| 941 | - if (!is_array($exp)) { |
|
| 942 | - return preg_replace($equiv, $cle, $exp); |
|
| 943 | - } else { |
|
| 944 | - foreach ($exp as $k => $v) { |
|
| 945 | - $exp[$k] = remplacer_jointnul($cle, $v, $equiv); |
|
| 946 | - } |
|
| 947 | - |
|
| 948 | - return $exp; |
|
| 949 | - } |
|
| 941 | + if (!is_array($exp)) { |
|
| 942 | + return preg_replace($equiv, $cle, $exp); |
|
| 943 | + } else { |
|
| 944 | + foreach ($exp as $k => $v) { |
|
| 945 | + $exp[$k] = remplacer_jointnul($cle, $v, $equiv); |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + return $exp; |
|
| 949 | + } |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | // calcul du nom du squelette |
| 953 | 953 | // http://code.spip.net/@calculer_nom_fonction_squel |
| 954 | 954 | function calculer_nom_fonction_squel($skel, $mime_type = 'html', $connect = '') { |
| 955 | - // ne pas doublonner les squelette selon qu'ils sont calcules depuis ecrire/ ou depuis la racine |
|
| 956 | - if ($l = strlen(_DIR_RACINE) and strncmp($skel, _DIR_RACINE, $l) == 0) { |
|
| 957 | - $skel = substr($skel, strlen(_DIR_RACINE)); |
|
| 958 | - } |
|
| 959 | - |
|
| 960 | - return $mime_type |
|
| 961 | - . (!$connect ? '' : preg_replace('/\W/', "_", $connect)) . '_' |
|
| 962 | - . md5($GLOBALS['spip_version_code'] . ' * ' . $skel . (isset($GLOBALS['marqueur_skel']) ? '*' . $GLOBALS['marqueur_skel'] : '')); |
|
| 955 | + // ne pas doublonner les squelette selon qu'ils sont calcules depuis ecrire/ ou depuis la racine |
|
| 956 | + if ($l = strlen(_DIR_RACINE) and strncmp($skel, _DIR_RACINE, $l) == 0) { |
|
| 957 | + $skel = substr($skel, strlen(_DIR_RACINE)); |
|
| 958 | + } |
|
| 959 | + |
|
| 960 | + return $mime_type |
|
| 961 | + . (!$connect ? '' : preg_replace('/\W/', "_", $connect)) . '_' |
|
| 962 | + . md5($GLOBALS['spip_version_code'] . ' * ' . $skel . (isset($GLOBALS['marqueur_skel']) ? '*' . $GLOBALS['marqueur_skel'] : '')); |
|
| 963 | 963 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $GLOBALS['debug_objets']['courant'] = $nom; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $phpfile = sous_repertoire(_DIR_SKELS, '', false, true) . $nom . '.php'; |
|
| 57 | + $phpfile = sous_repertoire(_DIR_SKELS, '', false, true).$nom.'.php'; |
|
| 58 | 58 | |
| 59 | 59 | // si squelette est deja compile et perenne, le charger |
| 60 | 60 | if (!squelette_obsolete($phpfile, $source)) { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | #} |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if (file_exists($lib = $squelette . '_fonctions' . '.php')) { |
|
| 70 | + if (file_exists($lib = $squelette.'_fonctions'.'.php')) { |
|
| 71 | 71 | include_once $lib; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | } catch (\ParseError $e) { |
| 107 | 107 | // Code syntaxiquement faux (critere etc mal programme') |
| 108 | - $msg = _T('zbug_erreur_compilation') . ' | Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 108 | + $msg = _T('zbug_erreur_compilation').' | Line '.$e->getLine().' : '.$e->getMessage(); |
|
| 109 | 109 | erreur_squelette($msg, $boucle); |
| 110 | 110 | // continuer pour trouver d'autres fautes eventuelles |
| 111 | 111 | // mais prevenir que c'est mort |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | if (defined('_VAR_MODE') and _VAR_MODE == 'debug') { |
| 135 | 135 | |
| 136 | 136 | // Tracer ce qui vient d'etre compile |
| 137 | - $GLOBALS['debug_objets']['code'][$nom . 'tout'] = $code; |
|
| 137 | + $GLOBALS['debug_objets']['code'][$nom.'tout'] = $code; |
|
| 138 | 138 | |
| 139 | 139 | // si c'est ce que demande le debusqueur, lui passer la main |
| 140 | 140 | if ($GLOBALS['debug_objets']['sourcefile'] |
@@ -156,13 +156,13 @@ discard block |
||
| 156 | 156 | $code = " |
| 157 | 157 | /* |
| 158 | 158 | * Squelette : $sourcefile |
| 159 | - * Date : " . gmdate("D, d M Y H:i:s", @filemtime($sourcefile)) . " GMT |
|
| 160 | - * Compile : " . gmdate("D, d M Y H:i:s", time()) . " GMT |
|
| 161 | - * " . (!$boucles ? "Pas de boucle" : ("Boucles : " . $noms)) . " |
|
| 159 | + * Date : ".gmdate("D, d M Y H:i:s", @filemtime($sourcefile))." GMT |
|
| 160 | + * Compile : " . gmdate("D, d M Y H:i:s", time())." GMT |
|
| 161 | + * " . (!$boucles ? "Pas de boucle" : ("Boucles : ".$noms))." |
|
| 162 | 162 | */ "; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $code = '<' . "?php\n" . $code . join('', $boucles) . "\n?" . '>'; |
|
| 165 | + $code = '<'."?php\n".$code.join('', $boucles)."\n?".'>'; |
|
| 166 | 166 | if (!defined('_VAR_NOCACHE') or !_VAR_NOCACHE) { |
| 167 | 167 | ecrire_fichier($phpfile, $code); |
| 168 | 168 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); |
| 223 | 223 | |
| 224 | 224 | if ($j == 'X-Spip-Filtre' and isset($headers[$j])) { |
| 225 | - $headers[$j] .= "|" . $r[3]; |
|
| 225 | + $headers[$j] .= "|".$r[3]; |
|
| 226 | 226 | } else { |
| 227 | 227 | $headers[$j] = $r[3]; |
| 228 | 228 | } |
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | // S'agit-il d'un resultat constant ou contenant du code php |
| 232 | 232 | $process_ins = ( |
| 233 | - strpos($corps, '<' . '?') === false |
|
| 233 | + strpos($corps, '<'.'?') === false |
|
| 234 | 234 | or |
| 235 | - (strpos($corps, '<' . '?xml') !== false and |
|
| 236 | - strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 235 | + (strpos($corps, '<'.'?xml') !== false and |
|
| 236 | + strpos(str_replace('<'.'?xml', '', $corps), '<'.'?') === false) |
|
| 237 | 237 | ) |
| 238 | 238 | ? 'html' |
| 239 | 239 | : 'php'; |
@@ -262,10 +262,10 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | if ($process_ins == 'html') { |
| 264 | 264 | $skel['process_ins'] = ( |
| 265 | - strpos($corps, '<' . '?') === false |
|
| 265 | + strpos($corps, '<'.'?') === false |
|
| 266 | 266 | or |
| 267 | - (strpos($corps, '<' . '?xml') !== false and |
|
| 268 | - strpos(str_replace('<' . '?xml', '', $corps), '<' . '?') === false) |
|
| 267 | + (strpos($corps, '<'.'?xml') !== false and |
|
| 268 | + strpos(str_replace('<'.'?xml', '', $corps), '<'.'?') === false) |
|
| 269 | 269 | ) |
| 270 | 270 | ? 'html' |
| 271 | 271 | : 'php'; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | // |
| 284 | 284 | |
| 285 | 285 | /** Code PHP pour inclure une balise dynamique à l'exécution d'une page */ |
| 286 | -define('CODE_INCLURE_BALISE', '<' . '?php |
|
| 286 | +define('CODE_INCLURE_BALISE', '<'.'?php |
|
| 287 | 287 | include_once("%s"); |
| 288 | 288 | if ($lang_select = "%s") $lang_select = lang_select($lang_select); |
| 289 | 289 | inserer_balise_dynamique(balise_%s_dyn(%s), array(%s)); |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | **/ |
| 311 | 311 | function synthetiser_balise_dynamique($nom, $args, $file, $context_compil) { |
| 312 | 312 | if (strncmp($file, "/", 1) !== 0) { |
| 313 | - $file = './" . _DIR_RACINE . "' . $file; |
|
| 313 | + $file = './" . _DIR_RACINE . "'.$file; |
|
| 314 | 314 | } |
| 315 | 315 | $r = sprintf(CODE_INCLURE_BALISE, |
| 316 | 316 | $file, |
@@ -339,18 +339,18 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | if (is_object($v)) { |
| 341 | 341 | if (PHP_VERSION_ID < 73000 and $v instanceof \stdClass) { |
| 342 | - return "(object) " . var_export((array) $v, true); |
|
| 342 | + return "(object) ".var_export((array) $v, true); |
|
| 343 | 343 | } |
| 344 | 344 | return var_export($v, true); |
| 345 | 345 | } elseif (!is_array($v)) { |
| 346 | - return "'" . texte_script($v) . "'"; |
|
| 346 | + return "'".texte_script($v)."'"; |
|
| 347 | 347 | } else { |
| 348 | 348 | $out = array(); |
| 349 | 349 | foreach ($v as $k => $val) { |
| 350 | - $out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val); |
|
| 350 | + $out [] = argumenter_squelette($k).'=>'.argumenter_squelette($val); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - return 'array(' . join(", ", $out) . ')'; |
|
| 353 | + return 'array('.join(", ", $out).')'; |
|
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | // Y a-t-il une fonction de traitement des arguments ? |
| 418 | - $f = 'balise_' . $nomfonction . '_stat'; |
|
| 418 | + $f = 'balise_'.$nomfonction.'_stat'; |
|
| 419 | 419 | |
| 420 | 420 | $r = !function_exists($f) ? $args : $f($args, $context_compil); |
| 421 | 421 | |
@@ -425,16 +425,16 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | // verifier que la fonction dyn est la, |
| 427 | 427 | // sinon se replier sur la generique si elle existe |
| 428 | - if (!function_exists('balise_' . $nomfonction . '_dyn')) { |
|
| 428 | + if (!function_exists('balise_'.$nomfonction.'_dyn')) { |
|
| 429 | 429 | if ($nomfonction_generique |
| 430 | - and $file = include_spip("balise/" . strtolower($nomfonction_generique)) |
|
| 431 | - and function_exists('balise_' . $nomfonction_generique . '_dyn') |
|
| 430 | + and $file = include_spip("balise/".strtolower($nomfonction_generique)) |
|
| 431 | + and function_exists('balise_'.$nomfonction_generique.'_dyn') |
|
| 432 | 432 | ) { |
| 433 | 433 | // et lui injecter en premier arg le nom de la balise |
| 434 | 434 | array_unshift($r, $nom); |
| 435 | 435 | $nomfonction = $nomfonction_generique; |
| 436 | 436 | if (!_DIR_RESTREINT) { |
| 437 | - $file = _DIR_RESTREINT_ABS . $file; |
|
| 437 | + $file = _DIR_RESTREINT_ABS.$file; |
|
| 438 | 438 | } |
| 439 | 439 | } else { |
| 440 | 440 | $msg = array('zbug_balise_inexistante', array('from' => 'CVT', 'balise' => $nom)); |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | $n = ''; |
| 502 | 502 | foreach (explode(',', $liste) as $val) { |
| 503 | 503 | if ($a = intval($val) and $val === strval($a)) { |
| 504 | - $n .= ',' . $val; |
|
| 504 | + $n .= ','.$val; |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | if (strlen($n)) { |
@@ -680,14 +680,14 @@ discard block |
||
| 680 | 680 | // on construit le where une fois, puis on ajoute les where complentaires si besoin, et on reconstruit le where en fonction |
| 681 | 681 | $i = 0; |
| 682 | 682 | do { |
| 683 | - $where[$k] = remplace_sous_requete($w, "(" . calculer_select( |
|
| 684 | - array($sous[1] . " AS id"), |
|
| 683 | + $where[$k] = remplace_sous_requete($w, "(".calculer_select( |
|
| 684 | + array($sous[1]." AS id"), |
|
| 685 | 685 | $from, |
| 686 | 686 | $from_type, |
| 687 | 687 | $wheresub, |
| 688 | 688 | $jsub, |
| 689 | 689 | array(), array(), '', |
| 690 | - $having, $table, $id, $serveur, false) . ")"); |
|
| 690 | + $having, $table, $id, $serveur, false).")"); |
|
| 691 | 691 | if (!$i) { |
| 692 | 692 | $i = 1; |
| 693 | 693 | $wherestring = calculer_where_to_string($where[$k]); |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | if ($sous[0] == 'SUBSELECT') { |
| 707 | 707 | // c'est une sous requete explicite sous la forme identique a sql_select : (SUBSELECT,$select,$from,$where,$groupby,$orderby,$limit,$having) |
| 708 | 708 | array_push($where_simples, $sous[3]); // est-ce utile dans ce cas ? |
| 709 | - $where[$k] = remplace_sous_requete($w, "(" . calculer_select( |
|
| 709 | + $where[$k] = remplace_sous_requete($w, "(".calculer_select( |
|
| 710 | 710 | $sous[1], # select |
| 711 | 711 | $sous[2], #from |
| 712 | 712 | array(), #from_type |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | $sous[6], #limit |
| 719 | 719 | $sous[7] ? $sous[7] : array(), #having |
| 720 | 720 | $table, $id, $serveur, false |
| 721 | - ) . ")"); |
|
| 721 | + ).")"); |
|
| 722 | 722 | } |
| 723 | 723 | array_pop($where_simples); |
| 724 | 724 | } |
@@ -779,15 +779,15 @@ discard block |
||
| 779 | 779 | // sans recours a preg_match |
| 780 | 780 | // un implode(' ',..) est fait dans reinjecte_joint un peu plus bas |
| 781 | 781 | $afrom[$t][$cle] = array( |
| 782 | - "\n" . |
|
| 783 | - (isset($from_type[$cle]) ? $from_type[$cle] : "INNER") . " JOIN", |
|
| 782 | + "\n". |
|
| 783 | + (isset($from_type[$cle]) ? $from_type[$cle] : "INNER")." JOIN", |
|
| 784 | 784 | $from[$cle], |
| 785 | 785 | "AS $cle", |
| 786 | 786 | "ON (", |
| 787 | 787 | "$cle.$c", |
| 788 | 788 | "=", |
| 789 | 789 | "$t.$carr", |
| 790 | - ($and ? "AND " . $and : "") . |
|
| 790 | + ($and ? "AND ".$and : ""). |
|
| 791 | 791 | ")" |
| 792 | 792 | ); |
| 793 | 793 | if (isset($afrom[$cle])) { |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | $t = key($from); |
| 822 | 822 | $c = current($from); |
| 823 | 823 | reset($from); |
| 824 | - $e = '/\b(' . "$t\\." . join("|" . $t . '\.', $equiv) . ')\b/'; |
|
| 824 | + $e = '/\b('."$t\\.".join("|".$t.'\.', $equiv).')\b/'; |
|
| 825 | 825 | if (!(strpos($t, ' ') or // jointure des le depart cf boucle_doc |
| 826 | 826 | calculer_jointnul($t, $select, $e) or |
| 827 | 827 | calculer_jointnul($t, $join, $e) or |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | unset($afrom[$t][$nt]); |
| 839 | 839 | $afrom[$nt] = $afrom[$t]; |
| 840 | 840 | unset($afrom[$t]); |
| 841 | - $e = '/\b' . preg_quote($nfrom[6]) . '\b/'; |
|
| 841 | + $e = '/\b'.preg_quote($nfrom[6]).'\b/'; |
|
| 842 | 842 | $t = $nfrom[4]; |
| 843 | 843 | $alias = ""; |
| 844 | 844 | // verifier que les deux cles sont homonymes, sinon installer un alias dans le select |
@@ -849,14 +849,14 @@ discard block |
||
| 849 | 849 | if ($newcle != $oldcle) { |
| 850 | 850 | // si l'ancienne cle etait deja dans le select avec un AS |
| 851 | 851 | // reprendre simplement ce AS |
| 852 | - $as = '/\b' . preg_quote($nfrom[6]) . '\s+(AS\s+\w+)\b/'; |
|
| 852 | + $as = '/\b'.preg_quote($nfrom[6]).'\s+(AS\s+\w+)\b/'; |
|
| 853 | 853 | if (preg_match($as, implode(',', $select), $m)) { |
| 854 | 854 | $alias = ""; |
| 855 | 855 | } else { |
| 856 | - $alias = ", " . $nfrom[4] . " AS $oldcle"; |
|
| 856 | + $alias = ", ".$nfrom[4]." AS $oldcle"; |
|
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | - $select = remplacer_jointnul($t . $alias, $select, $e); |
|
| 859 | + $select = remplacer_jointnul($t.$alias, $select, $e); |
|
| 860 | 860 | $join = remplacer_jointnul($t, $join, $e); |
| 861 | 861 | $where = remplacer_jointnul($t, $where, $e); |
| 862 | 862 | $having = remplacer_jointnul($t, $having, $e); |
@@ -890,9 +890,9 @@ discard block |
||
| 890 | 890 | } else { |
| 891 | 891 | $exp = ""; |
| 892 | 892 | if (strtoupper($join) === 'AND') { |
| 893 | - return $exp . join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 893 | + return $exp.join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 894 | 894 | } else { |
| 895 | - return $exp . join($join, $v); |
|
| 895 | + return $exp.join($join, $v); |
|
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | 898 | } |
@@ -958,6 +958,6 @@ discard block |
||
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | return $mime_type |
| 961 | - . (!$connect ? '' : preg_replace('/\W/', "_", $connect)) . '_' |
|
| 962 | - . md5($GLOBALS['spip_version_code'] . ' * ' . $skel . (isset($GLOBALS['marqueur_skel']) ? '*' . $GLOBALS['marqueur_skel'] : '')); |
|
| 961 | + . (!$connect ? '' : preg_replace('/\W/', "_", $connect)).'_' |
|
| 962 | + . md5($GLOBALS['spip_version_code'].' * '.$skel.(isset($GLOBALS['marqueur_skel']) ? '*'.$GLOBALS['marqueur_skel'] : '')); |
|
| 963 | 963 | } |