@@ -11,129 +11,129 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Decompilation de l'arbre de syntaxe abstraite d'un squelette SPIP |
| 18 | 18 | |
| 19 | 19 | function decompiler_boucle($struct, $fmt = '', $prof = 0) { |
| 20 | - $nom = $struct->id_boucle; |
|
| 21 | - $preaff = decompiler_($struct->preaff, $fmt, $prof); |
|
| 22 | - $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 23 | - $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 24 | - $altern = decompiler_($struct->altern, $fmt, $prof); |
|
| 25 | - $milieu = decompiler_($struct->milieu, $fmt, $prof); |
|
| 26 | - $postaff = decompiler_($struct->postaff, $fmt, $prof); |
|
| 27 | - |
|
| 28 | - $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
|
| 29 | - $type .= ($struct->type_requete ?: $struct->table_optionnelle); |
|
| 30 | - |
|
| 31 | - if ($struct->jointures_explicites) { |
|
| 32 | - $type .= ' ' . $struct->jointures_explicites; |
|
| 33 | - } |
|
| 34 | - if ($struct->table_optionnelle) { |
|
| 35 | - $type .= '?'; |
|
| 36 | - } |
|
| 37 | - // Revoir le cas de la boucle recursive |
|
| 38 | - |
|
| 39 | - $crit = $struct->param; |
|
| 40 | - if ($crit and !is_array($crit[0])) { |
|
| 41 | - $type = strtolower($type) . array_shift($crit); |
|
| 42 | - } |
|
| 43 | - $crit = decompiler_criteres($struct, $fmt, $prof); |
|
| 44 | - |
|
| 45 | - $f = 'format_boucle_' . $fmt; |
|
| 46 | - |
|
| 47 | - return $f($preaff, $avant, $nom, $type, $crit, $milieu, $apres, $altern, $postaff, $prof); |
|
| 20 | + $nom = $struct->id_boucle; |
|
| 21 | + $preaff = decompiler_($struct->preaff, $fmt, $prof); |
|
| 22 | + $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 23 | + $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 24 | + $altern = decompiler_($struct->altern, $fmt, $prof); |
|
| 25 | + $milieu = decompiler_($struct->milieu, $fmt, $prof); |
|
| 26 | + $postaff = decompiler_($struct->postaff, $fmt, $prof); |
|
| 27 | + |
|
| 28 | + $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
|
| 29 | + $type .= ($struct->type_requete ?: $struct->table_optionnelle); |
|
| 30 | + |
|
| 31 | + if ($struct->jointures_explicites) { |
|
| 32 | + $type .= ' ' . $struct->jointures_explicites; |
|
| 33 | + } |
|
| 34 | + if ($struct->table_optionnelle) { |
|
| 35 | + $type .= '?'; |
|
| 36 | + } |
|
| 37 | + // Revoir le cas de la boucle recursive |
|
| 38 | + |
|
| 39 | + $crit = $struct->param; |
|
| 40 | + if ($crit and !is_array($crit[0])) { |
|
| 41 | + $type = strtolower($type) . array_shift($crit); |
|
| 42 | + } |
|
| 43 | + $crit = decompiler_criteres($struct, $fmt, $prof); |
|
| 44 | + |
|
| 45 | + $f = 'format_boucle_' . $fmt; |
|
| 46 | + |
|
| 47 | + return $f($preaff, $avant, $nom, $type, $crit, $milieu, $apres, $altern, $postaff, $prof); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | function decompiler_include($struct, $fmt = '', $prof = 0) { |
| 51 | - $res = []; |
|
| 52 | - foreach ($struct->param ?: [] as $couple) { |
|
| 53 | - array_shift($couple); |
|
| 54 | - foreach ($couple as $v) { |
|
| 55 | - $res[] = decompiler_($v, $fmt, $prof); |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - $file = is_string($struct->texte) ? $struct->texte : |
|
| 59 | - decompiler_($struct->texte, $fmt, $prof); |
|
| 60 | - $f = 'format_inclure_' . $fmt; |
|
| 61 | - |
|
| 62 | - return $f($file, $res, $prof); |
|
| 51 | + $res = []; |
|
| 52 | + foreach ($struct->param ?: [] as $couple) { |
|
| 53 | + array_shift($couple); |
|
| 54 | + foreach ($couple as $v) { |
|
| 55 | + $res[] = decompiler_($v, $fmt, $prof); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + $file = is_string($struct->texte) ? $struct->texte : |
|
| 59 | + decompiler_($struct->texte, $fmt, $prof); |
|
| 60 | + $f = 'format_inclure_' . $fmt; |
|
| 61 | + |
|
| 62 | + return $f($file, $res, $prof); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function decompiler_texte($struct, $fmt = '', $prof = 0) { |
| 66 | - $f = 'format_texte_' . $fmt; |
|
| 66 | + $f = 'format_texte_' . $fmt; |
|
| 67 | 67 | |
| 68 | - return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
|
| 68 | + return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | function decompiler_polyglotte($struct, $fmt = '', $prof = 0) { |
| 72 | - $f = 'format_polyglotte_' . $fmt; |
|
| 72 | + $f = 'format_polyglotte_' . $fmt; |
|
| 73 | 73 | |
| 74 | - return $f($struct->traductions, $prof); |
|
| 74 | + return $f($struct->traductions, $prof); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | function decompiler_idiome($struct, $fmt = '', $prof = 0) { |
| 78 | - $args = []; |
|
| 79 | - foreach ($struct->arg as $k => $v) { |
|
| 80 | - $args[$k] = public_decompiler($v, $fmt, $prof); |
|
| 81 | - } |
|
| 78 | + $args = []; |
|
| 79 | + foreach ($struct->arg as $k => $v) { |
|
| 80 | + $args[$k] = public_decompiler($v, $fmt, $prof); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 83 | + $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 84 | 84 | |
| 85 | - $f = 'format_idiome_' . $fmt; |
|
| 85 | + $f = 'format_idiome_' . $fmt; |
|
| 86 | 86 | |
| 87 | - return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
|
| 87 | + return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | function decompiler_champ($struct, $fmt = '', $prof = 0) { |
| 91 | - $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 92 | - $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 93 | - $args = $filtres = ''; |
|
| 94 | - if ($p = $struct->param) { |
|
| 95 | - if ($p[0][0] === '') { |
|
| 96 | - $args = decompiler_liste([array_shift($p)], $fmt, $prof); |
|
| 97 | - } |
|
| 98 | - $filtres = decompiler_liste($p, $fmt, $prof); |
|
| 99 | - } |
|
| 100 | - $f = 'format_champ_' . $fmt; |
|
| 101 | - |
|
| 102 | - return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
|
| 91 | + $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 92 | + $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 93 | + $args = $filtres = ''; |
|
| 94 | + if ($p = $struct->param) { |
|
| 95 | + if ($p[0][0] === '') { |
|
| 96 | + $args = decompiler_liste([array_shift($p)], $fmt, $prof); |
|
| 97 | + } |
|
| 98 | + $filtres = decompiler_liste($p, $fmt, $prof); |
|
| 99 | + } |
|
| 100 | + $f = 'format_champ_' . $fmt; |
|
| 101 | + |
|
| 102 | + return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | function decompiler_liste($sources, $fmt = '', $prof = 0) { |
| 106 | - if (!is_array($sources)) { |
|
| 107 | - return ''; |
|
| 108 | - } |
|
| 109 | - $f = 'format_liste_' . $fmt; |
|
| 110 | - $res = ''; |
|
| 111 | - foreach ($sources as $arg) { |
|
| 112 | - if (!is_array($arg)) { |
|
| 113 | - continue; // ne devrait pas arriver. |
|
| 114 | - } else { |
|
| 115 | - $r = array_shift($arg); |
|
| 116 | - } |
|
| 117 | - $args = []; |
|
| 118 | - foreach ($arg as $v) { |
|
| 119 | - // cas des arguments entoures de ' ou " |
|
| 120 | - if ( |
|
| 121 | - ((is_countable($v) ? count($v) : 0) == 1) |
|
| 122 | - and $v[0]->type == 'texte' |
|
| 123 | - and (strlen($v[0]->apres) == 1) |
|
| 124 | - and $v[0]->apres == $v[0]->avant |
|
| 125 | - ) { |
|
| 126 | - $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 127 | - } else { |
|
| 128 | - $args[] = decompiler_($v, $fmt, 0 - $prof); |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - if (($r !== '') or $args) { |
|
| 132 | - $res .= $f($r, $args, $prof); |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - return $res; |
|
| 106 | + if (!is_array($sources)) { |
|
| 107 | + return ''; |
|
| 108 | + } |
|
| 109 | + $f = 'format_liste_' . $fmt; |
|
| 110 | + $res = ''; |
|
| 111 | + foreach ($sources as $arg) { |
|
| 112 | + if (!is_array($arg)) { |
|
| 113 | + continue; // ne devrait pas arriver. |
|
| 114 | + } else { |
|
| 115 | + $r = array_shift($arg); |
|
| 116 | + } |
|
| 117 | + $args = []; |
|
| 118 | + foreach ($arg as $v) { |
|
| 119 | + // cas des arguments entoures de ' ou " |
|
| 120 | + if ( |
|
| 121 | + ((is_countable($v) ? count($v) : 0) == 1) |
|
| 122 | + and $v[0]->type == 'texte' |
|
| 123 | + and (strlen($v[0]->apres) == 1) |
|
| 124 | + and $v[0]->apres == $v[0]->avant |
|
| 125 | + ) { |
|
| 126 | + $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 127 | + } else { |
|
| 128 | + $args[] = decompiler_($v, $fmt, 0 - $prof); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + if (($r !== '') or $args) { |
|
| 132 | + $res .= $f($r, $args, $prof); |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + return $res; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Decompilation des criteres: on triche et on deroge: |
@@ -141,93 +141,93 @@ discard block |
||
| 141 | 141 | // - le champ apres signale le critere {"separateur"} ou {'separateur'} |
| 142 | 142 | // - les champs sont implicitement etendus (crochets implicites mais interdits) |
| 143 | 143 | function decompiler_criteres($boucle, $fmt = '', $prof = 0) { |
| 144 | - $sources = $boucle->param; |
|
| 145 | - if (!is_array($sources)) { |
|
| 146 | - return ''; |
|
| 147 | - } |
|
| 148 | - $res = ''; |
|
| 149 | - $f = 'format_critere_' . $fmt; |
|
| 150 | - foreach ($sources as $crit) { |
|
| 151 | - if (!is_array($crit)) { |
|
| 152 | - continue; |
|
| 153 | - } // boucle recursive |
|
| 154 | - array_shift($crit); |
|
| 155 | - $args = []; |
|
| 156 | - foreach ($crit as $i => $v) { |
|
| 157 | - if ( |
|
| 158 | - ((is_countable($v) ? count($v) : 0) == 1) |
|
| 159 | - and $v[0]->type == 'texte' |
|
| 160 | - and $v[0]->apres |
|
| 161 | - ) { |
|
| 162 | - $args[] = [['texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres)]]; |
|
| 163 | - } else { |
|
| 164 | - $res2 = []; |
|
| 165 | - foreach ($v as $k => $p) { |
|
| 166 | - if ( |
|
| 167 | - isset($p->type) |
|
| 168 | - and function_exists($d = 'decompiler_' . $p->type) |
|
| 169 | - ) { |
|
| 170 | - $r = $d($p, $fmt, (0 - $prof)); |
|
| 171 | - $res2[] = [$p->type, $r]; |
|
| 172 | - } else { |
|
| 173 | - spip_log("critere $i / $k mal forme"); |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - $args[] = $res2; |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - $res .= $f($args); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - return $res; |
|
| 144 | + $sources = $boucle->param; |
|
| 145 | + if (!is_array($sources)) { |
|
| 146 | + return ''; |
|
| 147 | + } |
|
| 148 | + $res = ''; |
|
| 149 | + $f = 'format_critere_' . $fmt; |
|
| 150 | + foreach ($sources as $crit) { |
|
| 151 | + if (!is_array($crit)) { |
|
| 152 | + continue; |
|
| 153 | + } // boucle recursive |
|
| 154 | + array_shift($crit); |
|
| 155 | + $args = []; |
|
| 156 | + foreach ($crit as $i => $v) { |
|
| 157 | + if ( |
|
| 158 | + ((is_countable($v) ? count($v) : 0) == 1) |
|
| 159 | + and $v[0]->type == 'texte' |
|
| 160 | + and $v[0]->apres |
|
| 161 | + ) { |
|
| 162 | + $args[] = [['texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres)]]; |
|
| 163 | + } else { |
|
| 164 | + $res2 = []; |
|
| 165 | + foreach ($v as $k => $p) { |
|
| 166 | + if ( |
|
| 167 | + isset($p->type) |
|
| 168 | + and function_exists($d = 'decompiler_' . $p->type) |
|
| 169 | + ) { |
|
| 170 | + $r = $d($p, $fmt, (0 - $prof)); |
|
| 171 | + $res2[] = [$p->type, $r]; |
|
| 172 | + } else { |
|
| 173 | + spip_log("critere $i / $k mal forme"); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + $args[] = $res2; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + $res .= $f($args); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + return $res; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | |
| 186 | 186 | function decompiler_($liste, $fmt = '', $prof = 0) { |
| 187 | - if (!is_array($liste)) { |
|
| 188 | - return ''; |
|
| 189 | - } |
|
| 190 | - $prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1); |
|
| 191 | - $contenu = []; |
|
| 192 | - foreach ($liste as $k => $p) { |
|
| 193 | - if (!isset($p->type)) { |
|
| 194 | - continue; |
|
| 195 | - } #?????? |
|
| 196 | - $d = 'decompiler_' . $p->type; |
|
| 197 | - $next = $liste[$k + 1] ?? false; |
|
| 198 | - // Forcer le champ etendu si son source (pas les reecritures) |
|
| 199 | - // contenait des args et s'il est suivi d'espaces, |
|
| 200 | - // le champ simple les eliminant est un bug helas perenne. |
|
| 201 | - |
|
| 202 | - if ( |
|
| 203 | - $next |
|
| 204 | - and ($next->type == 'texte') |
|
| 205 | - and $p->type == 'champ' |
|
| 206 | - and !$p->apres |
|
| 207 | - and !$p->avant |
|
| 208 | - and $p->fonctions |
|
| 209 | - ) { |
|
| 210 | - $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
|
| 211 | - if ($n) { |
|
| 212 | - $champ = new Texte(); |
|
| 213 | - $champ->texte = substr($next->texte, 0, $n); |
|
| 214 | - $champ->ligne = $p->ligne; |
|
| 215 | - $p->apres = [$champ]; |
|
| 216 | - $next->texte = substr($next->texte, $n); |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - $contenu[] = [$d($p, $fmt, $prof2), $p->type]; |
|
| 220 | - } |
|
| 221 | - $f = 'format_suite_' . $fmt; |
|
| 222 | - |
|
| 223 | - return $f($contenu); |
|
| 187 | + if (!is_array($liste)) { |
|
| 188 | + return ''; |
|
| 189 | + } |
|
| 190 | + $prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1); |
|
| 191 | + $contenu = []; |
|
| 192 | + foreach ($liste as $k => $p) { |
|
| 193 | + if (!isset($p->type)) { |
|
| 194 | + continue; |
|
| 195 | + } #?????? |
|
| 196 | + $d = 'decompiler_' . $p->type; |
|
| 197 | + $next = $liste[$k + 1] ?? false; |
|
| 198 | + // Forcer le champ etendu si son source (pas les reecritures) |
|
| 199 | + // contenait des args et s'il est suivi d'espaces, |
|
| 200 | + // le champ simple les eliminant est un bug helas perenne. |
|
| 201 | + |
|
| 202 | + if ( |
|
| 203 | + $next |
|
| 204 | + and ($next->type == 'texte') |
|
| 205 | + and $p->type == 'champ' |
|
| 206 | + and !$p->apres |
|
| 207 | + and !$p->avant |
|
| 208 | + and $p->fonctions |
|
| 209 | + ) { |
|
| 210 | + $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
|
| 211 | + if ($n) { |
|
| 212 | + $champ = new Texte(); |
|
| 213 | + $champ->texte = substr($next->texte, 0, $n); |
|
| 214 | + $champ->ligne = $p->ligne; |
|
| 215 | + $p->apres = [$champ]; |
|
| 216 | + $next->texte = substr($next->texte, $n); |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + $contenu[] = [$d($p, $fmt, $prof2), $p->type]; |
|
| 220 | + } |
|
| 221 | + $f = 'format_suite_' . $fmt; |
|
| 222 | + |
|
| 223 | + return $f($contenu); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') { |
| 227 | - if (!include_spip('public/format_' . $fmt)) { |
|
| 228 | - return "'$fmt'?"; |
|
| 229 | - } |
|
| 230 | - $f = 'decompiler_' . $quoi; |
|
| 227 | + if (!include_spip('public/format_' . $fmt)) { |
|
| 228 | + return "'$fmt'?"; |
|
| 229 | + } |
|
| 230 | + $f = 'decompiler_' . $quoi; |
|
| 231 | 231 | |
| 232 | - return $f($liste, $fmt, $prof); |
|
| 232 | + return $f($liste, $fmt, $prof); |
|
| 233 | 233 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $type .= ($struct->type_requete ?: $struct->table_optionnelle); |
| 30 | 30 | |
| 31 | 31 | if ($struct->jointures_explicites) { |
| 32 | - $type .= ' ' . $struct->jointures_explicites; |
|
| 32 | + $type .= ' '.$struct->jointures_explicites; |
|
| 33 | 33 | } |
| 34 | 34 | if ($struct->table_optionnelle) { |
| 35 | 35 | $type .= '?'; |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $crit = $struct->param; |
| 40 | 40 | if ($crit and !is_array($crit[0])) { |
| 41 | - $type = strtolower($type) . array_shift($crit); |
|
| 41 | + $type = strtolower($type).array_shift($crit); |
|
| 42 | 42 | } |
| 43 | 43 | $crit = decompiler_criteres($struct, $fmt, $prof); |
| 44 | 44 | |
| 45 | - $f = 'format_boucle_' . $fmt; |
|
| 45 | + $f = 'format_boucle_'.$fmt; |
|
| 46 | 46 | |
| 47 | 47 | return $f($preaff, $avant, $nom, $type, $crit, $milieu, $apres, $altern, $postaff, $prof); |
| 48 | 48 | } |
@@ -55,21 +55,20 @@ discard block |
||
| 55 | 55 | $res[] = decompiler_($v, $fmt, $prof); |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | - $file = is_string($struct->texte) ? $struct->texte : |
|
| 59 | - decompiler_($struct->texte, $fmt, $prof); |
|
| 60 | - $f = 'format_inclure_' . $fmt; |
|
| 58 | + $file = is_string($struct->texte) ? $struct->texte : decompiler_($struct->texte, $fmt, $prof); |
|
| 59 | + $f = 'format_inclure_'.$fmt; |
|
| 61 | 60 | |
| 62 | 61 | return $f($file, $res, $prof); |
| 63 | 62 | } |
| 64 | 63 | |
| 65 | 64 | function decompiler_texte($struct, $fmt = '', $prof = 0) { |
| 66 | - $f = 'format_texte_' . $fmt; |
|
| 65 | + $f = 'format_texte_'.$fmt; |
|
| 67 | 66 | |
| 68 | 67 | return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
| 69 | 68 | } |
| 70 | 69 | |
| 71 | 70 | function decompiler_polyglotte($struct, $fmt = '', $prof = 0) { |
| 72 | - $f = 'format_polyglotte_' . $fmt; |
|
| 71 | + $f = 'format_polyglotte_'.$fmt; |
|
| 73 | 72 | |
| 74 | 73 | return $f($struct->traductions, $prof); |
| 75 | 74 | } |
@@ -82,7 +81,7 @@ discard block |
||
| 82 | 81 | |
| 83 | 82 | $filtres = decompiler_liste($struct->param, $fmt, $prof); |
| 84 | 83 | |
| 85 | - $f = 'format_idiome_' . $fmt; |
|
| 84 | + $f = 'format_idiome_'.$fmt; |
|
| 86 | 85 | |
| 87 | 86 | return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
| 88 | 87 | } |
@@ -97,7 +96,7 @@ discard block |
||
| 97 | 96 | } |
| 98 | 97 | $filtres = decompiler_liste($p, $fmt, $prof); |
| 99 | 98 | } |
| 100 | - $f = 'format_champ_' . $fmt; |
|
| 99 | + $f = 'format_champ_'.$fmt; |
|
| 101 | 100 | |
| 102 | 101 | return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
| 103 | 102 | } |
@@ -106,7 +105,7 @@ discard block |
||
| 106 | 105 | if (!is_array($sources)) { |
| 107 | 106 | return ''; |
| 108 | 107 | } |
| 109 | - $f = 'format_liste_' . $fmt; |
|
| 108 | + $f = 'format_liste_'.$fmt; |
|
| 110 | 109 | $res = ''; |
| 111 | 110 | foreach ($sources as $arg) { |
| 112 | 111 | if (!is_array($arg)) { |
@@ -123,7 +122,7 @@ discard block |
||
| 123 | 122 | and (strlen($v[0]->apres) == 1) |
| 124 | 123 | and $v[0]->apres == $v[0]->avant |
| 125 | 124 | ) { |
| 126 | - $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 125 | + $args[] = $v[0]->avant.$v[0]->texte.$v[0]->apres; |
|
| 127 | 126 | } else { |
| 128 | 127 | $args[] = decompiler_($v, $fmt, 0 - $prof); |
| 129 | 128 | } |
@@ -146,7 +145,7 @@ discard block |
||
| 146 | 145 | return ''; |
| 147 | 146 | } |
| 148 | 147 | $res = ''; |
| 149 | - $f = 'format_critere_' . $fmt; |
|
| 148 | + $f = 'format_critere_'.$fmt; |
|
| 150 | 149 | foreach ($sources as $crit) { |
| 151 | 150 | if (!is_array($crit)) { |
| 152 | 151 | continue; |
@@ -159,13 +158,13 @@ discard block |
||
| 159 | 158 | and $v[0]->type == 'texte' |
| 160 | 159 | and $v[0]->apres |
| 161 | 160 | ) { |
| 162 | - $args[] = [['texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres)]]; |
|
| 161 | + $args[] = [['texte', ($v[0]->apres.$v[0]->texte.$v[0]->apres)]]; |
|
| 163 | 162 | } else { |
| 164 | 163 | $res2 = []; |
| 165 | 164 | foreach ($v as $k => $p) { |
| 166 | 165 | if ( |
| 167 | 166 | isset($p->type) |
| 168 | - and function_exists($d = 'decompiler_' . $p->type) |
|
| 167 | + and function_exists($d = 'decompiler_'.$p->type) |
|
| 169 | 168 | ) { |
| 170 | 169 | $r = $d($p, $fmt, (0 - $prof)); |
| 171 | 170 | $res2[] = [$p->type, $r]; |
@@ -193,7 +192,7 @@ discard block |
||
| 193 | 192 | if (!isset($p->type)) { |
| 194 | 193 | continue; |
| 195 | 194 | } #?????? |
| 196 | - $d = 'decompiler_' . $p->type; |
|
| 195 | + $d = 'decompiler_'.$p->type; |
|
| 197 | 196 | $next = $liste[$k + 1] ?? false; |
| 198 | 197 | // Forcer le champ etendu si son source (pas les reecritures) |
| 199 | 198 | // contenait des args et s'il est suivi d'espaces, |
@@ -218,16 +217,16 @@ discard block |
||
| 218 | 217 | } |
| 219 | 218 | $contenu[] = [$d($p, $fmt, $prof2), $p->type]; |
| 220 | 219 | } |
| 221 | - $f = 'format_suite_' . $fmt; |
|
| 220 | + $f = 'format_suite_'.$fmt; |
|
| 222 | 221 | |
| 223 | 222 | return $f($contenu); |
| 224 | 223 | } |
| 225 | 224 | |
| 226 | 225 | function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') { |
| 227 | - if (!include_spip('public/format_' . $fmt)) { |
|
| 226 | + if (!include_spip('public/format_'.$fmt)) { |
|
| 228 | 227 | return "'$fmt'?"; |
| 229 | 228 | } |
| 230 | - $f = 'decompiler_' . $quoi; |
|
| 229 | + $f = 'decompiler_'.$quoi; |
|
| 231 | 230 | |
| 232 | 231 | return $f($liste, $fmt, $prof); |
| 233 | 232 | } |
@@ -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_fichiers_fonctions(); |
@@ -30,177 +30,177 @@ discard block |
||
| 30 | 30 | # En cas d'erreur process_ins est absent et texte est un tableau de 2 chaines |
| 31 | 31 | |
| 32 | 32 | function public_parametrer_dist($fond, $contexte = '', $cache = '', string $connect = '') { |
| 33 | - static $composer, $styliser, $notes = null; |
|
| 34 | - $page = tester_redirection($fond, $contexte, $connect); |
|
| 35 | - if ($page) { |
|
| 36 | - return $page; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - if (isset($contexte['lang'])) { |
|
| 40 | - $lang = $contexte['lang']; |
|
| 41 | - } elseif (!isset($lang)) { |
|
| 42 | - $lang = $GLOBALS['meta']['langue_site']; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']); |
|
| 46 | - if ($select) { |
|
| 47 | - $select = lang_select($lang); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug'); |
|
| 51 | - |
|
| 52 | - if (!$styliser) { |
|
| 53 | - $styliser = charger_fonction('styliser', 'public'); |
|
| 54 | - } |
|
| 55 | - [$skel, $mime_type, $gram, $sourcefile] = |
|
| 56 | - $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
|
| 57 | - |
|
| 58 | - if ($skel) { |
|
| 59 | - // sauver le nom de l'eventuel squelette en cours d'execution |
|
| 60 | - // (recursion possible a cause des modeles) |
|
| 61 | - if ($debug) { |
|
| 62 | - $courant = $GLOBALS['debug_objets']['courant'] ?? null; |
|
| 63 | - $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - // charger le squelette en specifiant les langages cibles et source |
|
| 67 | - // au cas il faudrait le compiler (source posterieure au resultat) |
|
| 68 | - |
|
| 69 | - if (!$composer) { |
|
| 70 | - $composer = charger_fonction('composer', 'public'); |
|
| 71 | - } |
|
| 72 | - $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect); |
|
| 73 | - } else { |
|
| 74 | - $fonc = ''; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - if (!$fonc) { // squelette inconnu (==='') ou faux (===false) |
|
| 78 | - $page = $fonc; |
|
| 79 | - } else { |
|
| 80 | - // Preparer l'appel de la fonction principale du squelette |
|
| 81 | - |
|
| 82 | - spip_timer($a = 'calcul page ' . random_int(0, 1000)); |
|
| 83 | - |
|
| 84 | - // On cree un marqueur de notes unique lie a cette composition |
|
| 85 | - // et on enregistre l'etat courant des globales de notes... |
|
| 86 | - if (is_null($notes)) { |
|
| 87 | - $notes = charger_fonction('notes', 'inc', true); |
|
| 88 | - } |
|
| 89 | - if ($notes) { |
|
| 90 | - $notes('', 'empiler'); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // Rajouter d'office ces deux parametres |
|
| 94 | - // (mais vaudrait mieux que le compilateur sache le simuler |
|
| 95 | - // car ca interdit l'usage de criteres conditionnels dessus). |
|
| 96 | - if (!isset($contexte['date'])) { |
|
| 97 | - $contexte['date'] = date('Y-m-d H:i:s'); |
|
| 98 | - $contexte['date_default'] = true; |
|
| 99 | - } else { |
|
| 100 | - $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - if (!isset($contexte['date_redac'])) { |
|
| 104 | - $contexte['date_redac'] = date('Y-m-d H:i:s'); |
|
| 105 | - $contexte['date_redac_default'] = true; |
|
| 106 | - } else { |
|
| 107 | - $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - // Passer le nom du cache pour produire sa destruction automatique |
|
| 111 | - try { |
|
| 112 | - $page = $fonc(['cache' => $cache], [$contexte]); |
|
| 113 | - } catch (Throwable $e) { |
|
| 114 | - $msg = _T('zbug_erreur_execution_page') . " $sourcefile"; |
|
| 115 | - $full_msg = $msg . ' | File ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 116 | - $full_msg = str_replace(_ROOT_RACINE, '[…]/', $full_msg); |
|
| 117 | - $corps = "<pre>$msg</pre>"; |
|
| 118 | - $page = analyse_resultat_skel($fond, ['cache' => $cache], $corps, $sourcefile); |
|
| 119 | - erreur_squelette($full_msg); |
|
| 120 | - unset($msg, $full_msg, $corps); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // Restituer les globales de notes telles qu'elles etaient avant l'appel |
|
| 124 | - // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent* |
|
| 125 | - // etre dans son resultat, autrement elles ne seraient pas prises en |
|
| 126 | - // compte a chaque calcul d'un texte contenant un modele, mais seulement |
|
| 127 | - // quand le modele serait calcule, et on aurait des resultats incoherents) |
|
| 128 | - if ($notes) { |
|
| 129 | - $notes('', 'depiler'); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // reinjecter en dynamique la pile des notes |
|
| 133 | - // si il y a des inclure dynamiques |
|
| 134 | - // si la pile n'est pas vide |
|
| 135 | - // la generalisation de cette injection permettrait de corriger le point juste au dessus |
|
| 136 | - // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
|
| 137 | - if ($notes) { |
|
| 138 | - $page['notes'] = $notes('', 'sauver_etat'); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - // spip_log: un joli contexte |
|
| 142 | - $infos = presenter_contexte(array_filter($contexte)); |
|
| 143 | - |
|
| 144 | - $profile = spip_timer($a); |
|
| 145 | - spip_log("calcul ($profile) [$skel] $infos" |
|
| 146 | - . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 147 | - |
|
| 148 | - if (defined('_CALCUL_PROFILER') and intval($profile) > _CALCUL_PROFILER) { |
|
| 149 | - spip_log("calcul ($profile) [$skel] $infos" |
|
| 150 | - . ' (' . strlen($page['texte']) . ' octets) | ' . $_SERVER['REQUEST_URI'], 'profiler' . _LOG_AVERTISSEMENT); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - if ($debug) { |
|
| 154 | - // si c'est ce que demande le debusqueur, lui passer la main |
|
| 155 | - $t = strlen($page['texte']) ? $page['texte'] : ' '; |
|
| 156 | - $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 157 | - $GLOBALS['debug_objets']['courant'] = $courant; |
|
| 158 | - $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
|
| 159 | - if ( |
|
| 160 | - $GLOBALS['debug_objets']['sourcefile'] |
|
| 161 | - and (_request('var_mode_objet') == $fonc) |
|
| 162 | - and (_request('var_mode_affiche') == 'resultat') |
|
| 163 | - ) { |
|
| 164 | - erreur_squelette(); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - // Si #CACHE{} n'etait pas la, le mettre a $delais |
|
| 168 | - if (!isset($page['entetes']['X-Spip-Cache'])) { |
|
| 169 | - // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut |
|
| 170 | - // si aucun #CACHE{} spécifié |
|
| 171 | - // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
|
| 172 | - // entre public et prive |
|
| 173 | - if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) { |
|
| 174 | - $page['entetes']['X-Spip-Cache'] = 0; |
|
| 175 | - } else { |
|
| 176 | - $page['entetes']['X-Spip-Cache'] = $GLOBALS['delais'] ?? 36000; |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - $page['contexte'] = $contexte; |
|
| 181 | - |
|
| 182 | - // faire remonter le fichier source |
|
| 183 | - static $js_inclus = false; |
|
| 184 | - if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
|
| 185 | - $page['sourcefile'] = $sourcefile; |
|
| 186 | - $page['texte'] = |
|
| 187 | - "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . '</h6>' . $page['texte'] . '</div>' |
|
| 188 | - . ($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>"); |
|
| 189 | - $js_inclus = true; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - // Si un modele contenait #SESSION, on note l'info dans $page |
|
| 193 | - if (isset($GLOBALS['cache_utilise_session'])) { |
|
| 194 | - $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session']; |
|
| 195 | - unset($GLOBALS['cache_utilise_session']); |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - if ($select) { |
|
| 200 | - lang_select(); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - return $page; |
|
| 33 | + static $composer, $styliser, $notes = null; |
|
| 34 | + $page = tester_redirection($fond, $contexte, $connect); |
|
| 35 | + if ($page) { |
|
| 36 | + return $page; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + if (isset($contexte['lang'])) { |
|
| 40 | + $lang = $contexte['lang']; |
|
| 41 | + } elseif (!isset($lang)) { |
|
| 42 | + $lang = $GLOBALS['meta']['langue_site']; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + $select = ((!isset($GLOBALS['forcer_lang']) or !$GLOBALS['forcer_lang']) and $lang <> $GLOBALS['spip_lang']); |
|
| 46 | + if ($select) { |
|
| 47 | + $select = lang_select($lang); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug'); |
|
| 51 | + |
|
| 52 | + if (!$styliser) { |
|
| 53 | + $styliser = charger_fonction('styliser', 'public'); |
|
| 54 | + } |
|
| 55 | + [$skel, $mime_type, $gram, $sourcefile] = |
|
| 56 | + $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
|
| 57 | + |
|
| 58 | + if ($skel) { |
|
| 59 | + // sauver le nom de l'eventuel squelette en cours d'execution |
|
| 60 | + // (recursion possible a cause des modeles) |
|
| 61 | + if ($debug) { |
|
| 62 | + $courant = $GLOBALS['debug_objets']['courant'] ?? null; |
|
| 63 | + $GLOBALS['debug_objets']['contexte'][$sourcefile] = $contexte; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + // charger le squelette en specifiant les langages cibles et source |
|
| 67 | + // au cas il faudrait le compiler (source posterieure au resultat) |
|
| 68 | + |
|
| 69 | + if (!$composer) { |
|
| 70 | + $composer = charger_fonction('composer', 'public'); |
|
| 71 | + } |
|
| 72 | + $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect); |
|
| 73 | + } else { |
|
| 74 | + $fonc = ''; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + if (!$fonc) { // squelette inconnu (==='') ou faux (===false) |
|
| 78 | + $page = $fonc; |
|
| 79 | + } else { |
|
| 80 | + // Preparer l'appel de la fonction principale du squelette |
|
| 81 | + |
|
| 82 | + spip_timer($a = 'calcul page ' . random_int(0, 1000)); |
|
| 83 | + |
|
| 84 | + // On cree un marqueur de notes unique lie a cette composition |
|
| 85 | + // et on enregistre l'etat courant des globales de notes... |
|
| 86 | + if (is_null($notes)) { |
|
| 87 | + $notes = charger_fonction('notes', 'inc', true); |
|
| 88 | + } |
|
| 89 | + if ($notes) { |
|
| 90 | + $notes('', 'empiler'); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // Rajouter d'office ces deux parametres |
|
| 94 | + // (mais vaudrait mieux que le compilateur sache le simuler |
|
| 95 | + // car ca interdit l'usage de criteres conditionnels dessus). |
|
| 96 | + if (!isset($contexte['date'])) { |
|
| 97 | + $contexte['date'] = date('Y-m-d H:i:s'); |
|
| 98 | + $contexte['date_default'] = true; |
|
| 99 | + } else { |
|
| 100 | + $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + if (!isset($contexte['date_redac'])) { |
|
| 104 | + $contexte['date_redac'] = date('Y-m-d H:i:s'); |
|
| 105 | + $contexte['date_redac_default'] = true; |
|
| 106 | + } else { |
|
| 107 | + $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + // Passer le nom du cache pour produire sa destruction automatique |
|
| 111 | + try { |
|
| 112 | + $page = $fonc(['cache' => $cache], [$contexte]); |
|
| 113 | + } catch (Throwable $e) { |
|
| 114 | + $msg = _T('zbug_erreur_execution_page') . " $sourcefile"; |
|
| 115 | + $full_msg = $msg . ' | File ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage(); |
|
| 116 | + $full_msg = str_replace(_ROOT_RACINE, '[…]/', $full_msg); |
|
| 117 | + $corps = "<pre>$msg</pre>"; |
|
| 118 | + $page = analyse_resultat_skel($fond, ['cache' => $cache], $corps, $sourcefile); |
|
| 119 | + erreur_squelette($full_msg); |
|
| 120 | + unset($msg, $full_msg, $corps); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // Restituer les globales de notes telles qu'elles etaient avant l'appel |
|
| 124 | + // Si l'inclus n'a pas affiche ses notes, tant pis (elles *doivent* |
|
| 125 | + // etre dans son resultat, autrement elles ne seraient pas prises en |
|
| 126 | + // compte a chaque calcul d'un texte contenant un modele, mais seulement |
|
| 127 | + // quand le modele serait calcule, et on aurait des resultats incoherents) |
|
| 128 | + if ($notes) { |
|
| 129 | + $notes('', 'depiler'); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // reinjecter en dynamique la pile des notes |
|
| 133 | + // si il y a des inclure dynamiques |
|
| 134 | + // si la pile n'est pas vide |
|
| 135 | + // la generalisation de cette injection permettrait de corriger le point juste au dessus |
|
| 136 | + // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
|
| 137 | + if ($notes) { |
|
| 138 | + $page['notes'] = $notes('', 'sauver_etat'); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + // spip_log: un joli contexte |
|
| 142 | + $infos = presenter_contexte(array_filter($contexte)); |
|
| 143 | + |
|
| 144 | + $profile = spip_timer($a); |
|
| 145 | + spip_log("calcul ($profile) [$skel] $infos" |
|
| 146 | + . ' (' . strlen($page['texte']) . ' octets)'); |
|
| 147 | + |
|
| 148 | + if (defined('_CALCUL_PROFILER') and intval($profile) > _CALCUL_PROFILER) { |
|
| 149 | + spip_log("calcul ($profile) [$skel] $infos" |
|
| 150 | + . ' (' . strlen($page['texte']) . ' octets) | ' . $_SERVER['REQUEST_URI'], 'profiler' . _LOG_AVERTISSEMENT); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + if ($debug) { |
|
| 154 | + // si c'est ce que demande le debusqueur, lui passer la main |
|
| 155 | + $t = strlen($page['texte']) ? $page['texte'] : ' '; |
|
| 156 | + $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 157 | + $GLOBALS['debug_objets']['courant'] = $courant; |
|
| 158 | + $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
|
| 159 | + if ( |
|
| 160 | + $GLOBALS['debug_objets']['sourcefile'] |
|
| 161 | + and (_request('var_mode_objet') == $fonc) |
|
| 162 | + and (_request('var_mode_affiche') == 'resultat') |
|
| 163 | + ) { |
|
| 164 | + erreur_squelette(); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + // Si #CACHE{} n'etait pas la, le mettre a $delais |
|
| 168 | + if (!isset($page['entetes']['X-Spip-Cache'])) { |
|
| 169 | + // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut |
|
| 170 | + // si aucun #CACHE{} spécifié |
|
| 171 | + // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
|
| 172 | + // entre public et prive |
|
| 173 | + if (test_espace_prive() or strncmp($fond, 'modeles/', 8) == 0) { |
|
| 174 | + $page['entetes']['X-Spip-Cache'] = 0; |
|
| 175 | + } else { |
|
| 176 | + $page['entetes']['X-Spip-Cache'] = $GLOBALS['delais'] ?? 36000; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + $page['contexte'] = $contexte; |
|
| 181 | + |
|
| 182 | + // faire remonter le fichier source |
|
| 183 | + static $js_inclus = false; |
|
| 184 | + if (defined('_VAR_INCLURE') and _VAR_INCLURE) { |
|
| 185 | + $page['sourcefile'] = $sourcefile; |
|
| 186 | + $page['texte'] = |
|
| 187 | + "<div class='inclure_blocs'><h6>" . $page['sourcefile'] . '</h6>' . $page['texte'] . '</div>' |
|
| 188 | + . ($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>"); |
|
| 189 | + $js_inclus = true; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + // Si un modele contenait #SESSION, on note l'info dans $page |
|
| 193 | + if (isset($GLOBALS['cache_utilise_session'])) { |
|
| 194 | + $page['invalideurs']['session'] = $GLOBALS['cache_utilise_session']; |
|
| 195 | + unset($GLOBALS['cache_utilise_session']); |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + if ($select) { |
|
| 200 | + lang_select(); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + return $page; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -209,37 +209,37 @@ discard block |
||
| 209 | 209 | * @return string |
| 210 | 210 | */ |
| 211 | 211 | function presenter_contexte($contexte, $profondeur_max = 1, $max_lines = 0) { |
| 212 | - $infos = []; |
|
| 213 | - $line = 0; |
|
| 214 | - foreach ($contexte as $var => $val) { |
|
| 215 | - $line++; |
|
| 216 | - if ($max_lines and $max_lines < $line) { |
|
| 217 | - $infos[] = '…'; |
|
| 218 | - break; |
|
| 219 | - } |
|
| 220 | - if ($val === null) { |
|
| 221 | - $val = ''; |
|
| 222 | - } elseif (is_array($val)) { |
|
| 223 | - if ($profondeur_max > 0) { |
|
| 224 | - $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 225 | - } else { |
|
| 226 | - $val = 'array:' . count($val); |
|
| 227 | - } |
|
| 228 | - } elseif (is_object($val)) { |
|
| 229 | - $val = get_class($val); |
|
| 230 | - } elseif (strlen("$val") > 30) { |
|
| 231 | - $val = substr("$val", 0, 29) . '…'; |
|
| 232 | - if (strstr($val, ' ')) { |
|
| 233 | - $val = "'$val'"; |
|
| 234 | - } |
|
| 235 | - } elseif (strstr($val, ' ')) { |
|
| 236 | - $val = "'$val'"; |
|
| 237 | - } elseif (!strlen($val)) { |
|
| 238 | - $val = "''"; |
|
| 239 | - } |
|
| 240 | - $infos[] = $var . '=' . $val; |
|
| 241 | - } |
|
| 242 | - return join(', ', $infos); |
|
| 212 | + $infos = []; |
|
| 213 | + $line = 0; |
|
| 214 | + foreach ($contexte as $var => $val) { |
|
| 215 | + $line++; |
|
| 216 | + if ($max_lines and $max_lines < $line) { |
|
| 217 | + $infos[] = '…'; |
|
| 218 | + break; |
|
| 219 | + } |
|
| 220 | + if ($val === null) { |
|
| 221 | + $val = ''; |
|
| 222 | + } elseif (is_array($val)) { |
|
| 223 | + if ($profondeur_max > 0) { |
|
| 224 | + $val = 'array:' . count($val) . '(' . presenter_contexte($val, $profondeur_max - 1, 3) . ')'; |
|
| 225 | + } else { |
|
| 226 | + $val = 'array:' . count($val); |
|
| 227 | + } |
|
| 228 | + } elseif (is_object($val)) { |
|
| 229 | + $val = get_class($val); |
|
| 230 | + } elseif (strlen("$val") > 30) { |
|
| 231 | + $val = substr("$val", 0, 29) . '…'; |
|
| 232 | + if (strstr($val, ' ')) { |
|
| 233 | + $val = "'$val'"; |
|
| 234 | + } |
|
| 235 | + } elseif (strstr($val, ' ')) { |
|
| 236 | + $val = "'$val'"; |
|
| 237 | + } elseif (!strlen($val)) { |
|
| 238 | + $val = "''"; |
|
| 239 | + } |
|
| 240 | + $infos[] = $var . '=' . $val; |
|
| 241 | + } |
|
| 242 | + return join(', ', $infos); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
@@ -256,11 +256,11 @@ discard block |
||
| 256 | 256 | * @return array|bool |
| 257 | 257 | */ |
| 258 | 258 | function tester_redirection($fond, $contexte, $connect) { |
| 259 | - static $tester_redirection = null; |
|
| 260 | - if (is_null($tester_redirection)) { |
|
| 261 | - $tester_redirection = charger_fonction('tester_redirection', 'public'); |
|
| 262 | - } |
|
| 263 | - return $tester_redirection($fond, $contexte, $connect); |
|
| 259 | + static $tester_redirection = null; |
|
| 260 | + if (is_null($tester_redirection)) { |
|
| 261 | + $tester_redirection = charger_fonction('tester_redirection', 'public'); |
|
| 262 | + } |
|
| 263 | + return $tester_redirection($fond, $contexte, $connect); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
@@ -276,42 +276,42 @@ discard block |
||
| 276 | 276 | * @return array|bool |
| 277 | 277 | */ |
| 278 | 278 | function public_tester_redirection_dist($fond, $contexte, $connect) { |
| 279 | - if ( |
|
| 280 | - $fond == 'article' |
|
| 281 | - and !empty($contexte['id_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 [ |
|
| 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; |
|
| 279 | + if ( |
|
| 280 | + $fond == 'article' |
|
| 281 | + and !empty($contexte['id_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 [ |
|
| 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 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('public/decompiler'); |
@@ -68,123 +68,123 @@ discard block |
||
| 68 | 68 | * - true si $opt 'erreurs' = 'reset' |
| 69 | 69 | **/ |
| 70 | 70 | function public_debusquer_dist($message = '', $lieu = '', $opt = []) { |
| 71 | - static $tableau_des_erreurs = []; |
|
| 72 | - |
|
| 73 | - // Pour des tests unitaires, pouvoir récupérer les erreurs générées |
|
| 74 | - if (isset($opt['erreurs'])) { |
|
| 75 | - if ($opt['erreurs'] == 'get') { |
|
| 76 | - return $tableau_des_erreurs; |
|
| 77 | - } |
|
| 78 | - if ($opt['erreurs'] == 'reset') { |
|
| 79 | - $tableau_des_erreurs = []; |
|
| 80 | - |
|
| 81 | - return true; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - // Erreur ou appel final ? |
|
| 86 | - if ($message) { |
|
| 87 | - $message = debusquer_compose_message($message); |
|
| 88 | - $tableau_des_erreurs[] = [$message, $lieu]; |
|
| 89 | - set_request('var_mode', 'debug'); |
|
| 90 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 91 | - // Permettre a la compil de continuer |
|
| 92 | - if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) { |
|
| 93 | - $lieu->code = "''"; |
|
| 94 | - } |
|
| 95 | - // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 96 | - $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 97 | - if (!$urgence) { |
|
| 98 | - return; |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - if (empty($GLOBALS['debug_objets']['principal'])) { |
|
| 102 | - // espace public ? |
|
| 103 | - if (isset($GLOBALS['fond'])) { |
|
| 104 | - $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - include_spip('inc/autoriser'); |
|
| 109 | - if (!autoriser('debug')) { |
|
| 110 | - return; |
|
| 111 | - } |
|
| 112 | - include_spip('inc/headers'); |
|
| 113 | - include_spip('inc/filtres'); |
|
| 114 | - |
|
| 115 | - lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 116 | - $fonc = _request('var_mode_objet'); |
|
| 117 | - $mode = _request('var_mode_affiche'); |
|
| 118 | - $self = str_replace("\\'", ''', self()); |
|
| 119 | - $self = parametre_url($self, 'var_mode', 'debug'); |
|
| 120 | - |
|
| 121 | - $res = debusquer_bandeau($tableau_des_erreurs) |
|
| 122 | - . '<br />' |
|
| 123 | - . debusquer_squelette($fonc, $mode, $self); |
|
| 124 | - |
|
| 125 | - if (!_DIR_RESTREINT or headers_sent()) { |
|
| 126 | - return $res; |
|
| 127 | - } |
|
| 128 | - if ($tableau_des_erreurs) { |
|
| 129 | - http_response_code(503); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - http_no_cache(); |
|
| 133 | - if (isset($_GET['var_profile'])) { |
|
| 134 | - $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', ''); |
|
| 135 | - $titre = parametre_url($titre, 'var_mode', ''); |
|
| 136 | - } else { |
|
| 137 | - if (!$fonc) { |
|
| 138 | - $fonc = $GLOBALS['debug_objets']['principal']; |
|
| 139 | - } |
|
| 140 | - $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 141 | - } |
|
| 142 | - if ($message === false) { |
|
| 143 | - lang_select(); |
|
| 144 | - |
|
| 145 | - return debusquer_entete($titre, $res); |
|
| 146 | - } else { |
|
| 147 | - echo debusquer_entete($titre, $res); |
|
| 148 | - } |
|
| 149 | - exit; |
|
| 71 | + static $tableau_des_erreurs = []; |
|
| 72 | + |
|
| 73 | + // Pour des tests unitaires, pouvoir récupérer les erreurs générées |
|
| 74 | + if (isset($opt['erreurs'])) { |
|
| 75 | + if ($opt['erreurs'] == 'get') { |
|
| 76 | + return $tableau_des_erreurs; |
|
| 77 | + } |
|
| 78 | + if ($opt['erreurs'] == 'reset') { |
|
| 79 | + $tableau_des_erreurs = []; |
|
| 80 | + |
|
| 81 | + return true; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + // Erreur ou appel final ? |
|
| 86 | + if ($message) { |
|
| 87 | + $message = debusquer_compose_message($message); |
|
| 88 | + $tableau_des_erreurs[] = [$message, $lieu]; |
|
| 89 | + set_request('var_mode', 'debug'); |
|
| 90 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 91 | + // Permettre a la compil de continuer |
|
| 92 | + if (is_object($lieu) and (!isset($lieu->code) or !$lieu->code)) { |
|
| 93 | + $lieu->code = "''"; |
|
| 94 | + } |
|
| 95 | + // forcer l'appel au debusqueur en cas de boucles infernales |
|
| 96 | + $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS and (is_countable($tableau_des_erreurs) ? count($tableau_des_erreurs) : 0) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 97 | + if (!$urgence) { |
|
| 98 | + return; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + if (empty($GLOBALS['debug_objets']['principal'])) { |
|
| 102 | + // espace public ? |
|
| 103 | + if (isset($GLOBALS['fond'])) { |
|
| 104 | + $GLOBALS['debug_objets']['principal'] = $GLOBALS['fond']; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + include_spip('inc/autoriser'); |
|
| 109 | + if (!autoriser('debug')) { |
|
| 110 | + return; |
|
| 111 | + } |
|
| 112 | + include_spip('inc/headers'); |
|
| 113 | + include_spip('inc/filtres'); |
|
| 114 | + |
|
| 115 | + lang_select($GLOBALS['visiteur_session']['lang']); |
|
| 116 | + $fonc = _request('var_mode_objet'); |
|
| 117 | + $mode = _request('var_mode_affiche'); |
|
| 118 | + $self = str_replace("\\'", ''', self()); |
|
| 119 | + $self = parametre_url($self, 'var_mode', 'debug'); |
|
| 120 | + |
|
| 121 | + $res = debusquer_bandeau($tableau_des_erreurs) |
|
| 122 | + . '<br />' |
|
| 123 | + . debusquer_squelette($fonc, $mode, $self); |
|
| 124 | + |
|
| 125 | + if (!_DIR_RESTREINT or headers_sent()) { |
|
| 126 | + return $res; |
|
| 127 | + } |
|
| 128 | + if ($tableau_des_erreurs) { |
|
| 129 | + http_response_code(503); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + http_no_cache(); |
|
| 133 | + if (isset($_GET['var_profile'])) { |
|
| 134 | + $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', ''); |
|
| 135 | + $titre = parametre_url($titre, 'var_mode', ''); |
|
| 136 | + } else { |
|
| 137 | + if (!$fonc) { |
|
| 138 | + $fonc = $GLOBALS['debug_objets']['principal']; |
|
| 139 | + } |
|
| 140 | + $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 141 | + } |
|
| 142 | + if ($message === false) { |
|
| 143 | + lang_select(); |
|
| 144 | + |
|
| 145 | + return debusquer_entete($titre, $res); |
|
| 146 | + } else { |
|
| 147 | + echo debusquer_entete($titre, $res); |
|
| 148 | + } |
|
| 149 | + exit; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | function debusquer_compose_message($msg) { |
| 153 | - if (is_array($msg)) { |
|
| 154 | - // si c'est un texte, c'est une traduction a faire, mais |
|
| 155 | - // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments) |
|
| 156 | - if (!is_numeric($msg[0]) and count($msg) == 2) { |
|
| 157 | - // message avec argument: instancier |
|
| 158 | - $msg = _T($msg[0], $msg[1], 'spip-debug-arg'); |
|
| 159 | - } else { |
|
| 160 | - // message SQL: interpreter |
|
| 161 | - $msg = debusquer_requete($msg); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - // FIXME: le fond n'est pas la si on n'est pas dans un squelette |
|
| 165 | - // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur |
|
| 166 | - $fond = $GLOBALS['fond'] ?? ''; |
|
| 167 | - // une erreur critique sort $message en array |
|
| 168 | - $debug = is_array($msg) ? $msg[1] : $msg; |
|
| 169 | - spip_log('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 170 | - |
|
| 171 | - return $msg; |
|
| 153 | + if (is_array($msg)) { |
|
| 154 | + // si c'est un texte, c'est une traduction a faire, mais |
|
| 155 | + // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments) |
|
| 156 | + if (!is_numeric($msg[0]) and count($msg) == 2) { |
|
| 157 | + // message avec argument: instancier |
|
| 158 | + $msg = _T($msg[0], $msg[1], 'spip-debug-arg'); |
|
| 159 | + } else { |
|
| 160 | + // message SQL: interpreter |
|
| 161 | + $msg = debusquer_requete($msg); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + // FIXME: le fond n'est pas la si on n'est pas dans un squelette |
|
| 165 | + // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur |
|
| 166 | + $fond = $GLOBALS['fond'] ?? ''; |
|
| 167 | + // une erreur critique sort $message en array |
|
| 168 | + $debug = is_array($msg) ? $msg[1] : $msg; |
|
| 169 | + spip_log('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 170 | + |
|
| 171 | + return $msg; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | function debusquer_bandeau($erreurs) { |
| 175 | 175 | |
| 176 | - if (!empty($erreurs)) { |
|
| 177 | - $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 176 | + if (!empty($erreurs)) { |
|
| 177 | + $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 178 | 178 | |
| 179 | - return debusquer_navigation($erreurs, $n); |
|
| 180 | - } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
|
| 181 | - include_spip('public/tracer'); |
|
| 182 | - [$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']); |
|
| 179 | + return debusquer_navigation($erreurs, $n); |
|
| 180 | + } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
|
| 181 | + include_spip('public/tracer'); |
|
| 182 | + [$temps, $nav] = chrono_requete($GLOBALS['tableau_des_temps']); |
|
| 183 | 183 | |
| 184 | - return debusquer_navigation($temps, $nav, 'debug-profile'); |
|
| 185 | - } else { |
|
| 186 | - return ''; |
|
| 187 | - } |
|
| 184 | + return debusquer_navigation($temps, $nav, 'debug-profile'); |
|
| 185 | + } else { |
|
| 186 | + return ''; |
|
| 187 | + } |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -194,42 +194,42 @@ discard block |
||
| 194 | 194 | * @return string Code HTML |
| 195 | 195 | **/ |
| 196 | 196 | function debusquer_contexte($env) { |
| 197 | - if (is_string($env) and is_array($env_tab = @unserialize($env))) { |
|
| 198 | - $env = $env_tab; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - if (!$env) { |
|
| 202 | - return ''; |
|
| 203 | - } |
|
| 204 | - $res = ''; |
|
| 205 | - foreach ($env as $nom => $valeur) { |
|
| 206 | - if (is_array($valeur)) { |
|
| 207 | - $valeur_simple = []; |
|
| 208 | - foreach ($valeur as $v) { |
|
| 209 | - if (is_array($v)) { |
|
| 210 | - $valeur_simple[] = 'array:' . count($v); |
|
| 211 | - } elseif (is_object($v)) { |
|
| 212 | - $valeur_simple[] = get_class($v); |
|
| 213 | - } elseif (is_string($v)) { |
|
| 214 | - $valeur_simple[] = "'" . $v . "'"; |
|
| 215 | - } else { |
|
| 216 | - $valeur_simple[] = $v; |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - $n = count($valeur); |
|
| 220 | - $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 221 | - $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 222 | - } elseif (is_object($valeur)) { |
|
| 223 | - $valeur = get_class($valeur); |
|
| 224 | - } elseif (is_string($valeur)) { |
|
| 225 | - $valeur = "'" . $valeur . "'"; |
|
| 226 | - } |
|
| 227 | - $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 228 | - . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 229 | - . "</td></tr>\n"; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 197 | + if (is_string($env) and is_array($env_tab = @unserialize($env))) { |
|
| 198 | + $env = $env_tab; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + if (!$env) { |
|
| 202 | + return ''; |
|
| 203 | + } |
|
| 204 | + $res = ''; |
|
| 205 | + foreach ($env as $nom => $valeur) { |
|
| 206 | + if (is_array($valeur)) { |
|
| 207 | + $valeur_simple = []; |
|
| 208 | + foreach ($valeur as $v) { |
|
| 209 | + if (is_array($v)) { |
|
| 210 | + $valeur_simple[] = 'array:' . count($v); |
|
| 211 | + } elseif (is_object($v)) { |
|
| 212 | + $valeur_simple[] = get_class($v); |
|
| 213 | + } elseif (is_string($v)) { |
|
| 214 | + $valeur_simple[] = "'" . $v . "'"; |
|
| 215 | + } else { |
|
| 216 | + $valeur_simple[] = $v; |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + $n = count($valeur); |
|
| 220 | + $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 221 | + $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 222 | + } elseif (is_object($valeur)) { |
|
| 223 | + $valeur = get_class($valeur); |
|
| 224 | + } elseif (is_string($valeur)) { |
|
| 225 | + $valeur = "'" . $valeur . "'"; |
|
| 226 | + } |
|
| 227 | + $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 228 | + . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 229 | + . "</td></tr>\n"; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + return "<div class='spip-env'><fieldset><legend onclick=\"this.parentElement.classList.toggle('expanded');\">#ENV</legend>\n<div><table>$res</table></div></fieldset></div>\n"; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | // Affichage du tableau des erreurs ou des temps de calcul |
@@ -237,66 +237,66 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | function debusquer_navigation($tableau, $caption = [], $id = 'debug-nav') { |
| 239 | 239 | |
| 240 | - if (_request('exec') == 'valider_xml') { |
|
| 241 | - return ''; |
|
| 242 | - } |
|
| 243 | - $GLOBALS['bouton_admin_debug'] = true; |
|
| 244 | - $res = ''; |
|
| 245 | - $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 246 | - foreach ($tableau as $i => $err) { |
|
| 247 | - $boucle = $ligne = $skel = ''; |
|
| 248 | - [$msg, $lieu] = $err; |
|
| 249 | - if (is_object($lieu)) { |
|
| 250 | - $ligne = $lieu->ligne; |
|
| 251 | - $boucle = !empty($lieu->id_boucle) ? $lieu->id_boucle : ''; |
|
| 252 | - if (isset($lieu->descr['nom'])) { |
|
| 253 | - $nom_code = $lieu->descr['nom']; |
|
| 254 | - $skel = $lieu->descr['sourcefile']; |
|
| 255 | - $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 256 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 257 | - $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 258 | - if ($boucle) { |
|
| 259 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 260 | - $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - $j = ($i + 1); |
|
| 266 | - $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 267 | - . $j |
|
| 268 | - . " </td><td style='text-align: left'>" |
|
| 269 | - . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 270 | - . "</td><td style='text-align: left'>" |
|
| 271 | - . ($skel ?: ' / ') |
|
| 272 | - . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 273 | - . ($boucle ?: ' / ') |
|
| 274 | - . "</td><td style='text-align: right'>" |
|
| 275 | - . $ligne |
|
| 276 | - . "</td></tr>\n"; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - return "\n<table id='$id'>" |
|
| 280 | - . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 281 | - . $caption[0] |
|
| 240 | + if (_request('exec') == 'valider_xml') { |
|
| 241 | + return ''; |
|
| 242 | + } |
|
| 243 | + $GLOBALS['bouton_admin_debug'] = true; |
|
| 244 | + $res = ''; |
|
| 245 | + $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
|
| 246 | + foreach ($tableau as $i => $err) { |
|
| 247 | + $boucle = $ligne = $skel = ''; |
|
| 248 | + [$msg, $lieu] = $err; |
|
| 249 | + if (is_object($lieu)) { |
|
| 250 | + $ligne = $lieu->ligne; |
|
| 251 | + $boucle = !empty($lieu->id_boucle) ? $lieu->id_boucle : ''; |
|
| 252 | + if (isset($lieu->descr['nom'])) { |
|
| 253 | + $nom_code = $lieu->descr['nom']; |
|
| 254 | + $skel = $lieu->descr['sourcefile']; |
|
| 255 | + $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
|
| 256 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 257 | + $skel = "<a href='$h3'><b>$skel</b></a>"; |
|
| 258 | + if ($boucle) { |
|
| 259 | + $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 260 | + $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + $j = ($i + 1); |
|
| 266 | + $res .= "<tr id='req$j'><td style='text-align: right'>" |
|
| 267 | + . $j |
|
| 268 | + . " </td><td style='text-align: left'>" |
|
| 269 | + . (is_array($msg) ? implode('', $msg) : $msg) |
|
| 270 | + . "</td><td style='text-align: left'>" |
|
| 271 | + . ($skel ?: ' / ') |
|
| 272 | + . "</td><td class='spip-debug-arg' style='text-align: left'>" |
|
| 273 | + . ($boucle ?: ' / ') |
|
| 274 | + . "</td><td style='text-align: right'>" |
|
| 275 | + . $ligne |
|
| 276 | + . "</td></tr>\n"; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + return "\n<table id='$id'>" |
|
| 280 | + . "<caption onclick=\"x = document.getElementById('$id'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\">" |
|
| 281 | + . $caption[0] |
|
| 282 | 282 | ## aide locale courte a ecrire, avec lien vers une grosse page de documentation |
| 283 | 283 | # aider('erreur_compilation'), |
| 284 | - . '</caption>' |
|
| 285 | - // fausse caption du chrono (mais vraie nav) |
|
| 286 | - . (!empty($caption[1]) ? $caption[1] : '') |
|
| 287 | - . '<tr><th>' |
|
| 288 | - . _T('numero') |
|
| 289 | - . '</th><th>' |
|
| 290 | - . _T('public:message') |
|
| 291 | - . '</th><th>' |
|
| 292 | - . _T('squelette') |
|
| 293 | - . '</th><th>' |
|
| 294 | - . _T('zbug_boucle') |
|
| 295 | - . '</th><th>' |
|
| 296 | - . _T('ligne') |
|
| 297 | - . '</th></tr>' |
|
| 298 | - . $res |
|
| 299 | - . '</table>'; |
|
| 284 | + . '</caption>' |
|
| 285 | + // fausse caption du chrono (mais vraie nav) |
|
| 286 | + . (!empty($caption[1]) ? $caption[1] : '') |
|
| 287 | + . '<tr><th>' |
|
| 288 | + . _T('numero') |
|
| 289 | + . '</th><th>' |
|
| 290 | + . _T('public:message') |
|
| 291 | + . '</th><th>' |
|
| 292 | + . _T('squelette') |
|
| 293 | + . '</th><th>' |
|
| 294 | + . _T('zbug_boucle') |
|
| 295 | + . '</th><th>' |
|
| 296 | + . _T('ligne') |
|
| 297 | + . '</th></tr>' |
|
| 298 | + . $res |
|
| 299 | + . '</table>'; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | |
@@ -316,514 +316,514 @@ discard block |
||
| 316 | 316 | * ou un tableau si l'erreur est critique |
| 317 | 317 | **/ |
| 318 | 318 | function debusquer_requete($message) { |
| 319 | - [$errno, $msg, $query] = $message; |
|
| 320 | - |
|
| 321 | - // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 322 | - // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 323 | - if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) { |
|
| 324 | - $errno = $regs[2]; |
|
| 325 | - } elseif ( |
|
| 326 | - is_numeric($errno) and ($errno == 1030 or $errno <= 1026) |
|
| 327 | - and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs) |
|
| 328 | - ) { |
|
| 329 | - $errno = $regs[1]; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - // Erreur systeme |
|
| 333 | - if (is_numeric($errno) and $errno > 0 and $errno < 200) { |
|
| 334 | - $retour = '<tt><br /><br /><blink>' |
|
| 335 | - . _T('info_erreur_systeme', ['errsys' => $errno]) |
|
| 336 | - . "</blink><br />\n<b>" |
|
| 337 | - . _T( |
|
| 338 | - 'info_erreur_systeme2', |
|
| 339 | - ['script' => generer_url_ecrire('base_repair')] |
|
| 340 | - ) |
|
| 341 | - . '</b><br />'; |
|
| 342 | - spip_log("Erreur systeme $errno"); |
|
| 343 | - |
|
| 344 | - return [$retour, '']; |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - // Requete erronee |
|
| 348 | - $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 349 | - . spip_htmlspecialchars($msg) |
|
| 350 | - . "\n<br /><span style='color: red'><b>" |
|
| 351 | - . spip_htmlspecialchars($query) |
|
| 352 | - . '</b></span></tt><br />'; |
|
| 353 | - |
|
| 354 | - //. aider('erreur_mysql'); |
|
| 355 | - |
|
| 356 | - return $err; |
|
| 319 | + [$errno, $msg, $query] = $message; |
|
| 320 | + |
|
| 321 | + // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
|
| 322 | + // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
|
| 323 | + if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) { |
|
| 324 | + $errno = $regs[2]; |
|
| 325 | + } elseif ( |
|
| 326 | + is_numeric($errno) and ($errno == 1030 or $errno <= 1026) |
|
| 327 | + and preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs) |
|
| 328 | + ) { |
|
| 329 | + $errno = $regs[1]; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + // Erreur systeme |
|
| 333 | + if (is_numeric($errno) and $errno > 0 and $errno < 200) { |
|
| 334 | + $retour = '<tt><br /><br /><blink>' |
|
| 335 | + . _T('info_erreur_systeme', ['errsys' => $errno]) |
|
| 336 | + . "</blink><br />\n<b>" |
|
| 337 | + . _T( |
|
| 338 | + 'info_erreur_systeme2', |
|
| 339 | + ['script' => generer_url_ecrire('base_repair')] |
|
| 340 | + ) |
|
| 341 | + . '</b><br />'; |
|
| 342 | + spip_log("Erreur systeme $errno"); |
|
| 343 | + |
|
| 344 | + return [$retour, '']; |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + // Requete erronee |
|
| 348 | + $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 349 | + . spip_htmlspecialchars($msg) |
|
| 350 | + . "\n<br /><span style='color: red'><b>" |
|
| 351 | + . spip_htmlspecialchars($query) |
|
| 352 | + . '</b></span></tt><br />'; |
|
| 353 | + |
|
| 354 | + //. aider('erreur_mysql'); |
|
| 355 | + |
|
| 356 | + return $err; |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | |
| 360 | 360 | function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = '') { |
| 361 | 361 | |
| 362 | - $id = $nom . $boucle; |
|
| 363 | - if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 364 | - foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 365 | - if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
|
| 366 | - $y = substr_count($v[0], "\n"); |
|
| 367 | - } else { |
|
| 368 | - if ($v[1][0] == '#') { // balise dynamique |
|
| 369 | - $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 370 | - } else // inclusion |
|
| 371 | - { |
|
| 372 | - $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 373 | - } |
|
| 374 | - $y = substr_count($incl, "\n") |
|
| 375 | - + substr_count($r[1], "\n") |
|
| 376 | - + substr_count($r[3], "\n"); |
|
| 377 | - } |
|
| 378 | - if ($n <= ($y + $debut)) { |
|
| 379 | - if ($v[1][0] == '?') { |
|
| 380 | - return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1)); |
|
| 381 | - } elseif ($v[1][0] == '!') { |
|
| 382 | - if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 383 | - return trouve_boucle_debug($n, $incl, $debut); |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - return [$nom, $boucle, $v[2] - 1 + $n - $debut]; |
|
| 388 | - } |
|
| 389 | - $debut += $y; |
|
| 390 | - } |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - return [$nom, $boucle, $n - $debut]; |
|
| 362 | + $id = $nom . $boucle; |
|
| 363 | + if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
|
| 364 | + foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
|
| 365 | + if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
|
| 366 | + $y = substr_count($v[0], "\n"); |
|
| 367 | + } else { |
|
| 368 | + if ($v[1][0] == '#') { // balise dynamique |
|
| 369 | + $incl = $GLOBALS['debug_objets']['resultat'][$v[2]]; |
|
| 370 | + } else // inclusion |
|
| 371 | + { |
|
| 372 | + $incl = $GLOBALS['debug_objets']['squelette'][trouve_squelette_inclus($v[0])]; |
|
| 373 | + } |
|
| 374 | + $y = substr_count($incl, "\n") |
|
| 375 | + + substr_count($r[1], "\n") |
|
| 376 | + + substr_count($r[3], "\n"); |
|
| 377 | + } |
|
| 378 | + if ($n <= ($y + $debut)) { |
|
| 379 | + if ($v[1][0] == '?') { |
|
| 380 | + return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1)); |
|
| 381 | + } elseif ($v[1][0] == '!') { |
|
| 382 | + if ($incl = trouve_squelette_inclus($v[1])) { |
|
| 383 | + return trouve_boucle_debug($n, $incl, $debut); |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + return [$nom, $boucle, $v[2] - 1 + $n - $debut]; |
|
| 388 | + } |
|
| 389 | + $debut += $y; |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + return [$nom, $boucle, $n - $debut]; |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | function trouve_squelette_inclus($script) { |
| 397 | 397 | |
| 398 | - preg_match('/include\(.(.*).php3?.\);/', $script, $reg); |
|
| 399 | - // si le script X.php n'est pas ecrire/public.php |
|
| 400 | - // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 401 | - if ($reg[1] == 'ecrire/public') { // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 402 | - if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) { // a defaut on cherche le param 'page' |
|
| 403 | - if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) { |
|
| 404 | - $reg[1] = 'inconnu'; |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 409 | - |
|
| 410 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 411 | - if (preg_match($incl, $v)) { |
|
| 412 | - return $k; |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - return ''; |
|
| 398 | + preg_match('/include\(.(.*).php3?.\);/', $script, $reg); |
|
| 399 | + // si le script X.php n'est pas ecrire/public.php |
|
| 400 | + // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
|
| 401 | + if ($reg[1] == 'ecrire/public') { // si c'est bien ecrire/public on cherche le param 'fond' |
|
| 402 | + if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) { // a defaut on cherche le param 'page' |
|
| 403 | + if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) { |
|
| 404 | + $reg[1] = 'inconnu'; |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 409 | + |
|
| 410 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
|
| 411 | + if (preg_match($incl, $v)) { |
|
| 412 | + return $k; |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + return ''; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | function reference_boucle_debug($n, $nom, $self) { |
| 420 | - [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
|
| 421 | - |
|
| 422 | - if (!$boucle) { |
|
| 423 | - return !$ligne ? '' : |
|
| 424 | - (' (' . |
|
| 425 | - (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 426 | - _T('squelette_ligne')) . |
|
| 427 | - " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
|
| 428 | - } else { |
|
| 429 | - $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 430 | - |
|
| 431 | - return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 432 | - " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 433 | - } |
|
| 420 | + [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
|
| 421 | + |
|
| 422 | + if (!$boucle) { |
|
| 423 | + return !$ligne ? '' : |
|
| 424 | + (' (' . |
|
| 425 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 426 | + _T('squelette_ligne')) . |
|
| 427 | + " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
|
| 428 | + } else { |
|
| 429 | + $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
|
| 430 | + |
|
| 431 | + return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 432 | + " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 433 | + } |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | // affiche un texte avec numero de ligne et ancre. |
| 437 | 437 | |
| 438 | 438 | function ancre_texte($texte, $fautifs = [], $nocpt = false) { |
| 439 | 439 | |
| 440 | - $var_mode_ligne = _request('var_mode_ligne'); |
|
| 441 | - if ($var_mode_ligne) { |
|
| 442 | - $fautifs[] = [$var_mode_ligne]; |
|
| 443 | - } |
|
| 444 | - $res = ''; |
|
| 445 | - |
|
| 446 | - $s = highlight_string($texte, true); |
|
| 447 | - if (substr($s, 0, 6) == '<code>') { |
|
| 448 | - $s = substr($s, 6); |
|
| 449 | - $res = '<code>'; |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - $s = preg_replace( |
|
| 453 | - ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 454 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 455 | - $s |
|
| 456 | - ); |
|
| 457 | - |
|
| 458 | - |
|
| 459 | - $tableau = explode('<br />', $s); |
|
| 460 | - |
|
| 461 | - $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"; |
|
| 462 | - |
|
| 463 | - $format10 = str_replace('white', 'lightgrey', $format); |
|
| 464 | - $formaterr = 'color: red;'; |
|
| 465 | - $i = 1; |
|
| 466 | - $flignes = []; |
|
| 467 | - $loc = [0, 0]; |
|
| 468 | - foreach ($fautifs as $lc) { |
|
| 469 | - if (is_array($lc)) { |
|
| 470 | - $l = array_shift($lc); |
|
| 471 | - $flignes[$l] = $lc; |
|
| 472 | - } else { |
|
| 473 | - $flignes[$lc] = $loc; |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - $ancre = md5($texte); |
|
| 478 | - foreach ($tableau as $ligne) { |
|
| 479 | - if (isset($flignes[$i])) { |
|
| 480 | - $ligne = str_replace(' ', ' ', $ligne); |
|
| 481 | - $indexmesg = $flignes[$i][1]; |
|
| 482 | - $err = textebrut($flignes[$i][2]); |
|
| 483 | - // tentative de pointer sur la colonne fautive; |
|
| 484 | - // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 485 | - // $m = $flignes[$i][0]; |
|
| 486 | - // $ligne = substr($ligne, 0, $m-1) . |
|
| 487 | - // sprintf($formaterr, substr($ligne,$m)); |
|
| 488 | - $bg = $formaterr; |
|
| 489 | - } else { |
|
| 490 | - $indexmesg = $ancre; |
|
| 491 | - $err = $bg = ''; |
|
| 492 | - } |
|
| 493 | - $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 494 | - $i++; |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - return "<div id='T$ancre'>" |
|
| 498 | - . '<div onclick="' |
|
| 499 | - . "jQuery(this).parent().find('a').toggle();" |
|
| 500 | - . '" title="' |
|
| 501 | - . _T('masquer_colonne') |
|
| 502 | - . '" style="cursor: pointer;">' |
|
| 503 | - . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 504 | - . '</div> |
|
| 440 | + $var_mode_ligne = _request('var_mode_ligne'); |
|
| 441 | + if ($var_mode_ligne) { |
|
| 442 | + $fautifs[] = [$var_mode_ligne]; |
|
| 443 | + } |
|
| 444 | + $res = ''; |
|
| 445 | + |
|
| 446 | + $s = highlight_string($texte, true); |
|
| 447 | + if (substr($s, 0, 6) == '<code>') { |
|
| 448 | + $s = substr($s, 6); |
|
| 449 | + $res = '<code>'; |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + $s = preg_replace( |
|
| 453 | + ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
|
| 454 | + '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 455 | + $s |
|
| 456 | + ); |
|
| 457 | + |
|
| 458 | + |
|
| 459 | + $tableau = explode('<br />', $s); |
|
| 460 | + |
|
| 461 | + $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"; |
|
| 462 | + |
|
| 463 | + $format10 = str_replace('white', 'lightgrey', $format); |
|
| 464 | + $formaterr = 'color: red;'; |
|
| 465 | + $i = 1; |
|
| 466 | + $flignes = []; |
|
| 467 | + $loc = [0, 0]; |
|
| 468 | + foreach ($fautifs as $lc) { |
|
| 469 | + if (is_array($lc)) { |
|
| 470 | + $l = array_shift($lc); |
|
| 471 | + $flignes[$l] = $lc; |
|
| 472 | + } else { |
|
| 473 | + $flignes[$lc] = $loc; |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + $ancre = md5($texte); |
|
| 478 | + foreach ($tableau as $ligne) { |
|
| 479 | + if (isset($flignes[$i])) { |
|
| 480 | + $ligne = str_replace(' ', ' ', $ligne); |
|
| 481 | + $indexmesg = $flignes[$i][1]; |
|
| 482 | + $err = textebrut($flignes[$i][2]); |
|
| 483 | + // tentative de pointer sur la colonne fautive; |
|
| 484 | + // marche pas car highlight_string rajoute des entites. A revoir. |
|
| 485 | + // $m = $flignes[$i][0]; |
|
| 486 | + // $ligne = substr($ligne, 0, $m-1) . |
|
| 487 | + // sprintf($formaterr, substr($ligne,$m)); |
|
| 488 | + $bg = $formaterr; |
|
| 489 | + } else { |
|
| 490 | + $indexmesg = $ancre; |
|
| 491 | + $err = $bg = ''; |
|
| 492 | + } |
|
| 493 | + $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 494 | + $i++; |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + return "<div id='T$ancre'>" |
|
| 498 | + . '<div onclick="' |
|
| 499 | + . "jQuery(this).parent().find('a').toggle();" |
|
| 500 | + . '" title="' |
|
| 501 | + . _T('masquer_colonne') |
|
| 502 | + . '" style="cursor: pointer;">' |
|
| 503 | + . ($nocpt ? '' : _T('info_numero_abbreviation')) |
|
| 504 | + . '</div> |
|
| 505 | 505 | ' . $res . "</div>\n"; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | // l'environnement graphique du debuggueur |
| 509 | 509 | |
| 510 | 510 | function debusquer_squelette($fonc, $mode, $self) { |
| 511 | - $legend = null; |
|
| 512 | - $texte = ''; |
|
| 513 | - |
|
| 514 | - if ($mode !== 'validation') { |
|
| 515 | - if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) { |
|
| 516 | - $res = "<div id='spip-boucles'>\n" |
|
| 517 | - . debusquer_navigation_squelettes($self) |
|
| 518 | - . '</div>'; |
|
| 519 | - } else { |
|
| 520 | - $res = ''; |
|
| 521 | - } |
|
| 522 | - if ($fonc) { |
|
| 523 | - $id = " id='$fonc'"; |
|
| 524 | - if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 525 | - [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
|
| 526 | - $texte .= $res2; |
|
| 527 | - } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 528 | - $legend = _T('zbug_' . $mode); |
|
| 529 | - $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 530 | - $texte = ancre_texte($texte, ['', '']); |
|
| 531 | - } |
|
| 532 | - } else { |
|
| 533 | - if (strlen(trim($res))) { |
|
| 534 | - return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 535 | - } else { |
|
| 536 | - // cas de l'appel sur erreur: montre la page |
|
| 537 | - return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
|
| 538 | - } |
|
| 539 | - } |
|
| 540 | - } else { |
|
| 541 | - $valider = charger_fonction('valider', 'xml'); |
|
| 542 | - $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 543 | - // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 544 | - $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 545 | - [$texte, $err] = emboite_texte($val, $fonc, $self); |
|
| 546 | - if ($err === false) { |
|
| 547 | - $err = _T('impossible'); |
|
| 548 | - } elseif ($err === true) { |
|
| 549 | - $err = _T('correcte'); |
|
| 550 | - } else { |
|
| 551 | - $err = ": $err"; |
|
| 552 | - } |
|
| 553 | - $legend = _T('validation') . ' ' . $err; |
|
| 554 | - $res = $id = ''; |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - return !trim($texte) ? '' : ( |
|
| 558 | - "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 559 | - . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 560 | - . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> ↑ " |
|
| 561 | - . ($legend ?: $mode) |
|
| 562 | - . '</a></legend>' |
|
| 563 | - . $texte |
|
| 564 | - . '</fieldset></div>' |
|
| 565 | - . '</div>'); |
|
| 511 | + $legend = null; |
|
| 512 | + $texte = ''; |
|
| 513 | + |
|
| 514 | + if ($mode !== 'validation') { |
|
| 515 | + if (isset($GLOBALS['debug_objets']['sourcefile']) and $GLOBALS['debug_objets']['sourcefile']) { |
|
| 516 | + $res = "<div id='spip-boucles'>\n" |
|
| 517 | + . debusquer_navigation_squelettes($self) |
|
| 518 | + . '</div>'; |
|
| 519 | + } else { |
|
| 520 | + $res = ''; |
|
| 521 | + } |
|
| 522 | + if ($fonc) { |
|
| 523 | + $id = " id='$fonc'"; |
|
| 524 | + if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 525 | + [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
|
| 526 | + $texte .= $res2; |
|
| 527 | + } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 528 | + $legend = _T('zbug_' . $mode); |
|
| 529 | + $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 530 | + $texte = ancre_texte($texte, ['', '']); |
|
| 531 | + } |
|
| 532 | + } else { |
|
| 533 | + if (strlen(trim($res))) { |
|
| 534 | + return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 535 | + } else { |
|
| 536 | + // cas de l'appel sur erreur: montre la page |
|
| 537 | + return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
|
| 538 | + } |
|
| 539 | + } |
|
| 540 | + } else { |
|
| 541 | + $valider = charger_fonction('valider', 'xml'); |
|
| 542 | + $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 543 | + // Si erreur, signaler leur nombre dans le formulaire admin |
|
| 544 | + $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
|
| 545 | + [$texte, $err] = emboite_texte($val, $fonc, $self); |
|
| 546 | + if ($err === false) { |
|
| 547 | + $err = _T('impossible'); |
|
| 548 | + } elseif ($err === true) { |
|
| 549 | + $err = _T('correcte'); |
|
| 550 | + } else { |
|
| 551 | + $err = ": $err"; |
|
| 552 | + } |
|
| 553 | + $legend = _T('validation') . ' ' . $err; |
|
| 554 | + $res = $id = ''; |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + return !trim($texte) ? '' : ( |
|
| 558 | + "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 559 | + . "<div id='debug_boucle'><fieldset$id><legend>" |
|
| 560 | + . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> ↑ " |
|
| 561 | + . ($legend ?: $mode) |
|
| 562 | + . '</a></legend>' |
|
| 563 | + . $texte |
|
| 564 | + . '</fieldset></div>' |
|
| 565 | + . '</div>'); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | |
| 569 | 569 | function emboite_texte($res, $fonc = '', $self = '') { |
| 570 | - $errs = $res->err; |
|
| 571 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 572 | - |
|
| 573 | - if (!$texte and !$errs) { |
|
| 574 | - return [ancre_texte('', ['', '']), false]; |
|
| 575 | - } |
|
| 576 | - if (!$errs) { |
|
| 577 | - return [ancre_texte($texte, ['', '']), true]; |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - if (!isset($GLOBALS['debug_objets'])) { |
|
| 581 | - $colors = ['#e0e0f0', '#f8f8ff']; |
|
| 582 | - $encore = count_occ($errs); |
|
| 583 | - $encore2 = []; |
|
| 584 | - $fautifs = []; |
|
| 585 | - |
|
| 586 | - $err = '<tr><th>' |
|
| 587 | - . _T('numero') |
|
| 588 | - . '</th><th>' |
|
| 589 | - . _T('occurence') |
|
| 590 | - . '</th><th>' |
|
| 591 | - . _T('ligne') |
|
| 592 | - . '</th><th>' |
|
| 593 | - . _T('colonne') |
|
| 594 | - . '</th><th>' |
|
| 595 | - . _T('erreur') |
|
| 596 | - . '</th></tr>'; |
|
| 597 | - |
|
| 598 | - $i = 0; |
|
| 599 | - $style = "style='text-align: right; padding-right: 5px'"; |
|
| 600 | - foreach ($errs as $r) { |
|
| 601 | - $i++; |
|
| 602 | - [$msg, $ligne, $col] = $r; |
|
| 603 | - #spip_log("$r = list($msg, $ligne, $col"); |
|
| 604 | - if (isset($encore2[$msg])) { |
|
| 605 | - $ref = ++$encore2[$msg]; |
|
| 606 | - } else { |
|
| 607 | - $encore2[$msg] = $ref = 1; |
|
| 608 | - } |
|
| 609 | - $err .= "<tr style='background-color: " |
|
| 610 | - . $colors[$i % 2] |
|
| 611 | - . "'><td $style><a href='#debut_err'>" |
|
| 612 | - . $i |
|
| 613 | - . "</a></td><td $style>" |
|
| 614 | - . "$ref/$encore[$msg]</td>" |
|
| 615 | - . "<td $style><a href='#L" |
|
| 616 | - . $ligne |
|
| 617 | - . "' id='T$i'>" |
|
| 618 | - . $ligne |
|
| 619 | - . "</a></td><td $style>" |
|
| 620 | - . $col |
|
| 621 | - . "</td><td>$msg</td></tr>\n"; |
|
| 622 | - $fautifs[] = [$ligne, $col, $i, $msg]; |
|
| 623 | - } |
|
| 624 | - $err = "<h2 style='text-align: center'>" |
|
| 625 | - . $i |
|
| 626 | - . "<a href='#fin_err'>" |
|
| 627 | - . ' ' . _T('erreur_texte') |
|
| 628 | - . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 629 | - . $err |
|
| 630 | - . " </table><a id='fin_err'></a>"; |
|
| 631 | - |
|
| 632 | - return [ancre_texte($texte, $fautifs), $err]; |
|
| 633 | - } else { |
|
| 634 | - [$msg, $fermant, $ouvrant] = $errs[0]; |
|
| 635 | - $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 636 | - $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 637 | - $err = $msg . |
|
| 638 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 639 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 640 | - |
|
| 641 | - return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
|
| 642 | - } |
|
| 570 | + $errs = $res->err; |
|
| 571 | + $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 572 | + |
|
| 573 | + if (!$texte and !$errs) { |
|
| 574 | + return [ancre_texte('', ['', '']), false]; |
|
| 575 | + } |
|
| 576 | + if (!$errs) { |
|
| 577 | + return [ancre_texte($texte, ['', '']), true]; |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + if (!isset($GLOBALS['debug_objets'])) { |
|
| 581 | + $colors = ['#e0e0f0', '#f8f8ff']; |
|
| 582 | + $encore = count_occ($errs); |
|
| 583 | + $encore2 = []; |
|
| 584 | + $fautifs = []; |
|
| 585 | + |
|
| 586 | + $err = '<tr><th>' |
|
| 587 | + . _T('numero') |
|
| 588 | + . '</th><th>' |
|
| 589 | + . _T('occurence') |
|
| 590 | + . '</th><th>' |
|
| 591 | + . _T('ligne') |
|
| 592 | + . '</th><th>' |
|
| 593 | + . _T('colonne') |
|
| 594 | + . '</th><th>' |
|
| 595 | + . _T('erreur') |
|
| 596 | + . '</th></tr>'; |
|
| 597 | + |
|
| 598 | + $i = 0; |
|
| 599 | + $style = "style='text-align: right; padding-right: 5px'"; |
|
| 600 | + foreach ($errs as $r) { |
|
| 601 | + $i++; |
|
| 602 | + [$msg, $ligne, $col] = $r; |
|
| 603 | + #spip_log("$r = list($msg, $ligne, $col"); |
|
| 604 | + if (isset($encore2[$msg])) { |
|
| 605 | + $ref = ++$encore2[$msg]; |
|
| 606 | + } else { |
|
| 607 | + $encore2[$msg] = $ref = 1; |
|
| 608 | + } |
|
| 609 | + $err .= "<tr style='background-color: " |
|
| 610 | + . $colors[$i % 2] |
|
| 611 | + . "'><td $style><a href='#debut_err'>" |
|
| 612 | + . $i |
|
| 613 | + . "</a></td><td $style>" |
|
| 614 | + . "$ref/$encore[$msg]</td>" |
|
| 615 | + . "<td $style><a href='#L" |
|
| 616 | + . $ligne |
|
| 617 | + . "' id='T$i'>" |
|
| 618 | + . $ligne |
|
| 619 | + . "</a></td><td $style>" |
|
| 620 | + . $col |
|
| 621 | + . "</td><td>$msg</td></tr>\n"; |
|
| 622 | + $fautifs[] = [$ligne, $col, $i, $msg]; |
|
| 623 | + } |
|
| 624 | + $err = "<h2 style='text-align: center'>" |
|
| 625 | + . $i |
|
| 626 | + . "<a href='#fin_err'>" |
|
| 627 | + . ' ' . _T('erreur_texte') |
|
| 628 | + . "</a></h2><table id='debut_err' style='width: 100%'>" |
|
| 629 | + . $err |
|
| 630 | + . " </table><a id='fin_err'></a>"; |
|
| 631 | + |
|
| 632 | + return [ancre_texte($texte, $fautifs), $err]; |
|
| 633 | + } else { |
|
| 634 | + [$msg, $fermant, $ouvrant] = $errs[0]; |
|
| 635 | + $rf = reference_boucle_debug($fermant, $fonc, $self); |
|
| 636 | + $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
|
| 637 | + $err = $msg . |
|
| 638 | + "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 639 | + "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 640 | + |
|
| 641 | + return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
|
| 642 | + } |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | function count_occ($regs) { |
| 646 | - $encore = []; |
|
| 647 | - foreach ($regs as $r) { |
|
| 648 | - if (isset($encore[$r[0]])) { |
|
| 649 | - $encore[$r[0]]++; |
|
| 650 | - } else { |
|
| 651 | - $encore[$r[0]] = 1; |
|
| 652 | - } |
|
| 653 | - } |
|
| 654 | - |
|
| 655 | - return $encore; |
|
| 646 | + $encore = []; |
|
| 647 | + foreach ($regs as $r) { |
|
| 648 | + if (isset($encore[$r[0]])) { |
|
| 649 | + $encore[$r[0]]++; |
|
| 650 | + } else { |
|
| 651 | + $encore[$r[0]] = 1; |
|
| 652 | + } |
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + return $encore; |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | function debusquer_navigation_squelettes($self) { |
| 659 | 659 | |
| 660 | - $res = ''; |
|
| 661 | - $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : ''; |
|
| 662 | - $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 663 | - $t_skel = _T('squelette'); |
|
| 664 | - foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 665 | - $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 666 | - $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile); |
|
| 667 | - $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T( |
|
| 668 | - 'zbug_profile', |
|
| 669 | - ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
|
| 670 | - ); |
|
| 671 | - |
|
| 672 | - $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 673 | - . $t_skel |
|
| 674 | - . ' ' |
|
| 675 | - . $sourcefile |
|
| 676 | - . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 677 | - . $t_skel |
|
| 678 | - . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 679 | - . _T('zbug_resultat') |
|
| 680 | - . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 681 | - . _T('zbug_code') |
|
| 682 | - . "</a>\n<a href='" |
|
| 683 | - . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', $self) |
|
| 684 | - . "'>" |
|
| 685 | - . _T('zbug_calcul') |
|
| 686 | - . '</a></legend>' |
|
| 687 | - . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 688 | - . debusquer_contexte($contexte[$sourcefile]) |
|
| 689 | - . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
|
| 690 | - . "</fieldset>\n"; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - return $res; |
|
| 660 | + $res = ''; |
|
| 661 | + $boucles = !empty($GLOBALS['debug_objets']['boucle']) ? $GLOBALS['debug_objets']['boucle'] : ''; |
|
| 662 | + $contexte = $GLOBALS['debug_objets']['contexte']; |
|
| 663 | + $t_skel = _T('squelette'); |
|
| 664 | + foreach ($GLOBALS['debug_objets']['sourcefile'] as $nom => $sourcefile) { |
|
| 665 | + $self2 = parametre_url($self, 'var_mode_objet', $nom); |
|
| 666 | + $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile); |
|
| 667 | + $temps = !isset($GLOBALS['debug_objets']['profile'][$sourcefile]) ? '' : _T( |
|
| 668 | + 'zbug_profile', |
|
| 669 | + ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
|
| 670 | + ); |
|
| 671 | + |
|
| 672 | + $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 673 | + . $t_skel |
|
| 674 | + . ' ' |
|
| 675 | + . $sourcefile |
|
| 676 | + . " :\n<a href='$self2&var_mode_affiche=squelette#f_$nom'>" |
|
| 677 | + . $t_skel |
|
| 678 | + . "</a>\n<a href='$self2&var_mode_affiche=resultat#f_$nom'>" |
|
| 679 | + . _T('zbug_resultat') |
|
| 680 | + . "</a>\n<a href='$self2&var_mode_affiche=code#f_$nom'>" |
|
| 681 | + . _T('zbug_code') |
|
| 682 | + . "</a>\n<a href='" |
|
| 683 | + . str_replace('var_mode=debug', 'var_profile=1&var_mode=recalcul', $self) |
|
| 684 | + . "'>" |
|
| 685 | + . _T('zbug_calcul') |
|
| 686 | + . '</a></legend>' |
|
| 687 | + . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 688 | + . debusquer_contexte($contexte[$sourcefile]) |
|
| 689 | + . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
|
| 690 | + . "</fieldset>\n"; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + return $res; |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source) { |
| 697 | - $i = 0; |
|
| 698 | - $res = ''; |
|
| 699 | - $var_mode_objet = _request('var_mode_objet'); |
|
| 700 | - $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : ''; |
|
| 701 | - |
|
| 702 | - foreach ($boucles as $objet => $boucle) { |
|
| 703 | - if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) { |
|
| 704 | - $i++; |
|
| 705 | - $nom = $boucle->id_boucle; |
|
| 706 | - $req = $boucle->type_requete; |
|
| 707 | - $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 708 | - $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 709 | - |
|
| 710 | - $res .= "\n<tr style='background-color: " . |
|
| 711 | - ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 712 | - "'><td align='right'>$i</td><td>\n" . |
|
| 713 | - "<a class='debug_link_boucle' href='" . |
|
| 714 | - $self2 . |
|
| 715 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 716 | - _T('zbug_boucle') . |
|
| 717 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 718 | - $self2 . |
|
| 719 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 720 | - _T('zbug_resultat') . |
|
| 721 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 722 | - $self2 . |
|
| 723 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 724 | - _T('zbug_code') . |
|
| 725 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 726 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 727 | - "'>" . |
|
| 728 | - _T('zbug_calcul') . |
|
| 729 | - "</a></td><td>\n" . |
|
| 730 | - (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 731 | - "</td><td>\n" . |
|
| 732 | - $req . |
|
| 733 | - "</td><td>\n" . |
|
| 734 | - spip_htmlspecialchars($crit) . |
|
| 735 | - '</td></tr>'; |
|
| 736 | - } |
|
| 737 | - } |
|
| 738 | - |
|
| 739 | - return $res; |
|
| 697 | + $i = 0; |
|
| 698 | + $res = ''; |
|
| 699 | + $var_mode_objet = _request('var_mode_objet'); |
|
| 700 | + $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : ''; |
|
| 701 | + |
|
| 702 | + foreach ($boucles as $objet => $boucle) { |
|
| 703 | + if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) { |
|
| 704 | + $i++; |
|
| 705 | + $nom = $boucle->id_boucle; |
|
| 706 | + $req = $boucle->type_requete; |
|
| 707 | + $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
|
| 708 | + $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 709 | + |
|
| 710 | + $res .= "\n<tr style='background-color: " . |
|
| 711 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 712 | + "'><td align='right'>$i</td><td>\n" . |
|
| 713 | + "<a class='debug_link_boucle' href='" . |
|
| 714 | + $self2 . |
|
| 715 | + "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 716 | + _T('zbug_boucle') . |
|
| 717 | + "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 718 | + $self2 . |
|
| 719 | + "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 720 | + _T('zbug_resultat') . |
|
| 721 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 722 | + $self2 . |
|
| 723 | + "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 724 | + _T('zbug_code') . |
|
| 725 | + "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 726 | + str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 727 | + "'>" . |
|
| 728 | + _T('zbug_calcul') . |
|
| 729 | + "</a></td><td>\n" . |
|
| 730 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 731 | + "</td><td>\n" . |
|
| 732 | + $req . |
|
| 733 | + "</td><td>\n" . |
|
| 734 | + spip_htmlspecialchars($crit) . |
|
| 735 | + '</td></tr>'; |
|
| 736 | + } |
|
| 737 | + } |
|
| 738 | + |
|
| 739 | + return $res; |
|
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | function debusquer_source($objet, $affiche) { |
| 743 | - $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 744 | - if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 745 | - $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 746 | - } else { |
|
| 747 | - $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 748 | - } |
|
| 749 | - $res2 = ''; |
|
| 750 | - |
|
| 751 | - if ($affiche == 'resultat') { |
|
| 752 | - $legend = $nom; |
|
| 753 | - $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 754 | - if (function_exists('_mysql_traite_query')) { |
|
| 755 | - $c = strtolower(_request('connect') ?? ''); |
|
| 756 | - $c = $GLOBALS['connexions'][$c ?: 0]['prefixe']; |
|
| 757 | - $req = _mysql_traite_query($req, '', $c); |
|
| 758 | - } |
|
| 759 | - // permettre le copier/coller facile |
|
| 760 | - // $res = ancre_texte($req, array(), true); |
|
| 761 | - $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 762 | - // formatage et affichage des resultats bruts de la requete |
|
| 763 | - $ress_req = spip_query($req); |
|
| 764 | - $brut_sql = ''; |
|
| 765 | - $num = 1; |
|
| 766 | - // eviter l'affichage de milliers de lignes |
|
| 767 | - // personnalisation possible dans mes_options |
|
| 768 | - $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 769 | - while ($retours_sql = sql_fetch($ress_req)) { |
|
| 770 | - if ($num <= $max_aff) { |
|
| 771 | - $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 772 | - $brut_sql .= '<p>'; |
|
| 773 | - foreach ($retours_sql as $key => $val) { |
|
| 774 | - $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 775 | - } |
|
| 776 | - $brut_sql .= '</p>'; |
|
| 777 | - } |
|
| 778 | - $num++; |
|
| 779 | - } |
|
| 780 | - $res2 = interdire_scripts($brut_sql); |
|
| 781 | - foreach ($quoi as $view) { |
|
| 782 | - // ne pas afficher les $contexte_inclus |
|
| 783 | - $view = preg_replace(',<\?php.+\?[>],Uims', '', $view); |
|
| 784 | - if ($view) { |
|
| 785 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 786 | - } |
|
| 787 | - } |
|
| 788 | - } elseif ($affiche == 'code') { |
|
| 789 | - $legend = $nom; |
|
| 790 | - $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 791 | - } elseif ($affiche == 'boucle') { |
|
| 792 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 793 | - // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 794 | - $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
|
| 795 | - $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 796 | - } elseif ($affiche == 'squelette') { |
|
| 797 | - $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 798 | - $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - return [$legend, $res, $res2]; |
|
| 743 | + $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
|
| 744 | + if (!empty($GLOBALS['debug_objets']['boucle'][$objet]->id_boucle)) { |
|
| 745 | + $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
|
| 746 | + } else { |
|
| 747 | + $nom = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 748 | + } |
|
| 749 | + $res2 = ''; |
|
| 750 | + |
|
| 751 | + if ($affiche == 'resultat') { |
|
| 752 | + $legend = $nom; |
|
| 753 | + $req = $GLOBALS['debug_objets']['requete'][$objet]; |
|
| 754 | + if (function_exists('_mysql_traite_query')) { |
|
| 755 | + $c = strtolower(_request('connect') ?? ''); |
|
| 756 | + $c = $GLOBALS['connexions'][$c ?: 0]['prefixe']; |
|
| 757 | + $req = _mysql_traite_query($req, '', $c); |
|
| 758 | + } |
|
| 759 | + // permettre le copier/coller facile |
|
| 760 | + // $res = ancre_texte($req, array(), true); |
|
| 761 | + $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 762 | + // formatage et affichage des resultats bruts de la requete |
|
| 763 | + $ress_req = spip_query($req); |
|
| 764 | + $brut_sql = ''; |
|
| 765 | + $num = 1; |
|
| 766 | + // eviter l'affichage de milliers de lignes |
|
| 767 | + // personnalisation possible dans mes_options |
|
| 768 | + $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
|
| 769 | + while ($retours_sql = sql_fetch($ress_req)) { |
|
| 770 | + if ($num <= $max_aff) { |
|
| 771 | + $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 772 | + $brut_sql .= '<p>'; |
|
| 773 | + foreach ($retours_sql as $key => $val) { |
|
| 774 | + $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 775 | + } |
|
| 776 | + $brut_sql .= '</p>'; |
|
| 777 | + } |
|
| 778 | + $num++; |
|
| 779 | + } |
|
| 780 | + $res2 = interdire_scripts($brut_sql); |
|
| 781 | + foreach ($quoi as $view) { |
|
| 782 | + // ne pas afficher les $contexte_inclus |
|
| 783 | + $view = preg_replace(',<\?php.+\?[>],Uims', '', $view); |
|
| 784 | + if ($view) { |
|
| 785 | + $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 786 | + } |
|
| 787 | + } |
|
| 788 | + } elseif ($affiche == 'code') { |
|
| 789 | + $legend = $nom; |
|
| 790 | + $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 791 | + } elseif ($affiche == 'boucle') { |
|
| 792 | + $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 793 | + // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
|
| 794 | + $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
|
| 795 | + $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
|
| 796 | + } elseif ($affiche == 'squelette') { |
|
| 797 | + $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
|
| 798 | + $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + return [$legend, $res, $res2]; |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | function debusquer_entete($titre, $corps) { |
| 805 | 805 | |
| 806 | - include_spip('balise/formulaire_admin'); |
|
| 807 | - include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 808 | - include_spip('inc/texte'); // pour corriger_typo |
|
| 809 | - |
|
| 810 | - return _DOCTYPE_ECRIRE . |
|
| 811 | - html_lang_attributes() . |
|
| 812 | - "<head>\n<title>" . |
|
| 813 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 814 | - _T('admin_debug') . ' ' . $titre . ' (' . |
|
| 815 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 816 | - ")</title>\n" . |
|
| 817 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 818 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 819 | - "' />\n" . |
|
| 820 | - http_script('', 'jquery.js') |
|
| 821 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 822 | - . "' type='text/css' />" . |
|
| 823 | - "</head>\n" . |
|
| 824 | - "<body style='margin:0 10px;'>\n" . |
|
| 825 | - "<div id='spip-debug-header'>" . |
|
| 826 | - $corps . |
|
| 827 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 828 | - '</div></body></html>'; |
|
| 806 | + include_spip('balise/formulaire_admin'); |
|
| 807 | + include_spip('public/assembler'); // pour inclure_balise_dynamique |
|
| 808 | + include_spip('inc/texte'); // pour corriger_typo |
|
| 809 | + |
|
| 810 | + return _DOCTYPE_ECRIRE . |
|
| 811 | + html_lang_attributes() . |
|
| 812 | + "<head>\n<title>" . |
|
| 813 | + ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 814 | + _T('admin_debug') . ' ' . $titre . ' (' . |
|
| 815 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 816 | + ")</title>\n" . |
|
| 817 | + "<meta http-equiv='Content-Type' content='text/html" . |
|
| 818 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 819 | + "' />\n" . |
|
| 820 | + http_script('', 'jquery.js') |
|
| 821 | + . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 822 | + . "' type='text/css' />" . |
|
| 823 | + "</head>\n" . |
|
| 824 | + "<body style='margin:0 10px;'>\n" . |
|
| 825 | + "<div id='spip-debug-header'>" . |
|
| 826 | + $corps . |
|
| 827 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 828 | + '</div></body></html>'; |
|
| 829 | 829 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | if (!$fonc) { |
| 138 | 138 | $fonc = $GLOBALS['debug_objets']['principal']; |
| 139 | 139 | } |
| 140 | - $titre = !$mode ? $fonc : ($mode . (isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' ' . $GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 140 | + $titre = !$mode ? $fonc : ($mode.(isset($GLOBALS['debug_objets']['sourcefile'][$fonc]) ? ' '.$GLOBALS['debug_objets']['sourcefile'][$fonc] : '')); |
|
| 141 | 141 | } |
| 142 | 142 | if ($message === false) { |
| 143 | 143 | lang_select(); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $fond = $GLOBALS['fond'] ?? ''; |
| 167 | 167 | // une erreur critique sort $message en array |
| 168 | 168 | $debug = is_array($msg) ? $msg[1] : $msg; |
| 169 | - spip_log('Debug: ' . $debug . ' (' . $fond . ')'); |
|
| 169 | + spip_log('Debug: '.$debug.' ('.$fond.')'); |
|
| 170 | 170 | |
| 171 | 171 | return $msg; |
| 172 | 172 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | function debusquer_bandeau($erreurs) { |
| 175 | 175 | |
| 176 | 176 | if (!empty($erreurs)) { |
| 177 | - $n = [(is_countable($erreurs) ? count($erreurs) : 0) . ' ' . _T('zbug_erreur_squelette')]; |
|
| 177 | + $n = [(is_countable($erreurs) ? count($erreurs) : 0).' '._T('zbug_erreur_squelette')]; |
|
| 178 | 178 | |
| 179 | 179 | return debusquer_navigation($erreurs, $n); |
| 180 | 180 | } elseif (!empty($GLOBALS['tableau_des_temps'])) { |
@@ -207,25 +207,25 @@ discard block |
||
| 207 | 207 | $valeur_simple = []; |
| 208 | 208 | foreach ($valeur as $v) { |
| 209 | 209 | if (is_array($v)) { |
| 210 | - $valeur_simple[] = 'array:' . count($v); |
|
| 210 | + $valeur_simple[] = 'array:'.count($v); |
|
| 211 | 211 | } elseif (is_object($v)) { |
| 212 | 212 | $valeur_simple[] = get_class($v); |
| 213 | 213 | } elseif (is_string($v)) { |
| 214 | - $valeur_simple[] = "'" . $v . "'"; |
|
| 214 | + $valeur_simple[] = "'".$v."'"; |
|
| 215 | 215 | } else { |
| 216 | 216 | $valeur_simple[] = $v; |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | $n = count($valeur); |
| 220 | - $valeur = (($n > 3) ? 'array:' . $n . ' ' : ''); |
|
| 221 | - $valeur .= '[' . join(', ', $valeur_simple) . ']'; |
|
| 220 | + $valeur = (($n > 3) ? 'array:'.$n.' ' : ''); |
|
| 221 | + $valeur .= '['.join(', ', $valeur_simple).']'; |
|
| 222 | 222 | } elseif (is_object($valeur)) { |
| 223 | 223 | $valeur = get_class($valeur); |
| 224 | 224 | } elseif (is_string($valeur)) { |
| 225 | - $valeur = "'" . $valeur . "'"; |
|
| 225 | + $valeur = "'".$valeur."'"; |
|
| 226 | 226 | } |
| 227 | - $res .= "\n<tr><td><strong>" . nl2br((string) entites_html($nom)) |
|
| 228 | - . '</strong></td><td>: ' . nl2br((string) entites_html($valeur)) |
|
| 227 | + $res .= "\n<tr><td><strong>".nl2br((string) entites_html($nom)) |
|
| 228 | + . '</strong></td><td>: '.nl2br((string) entites_html($valeur)) |
|
| 229 | 229 | . "</td></tr>\n"; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | $nom_code = $lieu->descr['nom']; |
| 254 | 254 | $skel = $lieu->descr['sourcefile']; |
| 255 | 255 | $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
| 256 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 256 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette').'#L'.$ligne; |
|
| 257 | 257 | $skel = "<a href='$h3'><b>$skel</b></a>"; |
| 258 | 258 | if ($boucle) { |
| 259 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 259 | + $h3 = parametre_url($h2.$boucle, 'var_mode_affiche', 'boucle'); |
|
| 260 | 260 | $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
| 261 | 261 | } |
| 262 | 262 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | // Requete erronee |
| 348 | - $err = '<b>' . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 348 | + $err = '<b>'._T('avis_erreur_mysql')." $errno</b><br /><tt>\n" |
|
| 349 | 349 | . spip_htmlspecialchars($msg) |
| 350 | 350 | . "\n<br /><span style='color: red'><b>" |
| 351 | 351 | . spip_htmlspecialchars($query) |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = '') { |
| 361 | 361 | |
| 362 | - $id = $nom . $boucle; |
|
| 362 | + $id = $nom.$boucle; |
|
| 363 | 363 | if (is_array($GLOBALS['debug_objets']['sequence'][$id])) { |
| 364 | 364 | foreach ($GLOBALS['debug_objets']['sequence'][$id] as $v) { |
| 365 | 365 | if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) { |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 408 | + $incl = ','.$reg[1].'[.]\w$,'; |
|
| 409 | 409 | |
| 410 | 410 | foreach ($GLOBALS['debug_objets']['sourcefile'] as $k => $v) { |
| 411 | 411 | if (preg_match($incl, $v)) { |
@@ -420,16 +420,13 @@ discard block |
||
| 420 | 420 | [$skel, $boucle, $ligne] = trouve_boucle_debug($n, $nom); |
| 421 | 421 | |
| 422 | 422 | if (!$boucle) { |
| 423 | - return !$ligne ? '' : |
|
| 424 | - (' (' . |
|
| 425 | - (($nom != $skel) ? _T('squelette_inclus_ligne') : |
|
| 426 | - _T('squelette_ligne')) . |
|
| 423 | + return !$ligne ? '' : (' ('. |
|
| 424 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : _T('squelette_ligne')). |
|
| 427 | 425 | " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
| 428 | 426 | } else { |
| 429 | 427 | $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
| 430 | 428 | |
| 431 | - return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 432 | - " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 429 | + 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>)"; |
|
| 433 | 430 | } |
| 434 | 431 | } |
| 435 | 432 | |
@@ -451,14 +448,14 @@ discard block |
||
| 451 | 448 | |
| 452 | 449 | $s = preg_replace( |
| 453 | 450 | ',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
| 454 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 451 | + '<\1>\2</\1><br />'."\n".'<\1>\3</\1>', |
|
| 455 | 452 | $s |
| 456 | 453 | ); |
| 457 | 454 | |
| 458 | 455 | |
| 459 | 456 | $tableau = explode('<br />', $s); |
| 460 | 457 | |
| 461 | - $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"; |
|
| 458 | + $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"; |
|
| 462 | 459 | |
| 463 | 460 | $format10 = str_replace('white', 'lightgrey', $format); |
| 464 | 461 | $formaterr = 'color: red;'; |
@@ -502,7 +499,7 @@ discard block |
||
| 502 | 499 | . '" style="cursor: pointer;">' |
| 503 | 500 | . ($nocpt ? '' : _T('info_numero_abbreviation')) |
| 504 | 501 | . '</div> |
| 505 | - ' . $res . "</div>\n"; |
|
| 502 | + ' . $res."</div>\n"; |
|
| 506 | 503 | } |
| 507 | 504 | |
| 508 | 505 | // l'environnement graphique du debuggueur |
@@ -524,14 +521,14 @@ discard block |
||
| 524 | 521 | if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
| 525 | 522 | [$legend, $texte, $res2] = debusquer_source($fonc, $mode); |
| 526 | 523 | $texte .= $res2; |
| 527 | - } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc . 'tout'])) { |
|
| 528 | - $legend = _T('zbug_' . $mode); |
|
| 529 | - $texte = $GLOBALS['debug_objets'][$mode][$fonc . 'tout']; |
|
| 524 | + } elseif (!empty($GLOBALS['debug_objets'][$mode][$fonc.'tout'])) { |
|
| 525 | + $legend = _T('zbug_'.$mode); |
|
| 526 | + $texte = $GLOBALS['debug_objets'][$mode][$fonc.'tout']; |
|
| 530 | 527 | $texte = ancre_texte($texte, ['', '']); |
| 531 | 528 | } |
| 532 | 529 | } else { |
| 533 | 530 | if (strlen(trim($res))) { |
| 534 | - return "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 531 | + return "<img src='".chemin_image('debug-xx.svg')."' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res</div>"; |
|
| 535 | 532 | } else { |
| 536 | 533 | // cas de l'appel sur erreur: montre la page |
| 537 | 534 | return $GLOBALS['debug_objets']['resultat']['tout'] ?? ''; |
@@ -539,7 +536,7 @@ discard block |
||
| 539 | 536 | } |
| 540 | 537 | } else { |
| 541 | 538 | $valider = charger_fonction('valider', 'xml'); |
| 542 | - $val = $valider($GLOBALS['debug_objets']['validation'][$fonc . 'tout']); |
|
| 539 | + $val = $valider($GLOBALS['debug_objets']['validation'][$fonc.'tout']); |
|
| 543 | 540 | // Si erreur, signaler leur nombre dans le formulaire admin |
| 544 | 541 | $GLOBALS['debug_objets']['validation'] = $val->err ? count($val->err) : ''; |
| 545 | 542 | [$texte, $err] = emboite_texte($val, $fonc, $self); |
@@ -550,14 +547,14 @@ discard block |
||
| 550 | 547 | } else { |
| 551 | 548 | $err = ": $err"; |
| 552 | 549 | } |
| 553 | - $legend = _T('validation') . ' ' . $err; |
|
| 550 | + $legend = _T('validation').' '.$err; |
|
| 554 | 551 | $res = $id = ''; |
| 555 | 552 | } |
| 556 | 553 | |
| 557 | 554 | return !trim($texte) ? '' : ( |
| 558 | - "<img src='" . chemin_image('debug-xx.svg') . "' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 555 | + "<img src='".chemin_image('debug-xx.svg')."' alt='afficher-masquer le debug' id='spip-debug-toggle' onclick=\"var x = document.getElementById('spip-debug'); (x.style.display == '' ? x.style.display = 'none' : x.style.display = '');\" /><div id='spip-debug'>$res" |
|
| 559 | 556 | . "<div id='debug_boucle'><fieldset$id><legend>" |
| 560 | - . "<a href='" . $self . '#f_' . substr($fonc, 0, 37) . "'> ↑ " |
|
| 557 | + . "<a href='".$self.'#f_'.substr($fonc, 0, 37)."'> ↑ " |
|
| 561 | 558 | . ($legend ?: $mode) |
| 562 | 559 | . '</a></legend>' |
| 563 | 560 | . $texte |
@@ -568,7 +565,7 @@ discard block |
||
| 568 | 565 | |
| 569 | 566 | function emboite_texte($res, $fonc = '', $self = '') { |
| 570 | 567 | $errs = $res->err; |
| 571 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 568 | + $texte = $res->entete.($errs ? '' : $res->page); |
|
| 572 | 569 | |
| 573 | 570 | if (!$texte and !$errs) { |
| 574 | 571 | return [ancre_texte('', ['', '']), false]; |
@@ -624,7 +621,7 @@ discard block |
||
| 624 | 621 | $err = "<h2 style='text-align: center'>" |
| 625 | 622 | . $i |
| 626 | 623 | . "<a href='#fin_err'>" |
| 627 | - . ' ' . _T('erreur_texte') |
|
| 624 | + . ' '._T('erreur_texte') |
|
| 628 | 625 | . "</a></h2><table id='debut_err' style='width: 100%'>" |
| 629 | 626 | . $err |
| 630 | 627 | . " </table><a id='fin_err'></a>"; |
@@ -634,9 +631,9 @@ discard block |
||
| 634 | 631 | [$msg, $fermant, $ouvrant] = $errs[0]; |
| 635 | 632 | $rf = reference_boucle_debug($fermant, $fonc, $self); |
| 636 | 633 | $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
| 637 | - $err = $msg . |
|
| 638 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 639 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 634 | + $err = $msg. |
|
| 635 | + "<a href='#L".$fermant."'>$fermant</a>$rf<br />". |
|
| 636 | + "<a href='#L".$ouvrant."'>$ouvrant</a>$ro"; |
|
| 640 | 637 | |
| 641 | 638 | return [ancre_texte($texte, [[$ouvrant], [$fermant]]), $err]; |
| 642 | 639 | } |
@@ -669,7 +666,7 @@ discard block |
||
| 669 | 666 | ['time' => $GLOBALS['debug_objets']['profile'][$sourcefile]] |
| 670 | 667 | ); |
| 671 | 668 | |
| 672 | - $res .= "<fieldset id='f_" . $nom . "'><legend>" |
|
| 669 | + $res .= "<fieldset id='f_".$nom."'><legend>" |
|
| 673 | 670 | . $t_skel |
| 674 | 671 | . ' ' |
| 675 | 672 | . $sourcefile |
@@ -684,7 +681,7 @@ discard block |
||
| 684 | 681 | . "'>" |
| 685 | 682 | . _T('zbug_calcul') |
| 686 | 683 | . '</a></legend>' |
| 687 | - . (!$temps ? '' : ("\n<span style='display:block;float:" . $GLOBALS['spip_lang_right'] . "'>$temps</span><br />")) |
|
| 684 | + . (!$temps ? '' : ("\n<span style='display:block;float:".$GLOBALS['spip_lang_right']."'>$temps</span><br />")) |
|
| 688 | 685 | . debusquer_contexte($contexte[$sourcefile]) |
| 689 | 686 | . (!$nav ? '' : ("<table width='100%'>\n$nav</table>\n")) |
| 690 | 687 | . "</fieldset>\n"; |
@@ -705,33 +702,33 @@ discard block |
||
| 705 | 702 | $nom = $boucle->id_boucle; |
| 706 | 703 | $req = $boucle->type_requete; |
| 707 | 704 | $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
| 708 | - $self2 = $self . '&var_mode_objet=' . $objet; |
|
| 709 | - |
|
| 710 | - $res .= "\n<tr style='background-color: " . |
|
| 711 | - ($i % 2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 712 | - "'><td align='right'>$i</td><td>\n" . |
|
| 713 | - "<a class='debug_link_boucle' href='" . |
|
| 714 | - $self2 . |
|
| 715 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 716 | - _T('zbug_boucle') . |
|
| 717 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 718 | - $self2 . |
|
| 719 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 720 | - _T('zbug_resultat') . |
|
| 721 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 722 | - $self2 . |
|
| 723 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 724 | - _T('zbug_code') . |
|
| 725 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 726 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 727 | - "'>" . |
|
| 728 | - _T('zbug_calcul') . |
|
| 729 | - "</a></td><td>\n" . |
|
| 730 | - (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom) . |
|
| 731 | - "</td><td>\n" . |
|
| 732 | - $req . |
|
| 733 | - "</td><td>\n" . |
|
| 734 | - spip_htmlspecialchars($crit) . |
|
| 705 | + $self2 = $self.'&var_mode_objet='.$objet; |
|
| 706 | + |
|
| 707 | + $res .= "\n<tr style='background-color: ". |
|
| 708 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff'). |
|
| 709 | + "'><td align='right'>$i</td><td>\n". |
|
| 710 | + "<a class='debug_link_boucle' href='". |
|
| 711 | + $self2. |
|
| 712 | + "&var_mode_affiche=boucle#f_$nom_skel'>". |
|
| 713 | + _T('zbug_boucle'). |
|
| 714 | + "</a></td><td>\n<a class='debug_link_boucle' href='". |
|
| 715 | + $self2. |
|
| 716 | + "&var_mode_affiche=resultat#f_$nom_skel'>". |
|
| 717 | + _T('zbug_resultat'). |
|
| 718 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 719 | + $self2. |
|
| 720 | + "&var_mode_affiche=code#f_$nom_skel'>". |
|
| 721 | + _T('zbug_code'). |
|
| 722 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 723 | + str_replace('var_mode=', 'var_profile=', $self2). |
|
| 724 | + "'>". |
|
| 725 | + _T('zbug_calcul'). |
|
| 726 | + "</a></td><td>\n". |
|
| 727 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom). |
|
| 728 | + "</td><td>\n". |
|
| 729 | + $req. |
|
| 730 | + "</td><td>\n". |
|
| 731 | + spip_htmlspecialchars($crit). |
|
| 735 | 732 | '</td></tr>'; |
| 736 | 733 | } |
| 737 | 734 | } |
@@ -758,7 +755,7 @@ discard block |
||
| 758 | 755 | } |
| 759 | 756 | // permettre le copier/coller facile |
| 760 | 757 | // $res = ancre_texte($req, array(), true); |
| 761 | - $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 758 | + $res = "<div id='T".md5($req)."'>\n<pre>\n".$req."</pre>\n</div>\n"; |
|
| 762 | 759 | // formatage et affichage des resultats bruts de la requete |
| 763 | 760 | $ress_req = spip_query($req); |
| 764 | 761 | $brut_sql = ''; |
@@ -768,10 +765,10 @@ discard block |
||
| 768 | 765 | $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
| 769 | 766 | while ($retours_sql = sql_fetch($ress_req)) { |
| 770 | 767 | if ($num <= $max_aff) { |
| 771 | - $brut_sql .= '<h3>' . ($num == 1 ? $num . ' sur ' . sql_count($ress_req) : $num) . '</h3>'; |
|
| 768 | + $brut_sql .= '<h3>'.($num == 1 ? $num.' sur '.sql_count($ress_req) : $num).'</h3>'; |
|
| 772 | 769 | $brut_sql .= '<p>'; |
| 773 | 770 | foreach ($retours_sql as $key => $val) { |
| 774 | - $brut_sql .= '<strong>' . $key . '</strong> => ' . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 771 | + $brut_sql .= '<strong>'.$key.'</strong> => '.spip_htmlspecialchars(couper($val, 150))."<br />\n"; |
|
| 775 | 772 | } |
| 776 | 773 | $brut_sql .= '</p>'; |
| 777 | 774 | } |
@@ -782,14 +779,14 @@ discard block |
||
| 782 | 779 | // ne pas afficher les $contexte_inclus |
| 783 | 780 | $view = preg_replace(',<\?php.+\?[>],Uims', '', $view); |
| 784 | 781 | if ($view) { |
| 785 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . '</fieldset>'; |
|
| 782 | + $res2 .= "\n<br /><fieldset>".interdire_scripts($view).'</fieldset>'; |
|
| 786 | 783 | } |
| 787 | 784 | } |
| 788 | 785 | } elseif ($affiche == 'code') { |
| 789 | 786 | $legend = $nom; |
| 790 | - $res = ancre_texte('<' . "?php\n" . $quoi . "\n?" . '>'); |
|
| 787 | + $res = ancre_texte('<'."?php\n".$quoi."\n?".'>'); |
|
| 791 | 788 | } elseif ($affiche == 'boucle') { |
| 792 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 789 | + $legend = _T('zbug_boucle').' '.$nom; |
|
| 793 | 790 | // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
| 794 | 791 | $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
| 795 | 792 | $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
@@ -807,23 +804,23 @@ discard block |
||
| 807 | 804 | include_spip('public/assembler'); // pour inclure_balise_dynamique |
| 808 | 805 | include_spip('inc/texte'); // pour corriger_typo |
| 809 | 806 | |
| 810 | - return _DOCTYPE_ECRIRE . |
|
| 811 | - html_lang_attributes() . |
|
| 812 | - "<head>\n<title>" . |
|
| 813 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 814 | - _T('admin_debug') . ' ' . $titre . ' (' . |
|
| 815 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 816 | - ")</title>\n" . |
|
| 817 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 818 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 819 | - "' />\n" . |
|
| 807 | + return _DOCTYPE_ECRIRE. |
|
| 808 | + html_lang_attributes(). |
|
| 809 | + "<head>\n<title>". |
|
| 810 | + ('SPIP '.$GLOBALS['spip_version_affichee'].' '. |
|
| 811 | + _T('admin_debug').' '.$titre.' ('. |
|
| 812 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))). |
|
| 813 | + ")</title>\n". |
|
| 814 | + "<meta http-equiv='Content-Type' content='text/html". |
|
| 815 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : ''). |
|
| 816 | + "' />\n". |
|
| 820 | 817 | http_script('', 'jquery.js') |
| 821 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 822 | - . "' type='text/css' />" . |
|
| 823 | - "</head>\n" . |
|
| 824 | - "<body style='margin:0 10px;'>\n" . |
|
| 825 | - "<div id='spip-debug-header'>" . |
|
| 826 | - $corps . |
|
| 827 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false) . |
|
| 818 | + . "<link rel='stylesheet' href='".url_absolue(find_in_path('spip_admin.css')) |
|
| 819 | + . "' type='text/css' />". |
|
| 820 | + "</head>\n". |
|
| 821 | + "<body style='margin:0 10px;'>\n". |
|
| 822 | + "<div id='spip-debug-header'>". |
|
| 823 | + $corps. |
|
| 824 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $GLOBALS['debug_objets']), false). |
|
| 828 | 825 | '</div></body></html>'; |
| 829 | 826 | } |