@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | // Decompilation de l'arbre de syntaxe abstraite d'un squelette SPIP |
| 16 | 16 | |
| 17 | -function decompiler_boucle($struct, $fmt='', $prof=0) |
|
| 17 | +function decompiler_boucle($struct, $fmt = '', $prof = 0) |
|
| 18 | 18 | { |
| 19 | 19 | $nom = $struct->id_boucle; |
| 20 | 20 | $avant = decompiler_($struct->avant, $fmt, $prof); |
@@ -23,98 +23,96 @@ discard block |
||
| 23 | 23 | $milieu = decompiler_($struct->milieu, $fmt, $prof); |
| 24 | 24 | |
| 25 | 25 | $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
| 26 | - $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 27 | - $struct->table_optionnelle); |
|
| 26 | + $type .= ($struct->type_requete ? $struct->type_requete : $struct->table_optionnelle); |
|
| 28 | 27 | |
| 29 | 28 | if ($struct->jointures_explicites) |
| 30 | - $type .= " " . $struct->jointures_explicites; |
|
| 29 | + $type .= " ".$struct->jointures_explicites; |
|
| 31 | 30 | if ($struct->table_optionnelle) |
| 32 | 31 | $type .= "?"; |
| 33 | 32 | // Revoir le cas de la boucle recursive |
| 34 | 33 | |
| 35 | 34 | $crit = $struct->param; |
| 36 | 35 | if ($crit AND !is_array($crit[0])) { |
| 37 | - $type = strtolower($type) . array_shift($crit); |
|
| 36 | + $type = strtolower($type).array_shift($crit); |
|
| 38 | 37 | } |
| 39 | - $crit = decompiler_criteres($struct, $fmt, $prof) ; |
|
| 38 | + $crit = decompiler_criteres($struct, $fmt, $prof); |
|
| 40 | 39 | |
| 41 | - $f = 'format_boucle_' . $fmt; |
|
| 40 | + $f = 'format_boucle_'.$fmt; |
|
| 42 | 41 | return $f($avant, $nom, $type, $crit, $milieu, $apres, $altern, $prof); |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | -function decompiler_include($struct, $fmt='', $prof=0) |
|
| 44 | +function decompiler_include($struct, $fmt = '', $prof = 0) |
|
| 46 | 45 | { |
| 47 | 46 | $res = array(); |
| 48 | - foreach($struct->param ? $struct->param : array() as $couple) { |
|
| 47 | + foreach ($struct->param ? $struct->param : array() as $couple) { |
|
| 49 | 48 | array_shift($couple); |
| 50 | - foreach($couple as $v) { |
|
| 51 | - $res[]= decompiler_($v, $fmt, $prof); |
|
| 49 | + foreach ($couple as $v) { |
|
| 50 | + $res[] = decompiler_($v, $fmt, $prof); |
|
| 52 | 51 | } |
| 53 | 52 | } |
| 54 | - $file = is_string($struct->texte) ? $struct->texte : |
|
| 55 | - decompiler_($struct->texte, $fmt, $prof); |
|
| 56 | - $f = 'format_inclure_' . $fmt; |
|
| 53 | + $file = is_string($struct->texte) ? $struct->texte : decompiler_($struct->texte, $fmt, $prof); |
|
| 54 | + $f = 'format_inclure_'.$fmt; |
|
| 57 | 55 | return $f($file, $res, $prof); |
| 58 | 56 | } |
| 59 | 57 | |
| 60 | -function decompiler_texte($struct, $fmt='', $prof=0) |
|
| 58 | +function decompiler_texte($struct, $fmt = '', $prof = 0) |
|
| 61 | 59 | { |
| 62 | - $f = 'format_texte_' . $fmt; |
|
| 60 | + $f = 'format_texte_'.$fmt; |
|
| 63 | 61 | return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
| 64 | 62 | } |
| 65 | 63 | |
| 66 | -function decompiler_polyglotte($struct, $fmt='', $prof=0) |
|
| 64 | +function decompiler_polyglotte($struct, $fmt = '', $prof = 0) |
|
| 67 | 65 | { |
| 68 | - $f = 'format_polyglotte_' . $fmt; |
|
| 66 | + $f = 'format_polyglotte_'.$fmt; |
|
| 69 | 67 | return $f($struct->traductions, $prof); |
| 70 | 68 | } |
| 71 | 69 | |
| 72 | -function decompiler_idiome($struct, $fmt='', $prof=0) |
|
| 70 | +function decompiler_idiome($struct, $fmt = '', $prof = 0) |
|
| 73 | 71 | { |
| 74 | 72 | $args = array(); |
| 75 | 73 | foreach ($struct->arg as $k => $v) { |
| 76 | - $args[$k]= public_decompiler($v, $fmt, $prof); |
|
| 74 | + $args[$k] = public_decompiler($v, $fmt, $prof); |
|
| 77 | 75 | } |
| 78 | 76 | |
| 79 | - $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 77 | + $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 80 | 78 | |
| 81 | - $f = 'format_idiome_' . $fmt; |
|
| 79 | + $f = 'format_idiome_'.$fmt; |
|
| 82 | 80 | return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
| 83 | 81 | } |
| 84 | 82 | |
| 85 | -function decompiler_champ($struct, $fmt='', $prof=0) |
|
| 83 | +function decompiler_champ($struct, $fmt = '', $prof = 0) |
|
| 86 | 84 | { |
| 87 | 85 | $avant = decompiler_($struct->avant, $fmt, $prof); |
| 88 | 86 | $apres = decompiler_($struct->apres, $fmt, $prof); |
| 89 | 87 | $args = $filtres = ''; |
| 90 | 88 | if ($p = $struct->param) { |
| 91 | - if ($p[0][0]==='') |
|
| 89 | + if ($p[0][0] === '') |
|
| 92 | 90 | $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
| 93 | 91 | $filtres = decompiler_liste($p, $fmt, $prof); |
| 94 | 92 | } |
| 95 | - $f = 'format_champ_' . $fmt; |
|
| 93 | + $f = 'format_champ_'.$fmt; |
|
| 96 | 94 | return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
| 97 | 95 | } |
| 98 | 96 | |
| 99 | -function decompiler_liste($sources, $fmt='', $prof=0) { |
|
| 97 | +function decompiler_liste($sources, $fmt = '', $prof = 0) { |
|
| 100 | 98 | if (!is_array($sources)) return ''; |
| 101 | - $f = 'format_liste_' . $fmt; |
|
| 99 | + $f = 'format_liste_'.$fmt; |
|
| 102 | 100 | $res = ''; |
| 103 | - foreach($sources as $arg) { |
|
| 104 | - if (!is_array($arg)) { |
|
| 101 | + foreach ($sources as $arg) { |
|
| 102 | + if (!is_array($arg)) { |
|
| 105 | 103 | continue; // ne devrait pas arriver. |
| 106 | - } else {$r = array_shift($arg);} |
|
| 104 | + } else {$r = array_shift($arg); } |
|
| 107 | 105 | $args = array(); |
| 108 | - foreach($arg as $v) { |
|
| 106 | + foreach ($arg as $v) { |
|
| 109 | 107 | // cas des arguments entoures de ' ou " |
| 110 | 108 | if ((count($v) == 1) |
| 111 | - AND $v[0]->type=='texte' |
|
| 109 | + AND $v[0]->type == 'texte' |
|
| 112 | 110 | AND (strlen($v[0]->apres) == 1) |
| 113 | 111 | AND $v[0]->apres == $v[0]->avant) |
| 114 | - $args[]= $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 115 | - else $args[]= decompiler_($v, $fmt, 0-$prof); |
|
| 112 | + $args[] = $v[0]->avant.$v[0]->texte.$v[0]->apres; |
|
| 113 | + else $args[] = decompiler_($v, $fmt, 0 - $prof); |
|
| 116 | 114 | } |
| 117 | - if (($r!=='') OR $args) $res .= $f($r, $args, $prof); |
|
| 115 | + if (($r !== '') OR $args) $res .= $f($r, $args, $prof); |
|
| 118 | 116 | } |
| 119 | 117 | return $res; |
| 120 | 118 | } |
@@ -123,30 +121,30 @@ discard block |
||
| 123 | 121 | // - le phraseur fournit un bout du source en plus de la compil |
| 124 | 122 | // - le champ apres signale le critere {"separateur"} ou {'separateur'} |
| 125 | 123 | // - les champs sont implicitement etendus (crochets implicites mais interdits) |
| 126 | -function decompiler_criteres($boucle, $fmt='', $prof=0) { |
|
| 124 | +function decompiler_criteres($boucle, $fmt = '', $prof = 0) { |
|
| 127 | 125 | $sources = $boucle->param; |
| 128 | 126 | if (!is_array($sources)) return ''; |
| 129 | 127 | $res = ''; |
| 130 | - $f = 'format_critere_' . $fmt; |
|
| 131 | - foreach($sources as $crit) { |
|
| 128 | + $f = 'format_critere_'.$fmt; |
|
| 129 | + foreach ($sources as $crit) { |
|
| 132 | 130 | if (!is_array($crit)) continue; // boucle recursive |
| 133 | 131 | array_shift($crit); |
| 134 | 132 | $args = array(); |
| 135 | - foreach($crit as $i => $v) { |
|
| 133 | + foreach ($crit as $i => $v) { |
|
| 136 | 134 | if ((count($v) == 1) |
| 137 | - AND $v[0]->type=='texte' |
|
| 135 | + AND $v[0]->type == 'texte' |
|
| 138 | 136 | AND $v[0]->apres) |
| 139 | - $args[]= array(array('texte', ( $v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 137 | + $args[] = array(array('texte', ($v[0]->apres.$v[0]->texte.$v[0]->apres))); |
|
| 140 | 138 | else { |
| 141 | 139 | $res2 = array(); |
| 142 | - foreach($v as $k => $p) { |
|
| 140 | + foreach ($v as $k => $p) { |
|
| 143 | 141 | if (isset($p->type) |
| 144 | - AND function_exists($d = 'decompiler_' . $p->type)) { |
|
| 145 | - $r = $d($p, $fmt, (0-$prof), @$v[$k+1]); |
|
| 146 | - $res2[]= array($p->type, $r); |
|
| 142 | + AND function_exists($d = 'decompiler_'.$p->type)) { |
|
| 143 | + $r = $d($p, $fmt, (0 - $prof), @$v[$k + 1]); |
|
| 144 | + $res2[] = array($p->type, $r); |
|
| 147 | 145 | } else spip_log("critere $i / $k mal forme"); |
| 148 | 146 | } |
| 149 | - $args[]= $res2; |
|
| 147 | + $args[] = $res2; |
|
| 150 | 148 | } |
| 151 | 149 | } |
| 152 | 150 | $res .= $f($args); |
@@ -155,15 +153,15 @@ discard block |
||
| 155 | 153 | } |
| 156 | 154 | |
| 157 | 155 | |
| 158 | -function decompiler_($liste, $fmt='', $prof=0) |
|
| 156 | +function decompiler_($liste, $fmt = '', $prof = 0) |
|
| 159 | 157 | { |
| 160 | 158 | if (!is_array($liste)) return ''; |
| 161 | - $prof2 = ($prof < 0) ? ($prof-1) : ($prof+1); |
|
| 159 | + $prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1); |
|
| 162 | 160 | $contenu = array(); |
| 163 | - foreach($liste as $k => $p) { |
|
| 161 | + foreach ($liste as $k => $p) { |
|
| 164 | 162 | if (!isset($p->type)) continue; #?????? |
| 165 | - $d = 'decompiler_' . $p->type; |
|
| 166 | - $next = isset($liste[$k+1]) ? $liste[$k+1] : false; |
|
| 163 | + $d = 'decompiler_'.$p->type; |
|
| 164 | + $next = isset($liste[$k + 1]) ? $liste[$k + 1] : false; |
|
| 167 | 165 | // Forcer le champ etendu si son source (pas les reecritures) |
| 168 | 166 | // contenait des args et s'il est suivi d'espaces, |
| 169 | 167 | // le champ simple les eliminant est un bug helas perenne. |
@@ -175,7 +173,7 @@ discard block |
||
| 175 | 173 | AND !$p->avant |
| 176 | 174 | AND $p->fonctions) { |
| 177 | 175 | $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
| 178 | - if ($n) { |
|
| 176 | + if ($n) { |
|
| 179 | 177 | $champ = new Texte; |
| 180 | 178 | $champ->texte = substr($next->texte, 0, $n); |
| 181 | 179 | $champ->ligne = $p->ligne; |
@@ -186,14 +184,14 @@ discard block |
||
| 186 | 184 | $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
| 187 | 185 | |
| 188 | 186 | } |
| 189 | - $f = 'format_suite_' . $fmt; |
|
| 187 | + $f = 'format_suite_'.$fmt; |
|
| 190 | 188 | return $f($contenu); |
| 191 | 189 | } |
| 192 | 190 | |
| 193 | -function public_decompiler($liste, $fmt='', $prof=0, $quoi='') |
|
| 191 | +function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') |
|
| 194 | 192 | { |
| 195 | - if (!include_spip('public/format_' . $fmt)) return "'$fmt'?"; |
|
| 196 | - $f = 'decompiler_' . $quoi; |
|
| 193 | + if (!include_spip('public/format_'.$fmt)) return "'$fmt'?"; |
|
| 194 | + $f = 'decompiler_'.$quoi; |
|
| 197 | 195 | return $f($liste, $fmt, $prof); |
| 198 | 196 | } |
| 199 | 197 | ?> |
@@ -45,55 +45,55 @@ |
||
| 45 | 45 | // restaurer l'etat des notes avant calcul |
| 46 | 46 | if (isset($page['notes']) |
| 47 | 47 | AND $page['notes'] |
| 48 | - AND $notes = charger_fonction("notes","inc",true)){ |
|
| 49 | - $notes($page['notes'],'restaurer_etat'); |
|
| 48 | + AND $notes = charger_fonction("notes", "inc", true)) { |
|
| 49 | + $notes($page['notes'], 'restaurer_etat'); |
|
| 50 | 50 | } |
| 51 | 51 | ob_start(); |
| 52 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 52 | + if (strpos($page['texte'], '?xml') !== false) |
|
| 53 | 53 | $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); |
| 54 | 54 | |
| 55 | 55 | try { |
| 56 | - $res = eval('?' . '>' . $page['texte']); |
|
| 56 | + $res = eval('?'.'>'.$page['texte']); |
|
| 57 | 57 | // error catching 5.2<=PHP<7 |
| 58 | 58 | if ($res === false |
| 59 | 59 | and function_exists('error_get_last') |
| 60 | - and ($erreur = error_get_last()) ) { |
|
| 60 | + and ($erreur = error_get_last())) { |
|
| 61 | 61 | $code = $page['texte']; |
| 62 | 62 | $GLOBALS['numero_ligne_php'] = 1; |
| 63 | - if (!function_exists('numerote_ligne_php')){ |
|
| 64 | - function numerote_ligne_php($match){ |
|
| 63 | + if (!function_exists('numerote_ligne_php')) { |
|
| 64 | + function numerote_ligne_php($match) { |
|
| 65 | 65 | $GLOBALS['numero_ligne_php']++; |
| 66 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 66 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'], 3, "0", STR_PAD_LEFT)."*/"; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 70 | - $code = trim(highlight_string($code,true)); |
|
| 71 | - erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
|
| 69 | + $code = "/*001*/".preg_replace_callback(",\n,", "numerote_ligne_php", $code); |
|
| 70 | + $code = trim(highlight_string($code, true)); |
|
| 71 | + erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code, array($page['source'], '', $erreur['file'], '', $GLOBALS['spip_lang'])); |
|
| 72 | 72 | $page['texte'] = "<!-- Erreur -->"; |
| 73 | 73 | } |
| 74 | 74 | else { |
| 75 | 75 | $page['texte'] = ob_get_contents(); |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | - catch (Exception $e){ |
|
| 78 | + catch (Exception $e) { |
|
| 79 | 79 | $code = $page['texte']; |
| 80 | 80 | $GLOBALS['numero_ligne_php'] = 1; |
| 81 | - if (!function_exists('numerote_ligne_php')){ |
|
| 82 | - function numerote_ligne_php($match){ |
|
| 81 | + if (!function_exists('numerote_ligne_php')) { |
|
| 82 | + function numerote_ligne_php($match) { |
|
| 83 | 83 | $GLOBALS['numero_ligne_php']++; |
| 84 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 84 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'], 3, "0", STR_PAD_LEFT)."*/"; |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 88 | - $code = trim(highlight_string($code,true)); |
|
| 89 | - erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang'])); |
|
| 87 | + $code = "/*001*/".preg_replace_callback(",\n,", "numerote_ligne_php", $code); |
|
| 88 | + $code = trim(highlight_string($code, true)); |
|
| 89 | + erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code, array($page['source'], '', $e->getFile(), '', $GLOBALS['spip_lang'])); |
|
| 90 | 90 | $page['texte'] = "<!-- Erreur -->"; |
| 91 | 91 | } |
| 92 | 92 | ob_end_clean(); |
| 93 | 93 | |
| 94 | 94 | $page['process_ins'] = 'html'; |
| 95 | 95 | |
| 96 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 96 | + if (strpos($page['texte'], '?xml') !== false) |
|
| 97 | 97 | $page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']); |
| 98 | 98 | } |
| 99 | 99 | |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | * @param Object $p |
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | -function index_boucle($p){ |
|
| 30 | +function index_boucle($p) { |
|
| 31 | 31 | |
| 32 | 32 | $idb = $p->id_boucle; |
| 33 | 33 | $explicite = $p->nom_boucle; |
| 34 | 34 | |
| 35 | 35 | if (strlen($explicite)) { |
| 36 | 36 | // Recherche d'un champ dans un etage superieur |
| 37 | - while (($idb !== $explicite) && ($idb !=='')) { |
|
| 37 | + while (($idb !== $explicite) && ($idb !== '')) { |
|
| 38 | 38 | $idb = $p->boucles[$idb]->id_parent; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | * permettre de remonter la pile des boucles ou non (dans ce cas on ne cherche que ds la 1ere boucle englobante) |
| 65 | 65 | * @return string |
| 66 | 66 | */ |
| 67 | -function index_pile($idb, $nom_champ, &$boucles, $explicite='', $defaut=null, $remonte_pile=true) { |
|
| 67 | +function index_pile($idb, $nom_champ, &$boucles, $explicite = '', $defaut = null, $remonte_pile = true) { |
|
| 68 | 68 | if (!is_string($defaut)) |
| 69 | - $defaut = '@$Pile[0][\''. strtolower($nom_champ) . '\']'; |
|
| 69 | + $defaut = '@$Pile[0][\''.strtolower($nom_champ).'\']'; |
|
| 70 | 70 | |
| 71 | 71 | $i = 0; |
| 72 | 72 | if (strlen($explicite)) { |
| 73 | 73 | // Recherche d'un champ dans un etage superieur |
| 74 | - while (($idb !== $explicite) && ($idb !=='')) { |
|
| 74 | + while (($idb !== $explicite) && ($idb !== '')) { |
|
| 75 | 75 | # spip_log("Cherchexpl: $nom_champ '$explicite' '$idb' '$i'"); |
| 76 | 76 | $i++; |
| 77 | 77 | $idb = $boucles[$idb]->id_parent; |
@@ -90,14 +90,14 @@ discard block |
||
| 90 | 90 | if (!in_array($t, $boucles[$idb]->select)) { |
| 91 | 91 | $boucles[$idb]->select[] = $t; |
| 92 | 92 | } |
| 93 | - $champ = '$Pile[$SP' . ($i ? "-$i" : "") . '][\'' . $c . '\']'; |
|
| 93 | + $champ = '$Pile[$SP'.($i ? "-$i" : "").'][\''.$c.'\']'; |
|
| 94 | 94 | if (!$joker) |
| 95 | - return index_compose($conditionnel,$champ); |
|
| 95 | + return index_compose($conditionnel, $champ); |
|
| 96 | 96 | |
| 97 | 97 | $conditionnel[] = "isset($champ)?$champ"; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ($remonte_pile){ |
|
| 100 | + if ($remonte_pile) { |
|
| 101 | 101 | # spip_log("On remonte vers $i"); |
| 102 | 102 | // Sinon on remonte d'un cran |
| 103 | 103 | $idb = $boucles[$idb]->id_parent; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | # spip_log("Pas vu $nom_champ"); |
| 111 | 111 | // esperons qu'il y sera |
| 112 | 112 | // on qu'on a fourni une valeur par "defaut" plus pertinent |
| 113 | - return index_compose($conditionnel,$defaut); |
|
| 113 | + return index_compose($conditionnel, $defaut); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | * @param string $defaut |
| 123 | 123 | * @return string |
| 124 | 124 | */ |
| 125 | -function index_compose($conditionnel,$defaut){ |
|
| 125 | +function index_compose($conditionnel, $defaut) { |
|
| 126 | 126 | while ($c = array_pop($conditionnel)) |
| 127 | 127 | // si on passe defaut = '', ne pas générer d'erreur de compilation. |
| 128 | - $defaut = "($c:(".($defaut?$defaut:"''")."))"; |
|
| 128 | + $defaut = "($c:(".($defaut ? $defaut : "''")."))"; |
|
| 129 | 129 | return $defaut; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | if (!$r) { |
| 140 | 140 | $joker = false; // indiquer a l'appelant |
| 141 | 141 | # continuer pour chercher l'erreur suivante |
| 142 | - return array("'#" . $r . ':' . $nom_champ . "'",''); |
|
| 142 | + return array("'#".$r.':'.$nom_champ."'", ''); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $desc = $boucles[$idb]->show; |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $nom_champ, |
| 174 | 174 | array($t[1]['id_table'], $nom_champ)); |
| 175 | 175 | } |
| 176 | - return array('',''); |
|
| 176 | + return array('', ''); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | } |
@@ -192,24 +192,24 @@ discard block |
||
| 192 | 192 | if (is_array($excep)) { |
| 193 | 193 | // permettre aux plugins de gerer eux meme des jointures derogatoire ingerables |
| 194 | 194 | $t = NULL; |
| 195 | - if (count($excep)==3){ |
|
| 195 | + if (count($excep) == 3) { |
|
| 196 | 196 | $index_exception_derogatoire = array_pop($excep); |
| 197 | 197 | $t = $index_exception_derogatoire($boucle, $desc, $nom_champ, $excep); |
| 198 | 198 | } |
| 199 | 199 | if ($t == NULL) { |
| 200 | - list($e, $x) = $excep; #PHP4 affecte de gauche a droite |
|
| 201 | - $excep = $x; #PHP5 de droite a gauche ! |
|
| 200 | + list($e, $x) = $excep; #PHP4 affecte de gauche a droite |
|
| 201 | + $excep = $x; #PHP5 de droite a gauche ! |
|
| 202 | 202 | $j = $trouver_table($e, $boucle->sql_serveur); |
| 203 | - if (!$j) return array('',''); |
|
| 203 | + if (!$j) return array('', ''); |
|
| 204 | 204 | $e = $j['table']; |
| 205 | 205 | if (!$t = array_search($e, $boucle->from)) { |
| 206 | 206 | $k = $j['key']['PRIMARY KEY']; |
| 207 | - if (strpos($k,',')) { |
|
| 207 | + if (strpos($k, ',')) { |
|
| 208 | 208 | $l = (preg_split('/\s*,\s*/', $k)); |
| 209 | 209 | $k = $desc['key']['PRIMARY KEY']; |
| 210 | 210 | if (!in_array($k, $l)) { |
| 211 | - spip_log("jointure impossible $e " . join(',', $l)); |
|
| 212 | - return array('',''); |
|
| 211 | + spip_log("jointure impossible $e ".join(',', $l)); |
|
| 212 | + return array('', ''); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | $k = array($boucle->id_table, array($e), $k); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | else $t = $boucle->id_table; |
| 222 | 222 | // demander a SQL de gerer le synonyme |
| 223 | 223 | // ca permet que excep soit dynamique (Cedric, 2/3/06) |
| 224 | - if ($excep != $nom_champ) $excep .= ' AS '. $nom_champ; |
|
| 224 | + if ($excep != $nom_champ) $excep .= ' AS '.$nom_champ; |
|
| 225 | 225 | return array("$t.$excep", $nom_champ); |
| 226 | 226 | } |
| 227 | 227 | |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | // Certaines des balises comportant un _ sont generiques |
| 276 | 276 | if ($f = strpos($nom, '_') |
| 277 | - AND $f = charger_fonction(substr($nom,0,$f+1), 'balise', true)) { |
|
| 277 | + AND $f = charger_fonction(substr($nom, 0, $f + 1), 'balise', true)) { |
|
| 278 | 278 | $res = $f($p); |
| 279 | 279 | if ($res !== NULL) |
| 280 | 280 | return $res; |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | array(%s%s))"); |
| 333 | 333 | |
| 334 | 334 | // http://doc.spip.org/@calculer_balise_dynamique |
| 335 | -function calculer_balise_dynamique($p, $nom, $l, $supp=array()) { |
|
| 335 | +function calculer_balise_dynamique($p, $nom, $l, $supp = array()) { |
|
| 336 | 336 | |
| 337 | 337 | if (!balise_distante_interdite($p)) { |
| 338 | 338 | $p->code = "''"; |
@@ -354,9 +354,9 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | $p->code = sprintf(CODE_EXECUTER_BALISE, $nom, |
| 356 | 356 | join(',', $collecte), |
| 357 | - ($collecte ? $param : substr($param,1)), # virer la virgule |
|
| 357 | + ($collecte ? $param : substr($param, 1)), # virer la virgule |
|
| 358 | 358 | memoriser_contexte_compil($p), |
| 359 | - (!$supp ? '' : (', ' . join(',', $supp)))); |
|
| 359 | + (!$supp ? '' : (', '.join(',', $supp)))); |
|
| 360 | 360 | |
| 361 | 361 | $p->interdire_scripts = false; |
| 362 | 362 | return $p; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | // http://doc.spip.org/@collecter_balise_dynamique |
| 372 | 372 | function collecter_balise_dynamique($l, &$p, $nom) { |
| 373 | 373 | $args = array(); |
| 374 | - foreach($l as $c) { $x = calculer_balise($c, $p); $args[] = $x->code;} |
|
| 374 | + foreach ($l as $c) { $x = calculer_balise($c, $p); $args[] = $x->code; } |
|
| 375 | 375 | return $args; |
| 376 | 376 | } |
| 377 | 377 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | $s = $p->boucles[$nom]->sql_serveur; |
| 396 | 396 | if (strlen($s) |
| 397 | 397 | AND strlen($serveur = strtolower($s)) |
| 398 | - AND !in_array($serveur,$GLOBALS['exception_des_connect'])) { |
|
| 398 | + AND !in_array($serveur, $GLOBALS['exception_des_connect'])) { |
|
| 399 | 399 | return $serveur; |
| 400 | 400 | } |
| 401 | 401 | } |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | $nom = $p->id_boucle; |
| 426 | 426 | |
| 427 | 427 | if ($nom AND trouver_nom_serveur_distant($p)) { |
| 428 | - spip_log( $nom .':' . $p->nom_champ .' '._T('zbug_distant_interdit')); |
|
| 428 | + spip_log($nom.':'.$p->nom_champ.' '._T('zbug_distant_interdit')); |
|
| 429 | 429 | return false; |
| 430 | 430 | } |
| 431 | 431 | return true; |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | // definis par $table_des_traitements, cf. ecrire/public/interfaces |
| 438 | 438 | // |
| 439 | 439 | // http://doc.spip.org/@champs_traitements |
| 440 | -function champs_traitements ($p) { |
|
| 440 | +function champs_traitements($p) { |
|
| 441 | 441 | global $table_des_traitements; |
| 442 | 442 | |
| 443 | 443 | if (isset($table_des_traitements[$p->nom_champ])) |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | $idb = index_boucle($p); |
| 458 | 458 | // mais on peut aussi etre hors boucle. Se mefier. |
| 459 | 459 | $type_requete = isset($p->boucles[$idb]->type_requete) ? $p->boucles[$idb]->type_requete : false; |
| 460 | - $table_sql = isset($p->boucles[$idb]->show['table_sql'])?$p->boucles[$idb]->show['table_sql']:false; |
|
| 460 | + $table_sql = isset($p->boucles[$idb]->show['table_sql']) ? $p->boucles[$idb]->show['table_sql'] : false; |
|
| 461 | 461 | |
| 462 | 462 | // le traitement peut n'etre defini que pour une table en particulier "spip_articles" |
| 463 | 463 | if ($table_sql AND isset($ps[$table_sql])) |
@@ -466,10 +466,10 @@ discard block |
||
| 466 | 466 | elseif ($type_requete AND isset($ps[$type_requete])) |
| 467 | 467 | $ps = $ps[$type_requete]; |
| 468 | 468 | // ou pour indiferrement quelle que soit la boucle |
| 469 | - elseif(isset($ps[0])) |
|
| 469 | + elseif (isset($ps[0])) |
|
| 470 | 470 | $ps = $ps[0]; |
| 471 | 471 | else |
| 472 | - $ps=false; |
|
| 472 | + $ps = false; |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | if (!$ps) return $p->code; |
@@ -484,9 +484,9 @@ discard block |
||
| 484 | 484 | AND |
| 485 | 485 | $p->descr['documents'] |
| 486 | 486 | AND ( |
| 487 | - (strpos($ps,'propre') !== false) |
|
| 487 | + (strpos($ps, 'propre') !== false) |
|
| 488 | 488 | OR |
| 489 | - (strpos($ps,'typo') !== false) |
|
| 489 | + (strpos($ps, 'typo') !== false) |
|
| 490 | 490 | )) |
| 491 | 491 | $ps = 'traiter_doublons_documents($doublons, '.$ps.')'; |
| 492 | 492 | |
@@ -531,11 +531,11 @@ discard block |
||
| 531 | 531 | function compose_filtres(&$p, $code) { |
| 532 | 532 | |
| 533 | 533 | $image_miette = false; |
| 534 | - foreach($p->param as $filtre) { |
|
| 534 | + foreach ($p->param as $filtre) { |
|
| 535 | 535 | $fonc = array_shift($filtre); |
| 536 | 536 | if (!$fonc) continue; // normalement qu'au premier tour. |
| 537 | - $is_filtre_image = ((substr($fonc,0,6)=='image_') AND $fonc!='image_graver'); |
|
| 538 | - if ($image_miette AND !$is_filtre_image){ |
|
| 537 | + $is_filtre_image = ((substr($fonc, 0, 6) == 'image_') AND $fonc != 'image_graver'); |
|
| 538 | + if ($image_miette AND !$is_filtre_image) { |
|
| 539 | 539 | // il faut graver maintenant car apres le filtre en cours |
| 540 | 540 | // on est pas sur d'avoir encore le nom du fichier dans le pipe |
| 541 | 541 | $code = "filtrer('image_graver', $code)"; |
@@ -548,14 +548,14 @@ discard block |
||
| 548 | 548 | } else {$sep = ':'; |
| 549 | 549 | // |?{a,b} *doit* avoir exactement 2 arguments ; on les force |
| 550 | 550 | if (count($filtre) != 2) |
| 551 | - $filtre = array(isset($filtre[0])?$filtre[0]:"", isset($filtre[1])?$filtre[1]:""); |
|
| 551 | + $filtre = array(isset($filtre[0]) ? $filtre[0] : "", isset($filtre[1]) ? $filtre[1] : ""); |
|
| 552 | 552 | } |
| 553 | 553 | $arglist = compose_filtres_args($p, $filtre, $sep); |
| 554 | - $logique = filtre_logique($fonc, $code, substr($arglist,1)); |
|
| 554 | + $logique = filtre_logique($fonc, $code, substr($arglist, 1)); |
|
| 555 | 555 | if ($logique) |
| 556 | 556 | $code = $logique; |
| 557 | 557 | else { |
| 558 | - $code = sandbox_composer_filtre($fonc,$code,$arglist,$p); |
|
| 558 | + $code = sandbox_composer_filtre($fonc, $code, $arglist, $p); |
|
| 559 | 559 | if ($is_filtre_image) $image_miette = true; |
| 560 | 560 | } |
| 561 | 561 | } |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | { |
| 596 | 596 | $arglist = ""; |
| 597 | 597 | foreach ($args as $arg) { |
| 598 | - $arglist .= $sep . |
|
| 598 | + $arglist .= $sep. |
|
| 599 | 599 | calculer_liste($arg, $p->descr, $p->boucles, $p->id_boucle); |
| 600 | 600 | } |
| 601 | 601 | return $arglist; |
@@ -607,17 +607,17 @@ discard block |
||
| 607 | 607 | // ET chez sa maman |
| 608 | 608 | // |
| 609 | 609 | // http://doc.spip.org/@calculer_argument_precedent |
| 610 | -function calculer_argument_precedent($idb, $nom_champ, &$boucles, $defaut=null) { |
|
| 610 | +function calculer_argument_precedent($idb, $nom_champ, &$boucles, $defaut = null) { |
|
| 611 | 611 | |
| 612 | 612 | // si recursif, forcer l'extraction du champ SQL mais ignorer le code |
| 613 | 613 | if ($boucles[$idb]->externe) { |
| 614 | - index_pile ($idb, $nom_champ, $boucles,'', $defaut); |
|
| 614 | + index_pile($idb, $nom_champ, $boucles, '', $defaut); |
|
| 615 | 615 | // retourner $Pile[$SP] et pas $Pile[0] si recursion en 1ere boucle |
| 616 | 616 | // on ignore le defaut fourni dans ce cas |
| 617 | 617 | $defaut = "@\$Pile[\$SP]['$nom_champ']"; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - return index_pile($boucles[$idb]->id_parent, $nom_champ, $boucles,'', $defaut); |
|
| 620 | + return index_pile($boucles[$idb]->id_parent, $nom_champ, $boucles, '', $defaut); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | // |
@@ -637,9 +637,9 @@ discard block |
||
| 637 | 637 | $b = $p->id_boucle; |
| 638 | 638 | $p->code = ''; |
| 639 | 639 | while ($b != '') { |
| 640 | - foreach($p->boucles[$b]->criteres as $critere) { |
|
| 640 | + foreach ($p->boucles[$b]->criteres as $critere) { |
|
| 641 | 641 | if ($critere->op == $motif) { |
| 642 | - $p->code = '$Pile[$SP' . (($n==0) ? "" : "-$n") . |
|
| 642 | + $p->code = '$Pile[$SP'.(($n == 0) ? "" : "-$n"). |
|
| 643 | 643 | "]['$champ']"; |
| 644 | 644 | $b = ''; |
| 645 | 645 | break 2; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | -function format_boucle_html ($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) |
|
| 15 | +function format_boucle_html($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) |
|
| 16 | 16 | { |
| 17 | 17 | $avant = $avant ? "<B$nom>$avant" : ""; |
| 18 | 18 | $apres = $apres ? "$apres</B$nom>" : ""; |
@@ -21,36 +21,36 @@ discard block |
||
| 21 | 21 | return "$avant<BOUCLE$nom($type)$crit$corps$apres$altern"; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -function format_inclure_html ($file, $args, $prof) |
|
| 24 | +function format_inclure_html($file, $args, $prof) |
|
| 25 | 25 | { |
| 26 | - if (strpos($file, '#')===false) |
|
| 27 | - $t = $file ? ("(" . $file . ")") : "" ; |
|
| 26 | + if (strpos($file, '#') === false) |
|
| 27 | + $t = $file ? ("(".$file.")") : ""; |
|
| 28 | 28 | else { |
| 29 | - $t = "{fond=" . $file . '}'; |
|
| 29 | + $t = "{fond=".$file.'}'; |
|
| 30 | 30 | } |
| 31 | - $args = !$args ? '' : ("{" . join(", ",$args) . "}"); |
|
| 32 | - return ("<INCLURE" . $t . $args . ">"); |
|
| 31 | + $args = !$args ? '' : ("{".join(", ", $args)."}"); |
|
| 32 | + return ("<INCLURE".$t.$args.">"); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | -function format_polyglotte_html ($args, $prof) |
|
| 35 | +function format_polyglotte_html($args, $prof) |
|
| 36 | 36 | { |
| 37 | 37 | $contenu = array(); |
| 38 | - foreach($args as $l=>$t) |
|
| 39 | - $contenu[]= ($l ? "[$l]" : '') . $t; |
|
| 40 | - return ("<multi>" . join(" ", $contenu) . "</multi>"); |
|
| 38 | + foreach ($args as $l=>$t) |
|
| 39 | + $contenu[] = ($l ? "[$l]" : '').$t; |
|
| 40 | + return ("<multi>".join(" ", $contenu)."</multi>"); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -function format_idiome_html ($nom, $module, $args, $filtres, $prof) |
|
| 43 | +function format_idiome_html($nom, $module, $args, $filtres, $prof) |
|
| 44 | 44 | { |
| 45 | 45 | foreach ($args as $k => $v) $args[$k] = "$k=$v"; |
| 46 | - $args = (!$args ? '' : ('{' . join(',', $args) . '}')); |
|
| 47 | - return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>"); |
|
| 46 | + $args = (!$args ? '' : ('{'.join(',', $args).'}')); |
|
| 47 | + return ("<:".($module ? "$module:" : "").$nom.$args.$filtres.":>"); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | -function format_champ_html ($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) |
|
| 50 | +function format_champ_html($nom, $boucle, $etoile, $avant, $apres, $args, $filtres, $prof) |
|
| 51 | 51 | { |
| 52 | 52 | $nom = "#" |
| 53 | - . ($boucle ? ($boucle . ":") : "") |
|
| 53 | + . ($boucle ? ($boucle.":") : "") |
|
| 54 | 54 | . $nom |
| 55 | 55 | . $etoile |
| 56 | 56 | . $args |
@@ -59,62 +59,62 @@ discard block |
||
| 59 | 59 | // Determiner si c'est un champ etendu, |
| 60 | 60 | |
| 61 | 61 | $s = ($avant OR $apres OR $filtres |
| 62 | - OR (strpos($args, '(#') !==false)); |
|
| 62 | + OR (strpos($args, '(#') !== false)); |
|
| 63 | 63 | |
| 64 | 64 | return ($s ? "[$avant($nom)$apres]" : $nom); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | -function format_critere_html ($critere) |
|
| 67 | +function format_critere_html($critere) |
|
| 68 | 68 | { |
| 69 | 69 | foreach ($critere as $k => $crit) { |
| 70 | 70 | $crit_s = ''; |
| 71 | 71 | foreach ($crit as $operande) { |
| 72 | 72 | list($type, $valeur) = $operande; |
| 73 | - if ($type == 'champ' AND $valeur[0]=='[') { |
|
| 74 | - $valeur = substr($valeur,1,-1); |
|
| 73 | + if ($type == 'champ' AND $valeur[0] == '[') { |
|
| 74 | + $valeur = substr($valeur, 1, -1); |
|
| 75 | 75 | if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) |
| 76 | - $valeur = substr($valeur,1,-1); |
|
| 76 | + $valeur = substr($valeur, 1, -1); |
|
| 77 | 77 | } |
| 78 | 78 | $crit_s .= $valeur; |
| 79 | 79 | } |
| 80 | 80 | $critere[$k] = $crit_s; |
| 81 | 81 | } |
| 82 | - return (!$critere ? "" : ("{" . join(",", $critere) . "}")); |
|
| 82 | + return (!$critere ? "" : ("{".join(",", $critere)."}")); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -function format_liste_html ($fonc, $args, $prof) |
|
| 85 | +function format_liste_html($fonc, $args, $prof) |
|
| 86 | 86 | { |
| 87 | - return ((($fonc!=='') ? "|$fonc" : $fonc) |
|
| 88 | - . (!$args ? "" : ("{" . join(",", $args) . "}"))); |
|
| 87 | + return ((($fonc !== '') ? "|$fonc" : $fonc) |
|
| 88 | + . (!$args ? "" : ("{".join(",", $args)."}"))); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Concatenation sans separateur: verifier qu'on ne cree pas de faux lexemes |
| 92 | -function format_suite_html ($args) |
|
| 92 | +function format_suite_html($args) |
|
| 93 | 93 | { |
| 94 | - for($i=0; $i < count($args)-1; $i++) { |
|
| 94 | + for ($i = 0; $i < count($args) - 1; $i++) { |
|
| 95 | 95 | list($texte, $type) = $args[$i]; |
| 96 | - list($texte2, $type2) = $args[$i+1]; |
|
| 96 | + list($texte2, $type2) = $args[$i + 1]; |
|
| 97 | 97 | if (!$texte OR !$texte2) continue; |
| 98 | - $c1 = substr($texte,-1); |
|
| 98 | + $c1 = substr($texte, -1); |
|
| 99 | 99 | if ($type2 !== 'texte') { |
| 100 | 100 | // si un texte se termine par ( et est suivi d'un champ |
| 101 | 101 | // ou assimiles, forcer la notation pleine |
| 102 | - if ($c1 == '(' AND substr($texte2,0,1) == '#') |
|
| 103 | - $args[$i+1][0] = '[(' . $texte2 . ')]'; |
|
| 102 | + if ($c1 == '(' AND substr($texte2, 0, 1) == '#') |
|
| 103 | + $args[$i + 1][0] = '[('.$texte2.')]'; |
|
| 104 | 104 | } else { |
| 105 | 105 | if ($type == 'texte') continue; |
| 106 | 106 | // si un champ ou assimiles est suivi d'un texte |
| 107 | 107 | // et si celui-ci commence par un caractere de champ |
| 108 | 108 | // forcer la notation pleine |
| 109 | - if (($c1 == '}' AND substr(ltrim($texte2),0,1) == '|') |
|
| 109 | + if (($c1 == '}' AND substr(ltrim($texte2), 0, 1) == '|') |
|
| 110 | 110 | OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2))) |
| 111 | - $args[$i][0] = '[(' . $texte . ')]'; |
|
| 111 | + $args[$i][0] = '[('.$texte.')]'; |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | return join("", array_map('array_shift', $args)); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | -function format_texte_html ($texte) |
|
| 117 | +function format_texte_html($texte) |
|
| 118 | 118 | { |
| 119 | 119 | return $texte; |
| 120 | 120 | } |
@@ -57,15 +57,15 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | // http://doc.spip.org/@argumenter_inclure |
| 60 | -function argumenter_inclure($params, $rejet_filtres, $p, &$boucles, $id_boucle, $echap=true, $lang = '', $fond1=false){ |
|
| 60 | +function argumenter_inclure($params, $rejet_filtres, $p, &$boucles, $id_boucle, $echap = true, $lang = '', $fond1 = false) { |
|
| 61 | 61 | $l = array(); |
| 62 | 62 | $erreur_p_i_i = ''; |
| 63 | 63 | if (!is_array($params)) return $l; |
| 64 | - foreach($params as $k => $couple) { |
|
| 64 | + foreach ($params as $k => $couple) { |
|
| 65 | 65 | // la liste d'arguments d'inclusion peut se terminer par un filtre |
| 66 | 66 | $filtre = array_shift($couple); |
| 67 | 67 | if ($filtre) break; |
| 68 | - foreach($couple as $n => $val) { |
|
| 68 | + foreach ($couple as $n => $val) { |
|
| 69 | 69 | $var = $val[0]; |
| 70 | 70 | if ($var->type != 'texte') { |
| 71 | 71 | if ($n OR $k OR $fond1) { |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | else $l[1] = calculer_liste($val, $p->descr, $boucles, $id_boucle); |
| 78 | 78 | } else { |
| 79 | - preg_match(",^([^=]*)(=?)(.*)$,m", $var->texte,$m); |
|
| 79 | + preg_match(",^([^=]*)(=?)(.*)$,m", $var->texte, $m); |
|
| 80 | 80 | $var = $m[1]; |
| 81 | - $auto = false;; |
|
| 81 | + $auto = false; ; |
|
| 82 | 82 | if ($m[2]) { |
| 83 | 83 | $v = $m[3]; |
| 84 | 84 | if (preg_match(',^[\'"](.*)[\'"]$,', $v, $m)) $v = $m[1]; |
@@ -97,8 +97,8 @@ discard block |
||
| 97 | 97 | ? index_pile($id_boucle, $var, $boucles) |
| 98 | 98 | : calculer_liste($val, $p->descr, $boucles, $id_boucle); |
| 99 | 99 | if ($var !== 1) |
| 100 | - $val = ($echap?"\'$var\' => ' . argumenter_squelette(":"'$var' => ") |
|
| 101 | - . $val . ($echap? ") . '":" "); |
|
| 100 | + $val = ($echap ? "\'$var\' => ' . argumenter_squelette(" : "'$var' => ") |
|
| 101 | + . $val.($echap ? ") . '" : " "); |
|
| 102 | 102 | else $val = $echap ? "'.$val.'" : $val; |
| 103 | 103 | $l[$var] = $val; |
| 104 | 104 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | // sauf si on n'en veut pas |
| 112 | 112 | if ($lang === false) return $l; |
| 113 | 113 | if (!$lang) $lang = '$GLOBALS["spip_lang"]'; |
| 114 | - $l['lang'] = ($echap?"\'lang\' => ' . argumenter_squelette(":"'lang' => ") . $lang . ($echap?") . '":" "); |
|
| 114 | + $l['lang'] = ($echap ? "\'lang\' => ' . argumenter_squelette(" : "'lang' => ").$lang.($echap ? ") . '" : " "); |
|
| 115 | 115 | |
| 116 | 116 | return $l; |
| 117 | 117 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $_contexte = argumenter_inclure($p->param, false, $p, $boucles, $id_boucle, true, '', true); |
| 141 | 141 | if (is_string($p->texte)) { |
| 142 | 142 | $fichier = $p->texte; |
| 143 | - $code = "\"".str_replace('"','\"',$fichier)."\""; |
|
| 143 | + $code = "\"".str_replace('"', '\"', $fichier)."\""; |
|
| 144 | 144 | |
| 145 | 145 | } else { |
| 146 | 146 | $code = calculer_liste($p->texte, $p->descr, $boucles, $id_boucle); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | if (is_array($_contexte)) { |
| 160 | 160 | // Critere d'inclusion {env} (et {self} pour compatibilite ascendante) |
| 161 | - if ($env = (isset($_contexte['env'])|| isset($_contexte['self']))) { |
|
| 161 | + if ($env = (isset($_contexte['env']) || isset($_contexte['self']))) { |
|
| 162 | 162 | unset($_contexte['env']); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | $_contexte['doublons'] = "\\'doublons\\' => '.var_export(\$doublons,true).'"; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ($ajax = isset($_contexte['ajax'])){ |
|
| 171 | - $ajax = preg_replace(",=>(.*)$,ims",'=> ($v=(\\1))?$v:true',$_contexte['ajax']); |
|
| 170 | + if ($ajax = isset($_contexte['ajax'])) { |
|
| 171 | + $ajax = preg_replace(",=>(.*)$,ims", '=> ($v=(\\1))?$v:true', $_contexte['ajax']); |
|
| 172 | 172 | unset($_contexte['ajax']); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | else |
| 178 | 178 | return false; // j'aurais voulu toucher le fond ... |
| 179 | 179 | |
| 180 | - $contexte = 'array(' . $_contexte .')'; |
|
| 180 | + $contexte = 'array('.$_contexte.')'; |
|
| 181 | 181 | |
| 182 | 182 | if ($env) { |
| 183 | 183 | $contexte = "array_merge('.var_export(\$Pile[0],1).',$contexte)"; |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | // s'il y a une extension .php, ce n'est pas un squelette |
| 187 | 187 | if ($fichier and preg_match('/^.+[.]php$/s', $fichier)) { |
| 188 | 188 | $code = sandbox_composer_inclure_php($fichier, $p, $contexte); |
| 189 | - } else { |
|
| 189 | + } else { |
|
| 190 | 190 | $_options[] = "\"compil\"=>array($compil)"; |
| 191 | 191 | if ($ajax) |
| 192 | 192 | $_options[] = $ajax; |
| 193 | 193 | $code = " ' . argumenter_squelette($code) . '"; |
| 194 | - $code = "echo " . sprintf(CODE_RECUPERER_FOND, $code, $contexte, implode(',',$_options), "_request(\"connect\")") . ';'; |
|
| 194 | + $code = "echo ".sprintf(CODE_RECUPERER_FOND, $code, $contexte, implode(',', $_options), "_request(\"connect\")").';'; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - return "\n'<'.'". "?php ". $code . "\n?'." . "'>'"; |
|
| 197 | + return "\n'<'.'"."?php ".$code."\n?'."."'>'"; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * @param bool $ignore_previsu |
| 212 | 212 | * true pour ne tester que le cas publie et ignorer l'eventuel var_mode=preview de la page |
| 213 | 213 | */ |
| 214 | -function instituer_boucle(&$boucle, $echapper=true, $ignore_previsu=false){ |
|
| 214 | +function instituer_boucle(&$boucle, $echapper = true, $ignore_previsu = false) { |
|
| 215 | 215 | /* |
| 216 | 216 | $show['statut'][] = array( |
| 217 | 217 | 'champ'=>'statut', // champ de la table sur lequel porte le filtrage par le statut |
@@ -238,12 +238,12 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | $id_table = $boucle->id_table; |
| 240 | 240 | $show = $boucle->show; |
| 241 | - if (isset($show['statut']) AND $show['statut']){ |
|
| 242 | - foreach($show['statut'] as $k=>$s){ |
|
| 241 | + if (isset($show['statut']) AND $show['statut']) { |
|
| 242 | + foreach ($show['statut'] as $k=>$s) { |
|
| 243 | 243 | // Restreindre aux elements publies si pas de {statut} ou autre dans les criteres |
| 244 | 244 | $filtrer = true; |
| 245 | 245 | if (isset($s['exception'])) { |
| 246 | - foreach(is_array($s['exception'])?$s['exception']:array($s['exception']) as $m) { |
|
| 246 | + foreach (is_array($s['exception']) ? $s['exception'] : array($s['exception']) as $m) { |
|
| 247 | 247 | if (isset($boucle->modificateur[$m]) OR isset($boucle->modificateur['criteres'][$m])) { |
| 248 | 248 | $filtrer = false; |
| 249 | 249 | break; |
@@ -252,19 +252,19 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | if ($filtrer) { |
| 255 | - if (is_array($s['champ'])){ |
|
| 256 | - $statut = preg_replace(',\W,','',array_pop($s['champ'])); // securite |
|
| 255 | + if (is_array($s['champ'])) { |
|
| 256 | + $statut = preg_replace(',\W,', '', array_pop($s['champ'])); // securite |
|
| 257 | 257 | $jointures = array(); |
| 258 | 258 | // indiquer la description de chaque table dans le tableau de jointures, |
| 259 | 259 | // ce qui permet d'eviter certains GROUP BY inutiles. |
| 260 | 260 | $trouver_table = charger_fonction('trouver_table', 'base'); |
| 261 | - foreach($s['champ'] as $j) { |
|
| 261 | + foreach ($s['champ'] as $j) { |
|
| 262 | 262 | $id = reset($j); |
| 263 | 263 | $def = $trouver_table($id); |
| 264 | - $jointures[] = array('',array($id,$def),end($j)); |
|
| 264 | + $jointures[] = array('', array($id, $def), end($j)); |
|
| 265 | 265 | } |
| 266 | 266 | $jointures[0][0] = $id_table; |
| 267 | - if (!array_search($id, $boucle->from)){ |
|
| 267 | + if (!array_search($id, $boucle->from)) { |
|
| 268 | 268 | include_spip('public/jointures'); |
| 269 | 269 | fabrique_jointures($boucle, $jointures, true, $boucle->show, $id_table, '', $echapper); |
| 270 | 270 | } |
@@ -273,20 +273,20 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | else { |
| 275 | 275 | $id = $id_table; |
| 276 | - $statut = preg_replace(',\W,','',$s['champ']); // securite |
|
| 276 | + $statut = preg_replace(',\W,', '', $s['champ']); // securite |
|
| 277 | 277 | } |
| 278 | - $mstatut = $id .'.'.$statut; |
|
| 278 | + $mstatut = $id.'.'.$statut; |
|
| 279 | 279 | |
| 280 | - $arg_ignore_previsu=($ignore_previsu?",true":''); |
|
| 280 | + $arg_ignore_previsu = ($ignore_previsu ? ",true" : ''); |
|
| 281 | 281 | include_spip('public/quete'); |
| 282 | 282 | if (isset($s['post_date']) AND $s['post_date'] |
| 283 | - AND $GLOBALS['meta']["post_dates"] == 'non'){ |
|
| 284 | - $date = $id.'.'.preg_replace(',\W,','',$s['post_date']); // securite |
|
| 283 | + AND $GLOBALS['meta']["post_dates"] == 'non') { |
|
| 284 | + $date = $id.'.'.preg_replace(',\W,', '', $s['post_date']); // securite |
|
| 285 | 285 | array_unshift($boucle->where, |
| 286 | 286 | $echapper ? |
| 287 | 287 | "\nquete_condition_postdates('$date',"._q($boucle->sql_serveur)."$arg_ignore_previsu)" |
| 288 | 288 | : |
| 289 | - quete_condition_postdates($date,$boucle->sql_serveur,$ignore_previsu) |
|
| 289 | + quete_condition_postdates($date, $boucle->sql_serveur, $ignore_previsu) |
|
| 290 | 290 | ); |
| 291 | 291 | } |
| 292 | 292 | array_unshift($boucle->where, |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | ._q($s['publie'])."," |
| 297 | 297 | ._q($boucle->sql_serveur)."$arg_ignore_previsu)" |
| 298 | 298 | : |
| 299 | - quete_condition_statut($mstatut,$s['previsu'],$s['publie'],$boucle->sql_serveur,$ignore_previsu) |
|
| 299 | + quete_condition_statut($mstatut, $s['previsu'], $s['publie'], $boucle->sql_serveur, $ignore_previsu) |
|
| 300 | 300 | ); |
| 301 | 301 | } |
| 302 | 302 | } |
@@ -325,10 +325,10 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | // en mode debug memoriser les premiers passages dans la boucle, |
| 327 | 327 | // mais pas tous, sinon ca pete. |
| 328 | - if (_request('var_mode_affiche') != 'resultat') |
|
| 328 | + if (_request('var_mode_affiche') != 'resultat') |
|
| 329 | 329 | $trace = ''; |
| 330 | 330 | else { |
| 331 | - $trace = $boucles[$id_boucle]->descr['nom'] . $id_boucle; |
|
| 331 | + $trace = $boucles[$id_boucle]->descr['nom'].$id_boucle; |
|
| 332 | 332 | $trace = "if (count(@\$GLOBALS['debug_objets']['resultat']['$trace'])<3) |
| 333 | 333 | \$GLOBALS['debug_objets']['resultat']['$trace'][] = \$t0;"; |
| 334 | 334 | } |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | return |
| 362 | 362 | // Numrows[$nom] peut ne pas être encore defini |
| 363 | 363 | "\n\t\$save_numrows = (isset(\$Numrows['$nom']) ? \$Numrows['$nom'] : array());" |
| 364 | - . "\n\t\$t0 = " . $boucles[$id_boucle]->return . ";" |
|
| 364 | + . "\n\t\$t0 = ".$boucles[$id_boucle]->return.";" |
|
| 365 | 365 | . "\n\t\$Numrows['$nom'] = (\$save_numrows);" |
| 366 | 366 | . $trace |
| 367 | 367 | . "\n\treturn \$t0;"; |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | $return = $boucle->return; |
| 422 | 422 | $type_boucle = $boucle->type_requete; |
| 423 | 423 | $primary = $boucle->primary; |
| 424 | - $constant = preg_match(CODE_MONOTONE, str_replace("\\'",'', $return)); |
|
| 425 | - $flag_cpt = $boucle->mode_partie ||$boucle->cptrows; |
|
| 424 | + $constant = preg_match(CODE_MONOTONE, str_replace("\\'", '', $return)); |
|
| 425 | + $flag_cpt = $boucle->mode_partie || $boucle->cptrows; |
|
| 426 | 426 | $corps = ''; |
| 427 | 427 | |
| 428 | 428 | // faudrait expanser le foreach a la compil, car y en a souvent qu'un |
| 429 | 429 | // et puis faire un [] plutot qu'un "','." |
| 430 | 430 | if ($boucle->doublons) |
| 431 | - $corps .= "\n\t\t\tforeach(" . $boucle->doublons . ' as $k) $doublons[$k] .= "," . ' . |
|
| 431 | + $corps .= "\n\t\t\tforeach(".$boucle->doublons.' as $k) $doublons[$k] .= "," . '. |
|
| 432 | 432 | index_pile($id_boucle, $primary, $boucles) |
| 433 | 433 | . "; // doublons\n"; |
| 434 | 434 | |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | // (sauf si forcer_lang==true ou si le titre contient <multi>). |
| 438 | 438 | // - a moins d'une demande explicite via {!lang_select} |
| 439 | 439 | if (!$constant && $boucle->lang_select != 'non' && |
| 440 | - (($boucle->lang_select == 'oui') || |
|
| 440 | + (($boucle->lang_select == 'oui') || |
|
| 441 | 441 | in_array($type_boucle, array( |
| 442 | 442 | 'articles', 'rubriques', 'hierarchie', 'breves' |
| 443 | 443 | ))) |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | if (strpos($return, '?php') === false |
| 466 | 466 | AND preg_match_all("/\W(_T[(]'[^']*'[)])/", $return, $r)) { |
| 467 | 467 | $i = 1; |
| 468 | - foreach($r[1] as $t) { |
|
| 468 | + foreach ($r[1] as $t) { |
|
| 469 | 469 | $init_lang .= "\n\t\$l$i = $t;"; |
| 470 | 470 | $return = str_replace($t, "\$l$i", $return); |
| 471 | 471 | $i++; |
@@ -475,19 +475,15 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | // gestion optimale des separateurs et des boucles constantes |
| 477 | 477 | if (count($boucle->separateur)) |
| 478 | - $code_sep = ("'" . str_replace("'","\'",join('',$boucle->separateur)) . "'"); |
|
| 478 | + $code_sep = ("'".str_replace("'", "\'", join('', $boucle->separateur))."'"); |
|
| 479 | 479 | |
| 480 | 480 | $corps .= |
| 481 | 481 | ((!$boucle->separateur) ? |
| 482 | - (($constant && !$corps && !$flag_cpt) ? $return : |
|
| 483 | - (($return==="''") ? '' : |
|
| 484 | - ("\n\t\t" . '$t0 .= ' . $return . ";"))) : |
|
| 485 | - ("\n\t\t\$t1 " . |
|
| 482 | + (($constant && !$corps && !$flag_cpt) ? $return : (($return === "''") ? '' : ("\n\t\t".'$t0 .= '.$return.";"))) : ("\n\t\t\$t1 ". |
|
| 486 | 483 | ((strpos($return, '$t1.') === 0) ? |
| 487 | - (".=" . substr($return,4)) : |
|
| 488 | - ('= ' . $return)) . |
|
| 489 | - ";\n\t\t" . |
|
| 490 | - '$t0 .= ((strlen($t1) && strlen($t0)) ? ' . $code_sep . " : '') . \$t1;")); |
|
| 484 | + (".=".substr($return, 4)) : ('= '.$return)). |
|
| 485 | + ";\n\t\t". |
|
| 486 | + '$t0 .= ((strlen($t1) && strlen($t0)) ? '.$code_sep." : '') . \$t1;")); |
|
| 491 | 487 | |
| 492 | 488 | // Calculer les invalideurs si c'est une boucle non constante et si on |
| 493 | 489 | // souhaite invalider ces elements |
@@ -510,7 +506,7 @@ discard block |
||
| 510 | 506 | |
| 511 | 507 | // si le corps est une constante, ne pas appeler le serveur N fois! |
| 512 | 508 | |
| 513 | - if (preg_match(CODE_MONOTONE,str_replace("\\'",'',$corps), $r)) { |
|
| 509 | + if (preg_match(CODE_MONOTONE, str_replace("\\'", '', $corps), $r)) { |
|
| 514 | 510 | if (!isset($r[2]) OR (!$r[2])) { |
| 515 | 511 | if (!$boucle->numrows) |
| 516 | 512 | return "\n\t\$t0 = '';"; |
@@ -527,7 +523,7 @@ discard block |
||
| 527 | 523 | if (!$boucle->numrows OR $boucle->limit OR $boucle->mode_partie OR $boucle->group) |
| 528 | 524 | $count = '1'; |
| 529 | 525 | else $count = 'count(*)'; |
| 530 | - $boucles[$id_boucle]->select[]= $count; |
|
| 526 | + $boucles[$id_boucle]->select[] = $count; |
|
| 531 | 527 | } |
| 532 | 528 | |
| 533 | 529 | if ($flag_cpt) |
@@ -560,7 +556,7 @@ discard block |
||
| 560 | 556 | $corps, |
| 561 | 557 | $fin_lang, |
| 562 | 558 | $trace, |
| 563 | - 'BOUCLE'.$id_boucle .' @ '.($boucle->descr['sourcefile']) |
|
| 559 | + 'BOUCLE'.$id_boucle.' @ '.($boucle->descr['sourcefile']) |
|
| 564 | 560 | ); |
| 565 | 561 | |
| 566 | 562 | # var_dump($a);exit; |
@@ -582,14 +578,14 @@ discard block |
||
| 582 | 578 | function calculer_requete_sql($boucle) |
| 583 | 579 | { |
| 584 | 580 | $init = array(); |
| 585 | - $init[] = calculer_dec('table', "'" . $boucle->id_table ."'"); |
|
| 586 | - $init[] = calculer_dec('id', "'" . $boucle->id_boucle ."'"); |
|
| 581 | + $init[] = calculer_dec('table', "'".$boucle->id_table."'"); |
|
| 582 | + $init[] = calculer_dec('id', "'".$boucle->id_boucle."'"); |
|
| 587 | 583 | # En absence de champ c'est un decompte : |
| 588 | - $init[] = calculer_dec('from', calculer_from($boucle)); |
|
| 584 | + $init[] = calculer_dec('from', calculer_from($boucle)); |
|
| 589 | 585 | $init[] = calculer_dec('type', calculer_from_type($boucle)); |
| 590 | - $init[] = calculer_dec('groupby', 'array(' . (($g=join("\",\n\t\t\"",$boucle->group))?'"'.$g.'"':'') . ")"); |
|
| 591 | - $init[] = calculer_dec('select', 'array("' . join("\",\n\t\t\"", $boucle->select). "\")"); |
|
| 592 | - $init[] = calculer_dec('orderby', 'array(' . calculer_order($boucle) . ")"); |
|
| 586 | + $init[] = calculer_dec('groupby', 'array('.(($g = join("\",\n\t\t\"", $boucle->group)) ? '"'.$g.'"' : '').")"); |
|
| 587 | + $init[] = calculer_dec('select', 'array("'.join("\",\n\t\t\"", $boucle->select)."\")"); |
|
| 588 | + $init[] = calculer_dec('orderby', 'array('.calculer_order($boucle).")"); |
|
| 593 | 589 | $init[] = calculer_dec('where', calculer_dump_array($boucle->where)); |
| 594 | 590 | $init[] = calculer_dec('join', calculer_dump_join($boucle->join)); |
| 595 | 591 | $init[] = calculer_dec('limit', |
@@ -599,7 +595,7 @@ discard block |
||
| 599 | 595 | $boucle->limit)); |
| 600 | 596 | $init[] = calculer_dec('having', calculer_dump_array($boucle->having)); |
| 601 | 597 | $s = $d = ""; |
| 602 | - foreach ($init as $i){ |
|
| 598 | + foreach ($init as $i) { |
|
| 603 | 599 | if (reset($i)) |
| 604 | 600 | $s .= "\n\t\t".end($i); |
| 605 | 601 | else |
@@ -683,22 +679,22 @@ discard block |
||
| 683 | 679 | ) |
| 684 | 680 | $static = ""; |
| 685 | 681 | |
| 686 | - return array($static,'$command[\''.$nom.'\'] = ' . $val . ';'); |
|
| 682 | + return array($static, '$command[\''.$nom.'\'] = '.$val.';'); |
|
| 687 | 683 | } |
| 688 | 684 | |
| 689 | 685 | // http://doc.spip.org/@calculer_dump_array |
| 690 | 686 | function calculer_dump_array($a) |
| 691 | 687 | { |
| 692 | - if (!is_array($a)) return $a ; |
|
| 688 | + if (!is_array($a)) return $a; |
|
| 693 | 689 | $res = ""; |
| 694 | 690 | if ($a AND $a[0] == "'?'") |
| 695 | - return ("(" . calculer_dump_array($a[1]) . |
|
| 696 | - " ? " . calculer_dump_array($a[2]) . |
|
| 697 | - " : " . calculer_dump_array($a[3]) . |
|
| 691 | + return ("(".calculer_dump_array($a[1]). |
|
| 692 | + " ? ".calculer_dump_array($a[2]). |
|
| 693 | + " : ".calculer_dump_array($a[3]). |
|
| 698 | 694 | ")"); |
| 699 | 695 | else { |
| 700 | - foreach($a as $v) $res .= ", " . calculer_dump_array($v); |
|
| 701 | - return "\n\t\t\tarray(" . substr($res,2) . ')'; |
|
| 696 | + foreach ($a as $v) $res .= ", ".calculer_dump_array($v); |
|
| 697 | + return "\n\t\t\tarray(".substr($res, 2).')'; |
|
| 702 | 698 | } |
| 703 | 699 | } |
| 704 | 700 | |
@@ -706,25 +702,25 @@ discard block |
||
| 706 | 702 | function calculer_dump_join($a) |
| 707 | 703 | { |
| 708 | 704 | $res = ""; |
| 709 | - foreach($a as $k => $v) |
|
| 710 | - $res .= ", '$k' => array(".implode(',',$v).")"; |
|
| 711 | - return 'array(' . substr($res,2) . ')'; |
|
| 705 | + foreach ($a as $k => $v) |
|
| 706 | + $res .= ", '$k' => array(".implode(',', $v).")"; |
|
| 707 | + return 'array('.substr($res, 2).')'; |
|
| 712 | 708 | } |
| 713 | 709 | |
| 714 | 710 | // http://doc.spip.org/@calculer_from |
| 715 | 711 | function calculer_from(&$boucle) |
| 716 | 712 | { |
| 717 | 713 | $res = ""; |
| 718 | - foreach($boucle->from as $k => $v) $res .= ",'$k' => '$v'"; |
|
| 719 | - return 'array(' . substr($res,1) . ')'; |
|
| 714 | + foreach ($boucle->from as $k => $v) $res .= ",'$k' => '$v'"; |
|
| 715 | + return 'array('.substr($res, 1).')'; |
|
| 720 | 716 | } |
| 721 | 717 | |
| 722 | 718 | // http://doc.spip.org/@calculer_from_type |
| 723 | 719 | function calculer_from_type(&$boucle) |
| 724 | 720 | { |
| 725 | 721 | $res = ""; |
| 726 | - foreach($boucle->from_type as $k => $v) $res .= ",'$k' => '$v'"; |
|
| 727 | - return 'array(' . substr($res,1) . ')'; |
|
| 722 | + foreach ($boucle->from_type as $k => $v) $res .= ",'$k' => '$v'"; |
|
| 723 | + return 'array('.substr($res, 1).')'; |
|
| 728 | 724 | } |
| 729 | 725 | |
| 730 | 726 | // http://doc.spip.org/@calculer_order |
@@ -749,7 +745,7 @@ discard block |
||
| 749 | 745 | // (qui sera argument d'un Return ou la partie droite d'une affectation). |
| 750 | 746 | |
| 751 | 747 | // http://doc.spip.org/@calculer_liste |
| 752 | -function calculer_liste($tableau, $descr, &$boucles, $id_boucle='') { |
|
| 748 | +function calculer_liste($tableau, $descr, &$boucles, $id_boucle = '') { |
|
| 753 | 749 | if (!$tableau) return "''"; |
| 754 | 750 | if (!isset($descr['niv'])) $descr['niv'] = 0; |
| 755 | 751 | $codes = compile_cas($tableau, $descr, $boucles, $id_boucle); |
@@ -758,28 +754,28 @@ discard block |
||
| 758 | 754 | if (!$n) return "''"; |
| 759 | 755 | $tab = str_repeat("\t", $descr['niv']); |
| 760 | 756 | if (_request('var_mode_affiche') != 'validation') { |
| 761 | - if ($n==1) |
|
| 757 | + if ($n == 1) |
|
| 762 | 758 | return $codes[0]; |
| 763 | 759 | else { |
| 764 | 760 | $res = ''; |
| 765 | - foreach($codes as $code) { |
|
| 761 | + foreach ($codes as $code) { |
|
| 766 | 762 | if (!preg_match("/^'[^']*'$/", $code) |
| 767 | - OR substr($res,-1,1)!=="'") |
|
| 768 | - $res .= " .\n$tab$code"; |
|
| 763 | + OR substr($res, -1, 1) !== "'") |
|
| 764 | + $res .= " .\n$tab$code"; |
|
| 769 | 765 | else { |
| 770 | - $res = substr($res,0,-1) . substr($code,1); |
|
| 766 | + $res = substr($res, 0, -1).substr($code, 1); |
|
| 771 | 767 | } |
| 772 | 768 | } |
| 773 | - return '(' . substr($res,2+$descr['niv']) . ')'; |
|
| 769 | + return '('.substr($res, 2 + $descr['niv']).')'; |
|
| 774 | 770 | } |
| 775 | 771 | } else { |
| 776 | - $nom = $descr['nom'] . $id_boucle . ($descr['niv']?$descr['niv']:''); |
|
| 777 | - return "join('', array_map('array_shift', \$GLOBALS['debug_objets']['sequence']['$nom'] = array(" . join(" ,\n$tab", $codes) . ")))"; |
|
| 772 | + $nom = $descr['nom'].$id_boucle.($descr['niv'] ? $descr['niv'] : ''); |
|
| 773 | + return "join('', array_map('array_shift', \$GLOBALS['debug_objets']['sequence']['$nom'] = array(".join(" ,\n$tab", $codes).")))"; |
|
| 778 | 774 | } |
| 779 | 775 | } |
| 780 | 776 | |
| 781 | -define('_REGEXP_COND_VIDE_NONVIDE',"/^[(](.*)[?]\s*''\s*:\s*('[^']+')\s*[)]$/"); |
|
| 782 | -define('_REGEXP_COND_NONVIDE_VIDE',"/^[(](.*)[?]\s*('[^']+')\s*:\s*''\s*[)]$/"); |
|
| 777 | +define('_REGEXP_COND_VIDE_NONVIDE', "/^[(](.*)[?]\s*''\s*:\s*('[^']+')\s*[)]$/"); |
|
| 778 | +define('_REGEXP_COND_NONVIDE_VIDE', "/^[(](.*)[?]\s*('[^']+')\s*:\s*''\s*[)]$/"); |
|
| 783 | 779 | define('_REGEXP_CONCAT_NON_VIDE', "/^(.*)[.]\s*'[^']+'\s*$/"); |
| 784 | 780 | |
| 785 | 781 | // http://doc.spip.org/@compile_cas |
@@ -797,31 +793,31 @@ discard block |
||
| 797 | 793 | // par un caractere distinguant le cas, pour exploitation par debug. |
| 798 | 794 | foreach ($tableau as $p) { |
| 799 | 795 | |
| 800 | - switch($p->type) { |
|
| 796 | + switch ($p->type) { |
|
| 801 | 797 | // texte seul |
| 802 | 798 | case 'texte': |
| 803 | 799 | $code = sandbox_composer_texte($p->texte, $p); |
| 804 | - $commentaire= strlen($p->texte) . " signes"; |
|
| 805 | - $avant=''; |
|
| 806 | - $apres=''; |
|
| 800 | + $commentaire = strlen($p->texte)." signes"; |
|
| 801 | + $avant = ''; |
|
| 802 | + $apres = ''; |
|
| 807 | 803 | $altern = "''"; |
| 808 | 804 | break; |
| 809 | 805 | |
| 810 | 806 | case 'polyglotte': |
| 811 | 807 | $code = ""; |
| 812 | - foreach($p->traductions as $k => $v) { |
|
| 813 | - $code .= ",'" . |
|
| 814 | - str_replace(array("\\","'"),array("\\\\","\\'"), $k) . |
|
| 815 | - "' => '" . |
|
| 816 | - str_replace(array("\\","'"),array("\\\\","\\'"), $v) . |
|
| 808 | + foreach ($p->traductions as $k => $v) { |
|
| 809 | + $code .= ",'". |
|
| 810 | + str_replace(array("\\", "'"), array("\\\\", "\\'"), $k). |
|
| 811 | + "' => '". |
|
| 812 | + str_replace(array("\\", "'"), array("\\\\", "\\'"), $v). |
|
| 817 | 813 | "'"; |
| 818 | 814 | } |
| 819 | - $code = "choisir_traduction(array(" . |
|
| 820 | - substr($code,1) . |
|
| 815 | + $code = "choisir_traduction(array(". |
|
| 816 | + substr($code, 1). |
|
| 821 | 817 | "))"; |
| 822 | - $commentaire= '&'; |
|
| 823 | - $avant=''; |
|
| 824 | - $apres=''; |
|
| 818 | + $commentaire = '&'; |
|
| 819 | + $avant = ''; |
|
| 820 | + $apres = ''; |
|
| 825 | 821 | $altern = "''"; |
| 826 | 822 | break; |
| 827 | 823 | |
@@ -833,9 +829,9 @@ discard block |
||
| 833 | 829 | $err_e_c = true; |
| 834 | 830 | $code = "''"; |
| 835 | 831 | } else { |
| 836 | - $commentaire = '<INCLURE ' . addslashes(str_replace("\n", ' ', $code)) . '>'; |
|
| 837 | - $avant=''; |
|
| 838 | - $apres=''; |
|
| 832 | + $commentaire = '<INCLURE '.addslashes(str_replace("\n", ' ', $code)).'>'; |
|
| 833 | + $avant = ''; |
|
| 834 | + $apres = ''; |
|
| 839 | 835 | $altern = "''"; |
| 840 | 836 | } |
| 841 | 837 | break; |
@@ -857,14 +853,14 @@ discard block |
||
| 857 | 853 | $err_e_c = true; |
| 858 | 854 | $code = "''"; |
| 859 | 855 | } else { |
| 860 | - $code = 'BOUCLE' . |
|
| 861 | - str_replace("-","_", $nom) . $descr['nom'] . |
|
| 856 | + $code = 'BOUCLE'. |
|
| 857 | + str_replace("-", "_", $nom).$descr['nom']. |
|
| 862 | 858 | '($Cache, $Pile, $doublons, $Numrows, $SP)'; |
| 863 | - $commentaire= "?$nom"; |
|
| 859 | + $commentaire = "?$nom"; |
|
| 864 | 860 | if (!$boucles[$nom]->milieu |
| 865 | 861 | AND $boucles[$nom]->type_requete <> TYPE_RECURSIF) { |
| 866 | 862 | if ($altern != "''") $code .= "\n. $altern"; |
| 867 | - if ($avant<>"''" OR $apres<>"''") |
|
| 863 | + if ($avant <> "''" OR $apres <> "''") |
|
| 868 | 864 | spip_log("boucle $nom toujours vide, code superflu dans $id"); |
| 869 | 865 | $avant = $apres = $altern = "''"; |
| 870 | 866 | } else if ($altern != "''") $altern = "($altern)"; |
@@ -877,23 +873,21 @@ discard block |
||
| 877 | 873 | foreach ($p->arg as $k => $v) { |
| 878 | 874 | $_v = calculer_liste($v, $descr, $boucles, $id_boucle); |
| 879 | 875 | if ($k) { |
| 880 | - $l[] = _q($k) . ' => ' . $_v; |
|
| 876 | + $l[] = _q($k).' => '.$_v; |
|
| 881 | 877 | } else { |
| 882 | 878 | $code = $_v; |
| 883 | 879 | } |
| 884 | 880 | } |
| 885 | 881 | // Si le module n'est pas fourni, l'expliciter sauf si calculé |
| 886 | 882 | if ($p->module) { |
| 887 | - $m = $p->module .':'.$p->nom_champ; |
|
| 883 | + $m = $p->module.':'.$p->nom_champ; |
|
| 888 | 884 | } elseif ($p->nom_champ) { |
| 889 | - $m = MODULES_IDIOMES .':'.$p->nom_champ; |
|
| 885 | + $m = MODULES_IDIOMES.':'.$p->nom_champ; |
|
| 890 | 886 | } else { |
| 891 | 887 | $m = ''; |
| 892 | 888 | } |
| 893 | - $code = (!$code ? "'$m'" : |
|
| 894 | - ($m ? "'$m' . $code" : |
|
| 895 | - ("(strpos(\$x=$code, ':') ? \$x : ('" . MODULES_IDIOMES . ":' . \$x))"))) |
|
| 896 | - . (!$l ? '' : (", array(" . implode(",\n", $l) . ")")); |
|
| 889 | + $code = (!$code ? "'$m'" : ($m ? "'$m' . $code" : ("(strpos(\$x=$code, ':') ? \$x : ('".MODULES_IDIOMES.":' . \$x))"))) |
|
| 890 | + . (!$l ? '' : (", array(".implode(",\n", $l).")")); |
|
| 897 | 891 | $code = "_T($code)"; |
| 898 | 892 | if ($p->param) { |
| 899 | 893 | $p->id_boucle = $id_boucle; |
@@ -901,8 +895,8 @@ discard block |
||
| 901 | 895 | $code = compose_filtres($p, $code); |
| 902 | 896 | } |
| 903 | 897 | $commentaire = ":"; |
| 904 | - $avant=''; |
|
| 905 | - $apres=''; |
|
| 898 | + $avant = ''; |
|
| 899 | + $apres = ''; |
|
| 906 | 900 | $altern = "''"; |
| 907 | 901 | break; |
| 908 | 902 | |
@@ -916,7 +910,7 @@ discard block |
||
| 916 | 910 | $p->type_requete = $type; |
| 917 | 911 | |
| 918 | 912 | $code = calculer_champ($p); |
| 919 | - $commentaire = '#' . $p->nom_champ . $p->etoile; |
|
| 913 | + $commentaire = '#'.$p->nom_champ.$p->etoile; |
|
| 920 | 914 | $avant = calculer_liste($p->avant, |
| 921 | 915 | $descr, $boucles, $id_boucle); |
| 922 | 916 | $apres = calculer_liste($p->apres, |
@@ -926,7 +920,7 @@ discard block |
||
| 926 | 920 | // forcer la conversion en une chaine par strval |
| 927 | 921 | // si ca peut etre autre chose qu'une chaine |
| 928 | 922 | if (($avant != "''" OR $apres != "''") |
| 929 | - AND $code[0]!= "'" |
|
| 923 | + AND $code[0] != "'" |
|
| 930 | 924 | # AND (strpos($code,'interdire_scripts') !== 0) |
| 931 | 925 | AND !preg_match(_REGEXP_COND_VIDE_NONVIDE, $code) |
| 932 | 926 | AND !preg_match(_REGEXP_COND_NONVIDE_VIDE, $code) |
@@ -944,11 +938,10 @@ discard block |
||
| 944 | 938 | |
| 945 | 939 | if ($code != "''") { |
| 946 | 940 | $code = compile_retour($code, $avant, $apres, $altern, $tab, $descr['niv']); |
| 947 | - $codes[]= (($mode == 'validation') ? |
|
| 948 | - "array($code, '$commentaire', " . $p->ligne . ")" |
|
| 941 | + $codes[] = (($mode == 'validation') ? |
|
| 942 | + "array($code, '$commentaire', ".$p->ligne.")" |
|
| 949 | 943 | : (($mode == 'code') ? |
| 950 | - "\n// $commentaire\n$code" : |
|
| 951 | - $code)); |
|
| 944 | + "\n// $commentaire\n$code" : $code)); |
|
| 952 | 945 | } |
| 953 | 946 | } // foreach |
| 954 | 947 | |
@@ -964,24 +957,24 @@ discard block |
||
| 964 | 957 | { |
| 965 | 958 | if ($avant == "''") $avant = ''; |
| 966 | 959 | if ($apres == "''") $apres = ''; |
| 967 | - if (!$avant AND !$apres AND ($altern==="''")) return $code; |
|
| 960 | + if (!$avant AND !$apres AND ($altern === "''")) return $code; |
|
| 968 | 961 | |
| 969 | 962 | if (preg_match(_REGEXP_CONCAT_NON_VIDE, $code)) { |
| 970 | 963 | $t = $code; |
| 971 | 964 | $cond = ''; |
| 972 | - } elseif (preg_match(_REGEXP_COND_VIDE_NONVIDE,$code, $r)) { |
|
| 965 | + } elseif (preg_match(_REGEXP_COND_VIDE_NONVIDE, $code, $r)) { |
|
| 973 | 966 | $t = $r[2]; |
| 974 | - $cond = '!' . $r[1]; |
|
| 975 | - } else if (preg_match(_REGEXP_COND_NONVIDE_VIDE,$code, $r)) { |
|
| 967 | + $cond = '!'.$r[1]; |
|
| 968 | + } else if (preg_match(_REGEXP_COND_NONVIDE_VIDE, $code, $r)) { |
|
| 976 | 969 | $t = $r[2]; |
| 977 | 970 | $cond = $r[1]; |
| 978 | 971 | } else { |
| 979 | - $t = '$t' . $n; |
|
| 972 | + $t = '$t'.$n; |
|
| 980 | 973 | $cond = "($t = $code)!==''"; |
| 981 | 974 | } |
| 982 | 975 | |
| 983 | - $res = (!$avant ? "" : "$avant . ") . |
|
| 984 | - $t . |
|
| 976 | + $res = (!$avant ? "" : "$avant . "). |
|
| 977 | + $t. |
|
| 985 | 978 | (!$apres ? "" : " . $apres"); |
| 986 | 979 | |
| 987 | 980 | if ($res !== $t) $res = "($res)"; |
@@ -991,9 +984,9 @@ discard block |
||
| 991 | 984 | |
| 992 | 985 | function compile_inclure_doublons($lexemes) |
| 993 | 986 | { |
| 994 | - foreach($lexemes as $v) |
|
| 995 | - if($v->type === 'include' AND $v->param) |
|
| 996 | - foreach($v->param as $r) |
|
| 987 | + foreach ($lexemes as $v) |
|
| 988 | + if ($v->type === 'include' AND $v->param) |
|
| 989 | + foreach ($v->param as $r) |
|
| 997 | 990 | if (trim($r[0]) === 'doublons') |
| 998 | 991 | return true; |
| 999 | 992 | return false; |
@@ -1015,7 +1008,7 @@ discard block |
||
| 1015 | 1008 | // En cas d'erreur, elle retournera un tableau des 2 premiers elements seulement |
| 1016 | 1009 | |
| 1017 | 1010 | // http://doc.spip.org/@public_compiler_dist |
| 1018 | -function public_compiler_dist($squelette, $nom, $gram, $sourcefile, $connect=''){ |
|
| 1011 | +function public_compiler_dist($squelette, $nom, $gram, $sourcefile, $connect = '') { |
|
| 1019 | 1012 | // Pre-traitement : reperer le charset du squelette, et le convertir |
| 1020 | 1013 | // Bonus : supprime le BOM |
| 1021 | 1014 | include_spip('inc/charsets'); |
@@ -1023,7 +1016,7 @@ discard block |
||
| 1023 | 1016 | |
| 1024 | 1017 | // rendre inertes les echappements de #[](){}<> |
| 1025 | 1018 | $i = 0; |
| 1026 | - while(false !== strpos($squelette, $inerte = '-INERTE'.$i)) $i++; |
|
| 1019 | + while (false !== strpos($squelette, $inerte = '-INERTE'.$i)) $i++; |
|
| 1027 | 1020 | $squelette = preg_replace_callback(',\\\\([#[()\]{}<>]),', |
| 1028 | 1021 | create_function('$a', "return '$inerte-'.ord(\$a[1]).'-';"), $squelette, -1, $esc); |
| 1029 | 1022 | |
@@ -1035,14 +1028,14 @@ discard block |
||
| 1035 | 1028 | // Phraser le squelette, selon sa grammaire |
| 1036 | 1029 | |
| 1037 | 1030 | $boucles = array(); |
| 1038 | - $f = charger_fonction('phraser_' . $gram, 'public'); |
|
| 1031 | + $f = charger_fonction('phraser_'.$gram, 'public'); |
|
| 1039 | 1032 | |
| 1040 | 1033 | $squelette = $f($squelette, '', $boucles, $descr); |
| 1041 | 1034 | $boucles = compiler_squelette($squelette, $boucles, $nom, $descr, $sourcefile, $connect); |
| 1042 | 1035 | |
| 1043 | 1036 | // restituer les echappements |
| 1044 | 1037 | if ($esc) |
| 1045 | - foreach($boucles as $i=>$boucle) { |
|
| 1038 | + foreach ($boucles as $i=>$boucle) { |
|
| 1046 | 1039 | $boucles[$i]->return = preg_replace_callback(",$inerte-(\d+)-,", create_function('$a', 'return chr($a[1]);'), |
| 1047 | 1040 | $boucle->return); |
| 1048 | 1041 | $boucles[$i]->descr['squelette'] = preg_replace_callback(",$inerte-(\d+)-,", create_function('$a', 'return "\\\\".chr($a[1]);'), |
@@ -1052,17 +1045,17 @@ discard block |
||
| 1052 | 1045 | $debug = ($boucles AND defined('_VAR_MODE') AND _VAR_MODE == 'debug'); |
| 1053 | 1046 | if ($debug) { |
| 1054 | 1047 | include_spip('public/decompiler'); |
| 1055 | - foreach($boucles as $id => $boucle) { |
|
| 1048 | + foreach ($boucles as $id => $boucle) { |
|
| 1056 | 1049 | if ($id) |
| 1057 | - $decomp = "\n/* BOUCLE " . |
|
| 1058 | - $boucle->type_requete . |
|
| 1059 | - " " . |
|
| 1060 | - str_replace('*/', '* /', public_decompiler($boucle, $gram, 0, 'criteres')) . |
|
| 1050 | + $decomp = "\n/* BOUCLE ". |
|
| 1051 | + $boucle->type_requete. |
|
| 1052 | + " ". |
|
| 1053 | + str_replace('*/', '* /', public_decompiler($boucle, $gram, 0, 'criteres')). |
|
| 1061 | 1054 | " */\n"; |
| 1062 | - else $decomp = ("\n/*\n" . |
|
| 1055 | + else $decomp = ("\n/*\n". |
|
| 1063 | 1056 | str_replace('*/', '* /', public_decompiler($squelette, $gram)) |
| 1064 | 1057 | . "\n*/"); |
| 1065 | - $boucles[$id]->return = $decomp .$boucle->return; |
|
| 1058 | + $boucles[$id]->return = $decomp.$boucle->return; |
|
| 1066 | 1059 | $GLOBALS['debug_objets']['code'][$nom.$id] = $boucle->return; |
| 1067 | 1060 | } |
| 1068 | 1061 | } |
@@ -1073,7 +1066,7 @@ discard block |
||
| 1073 | 1066 | // Point d'entree pour arbre de syntaxe abstraite fourni en premier argument |
| 1074 | 1067 | // Autres specifications comme ci-dessus |
| 1075 | 1068 | |
| 1076 | -function compiler_squelette($squelette, $boucles, $nom, $descr, $sourcefile, $connect=''){ |
|
| 1069 | +function compiler_squelette($squelette, $boucles, $nom, $descr, $sourcefile, $connect = '') { |
|
| 1077 | 1070 | static $trouver_table; |
| 1078 | 1071 | spip_timer('calcul_skel'); |
| 1079 | 1072 | |
@@ -1096,7 +1089,7 @@ discard block |
||
| 1096 | 1089 | if (!$trouver_table) |
| 1097 | 1090 | $trouver_table = charger_fonction('trouver_table', 'base'); |
| 1098 | 1091 | |
| 1099 | - foreach($boucles as $id => $boucle) { |
|
| 1092 | + foreach ($boucles as $id => $boucle) { |
|
| 1100 | 1093 | if (!($type = $boucle->type_requete)) continue; |
| 1101 | 1094 | if (!$descr['documents'] AND ( |
| 1102 | 1095 | (($type == 'documents') AND $boucle->doublons) OR |
@@ -1127,14 +1120,14 @@ discard block |
||
| 1127 | 1120 | // c'est peut etre une table qui necessite son connecteur dedie fourni |
| 1128 | 1121 | // permet une ecriture allegee (GEO) -> (geo:GEO) |
| 1129 | 1122 | if (!$show |
| 1130 | - AND $show=$trouver_table($type, strtolower($type))) { |
|
| 1123 | + AND $show = $trouver_table($type, strtolower($type))) { |
|
| 1131 | 1124 | $boucles[$id]->sql_serveur = strtolower($type); |
| 1132 | 1125 | } |
| 1133 | 1126 | if ($show) { |
| 1134 | 1127 | $boucles[$id]->show = $show; |
| 1135 | 1128 | // recopie les infos les plus importantes |
| 1136 | 1129 | $boucles[$id]->primary = $show['key']["PRIMARY KEY"]; |
| 1137 | - $boucles[$id]->id_table = $x = preg_replace(",^spip_,","",$show['id_table']); |
|
| 1130 | + $boucles[$id]->id_table = $x = preg_replace(",^spip_,", "", $show['id_table']); |
|
| 1138 | 1131 | $boucles[$id]->from[$x] = $nom_table = $show['table']; |
| 1139 | 1132 | $boucles[$id]->iterateur = 'SQL'; |
| 1140 | 1133 | |
@@ -1143,20 +1136,19 @@ discard block |
||
| 1143 | 1136 | AND is_array($show['tables_jointures']) |
| 1144 | 1137 | AND count($x = $show['tables_jointures'])) |
| 1145 | 1138 | $boucles[$id]->jointures = $x; |
| 1146 | - if ($boucles[$id]->jointures_explicites){ |
|
| 1147 | - $jointures = preg_split("/\s+/",$boucles[$id]->jointures_explicites); |
|
| 1148 | - while ($j=array_pop($jointures)) |
|
| 1149 | - array_unshift($boucles[$id]->jointures,$j); |
|
| 1139 | + if ($boucles[$id]->jointures_explicites) { |
|
| 1140 | + $jointures = preg_split("/\s+/", $boucles[$id]->jointures_explicites); |
|
| 1141 | + while ($j = array_pop($jointures)) |
|
| 1142 | + array_unshift($boucles[$id]->jointures, $j); |
|
| 1150 | 1143 | } |
| 1151 | 1144 | } else { |
| 1152 | 1145 | // Pas une erreur si la table est optionnelle |
| 1153 | 1146 | if ($boucles[$id]->table_optionnelle) |
| 1154 | 1147 | $boucles[$id]->type_requete = ''; |
| 1155 | - else { |
|
| 1148 | + else { |
|
| 1156 | 1149 | $boucles[$id]->type_requete = false; |
| 1157 | 1150 | $boucle = $boucles[$id]; |
| 1158 | - $x = (!$boucle->sql_serveur ? '' : |
|
| 1159 | - ($boucle->sql_serveur . ":")) . |
|
| 1151 | + $x = (!$boucle->sql_serveur ? '' : ($boucle->sql_serveur.":")). |
|
| 1160 | 1152 | $type; |
| 1161 | 1153 | $msg = array('zbug_table_inconnue', |
| 1162 | 1154 | array('table' => $x)); |
@@ -1169,7 +1161,7 @@ discard block |
||
| 1169 | 1161 | |
| 1170 | 1162 | // Commencer par reperer les boucles appelees explicitement |
| 1171 | 1163 | // car elles indexent les arguments de maniere derogatoire |
| 1172 | - foreach($boucles as $id => $boucle) { |
|
| 1164 | + foreach ($boucles as $id => $boucle) { |
|
| 1173 | 1165 | if ($boucle->type_requete == TYPE_RECURSIF AND $boucle->param) { |
| 1174 | 1166 | $boucles[$id]->descr = &$descr; |
| 1175 | 1167 | $rec = &$boucles[$boucle->param[0]]; |
@@ -1189,7 +1181,7 @@ discard block |
||
| 1189 | 1181 | } |
| 1190 | 1182 | } |
| 1191 | 1183 | } |
| 1192 | - foreach($boucles as $id => $boucle) { |
|
| 1184 | + foreach ($boucles as $id => $boucle) { |
|
| 1193 | 1185 | $id = strval($id); // attention au type dans index_pile |
| 1194 | 1186 | $type = $boucle->type_requete; |
| 1195 | 1187 | if ($type AND $type != TYPE_RECURSIF) { |
@@ -1223,9 +1215,9 @@ discard block |
||
| 1223 | 1215 | // en particulier les requetes SQL et TOTAL_BOUCLE |
| 1224 | 1216 | // de'terminables seulement maintenant |
| 1225 | 1217 | |
| 1226 | - foreach($boucles as $id => $boucle) { |
|
| 1218 | + foreach ($boucles as $id => $boucle) { |
|
| 1227 | 1219 | $boucle = $boucles[$id] = pipeline('pre_boucle', $boucle); |
| 1228 | - if ($boucle->return === false) {$corps = false; continue;} |
|
| 1220 | + if ($boucle->return === false) {$corps = false; continue; } |
|
| 1229 | 1221 | // appeler la fonction de definition de la boucle |
| 1230 | 1222 | |
| 1231 | 1223 | if ($req = $boucle->type_requete) { |
@@ -1242,25 +1234,25 @@ discard block |
||
| 1242 | 1234 | // fonction de boucle avec table |
| 1243 | 1235 | AND (!function_exists($f = "boucle_".$table)) |
| 1244 | 1236 | AND (!function_exists($f = $f."_dist")) |
| 1245 | - ){ |
|
| 1237 | + ) { |
|
| 1246 | 1238 | // fonction de boucle standard |
| 1247 | 1239 | if (!function_exists($f = 'boucle_DEFAUT')) { |
| 1248 | 1240 | $f = 'boucle_DEFAUT_dist'; |
| 1249 | 1241 | } |
| 1250 | 1242 | } |
| 1251 | 1243 | |
| 1252 | - $req = "\n\n\tstatic \$command = array();\n\t" . |
|
| 1253 | - "static \$connect;\n\t" . |
|
| 1254 | - "\$command['connect'] = \$connect = " . |
|
| 1255 | - _q($boucle->sql_serveur) . |
|
| 1256 | - ";" . |
|
| 1244 | + $req = "\n\n\tstatic \$command = array();\n\t". |
|
| 1245 | + "static \$connect;\n\t". |
|
| 1246 | + "\$command['connect'] = \$connect = ". |
|
| 1247 | + _q($boucle->sql_serveur). |
|
| 1248 | + ";". |
|
| 1257 | 1249 | $f($id, $boucles); |
| 1258 | 1250 | } else $req = ("\n\treturn '';"); |
| 1259 | 1251 | |
| 1260 | 1252 | $boucles[$id]->return = |
| 1261 | - "\n\nfunction BOUCLE" . strtr($id,"-","_") . $nom . |
|
| 1262 | - '(&$Cache, &$Pile, &$doublons, &$Numrows, $SP) {' . |
|
| 1263 | - $req . |
|
| 1253 | + "\n\nfunction BOUCLE".strtr($id, "-", "_").$nom. |
|
| 1254 | + '(&$Cache, &$Pile, &$doublons, &$Numrows, $SP) {'. |
|
| 1255 | + $req. |
|
| 1264 | 1256 | "\n}\n"; |
| 1265 | 1257 | } |
| 1266 | 1258 | |
@@ -1268,7 +1260,7 @@ discard block |
||
| 1268 | 1260 | // retourner False, sinon inserer leur decompilation |
| 1269 | 1261 | if (is_bool($corps)) return false; |
| 1270 | 1262 | |
| 1271 | - $principal = "\nfunction " . $nom . '($Cache, $Pile, $doublons=array(), $Numrows=array(), $SP=0) { |
|
| 1263 | + $principal = "\nfunction ".$nom.'($Cache, $Pile, $doublons=array(), $Numrows=array(), $SP=0) { |
|
| 1272 | 1264 | ' |
| 1273 | 1265 | // reporter de maniere securisee les doublons inclus |
| 1274 | 1266 | .' |
@@ -1276,15 +1268,15 @@ discard block |
||
| 1276 | 1268 | $doublons = nettoyer_env_doublons($Pile[0]["doublons"]); |
| 1277 | 1269 | |
| 1278 | 1270 | $connect = ' . |
| 1279 | - _q($connect) . '; |
|
| 1271 | + _q($connect).'; |
|
| 1280 | 1272 | $page = ' . |
| 1281 | 1273 | // ATTENTION, le calcul de l'expression $corps affectera $Cache |
| 1282 | 1274 | // c'est pourquoi on l'affecte a la variable auxiliaire $page. |
| 1283 | 1275 | // avant de referencer $Cache |
| 1284 | - $corps . "; |
|
| 1276 | + $corps."; |
|
| 1285 | 1277 | |
| 1286 | - return analyse_resultat_skel(".var_export($nom,true) |
|
| 1287 | - .", \$Cache, \$page, ".var_export($sourcefile,true)."); |
|
| 1278 | + return analyse_resultat_skel(".var_export($nom, true) |
|
| 1279 | + .", \$Cache, \$page, ".var_export($sourcefile, true)."); |
|
| 1288 | 1280 | }"; |
| 1289 | 1281 | |
| 1290 | 1282 | $secondes = spip_timer('calcul_skel'); |
@@ -1298,10 +1290,10 @@ discard block |
||
| 1298 | 1290 | $code->return = ' |
| 1299 | 1291 | // |
| 1300 | 1292 | // Fonction principale du squelette ' . |
| 1301 | - $sourcefile . |
|
| 1302 | - ($connect ? " pour $connect" : '') . |
|
| 1303 | - (!CODE_COMMENTE ? '' : "\n// Temps de compilation total: $secondes") . |
|
| 1304 | - "\n//\n" . |
|
| 1293 | + $sourcefile. |
|
| 1294 | + ($connect ? " pour $connect" : ''). |
|
| 1295 | + (!CODE_COMMENTE ? '' : "\n// Temps de compilation total: $secondes"). |
|
| 1296 | + "\n//\n". |
|
| 1305 | 1297 | $principal; |
| 1306 | 1298 | |
| 1307 | 1299 | $boucles[''] = $code; |
@@ -1350,7 +1342,7 @@ discard block |
||
| 1350 | 1342 | **/ |
| 1351 | 1343 | function requeteur_data_dist(&$boucles, &$boucle, &$id) { |
| 1352 | 1344 | include_spip('iterateur/data'); |
| 1353 | - if ($h = charger_fonction($boucle->type_requete . '_to_array' , 'inc', true)) { |
|
| 1345 | + if ($h = charger_fonction($boucle->type_requete.'_to_array', 'inc', true)) { |
|
| 1354 | 1346 | $g = charger_fonction('data', 'iterateur'); |
| 1355 | 1347 | $boucles[$id] = $g($boucle); |
| 1356 | 1348 | // from[0] stocke le type de data (rss, yql, ...) |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | // donc il faut l'inclure "en globals" |
| 19 | 19 | if ($f = find_in_path('mes_fonctions.php')) { |
| 20 | 20 | global $dossier_squelettes; |
| 21 | - include_once(_ROOT_CWD . $f); |
|
| 21 | + include_once(_ROOT_CWD.$f); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (@is_readable(_CACHE_PLUGINS_FCT)) { |
| 25 | 25 | // chargement optimise precompile |
| 26 | 26 | include_once(_CACHE_PLUGINS_FCT); |
| 27 | 27 | } |
| 28 | -if (test_espace_prive ()) |
|
| 28 | +if (test_espace_prive()) |
|
| 29 | 29 | include_spip('inc/filtres_ecrire'); |
| 30 | 30 | |
| 31 | 31 | # Determine le squelette associe a une requete |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | # En cas d'erreur process_ins est absent et texte est un tableau de 2 chaines |
| 43 | 43 | |
| 44 | 44 | // http://doc.spip.org/@public_parametrer_dist |
| 45 | -function public_parametrer_dist($fond, $contexte='', $cache='', $connect='') { |
|
| 46 | - static $composer,$styliser,$notes=null; |
|
| 45 | +function public_parametrer_dist($fond, $contexte = '', $cache = '', $connect = '') { |
|
| 46 | + static $composer, $styliser, $notes = null; |
|
| 47 | 47 | $page = tester_redirection($fond, $contexte, $connect); |
| 48 | 48 | if ($page) return $page; |
| 49 | 49 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | if (!$styliser) |
| 61 | 61 | $styliser = charger_fonction('styliser', 'public'); |
| 62 | - list($skel,$mime_type, $gram, $sourcefile) = |
|
| 62 | + list($skel, $mime_type, $gram, $sourcefile) = |
|
| 63 | 63 | $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
| 64 | 64 | |
| 65 | 65 | if ($skel) { |
@@ -87,14 +87,14 @@ discard block |
||
| 87 | 87 | else { |
| 88 | 88 | // Preparer l'appel de la fonction principale du squelette |
| 89 | 89 | |
| 90 | - spip_timer($a = 'calcul page '.rand(0,1000)); |
|
| 90 | + spip_timer($a = 'calcul page '.rand(0, 1000)); |
|
| 91 | 91 | |
| 92 | 92 | // On cree un marqueur de notes unique lie a cette composition |
| 93 | 93 | // et on enregistre l'etat courant des globales de notes... |
| 94 | 94 | if (is_null($notes)) |
| 95 | 95 | $notes = charger_fonction('notes', 'inc', true); |
| 96 | 96 | if ($notes) |
| 97 | - $notes('','empiler'); |
|
| 97 | + $notes('', 'empiler'); |
|
| 98 | 98 | |
| 99 | 99 | // Rajouter d'office ces deux parametres |
| 100 | 100 | // (mais vaudrait mieux que le compilateur sache le simuler |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | // compte a chaque calcul d'un texte contenant un modele, mais seulement |
| 119 | 119 | // quand le modele serait calcule, et on aurait des resultats incoherents) |
| 120 | 120 | if ($notes) |
| 121 | - $notes('','depiler'); |
|
| 121 | + $notes('', 'depiler'); |
|
| 122 | 122 | |
| 123 | 123 | // reinjecter en dynamique la pile des notes |
| 124 | 124 | // si il y a des inclure dynamiques |
@@ -126,15 +126,15 @@ discard block |
||
| 126 | 126 | // la generalisation de cette injection permettrait de corriger le point juste au dessus |
| 127 | 127 | // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
| 128 | 128 | if ($notes) |
| 129 | - $page['notes'] = $notes('','sauver_etat'); |
|
| 129 | + $page['notes'] = $notes('', 'sauver_etat'); |
|
| 130 | 130 | |
| 131 | 131 | // spip_log: un joli contexte |
| 132 | 132 | $infos = array(); |
| 133 | 133 | foreach (array_filter($contexte) as $var => $val) { |
| 134 | 134 | if (is_array($val)) $val = serialize($val); |
| 135 | 135 | if (strlen("$val") > 30) |
| 136 | - $val = substr("$val", 0,27).'..'; |
|
| 137 | - if (strstr($val,' ')) |
|
| 136 | + $val = substr("$val", 0, 27).'..'; |
|
| 137 | + if (strstr($val, ' ')) |
|
| 138 | 138 | $val = "'$val'"; |
| 139 | 139 | $infos[] = $var.'='.$val; |
| 140 | 140 | } |
@@ -143,16 +143,16 @@ discard block |
||
| 143 | 143 | . join(', ', $infos) |
| 144 | 144 | .' ('.strlen($page['texte']).' octets)'); |
| 145 | 145 | |
| 146 | - if (defined('_CALCUL_PROFILER') AND intval($profile)>_CALCUL_PROFILER){ |
|
| 146 | + if (defined('_CALCUL_PROFILER') AND intval($profile) > _CALCUL_PROFILER) { |
|
| 147 | 147 | spip_log("calcul ($profile) [$skel] " |
| 148 | 148 | . join(', ', $infos) |
| 149 | - .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'],"profiler"._LOG_AVERTISSEMENT); |
|
| 149 | + .' ('.strlen($page['texte']).' octets) | '.$_SERVER['REQUEST_URI'], "profiler"._LOG_AVERTISSEMENT); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | if ($debug) { |
| 153 | 153 | // si c'est ce que demande le debusqueur, lui passer la main |
| 154 | 154 | $t = strlen($page['texte']) ? $page['texte'] : " "; |
| 155 | - $GLOBALS['debug_objets']['resultat'][$fonc . 'tout'] = $t; |
|
| 155 | + $GLOBALS['debug_objets']['resultat'][$fonc.'tout'] = $t; |
|
| 156 | 156 | $GLOBALS['debug_objets']['courant'] = $courant; |
| 157 | 157 | $GLOBALS['debug_objets']['profile'][$sourcefile] = $profile; |
| 158 | 158 | if ($GLOBALS['debug_objets']['sourcefile'] |
@@ -162,26 +162,26 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | // Si #CACHE{} n'etait pas la, le mettre a $delais |
| 165 | - if (!isset($page['entetes']['X-Spip-Cache'])){ |
|
| 165 | + if (!isset($page['entetes']['X-Spip-Cache'])) { |
|
| 166 | 166 | // Dans l'espace prive ou dans un modeles/ on pose un cache 0 par defaut |
| 167 | 167 | // si aucun #CACHE{} specifie |
| 168 | 168 | // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
| 169 | 169 | // entre public et prive |
| 170 | - if (test_espace_prive() OR strncmp($fond,'modeles/',8)==0) |
|
| 170 | + if (test_espace_prive() OR strncmp($fond, 'modeles/', 8) == 0) |
|
| 171 | 171 | $page['entetes']['X-Spip-Cache'] = 0; |
| 172 | 172 | else |
| 173 | - $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais'])?$GLOBALS['delais']:36000; |
|
| 173 | + $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais']) ? $GLOBALS['delais'] : 36000; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $page['contexte'] = $contexte; |
| 177 | 177 | |
| 178 | 178 | // faire remonter le fichier source |
| 179 | 179 | static $js_inclus = false; |
| 180 | - if (defined('_VAR_INCLURE') AND _VAR_INCLURE){ |
|
| 180 | + if (defined('_VAR_INCLURE') AND _VAR_INCLURE) { |
|
| 181 | 181 | $page['sourcefile'] = $sourcefile; |
| 182 | 182 | $page['texte'] = |
| 183 | 183 | "<div class='inclure_blocs'><h6>".$page['sourcefile']."</h6>".$page['texte']."</div>" |
| 184 | - . ($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>"); |
|
| 184 | + . ($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>"); |
|
| 185 | 185 | $js_inclus = true; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -219,13 +219,13 @@ discard block |
||
| 219 | 219 | if (strlen($m)) { |
| 220 | 220 | include_spip('inc/texte'); |
| 221 | 221 | // les navigateurs pataugent si l'URL est vide |
| 222 | - if ($url = virtuel_redirige($m, true)){ |
|
| 222 | + if ($url = virtuel_redirige($m, true)) { |
|
| 223 | 223 | // passer en url absolue car cette redirection pourra |
| 224 | 224 | // etre utilisee dans un contexte d'url qui change |
| 225 | 225 | // y compris url arbo |
| 226 | 226 | $status = 302; |
| 227 | 227 | if (defined('_STATUS_REDIRECTION_VIRTUEL')) |
| 228 | - $status=_STATUS_REDIRECTION_VIRTUEL; |
|
| 228 | + $status = _STATUS_REDIRECTION_VIRTUEL; |
|
| 229 | 229 | if (!preg_match(',^\w+:,', $url)) { |
| 230 | 230 | include_spip('inc/filtres_mini'); |
| 231 | 231 | $url = url_absolue($url); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | . "?php include_spip('inc/headers');redirige_par_entete('" |
| 236 | 236 | . texte_script($url) |
| 237 | 237 | . "','',$status);" |
| 238 | - . "?" . ">", |
|
| 238 | + . "?".">", |
|
| 239 | 239 | 'process_ins' => 'php', |
| 240 | 240 | 'status' => $status); |
| 241 | 241 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | if (!function_exists('strripos')) { |
| 23 | 23 | // http://doc.spip.org/@strripos |
| 24 | 24 | function strripos($botte, $aiguille) { |
| 25 | - if (preg_match('@^(.*)' . preg_quote($aiguille, '@') . '@is', |
|
| 25 | + if (preg_match('@^(.*)'.preg_quote($aiguille, '@').'@is', |
|
| 26 | 26 | $botte, $regs)) { |
| 27 | 27 | return strlen($regs[1]); |
| 28 | 28 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | if (!function_exists('stripos')) { |
| 33 | 33 | // http://doc.spip.org/@stripos |
| 34 | 34 | function stripos($botte, $aiguille) { |
| 35 | - if (preg_match('@^(.*)' . preg_quote($aiguille, '@') . '@isU', |
|
| 35 | + if (preg_match('@^(.*)'.preg_quote($aiguille, '@').'@isU', |
|
| 36 | 36 | $botte, $regs)) { |
| 37 | 37 | return strlen($regs[1]); |
| 38 | 38 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | . "' type='text/css' />\n"; |
| 50 | 50 | if ($f = find_in_path('spip_admin_perso.css')) |
| 51 | 51 | $css .= "<link rel='stylesheet' href='" |
| 52 | - . url_absolue(direction_css($f)) . "' type='text/css' />\n"; |
|
| 52 | + . url_absolue(direction_css($f))."' type='text/css' />\n"; |
|
| 53 | 53 | |
| 54 | 54 | ($pos = stripos($contenu, '</head>')) |
| 55 | 55 | || ($pos = stripos($contenu, '<body>')) |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @return null|string |
| 64 | 64 | * - string si $message à false. |
| 65 | 65 | **/ |
| 66 | -function public_debusquer_dist($message = '', $lieu = '', $opt = array()){ |
|
| 66 | +function public_debusquer_dist($message = '', $lieu = '', $opt = array()) { |
|
| 67 | 67 | global $visiteur_session; |
| 68 | 68 | global $debug_objets; |
| 69 | 69 | static $tableau_des_erreurs = array(); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Erreur ou appel final ? |
| 83 | - if ($message){ |
|
| 83 | + if ($message) { |
|
| 84 | 84 | $message = debusquer_compose_message($message); |
| 85 | 85 | $tableau_des_erreurs[] = array($message, $lieu); |
| 86 | 86 | set_request('var_mode', 'debug'); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | if (is_object($lieu) AND (!isset($lieu->code) OR !$lieu->code)) |
| 90 | 90 | $lieu->code = "''"; |
| 91 | 91 | // forcer l'appel au debusqueur en cas de boucles infernales |
| 92 | - $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS AND count($tableau_des_erreurs)>_DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 92 | + $urgence = (_DEBUG_MAX_SQUELETTE_ERREURS AND count($tableau_des_erreurs) > _DEBUG_MAX_SQUELETTE_ERREURS); |
|
| 93 | 93 | if (!$urgence) return; |
| 94 | 94 | } |
| 95 | 95 | if (empty($debug_objets['principal'])) |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | if (ob_get_length() |
| 109 | 109 | AND |
| 110 | 110 | !in_array('ob_gzhandler', ob_get_status()) |
| 111 | - ){ |
|
| 111 | + ) { |
|
| 112 | 112 | ob_end_clean(); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -126,15 +126,15 @@ discard block |
||
| 126 | 126 | if ($tableau_des_erreurs) http_status(503); |
| 127 | 127 | |
| 128 | 128 | http_no_cache(); |
| 129 | - if (isset($_GET['var_profile'])){ |
|
| 129 | + if (isset($_GET['var_profile'])) { |
|
| 130 | 130 | $titre = parametre_url($GLOBALS['REQUEST_URI'], 'var_profile', ''); |
| 131 | 131 | $titre = parametre_url($titre, 'var_mode', ''); |
| 132 | 132 | } |
| 133 | 133 | else { |
| 134 | 134 | if (!$fonc) $fonc = $debug_objets['principal']; |
| 135 | - $titre = !$mode ? $fonc : ($mode . ' ' . $debug_objets['sourcefile'][$fonc]); |
|
| 135 | + $titre = !$mode ? $fonc : ($mode.' '.$debug_objets['sourcefile'][$fonc]); |
|
| 136 | 136 | } |
| 137 | - if ($message===false){ |
|
| 137 | + if ($message === false) { |
|
| 138 | 138 | lang_select(); |
| 139 | 139 | return debusquer_entete($titre, $res); |
| 140 | 140 | } |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | exit; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | -function debusquer_compose_message($msg){ |
|
| 147 | - if (is_array($msg)){ |
|
| 146 | +function debusquer_compose_message($msg) { |
|
| 147 | + if (is_array($msg)) { |
|
| 148 | 148 | // si c'est un texte, c'est une traduction a faire, mais |
| 149 | 149 | // sqlite renvoit aussi des erreurs alpha num (mais avec 3 arguments) |
| 150 | - if (!is_numeric($msg[0]) AND count($msg)==2) { |
|
| 150 | + if (!is_numeric($msg[0]) AND count($msg) == 2) { |
|
| 151 | 151 | // message avec argument: instancier |
| 152 | 152 | $msg = _T($msg[0], $msg[1], 'spip-debug-arg'); |
| 153 | 153 | } else { |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | // FIXME: le fond n'est pas la si on n'est pas dans un squelette |
| 159 | 159 | // cela dit, ca serait bien d'indiquer tout de meme d'ou vient l'erreur |
| 160 | - $fond = isset($GLOBALS['fond']) ? $GLOBALS['fond'] : ""; |
|
| 160 | + $fond = isset($GLOBALS['fond']) ? $GLOBALS['fond'] : ""; |
|
| 161 | 161 | // une erreur critique sort $message en array |
| 162 | 162 | $debug = is_array($msg) ? $msg[1] : $msg; |
| 163 | - spip_log("Debug: " . $debug . " (" . $fond . ")"); |
|
| 163 | + spip_log("Debug: ".$debug." (".$fond.")"); |
|
| 164 | 164 | return $msg; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | -function debusquer_bandeau($erreurs){ |
|
| 167 | +function debusquer_bandeau($erreurs) { |
|
| 168 | 168 | |
| 169 | - if (!empty($erreurs)){ |
|
| 170 | - $n = array(count($erreurs) . ' ' . _T('zbug_erreur_squelette')); |
|
| 169 | + if (!empty($erreurs)) { |
|
| 170 | + $n = array(count($erreurs).' '._T('zbug_erreur_squelette')); |
|
| 171 | 171 | return debusquer_navigation($erreurs, $n); |
| 172 | 172 | } |
| 173 | 173 | elseif (!empty($GLOBALS['tableau_des_temps'])) { |
@@ -179,17 +179,17 @@ discard block |
||
| 179 | 179 | return ''; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | -function debusquer_contexte($env){ |
|
| 182 | +function debusquer_contexte($env) { |
|
| 183 | 183 | |
| 184 | 184 | if (is_array($env_tab = @unserialize($env))) $env = $env_tab; |
| 185 | 185 | |
| 186 | 186 | if (!$env) return ''; |
| 187 | 187 | $res = ""; |
| 188 | - foreach ($env as $nom => $valeur){ |
|
| 188 | + foreach ($env as $nom => $valeur) { |
|
| 189 | 189 | if (is_array($valeur)) |
| 190 | - $valeur = '(' . count($valeur) . ' items) [' . join(',', $valeur) . ']'; |
|
| 191 | - $res .= "\n<tr><td><strong>" . nl2br(entites_html($nom)) |
|
| 192 | - . "</strong></td><td>: " . nl2br(entites_html($valeur)) |
|
| 190 | + $valeur = '('.count($valeur).' items) ['.join(',', $valeur).']'; |
|
| 191 | + $res .= "\n<tr><td><strong>".nl2br(entites_html($nom)) |
|
| 192 | + . "</strong></td><td>: ".nl2br(entites_html($valeur)) |
|
| 193 | 193 | . "</td></tr>\n"; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -199,32 +199,32 @@ discard block |
||
| 199 | 199 | // Affichage du tableau des erreurs ou des temps de calcul |
| 200 | 200 | // Cliquer sur les numeros en premiere colonne permet de voir le code |
| 201 | 201 | |
| 202 | -function debusquer_navigation($tableau, $caption = array(), $id = 'debug-nav'){ |
|
| 202 | +function debusquer_navigation($tableau, $caption = array(), $id = 'debug-nav') { |
|
| 203 | 203 | |
| 204 | - if (_request('exec')=='valider_xml') return ''; |
|
| 204 | + if (_request('exec') == 'valider_xml') return ''; |
|
| 205 | 205 | $GLOBALS['bouton_admin_debug'] = true; |
| 206 | 206 | $res = ''; |
| 207 | 207 | $href = quote_amp(parametre_url($GLOBALS['REQUEST_URI'], 'var_mode', 'debug')); |
| 208 | - foreach ($tableau as $i => $err){ |
|
| 208 | + foreach ($tableau as $i => $err) { |
|
| 209 | 209 | $boucle = $ligne = $skel = ''; |
| 210 | 210 | list($msg, $lieu) = $err; |
| 211 | - if (is_object($lieu)){ |
|
| 211 | + if (is_object($lieu)) { |
|
| 212 | 212 | $ligne = $lieu->ligne; |
| 213 | 213 | $boucle = $lieu->id_boucle ? $lieu->id_boucle : ''; |
| 214 | - if (isset($lieu->descr['nom'])){ |
|
| 214 | + if (isset($lieu->descr['nom'])) { |
|
| 215 | 215 | $nom_code = $lieu->descr['nom']; |
| 216 | 216 | $skel = $lieu->descr['sourcefile']; |
| 217 | 217 | $h2 = parametre_url($href, 'var_mode_objet', $nom_code); |
| 218 | - $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette') . '#L' . $ligne; |
|
| 218 | + $h3 = parametre_url($h2, 'var_mode_affiche', 'squelette').'#L'.$ligne; |
|
| 219 | 219 | $skel = "<a href='$h3'><b>$skel</b></a>"; |
| 220 | - if ($boucle){ |
|
| 221 | - $h3 = parametre_url($h2 . $boucle, 'var_mode_affiche', 'boucle'); |
|
| 220 | + if ($boucle) { |
|
| 221 | + $h3 = parametre_url($h2.$boucle, 'var_mode_affiche', 'boucle'); |
|
| 222 | 222 | $boucle = "<a href='$h3'><b>$boucle</b></a>"; |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - $j = ($i+1); |
|
| 227 | + $j = ($i + 1); |
|
| 228 | 228 | $res .= "<tr id='req$j'><td style='text-align: right'>" |
| 229 | 229 | . $j |
| 230 | 230 | . " </td><td style='text-align: left'>" |
@@ -278,22 +278,22 @@ discard block |
||
| 278 | 278 | * Retourne le texte de l'erreur a afficher |
| 279 | 279 | * ou un tableau si l'erreur est critique |
| 280 | 280 | **/ |
| 281 | -function debusquer_requete($message){ |
|
| 281 | +function debusquer_requete($message) { |
|
| 282 | 282 | list($errno, $msg, $query) = $message; |
| 283 | 283 | |
| 284 | 284 | // FIXME: ces écritures mélangent divers syntaxe des moteurs SQL |
| 285 | 285 | // il serait plus prudent certainement d'avoir une fonction d'analyse par moteur |
| 286 | - if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)){ |
|
| 286 | + if (preg_match(',err(no|code):?[[:space:]]*([0-9]+),i', $msg, $regs)) { |
|
| 287 | 287 | $errno = $regs[2]; |
| 288 | 288 | } |
| 289 | - elseif (is_numeric($errno) and ($errno==1030 OR $errno<=1026) |
|
| 289 | + elseif (is_numeric($errno) and ($errno == 1030 OR $errno <= 1026) |
|
| 290 | 290 | AND preg_match(',[^[:alnum:]]([0-9]+)[^[:alnum:]],', $msg, $regs) |
| 291 | 291 | ) { |
| 292 | 292 | $errno = $regs[1]; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | // Erreur systeme |
| 296 | - if (is_numeric($errno) and $errno>0 AND $errno<200){ |
|
| 296 | + if (is_numeric($errno) and $errno > 0 AND $errno < 200) { |
|
| 297 | 297 | $retour = "<tt><br /><br /><blink>" |
| 298 | 298 | . _T('info_erreur_systeme', array('errsys' => $errno)) |
| 299 | 299 | . "</blink><br />\n<b>" |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | // Requete erronee |
| 308 | - $err = "<b>" . _T('avis_erreur_mysql') . " $errno</b><br /><tt>\n" |
|
| 308 | + $err = "<b>"._T('avis_erreur_mysql')." $errno</b><br /><tt>\n" |
|
| 309 | 309 | . spip_htmlspecialchars($msg) |
| 310 | 310 | . "\n<br /><span style='color: red'><b>" |
| 311 | 311 | . spip_htmlspecialchars($query) |
@@ -318,17 +318,17 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | |
| 320 | 320 | // http://doc.spip.org/@trouve_boucle_debug |
| 321 | -function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = ""){ |
|
| 321 | +function trouve_boucle_debug($n, $nom, $debut = 0, $boucle = "") { |
|
| 322 | 322 | global $debug_objets; |
| 323 | 323 | |
| 324 | - $id = $nom . $boucle; |
|
| 325 | - if (is_array($debug_objets['sequence'][$id])){ |
|
| 326 | - foreach ($debug_objets['sequence'][$id] as $v){ |
|
| 324 | + $id = $nom.$boucle; |
|
| 325 | + if (is_array($debug_objets['sequence'][$id])) { |
|
| 326 | + foreach ($debug_objets['sequence'][$id] as $v) { |
|
| 327 | 327 | |
| 328 | 328 | if (!preg_match('/^(.*)(<\?.*\?>)(.*)$/s', $v[0], $r)) |
| 329 | 329 | $y = substr_count($v[0], "\n"); |
| 330 | 330 | else { |
| 331 | - if ($v[1][0]=='#') |
|
| 331 | + if ($v[1][0] == '#') |
|
| 332 | 332 | // balise dynamique |
| 333 | 333 | $incl = $debug_objets['resultat'][$v[2]]; |
| 334 | 334 | else |
@@ -338,82 +338,79 @@ discard block |
||
| 338 | 338 | +substr_count($r[1], "\n") |
| 339 | 339 | +substr_count($r[3], "\n"); |
| 340 | 340 | } |
| 341 | - if ($n<=($y+$debut)){ |
|
| 342 | - if ($v[1][0]=='?') |
|
| 341 | + if ($n <= ($y + $debut)) { |
|
| 342 | + if ($v[1][0] == '?') |
|
| 343 | 343 | return trouve_boucle_debug($n, $nom, $debut, substr($v[1], 1)); |
| 344 | - elseif ($v[1][0]=='!') { |
|
| 344 | + elseif ($v[1][0] == '!') { |
|
| 345 | 345 | if ($incl = trouve_squelette_inclus($v[1])) |
| 346 | 346 | return trouve_boucle_debug($n, $incl, $debut); |
| 347 | 347 | } |
| 348 | - return array($nom, $boucle, $v[2]-1+$n-$debut); |
|
| 348 | + return array($nom, $boucle, $v[2] - 1 + $n - $debut); |
|
| 349 | 349 | } |
| 350 | 350 | $debut += $y; |
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | - return array($nom, $boucle, $n-$debut); |
|
| 353 | + return array($nom, $boucle, $n - $debut); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // http://doc.spip.org/@trouve_squelette_inclus |
| 357 | -function trouve_squelette_inclus($script){ |
|
| 357 | +function trouve_squelette_inclus($script) { |
|
| 358 | 358 | global $debug_objets; |
| 359 | 359 | preg_match('/include\(.(.*).php3?.\);/', $script, $reg); |
| 360 | 360 | // si le script X.php n'est pas ecrire/public.php |
| 361 | 361 | // on suppose qu'il prend le squelette X.html (pas sur, mais y a pas mieux) |
| 362 | - if ($reg[1]=='ecrire/public') |
|
| 362 | + if ($reg[1] == 'ecrire/public') |
|
| 363 | 363 | // si c'est bien ecrire/public on cherche le param 'fond' |
| 364 | 364 | if (!preg_match("/'fond' => '([^']*)'/", $script, $reg)) |
| 365 | 365 | // a defaut on cherche le param 'page' |
| 366 | 366 | if (!preg_match("/'param' => '([^']*)'/", $script, $reg)) |
| 367 | 367 | $reg[1] = "inconnu"; |
| 368 | - $incl = ',' . $reg[1] . '[.]\w$,'; |
|
| 368 | + $incl = ','.$reg[1].'[.]\w$,'; |
|
| 369 | 369 | |
| 370 | - foreach ($debug_objets['sourcefile'] as $k => $v){ |
|
| 370 | + foreach ($debug_objets['sourcefile'] as $k => $v) { |
|
| 371 | 371 | if (preg_match($incl, $v)) return $k; |
| 372 | 372 | } |
| 373 | 373 | return ""; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // http://doc.spip.org/@reference_boucle_debug |
| 377 | -function reference_boucle_debug($n, $nom, $self){ |
|
| 377 | +function reference_boucle_debug($n, $nom, $self) { |
|
| 378 | 378 | list($skel, $boucle, $ligne) = trouve_boucle_debug($n, $nom); |
| 379 | 379 | |
| 380 | 380 | if (!$boucle) |
| 381 | - return !$ligne ? "" : |
|
| 382 | - (" (" . |
|
| 383 | - (($nom!=$skel) ? _T('squelette_inclus_ligne') : |
|
| 384 | - _T('squelette_ligne')) . |
|
| 381 | + return !$ligne ? "" : (" (". |
|
| 382 | + (($nom != $skel) ? _T('squelette_inclus_ligne') : _T('squelette_ligne')). |
|
| 385 | 383 | " <a href='$self&var_mode_objet=$skel&var_mode_affiche=squelette&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"); |
| 386 | 384 | else { |
| 387 | 385 | $self .= "&var_mode_objet=$skel$boucle&var_mode_affiche=boucle"; |
| 388 | 386 | |
| 389 | - return !$ligne ? " (boucle\n<a href='$self#$skel$boucle'>$boucle</a>)" : |
|
| 390 | - " (boucle $boucle ligne\n<a href='$self&var_mode_ligne=$ligne#L$ligne'>$ligne</a>)"; |
|
| 387 | + 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>)"; |
|
| 391 | 388 | } |
| 392 | 389 | } |
| 393 | 390 | |
| 394 | 391 | // affiche un texte avec numero de ligne et ancre. |
| 395 | 392 | |
| 396 | 393 | // http://doc.spip.org/@ancre_texte |
| 397 | -function ancre_texte($texte, $fautifs = array(), $nocpt = false){ |
|
| 394 | +function ancre_texte($texte, $fautifs = array(), $nocpt = false) { |
|
| 398 | 395 | |
| 399 | 396 | $var_mode_ligne = _request('var_mode_ligne'); |
| 400 | 397 | if ($var_mode_ligne) $fautifs[] = array($var_mode_ligne); |
| 401 | 398 | $res = ''; |
| 402 | 399 | |
| 403 | 400 | $s = highlight_string($texte, true); |
| 404 | - if (substr($s, 0, 6)=='<code>'){ |
|
| 401 | + if (substr($s, 0, 6) == '<code>') { |
|
| 405 | 402 | $s = substr($s, 6); |
| 406 | 403 | $res = '<code>'; |
| 407 | 404 | } |
| 408 | 405 | |
| 409 | 406 | $s = preg_replace(',<(\w[^<>]*)>([^<]*)<br />([^<]*)</\1>,', |
| 410 | - '<\1>\2</\1><br />' . "\n" . '<\1>\3</\1>', |
|
| 407 | + '<\1>\2</\1><br />'."\n".'<\1>\3</\1>', |
|
| 411 | 408 | $s); |
| 412 | 409 | |
| 413 | 410 | |
| 414 | 411 | $tableau = explode("<br />", $s); |
| 415 | 412 | |
| 416 | - $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"; |
|
| 413 | + $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"; |
|
| 417 | 414 | |
| 418 | 415 | $format10 = str_replace('white', 'lightgrey', $format); |
| 419 | 416 | $formaterr = "color: red;"; |
@@ -421,14 +418,14 @@ discard block |
||
| 421 | 418 | $flignes = array(); |
| 422 | 419 | $loc = array(0, 0); |
| 423 | 420 | foreach ($fautifs as $lc) |
| 424 | - if (is_array($lc)){ |
|
| 421 | + if (is_array($lc)) { |
|
| 425 | 422 | $l = array_shift($lc); |
| 426 | 423 | $flignes[$l] = $lc; |
| 427 | 424 | } else $flignes[$lc] = $loc; |
| 428 | 425 | |
| 429 | 426 | $ancre = md5($texte); |
| 430 | - foreach ($tableau as $ligne){ |
|
| 431 | - if (isset($flignes[$i])){ |
|
| 427 | + foreach ($tableau as $ligne) { |
|
| 428 | + if (isset($flignes[$i])) { |
|
| 432 | 429 | $ligne = str_replace(' ', ' ', $ligne); |
| 433 | 430 | $indexmesg = $flignes[$i][1]; |
| 434 | 431 | $err = textebrut($flignes[$i][2]); |
@@ -442,7 +439,7 @@ discard block |
||
| 442 | 439 | $indexmesg = $ancre; |
| 443 | 440 | $err = $bg = ''; |
| 444 | 441 | } |
| 445 | - $res .= sprintf((($i%10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 442 | + $res .= sprintf((($i % 10) ? $format : $format10), $i, $bg, $indexmesg, $err, $i, $ligne); |
|
| 446 | 443 | $i++; |
| 447 | 444 | } |
| 448 | 445 | |
@@ -454,31 +451,31 @@ discard block |
||
| 454 | 451 | . '" style="cursor: pointer;">' |
| 455 | 452 | . ($nocpt ? '' : _T('info_numero_abbreviation')) |
| 456 | 453 | . "</div> |
| 457 | - " . $res . "</div>\n"; |
|
| 454 | + " . $res."</div>\n"; |
|
| 458 | 455 | } |
| 459 | 456 | |
| 460 | 457 | // l'environnement graphique du debuggueur |
| 461 | 458 | |
| 462 | -function debusquer_squelette($fonc, $mode, $self){ |
|
| 459 | +function debusquer_squelette($fonc, $mode, $self) { |
|
| 463 | 460 | global $debug_objets; |
| 464 | 461 | |
| 465 | - if ($mode!=='validation'){ |
|
| 466 | - if (isset($debug_objets['sourcefile']) and $debug_objets['sourcefile']){ |
|
| 462 | + if ($mode !== 'validation') { |
|
| 463 | + if (isset($debug_objets['sourcefile']) and $debug_objets['sourcefile']) { |
|
| 467 | 464 | $res = "<div id='spip-boucles'>\n" |
| 468 | 465 | . debusquer_navigation_squelettes($self) |
| 469 | 466 | . "</div>"; |
| 470 | 467 | } |
| 471 | 468 | else |
| 472 | 469 | $res = ''; |
| 473 | - if ($fonc){ |
|
| 470 | + if ($fonc) { |
|
| 474 | 471 | $id = " id='$fonc'"; |
| 475 | - if (!empty($GLOBALS['debug_objets'][$mode][$fonc])){ |
|
| 472 | + if (!empty($GLOBALS['debug_objets'][$mode][$fonc])) { |
|
| 476 | 473 | list($legend, $texte, $res2) = debusquer_source($fonc, $mode); |
| 477 | 474 | $texte .= $res2; |
| 478 | 475 | } |
| 479 | - elseif (!empty($debug_objets[$mode][$fonc . 'tout'])) { |
|
| 480 | - $legend = _T('zbug_' . $mode); |
|
| 481 | - $texte = $debug_objets[$mode][$fonc . 'tout']; |
|
| 476 | + elseif (!empty($debug_objets[$mode][$fonc.'tout'])) { |
|
| 477 | + $legend = _T('zbug_'.$mode); |
|
| 478 | + $texte = $debug_objets[$mode][$fonc.'tout']; |
|
| 482 | 479 | $texte = ancre_texte($texte, array('', '')); |
| 483 | 480 | } |
| 484 | 481 | } |
@@ -490,17 +487,17 @@ discard block |
||
| 490 | 487 | } |
| 491 | 488 | else { |
| 492 | 489 | $valider = charger_fonction('valider', 'xml'); |
| 493 | - $val = $valider($debug_objets['validation'][$fonc . 'tout']); |
|
| 490 | + $val = $valider($debug_objets['validation'][$fonc.'tout']); |
|
| 494 | 491 | // Si erreur, signaler leur nombre dans le formulaire admin |
| 495 | 492 | $debug_objets['validation'] = $val->err ? count($val->err) : ''; |
| 496 | 493 | list($texte, $err) = emboite_texte($val, $fonc, $self); |
| 497 | - if ($err===false) |
|
| 494 | + if ($err === false) |
|
| 498 | 495 | $err = _T('impossible'); |
| 499 | - elseif ($err===true) |
|
| 496 | + elseif ($err === true) |
|
| 500 | 497 | $err = _T('correcte'); |
| 501 | 498 | else |
| 502 | 499 | $err = ": $err"; |
| 503 | - $legend = _T('validation') . ' ' . $err; |
|
| 500 | + $legend = _T('validation').' '.$err; |
|
| 504 | 501 | $res = $id = ''; |
| 505 | 502 | } |
| 506 | 503 | return !trim($texte) ? '' : ( |
@@ -516,16 +513,16 @@ discard block |
||
| 516 | 513 | |
| 517 | 514 | |
| 518 | 515 | // http://doc.spip.org/@emboite_texte |
| 519 | -function emboite_texte($res, $fonc = '', $self = ''){ |
|
| 516 | +function emboite_texte($res, $fonc = '', $self = '') { |
|
| 520 | 517 | $errs = $res->err; |
| 521 | - $texte = $res->entete . ($errs ? '' : $res->page); |
|
| 518 | + $texte = $res->entete.($errs ? '' : $res->page); |
|
| 522 | 519 | |
| 523 | 520 | if (!$texte and !$errs) |
| 524 | 521 | return array(ancre_texte('', array('', '')), false); |
| 525 | 522 | if (!$errs) |
| 526 | 523 | return array(ancre_texte($texte, array('', '')), true); |
| 527 | 524 | |
| 528 | - if (!isset($GLOBALS['debug_objets'])){ |
|
| 525 | + if (!isset($GLOBALS['debug_objets'])) { |
|
| 529 | 526 | |
| 530 | 527 | $colors = array('#e0e0f0', '#f8f8ff'); |
| 531 | 528 | $encore = count_occ($errs); |
@@ -546,7 +543,7 @@ discard block |
||
| 546 | 543 | |
| 547 | 544 | $i = 0; |
| 548 | 545 | $style = "style='text-align: right; padding-right: 5px'"; |
| 549 | - foreach ($errs as $r){ |
|
| 546 | + foreach ($errs as $r) { |
|
| 550 | 547 | $i++; |
| 551 | 548 | list($msg, $ligne, $col) = $r; |
| 552 | 549 | #spip_log("$r = list($msg, $ligne, $col"); |
@@ -556,7 +553,7 @@ discard block |
||
| 556 | 553 | $encore2[$msg] = $ref = 1; |
| 557 | 554 | } |
| 558 | 555 | $err .= "<tr style='background-color: " |
| 559 | - . $colors[$i%2] |
|
| 556 | + . $colors[$i % 2] |
|
| 560 | 557 | . "'><td $style><a href='#debut_err'>" |
| 561 | 558 | . $i |
| 562 | 559 | . "</a></td><td $style>" |
@@ -573,7 +570,7 @@ discard block |
||
| 573 | 570 | $err = "<h2 style='text-align: center'>" |
| 574 | 571 | . $i |
| 575 | 572 | . "<a href='#fin_err'>" |
| 576 | - . " " . _T('erreur_texte') |
|
| 573 | + . " "._T('erreur_texte') |
|
| 577 | 574 | . "</a></h2><table id='debut_err' style='width: 100%'>" |
| 578 | 575 | . $err |
| 579 | 576 | . " </table><a id='fin_err'></a>"; |
@@ -583,17 +580,17 @@ discard block |
||
| 583 | 580 | list($msg, $fermant, $ouvrant) = $errs[0]; |
| 584 | 581 | $rf = reference_boucle_debug($fermant, $fonc, $self); |
| 585 | 582 | $ro = reference_boucle_debug($ouvrant, $fonc, $self); |
| 586 | - $err = $msg . |
|
| 587 | - "<a href='#L" . $fermant . "'>$fermant</a>$rf<br />" . |
|
| 588 | - "<a href='#L" . $ouvrant . "'>$ouvrant</a>$ro"; |
|
| 583 | + $err = $msg. |
|
| 584 | + "<a href='#L".$fermant."'>$fermant</a>$rf<br />". |
|
| 585 | + "<a href='#L".$ouvrant."'>$ouvrant</a>$ro"; |
|
| 589 | 586 | return array(ancre_texte($texte, array(array($ouvrant), array($fermant))), $err); |
| 590 | 587 | } |
| 591 | 588 | } |
| 592 | 589 | |
| 593 | 590 | // http://doc.spip.org/@count_occ |
| 594 | -function count_occ($regs){ |
|
| 591 | +function count_occ($regs) { |
|
| 595 | 592 | $encore = array(); |
| 596 | - foreach ($regs as $r){ |
|
| 593 | + foreach ($regs as $r) { |
|
| 597 | 594 | if (isset($encore[$r[0]])) |
| 598 | 595 | $encore[$r[0]]++; |
| 599 | 596 | else |
@@ -602,14 +599,14 @@ discard block |
||
| 602 | 599 | return $encore; |
| 603 | 600 | } |
| 604 | 601 | |
| 605 | -function debusquer_navigation_squelettes($self){ |
|
| 602 | +function debusquer_navigation_squelettes($self) { |
|
| 606 | 603 | global $debug_objets, $spip_lang_right; |
| 607 | 604 | |
| 608 | 605 | $res = ''; |
| 609 | 606 | $boucles = !empty($debug_objets['boucle']) ? $debug_objets['boucle'] : ''; |
| 610 | 607 | $contexte = $debug_objets['contexte']; |
| 611 | 608 | $t_skel = _T('squelette'); |
| 612 | - foreach ($debug_objets['sourcefile'] as $nom => $sourcefile){ |
|
| 609 | + foreach ($debug_objets['sourcefile'] as $nom => $sourcefile) { |
|
| 613 | 610 | $self2 = parametre_url($self, 'var_mode_objet', $nom); |
| 614 | 611 | $nav = !$boucles ? '' : debusquer_navigation_boucles($boucles, $nom, $self, $sourcefile); |
| 615 | 612 | $temps = !isset($debug_objets['profile'][$sourcefile]) ? '' : _T('zbug_profile', array('time' => $debug_objets['profile'][$sourcefile])); |
@@ -637,67 +634,67 @@ discard block |
||
| 637 | 634 | return $res; |
| 638 | 635 | } |
| 639 | 636 | |
| 640 | -function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source){ |
|
| 637 | +function debusquer_navigation_boucles($boucles, $nom_skel, $self, $nom_source) { |
|
| 641 | 638 | $i = 0; |
| 642 | 639 | $res = ''; |
| 643 | 640 | $var_mode_objet = _request('var_mode_objet'); |
| 644 | 641 | $gram = preg_match('/[.](\w+)$/', $nom_source, $r) ? $r[1] : ''; |
| 645 | 642 | |
| 646 | - foreach ($boucles as $objet => $boucle){ |
|
| 647 | - if (substr($objet, 0, strlen($nom_skel))==$nom_skel){ |
|
| 643 | + foreach ($boucles as $objet => $boucle) { |
|
| 644 | + if (substr($objet, 0, strlen($nom_skel)) == $nom_skel) { |
|
| 648 | 645 | $i++; |
| 649 | 646 | $nom = $boucle->id_boucle; |
| 650 | 647 | $req = $boucle->type_requete; |
| 651 | 648 | $crit = public_decompiler($boucle, $gram, 0, 'criteres'); |
| 652 | - $self2 = $self . "&var_mode_objet=" . $objet; |
|
| 653 | - |
|
| 654 | - $res .= "\n<tr style='background-color: " . |
|
| 655 | - ($i%2 ? '#e0e0f0' : '#f8f8ff') . |
|
| 656 | - "'><td align='right'>$i</td><td>\n" . |
|
| 657 | - "<a class='debug_link_boucle' href='" . |
|
| 658 | - $self2 . |
|
| 659 | - "&var_mode_affiche=boucle#f_$nom_skel'>" . |
|
| 660 | - _T('zbug_boucle') . |
|
| 661 | - "</a></td><td>\n<a class='debug_link_boucle' href='" . |
|
| 662 | - $self2 . |
|
| 663 | - "&var_mode_affiche=resultat#f_$nom_skel'>" . |
|
| 664 | - _T('zbug_resultat') . |
|
| 665 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 666 | - $self2 . |
|
| 667 | - "&var_mode_affiche=code#f_$nom_skel'>" . |
|
| 668 | - _T('zbug_code') . |
|
| 669 | - "</a></td><td>\n<a class='debug_link_resultat' href='" . |
|
| 670 | - str_replace('var_mode=', 'var_profile=', $self2) . |
|
| 671 | - "'>" . |
|
| 672 | - _T('zbug_calcul') . |
|
| 673 | - "</a></td><td>\n" . |
|
| 674 | - (($var_mode_objet==$objet) ? "<b>$nom</b>" : $nom) . |
|
| 675 | - "</td><td>\n" . |
|
| 676 | - $req . |
|
| 677 | - "</td><td>\n" . |
|
| 678 | - spip_htmlspecialchars($crit) . |
|
| 649 | + $self2 = $self."&var_mode_objet=".$objet; |
|
| 650 | + |
|
| 651 | + $res .= "\n<tr style='background-color: ". |
|
| 652 | + ($i % 2 ? '#e0e0f0' : '#f8f8ff'). |
|
| 653 | + "'><td align='right'>$i</td><td>\n". |
|
| 654 | + "<a class='debug_link_boucle' href='". |
|
| 655 | + $self2. |
|
| 656 | + "&var_mode_affiche=boucle#f_$nom_skel'>". |
|
| 657 | + _T('zbug_boucle'). |
|
| 658 | + "</a></td><td>\n<a class='debug_link_boucle' href='". |
|
| 659 | + $self2. |
|
| 660 | + "&var_mode_affiche=resultat#f_$nom_skel'>". |
|
| 661 | + _T('zbug_resultat'). |
|
| 662 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 663 | + $self2. |
|
| 664 | + "&var_mode_affiche=code#f_$nom_skel'>". |
|
| 665 | + _T('zbug_code'). |
|
| 666 | + "</a></td><td>\n<a class='debug_link_resultat' href='". |
|
| 667 | + str_replace('var_mode=', 'var_profile=', $self2). |
|
| 668 | + "'>". |
|
| 669 | + _T('zbug_calcul'). |
|
| 670 | + "</a></td><td>\n". |
|
| 671 | + (($var_mode_objet == $objet) ? "<b>$nom</b>" : $nom). |
|
| 672 | + "</td><td>\n". |
|
| 673 | + $req. |
|
| 674 | + "</td><td>\n". |
|
| 675 | + spip_htmlspecialchars($crit). |
|
| 679 | 676 | "</td></tr>"; |
| 680 | 677 | } |
| 681 | 678 | } |
| 682 | 679 | return $res; |
| 683 | 680 | } |
| 684 | 681 | |
| 685 | -function debusquer_source($objet, $affiche){ |
|
| 682 | +function debusquer_source($objet, $affiche) { |
|
| 686 | 683 | $quoi = $GLOBALS['debug_objets'][$affiche][$objet]; |
| 687 | 684 | $nom = $GLOBALS['debug_objets']['boucle'][$objet]->id_boucle; |
| 688 | 685 | $res2 = ""; |
| 689 | 686 | |
| 690 | - if ($affiche=='resultat'){ |
|
| 687 | + if ($affiche == 'resultat') { |
|
| 691 | 688 | $legend = $nom; |
| 692 | 689 | $req = $GLOBALS['debug_objets']['requete'][$objet]; |
| 693 | - if (function_exists('traite_query')){ |
|
| 690 | + if (function_exists('traite_query')) { |
|
| 694 | 691 | $c = strtolower(_request('connect')); |
| 695 | 692 | $c = $GLOBALS['connexions'][$c ? $c : 0]['prefixe']; |
| 696 | 693 | $req = traite_query($req, '', $c); |
| 697 | 694 | } |
| 698 | 695 | // permettre le copier/coller facile |
| 699 | 696 | // $res = ancre_texte($req, array(), true); |
| 700 | - $res = "<div id='T" . md5($req) . "'>\n<pre>\n" . $req . "</pre>\n</div>\n"; |
|
| 697 | + $res = "<div id='T".md5($req)."'>\n<pre>\n".$req."</pre>\n</div>\n"; |
|
| 701 | 698 | // formatage et affichage des resultats bruts de la requete |
| 702 | 699 | $ress_req = spip_query($req); |
| 703 | 700 | $brut_sql = ''; |
@@ -705,38 +702,38 @@ discard block |
||
| 705 | 702 | // eviter l'affichage de milliers de lignes |
| 706 | 703 | // personnalisation possible dans mes_options |
| 707 | 704 | $max_aff = defined('_MAX_DEBUG_AFF') ? _MAX_DEBUG_AFF : 50; |
| 708 | - while ($retours_sql = sql_fetch($ress_req)){ |
|
| 709 | - if ($num<=$max_aff){ |
|
| 710 | - $brut_sql .= "<h3>" . ($num==1 ? $num . " sur " . sql_count($ress_req) : $num) . "</h3>"; |
|
| 705 | + while ($retours_sql = sql_fetch($ress_req)) { |
|
| 706 | + if ($num <= $max_aff) { |
|
| 707 | + $brut_sql .= "<h3>".($num == 1 ? $num." sur ".sql_count($ress_req) : $num)."</h3>"; |
|
| 711 | 708 | $brut_sql .= "<p>"; |
| 712 | - foreach ($retours_sql as $key => $val){ |
|
| 713 | - $brut_sql .= "<strong>" . $key . "</strong> => " . spip_htmlspecialchars(couper($val, 150)) . "<br />\n"; |
|
| 709 | + foreach ($retours_sql as $key => $val) { |
|
| 710 | + $brut_sql .= "<strong>".$key."</strong> => ".spip_htmlspecialchars(couper($val, 150))."<br />\n"; |
|
| 714 | 711 | } |
| 715 | 712 | $brut_sql .= "</p>"; |
| 716 | 713 | } |
| 717 | 714 | $num++; |
| 718 | 715 | } |
| 719 | 716 | $res2 = interdire_scripts($brut_sql); |
| 720 | - foreach ($quoi as $view){ |
|
| 717 | + foreach ($quoi as $view) { |
|
| 721 | 718 | // ne pas afficher les $contexte_inclus |
| 722 | 719 | $view = preg_replace(",<\?php.+\?[>],Uims", "", $view); |
| 723 | - if ($view){ |
|
| 724 | - $res2 .= "\n<br /><fieldset>" . interdire_scripts($view) . "</fieldset>"; |
|
| 720 | + if ($view) { |
|
| 721 | + $res2 .= "\n<br /><fieldset>".interdire_scripts($view)."</fieldset>"; |
|
| 725 | 722 | } |
| 726 | 723 | } |
| 727 | 724 | |
| 728 | 725 | } |
| 729 | - elseif ($affiche=='code'){ |
|
| 726 | + elseif ($affiche == 'code') { |
|
| 730 | 727 | $legend = $nom; |
| 731 | - $res = ancre_texte("<" . "?php\n" . $quoi . "\n?" . ">"); |
|
| 728 | + $res = ancre_texte("<"."?php\n".$quoi."\n?".">"); |
|
| 732 | 729 | } |
| 733 | - elseif ($affiche=='boucle'){ |
|
| 734 | - $legend = _T('zbug_boucle') . ' ' . $nom; |
|
| 730 | + elseif ($affiche == 'boucle') { |
|
| 731 | + $legend = _T('zbug_boucle').' '.$nom; |
|
| 735 | 732 | // Le compilateur prefixe le nom des boucles par l'extension du fichier source. |
| 736 | 733 | $gram = preg_match('/^([^_]+)_/', $objet, $r) ? $r[1] : ''; |
| 737 | 734 | $res = ancre_texte(public_decompiler($quoi, $gram, 0, 'boucle')); |
| 738 | 735 | } |
| 739 | - elseif ($affiche=='squelette'){ |
|
| 736 | + elseif ($affiche == 'squelette') { |
|
| 740 | 737 | $legend = $GLOBALS['debug_objets']['sourcefile'][$objet]; |
| 741 | 738 | $res = ancre_texte($GLOBALS['debug_objets']['squelette'][$objet]); |
| 742 | 739 | } |
@@ -745,30 +742,30 @@ discard block |
||
| 745 | 742 | } |
| 746 | 743 | |
| 747 | 744 | // http://doc.spip.org/@debusquer_entete |
| 748 | -function debusquer_entete($titre, $corps){ |
|
| 745 | +function debusquer_entete($titre, $corps) { |
|
| 749 | 746 | global $debug_objets; |
| 750 | 747 | include_spip('balise/formulaire_admin'); |
| 751 | 748 | include_spip('public/assembler'); // pour inclure_balise_dynamique |
| 752 | 749 | include_spip('inc/texte'); // pour corriger_typo |
| 753 | 750 | |
| 754 | - return _DOCTYPE_ECRIRE . |
|
| 755 | - html_lang_attributes() . |
|
| 756 | - "<head>\n<title>" . |
|
| 757 | - ('SPIP ' . $GLOBALS['spip_version_affichee'] . ' ' . |
|
| 758 | - _T('admin_debug') . ' ' . $titre . ' (' . |
|
| 759 | - supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))) . |
|
| 760 | - ")</title>\n" . |
|
| 761 | - "<meta http-equiv='Content-Type' content='text/html" . |
|
| 762 | - (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : '') . |
|
| 763 | - "' />\n" . |
|
| 751 | + return _DOCTYPE_ECRIRE. |
|
| 752 | + html_lang_attributes(). |
|
| 753 | + "<head>\n<title>". |
|
| 754 | + ('SPIP '.$GLOBALS['spip_version_affichee'].' '. |
|
| 755 | + _T('admin_debug').' '.$titre.' ('. |
|
| 756 | + supprimer_tags(corriger_typo($GLOBALS['meta']['nom_site']))). |
|
| 757 | + ")</title>\n". |
|
| 758 | + "<meta http-equiv='Content-Type' content='text/html". |
|
| 759 | + (($c = $GLOBALS['meta']['charset']) ? "; charset=$c" : ''). |
|
| 760 | + "' />\n". |
|
| 764 | 761 | http_script('', 'jquery.js') |
| 765 | - . "<link rel='stylesheet' href='" . url_absolue(find_in_path('spip_admin.css')) |
|
| 766 | - . "' type='text/css' />" . |
|
| 767 | - "</head>\n" . |
|
| 768 | - "<body style='margin:0 10px;'>\n" . |
|
| 769 | - "<div id='spip-debug-header'>" . |
|
| 770 | - $corps . |
|
| 771 | - inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $debug_objets), false) . |
|
| 762 | + . "<link rel='stylesheet' href='".url_absolue(find_in_path('spip_admin.css')) |
|
| 763 | + . "' type='text/css' />". |
|
| 764 | + "</head>\n". |
|
| 765 | + "<body style='margin:0 10px;'>\n". |
|
| 766 | + "<div id='spip-debug-header'>". |
|
| 767 | + $corps. |
|
| 768 | + inclure_balise_dynamique(balise_FORMULAIRE_ADMIN_dyn('spip-admin-float', $debug_objets), false). |
|
| 772 | 769 | '</div></body></html>'; |
| 773 | 770 | } |
| 774 | 771 | |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | * @param Object $p |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | -function sandbox_composer_texte($texte, &$p){ |
|
| 29 | - $code = "'".str_replace(array("\\","'"),array("\\\\","\\'"), $texte)."'"; |
|
| 28 | +function sandbox_composer_texte($texte, &$p) { |
|
| 29 | + $code = "'".str_replace(array("\\", "'"), array("\\\\", "\\'"), $texte)."'"; |
|
| 30 | 30 | return $code; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param Object $p |
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | -function sandbox_composer_filtre($fonc, $code, $arglist, &$p){ |
|
| 43 | +function sandbox_composer_filtre($fonc, $code, $arglist, &$p) { |
|
| 44 | 44 | if (isset($GLOBALS['spip_matrice'][$fonc])) { |
| 45 | 45 | $code = "filtrer('$fonc',$code$arglist)"; |
| 46 | 46 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param array $_contexte |
| 90 | 90 | * @return string |
| 91 | 91 | */ |
| 92 | -function sandbox_composer_inclure_php($fichier, &$p, $_contexte){ |
|
| 92 | +function sandbox_composer_inclure_php($fichier, &$p, $_contexte) { |
|
| 93 | 93 | $compil = texte_script(memoriser_contexte_compil($p)); |
| 94 | 94 | // si inexistant, on essaiera a l'execution |
| 95 | 95 | if ($path = find_in_path($fichier)) |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param Object $p |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | -function sandbox_composer_interdire_scripts($code, &$p){ |
|
| 109 | +function sandbox_composer_interdire_scripts($code, &$p) { |
|
| 110 | 110 | // Securite |
| 111 | 111 | if ($p->interdire_scripts |
| 112 | 112 | AND $p->etoile != '**') { |
@@ -132,19 +132,19 @@ discard block |
||
| 132 | 132 | * @param array ... |
| 133 | 133 | * @return mixed|string |
| 134 | 134 | */ |
| 135 | -function sandbox_filtrer_squelette($skel, $corps, $filtres){ |
|
| 135 | +function sandbox_filtrer_squelette($skel, $corps, $filtres) { |
|
| 136 | 136 | $series_filtres = func_get_args(); |
| 137 | - array_shift($series_filtres);// skel |
|
| 138 | - array_shift($series_filtres);// corps |
|
| 137 | + array_shift($series_filtres); // skel |
|
| 138 | + array_shift($series_filtres); // corps |
|
| 139 | 139 | |
| 140 | 140 | // proteger les <INCLUDE> et tous les morceaux de php licites |
| 141 | 141 | if ($skel['process_ins'] == 'php') |
| 142 | - $corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS','echapper_php_callback', $corps); |
|
| 142 | + $corps = preg_replace_callback(',<[?](\s|php|=).*[?]>,UimsS', 'echapper_php_callback', $corps); |
|
| 143 | 143 | |
| 144 | 144 | // recuperer les couples de remplacement |
| 145 | 145 | $replace = echapper_php_callback(); |
| 146 | 146 | |
| 147 | - foreach($series_filtres as $filtres){ |
|
| 147 | + foreach ($series_filtres as $filtres) { |
|
| 148 | 148 | if (count($filtres)) |
| 149 | 149 | foreach ($filtres as $filtre) { |
| 150 | 150 | if ($filtre AND $f = chercher_filtre($filtre)) |
@@ -153,12 +153,12 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // restaurer les echappements |
| 156 | - return str_replace($replace[0],$replace[1],$corps); |
|
| 156 | + return str_replace($replace[0], $replace[1], $corps); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | // http://doc.spip.org/@echapper_php_callback |
| 161 | -function echapper_php_callback($r=null) { |
|
| 161 | +function echapper_php_callback($r = null) { |
|
| 162 | 162 | static $src = array(); |
| 163 | 163 | static $dst = array(); |
| 164 | 164 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | // si on recoit pas un tableau, on renvoit les couples de substitution |
| 173 | 173 | // et on RAZ les remplacements |
| 174 | - $r = array($src,$dst); |
|
| 174 | + $r = array($src, $dst); |
|
| 175 | 175 | $src = $dst = array(); |
| 176 | 176 | return $r; |
| 177 | 177 | } |