@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // Decompilation de l'arbre de syntaxe abstraite d'un squelette SPIP |
| 16 | 18 | |
@@ -26,10 +28,12 @@ discard block |
||
| 26 | 28 | $type .= ($struct->type_requete ? $struct->type_requete : |
| 27 | 29 | $struct->table_optionnelle); |
| 28 | 30 | |
| 29 | - if ($struct->jointures_explicites) |
|
| 30 | - $type .= " " . $struct->jointures_explicites; |
|
| 31 | - if ($struct->table_optionnelle) |
|
| 32 | - $type .= "?"; |
|
| 31 | + if ($struct->jointures_explicites) { |
|
| 32 | + $type .= " " . $struct->jointures_explicites; |
|
| 33 | + } |
|
| 34 | + if ($struct->table_optionnelle) { |
|
| 35 | + $type .= "?"; |
|
| 36 | + } |
|
| 33 | 37 | // Revoir le cas de la boucle recursive |
| 34 | 38 | |
| 35 | 39 | $crit = $struct->param; |
@@ -88,8 +92,9 @@ discard block |
||
| 88 | 92 | $apres = decompiler_($struct->apres, $fmt, $prof); |
| 89 | 93 | $args = $filtres = ''; |
| 90 | 94 | if ($p = $struct->param) { |
| 91 | - if ($p[0][0]==='') |
|
| 92 | - $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 95 | + if ($p[0][0]==='') { |
|
| 96 | + $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 97 | + } |
|
| 93 | 98 | $filtres = decompiler_liste($p, $fmt, $prof); |
| 94 | 99 | } |
| 95 | 100 | $f = 'format_champ_' . $fmt; |
@@ -97,7 +102,9 @@ discard block |
||
| 97 | 102 | } |
| 98 | 103 | |
| 99 | 104 | function decompiler_liste($sources, $fmt='', $prof=0) { |
| 100 | - if (!is_array($sources)) return ''; |
|
| 105 | + if (!is_array($sources)) { |
|
| 106 | + return ''; |
|
| 107 | + } |
|
| 101 | 108 | $f = 'format_liste_' . $fmt; |
| 102 | 109 | $res = ''; |
| 103 | 110 | foreach($sources as $arg) { |
@@ -110,11 +117,15 @@ discard block |
||
| 110 | 117 | if ((count($v) == 1) |
| 111 | 118 | AND $v[0]->type=='texte' |
| 112 | 119 | AND (strlen($v[0]->apres) == 1) |
| 113 | - 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); |
|
| 120 | + AND $v[0]->apres == $v[0]->avant) { |
|
| 121 | + $args[]= $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 122 | + } else { |
|
| 123 | + $args[]= decompiler_($v, $fmt, 0-$prof); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + if (($r!=='') OR $args) { |
|
| 127 | + $res .= $f($r, $args, $prof); |
|
| 116 | 128 | } |
| 117 | - if (($r!=='') OR $args) $res .= $f($r, $args, $prof); |
|
| 118 | 129 | } |
| 119 | 130 | return $res; |
| 120 | 131 | } |
@@ -125,26 +136,33 @@ discard block |
||
| 125 | 136 | // - les champs sont implicitement etendus (crochets implicites mais interdits) |
| 126 | 137 | function decompiler_criteres($boucle, $fmt='', $prof=0) { |
| 127 | 138 | $sources = $boucle->param; |
| 128 | - if (!is_array($sources)) return ''; |
|
| 139 | + if (!is_array($sources)) { |
|
| 140 | + return ''; |
|
| 141 | + } |
|
| 129 | 142 | $res = ''; |
| 130 | 143 | $f = 'format_critere_' . $fmt; |
| 131 | 144 | foreach($sources as $crit) { |
| 132 | - if (!is_array($crit)) continue; // boucle recursive |
|
| 145 | + if (!is_array($crit)) { |
|
| 146 | + continue; |
|
| 147 | + } |
|
| 148 | + // boucle recursive |
|
| 133 | 149 | array_shift($crit); |
| 134 | 150 | $args = array(); |
| 135 | 151 | foreach($crit as $i => $v) { |
| 136 | 152 | if ((count($v) == 1) |
| 137 | 153 | AND $v[0]->type=='texte' |
| 138 | - AND $v[0]->apres) |
|
| 139 | - $args[]= array(array('texte', ( $v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 140 | - else { |
|
| 154 | + AND $v[0]->apres) { |
|
| 155 | + $args[]= array(array('texte', ( $v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 156 | + } else { |
|
| 141 | 157 | $res2 = array(); |
| 142 | 158 | foreach($v as $k => $p) { |
| 143 | 159 | if (isset($p->type) |
| 144 | 160 | AND function_exists($d = 'decompiler_' . $p->type)) { |
| 145 | 161 | $r = $d($p, $fmt, (0-$prof), @$v[$k+1]); |
| 146 | 162 | $res2[]= array($p->type, $r); |
| 147 | - } else spip_log("critere $i / $k mal forme"); |
|
| 163 | + } else { |
|
| 164 | + spip_log("critere $i / $k mal forme"); |
|
| 165 | + } |
|
| 148 | 166 | } |
| 149 | 167 | $args[]= $res2; |
| 150 | 168 | } |
@@ -157,11 +175,16 @@ discard block |
||
| 157 | 175 | |
| 158 | 176 | function decompiler_($liste, $fmt='', $prof=0) |
| 159 | 177 | { |
| 160 | - if (!is_array($liste)) return ''; |
|
| 178 | + if (!is_array($liste)) { |
|
| 179 | + return ''; |
|
| 180 | + } |
|
| 161 | 181 | $prof2 = ($prof < 0) ? ($prof-1) : ($prof+1); |
| 162 | 182 | $contenu = array(); |
| 163 | 183 | foreach($liste as $k => $p) { |
| 164 | - if (!isset($p->type)) continue; #?????? |
|
| 184 | + if (!isset($p->type)) { |
|
| 185 | + continue; |
|
| 186 | + } |
|
| 187 | + #?????? |
|
| 165 | 188 | $d = 'decompiler_' . $p->type; |
| 166 | 189 | $next = isset($liste[$k+1]) ? $liste[$k+1] : false; |
| 167 | 190 | // Forcer le champ etendu si son source (pas les reecritures) |
@@ -192,7 +215,9 @@ discard block |
||
| 192 | 215 | |
| 193 | 216 | function public_decompiler($liste, $fmt='', $prof=0, $quoi='') |
| 194 | 217 | { |
| 195 | - if (!include_spip('public/format_' . $fmt)) return "'$fmt'?"; |
|
| 218 | + if (!include_spip('public/format_' . $fmt)) { |
|
| 219 | + return "'$fmt'?"; |
|
| 220 | + } |
|
| 196 | 221 | $f = 'decompiler_' . $quoi; |
| 197 | 222 | return $f($liste, $fmt, $prof); |
| 198 | 223 | } |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * Evaluer la page produite par un squelette |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $notes($page['notes'],'restaurer_etat'); |
| 50 | 52 | } |
| 51 | 53 | ob_start(); |
| 52 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 53 | - $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); |
|
| 54 | + if (strpos($page['texte'],'?xml')!==false) { |
|
| 55 | + $page['texte'] = str_replace('<'.'?xml', "<\1?xml", $page['texte']); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | try { |
| 56 | 59 | $res = eval('?' . '>' . $page['texte']); |
@@ -70,12 +73,10 @@ discard block |
||
| 70 | 73 | $code = trim(highlight_string($code,true)); |
| 71 | 74 | erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
| 72 | 75 | $page['texte'] = "<!-- Erreur -->"; |
| 73 | - } |
|
| 74 | - else { |
|
| 76 | + } else { |
|
| 75 | 77 | $page['texte'] = ob_get_contents(); |
| 76 | 78 | } |
| 77 | - } |
|
| 78 | - catch (Exception $e){ |
|
| 79 | + } catch (Exception $e){ |
|
| 79 | 80 | $code = $page['texte']; |
| 80 | 81 | $GLOBALS['numero_ligne_php'] = 1; |
| 81 | 82 | if (!function_exists('numerote_ligne_php')){ |
@@ -93,8 +94,9 @@ discard block |
||
| 93 | 94 | |
| 94 | 95 | $page['process_ins'] = 'html'; |
| 95 | 96 | |
| 96 | - if (strpos($page['texte'],'?xml')!==false) |
|
| 97 | - $page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']); |
|
| 98 | -} |
|
| 97 | + if (strpos($page['texte'],'?xml')!==false) { |
|
| 98 | + $page['texte'] = str_replace("<\1?xml", '<'.'?xml', $page['texte']); |
|
| 99 | + } |
|
| 100 | + } |
|
| 99 | 101 | |
| 100 | 102 | page_base_href($page['texte']); |
@@ -13,7 +13,9 @@ discard block |
||
| 13 | 13 | // fonctions de recherche et de reservation |
| 14 | 14 | // dans l'arborescence des boucles |
| 15 | 15 | |
| 16 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 16 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 17 | + return; |
|
| 18 | +} |
|
| 17 | 19 | |
| 18 | 20 | /** |
| 19 | 21 | * Retrouver l'index de la boucle dans le cas ou une reference explicite est demandee |
@@ -65,8 +67,9 @@ discard block |
||
| 65 | 67 | * @return string |
| 66 | 68 | */ |
| 67 | 69 | function index_pile($idb, $nom_champ, &$boucles, $explicite='', $defaut=null, $remonte_pile=true) { |
| 68 | - if (!is_string($defaut)) |
|
| 69 | - $defaut = '@$Pile[0][\''. strtolower($nom_champ) . '\']'; |
|
| 70 | + if (!is_string($defaut)) { |
|
| 71 | + $defaut = '@$Pile[0][\''. strtolower($nom_champ) . '\']'; |
|
| 72 | + } |
|
| 70 | 73 | |
| 71 | 74 | $i = 0; |
| 72 | 75 | if (strlen($explicite)) { |
@@ -91,8 +94,9 @@ discard block |
||
| 91 | 94 | $boucles[$idb]->select[] = $t; |
| 92 | 95 | } |
| 93 | 96 | $champ = '$Pile[$SP' . ($i ? "-$i" : "") . '][\'' . $c . '\']'; |
| 94 | - if (!$joker) |
|
| 95 | - return index_compose($conditionnel,$champ); |
|
| 97 | + if (!$joker) { |
|
| 98 | + return index_compose($conditionnel,$champ); |
|
| 99 | + } |
|
| 96 | 100 | |
| 97 | 101 | $conditionnel[] = "isset($champ)?$champ"; |
| 98 | 102 | } |
@@ -102,9 +106,9 @@ discard block |
||
| 102 | 106 | // Sinon on remonte d'un cran |
| 103 | 107 | $idb = $boucles[$idb]->id_parent; |
| 104 | 108 | $i++; |
| 109 | + } else { |
|
| 110 | + $idb = null; |
|
| 105 | 111 | } |
| 106 | - else |
|
| 107 | - $idb = null; |
|
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | # spip_log("Pas vu $nom_champ"); |
@@ -123,9 +127,10 @@ discard block |
||
| 123 | 127 | * @return string |
| 124 | 128 | */ |
| 125 | 129 | function index_compose($conditionnel,$defaut){ |
| 126 | - while ($c = array_pop($conditionnel)) |
|
| 127 | - // si on passe defaut = '', ne pas générer d'erreur de compilation. |
|
| 130 | + while ($c = array_pop($conditionnel)) { |
|
| 131 | + // si on passe defaut = '', ne pas générer d'erreur de compilation. |
|
| 128 | 132 | $defaut = "($c:(".($defaut?$defaut:"''")."))"; |
| 133 | + } |
|
| 129 | 134 | return $defaut; |
| 130 | 135 | } |
| 131 | 136 | |
@@ -135,7 +140,9 @@ discard block |
||
| 135 | 140 | |
| 136 | 141 | $r = $boucles[$idb]->type_requete; |
| 137 | 142 | |
| 138 | - if ($r == 'boucle') return array(); |
|
| 143 | + if ($r == 'boucle') { |
|
| 144 | + return array(); |
|
| 145 | + } |
|
| 139 | 146 | if (!$r) { |
| 140 | 147 | $joker = false; // indiquer a l'appelant |
| 141 | 148 | # continuer pour chercher l'erreur suivante |
@@ -144,13 +151,13 @@ discard block |
||
| 144 | 151 | |
| 145 | 152 | $desc = $boucles[$idb]->show; |
| 146 | 153 | $excep = isset($exceptions_des_tables[$r]) ? $exceptions_des_tables[$r] : ''; |
| 147 | - if ($excep) |
|
| 148 | - $excep = isset($excep[$nom_champ]) ? $excep[$nom_champ] : ''; |
|
| 154 | + if ($excep) { |
|
| 155 | + $excep = isset($excep[$nom_champ]) ? $excep[$nom_champ] : ''; |
|
| 156 | + } |
|
| 149 | 157 | if ($excep) { |
| 150 | 158 | $joker = false; // indiquer a l'appelant |
| 151 | 159 | return index_exception($boucles[$idb], $desc, $nom_champ, $excep); |
| 152 | - } |
|
| 153 | - else { |
|
| 160 | + } else { |
|
| 154 | 161 | if (isset($desc['field'][$nom_champ])) { |
| 155 | 162 | $t = $boucles[$idb]->id_table; |
| 156 | 163 | $joker = false; // indiquer a l'appelant |
@@ -160,18 +167,18 @@ discard block |
||
| 160 | 167 | elseif (/*$joker AND */isset($desc['field']['*'])) { |
| 161 | 168 | $joker = true; // indiquer a l'appelant |
| 162 | 169 | return array($nom_champ, $nom_champ); |
| 163 | - } |
|
| 164 | - else { |
|
| 170 | + } else { |
|
| 165 | 171 | $joker = false; // indiquer a l'appelant |
| 166 | 172 | if ($boucles[$idb]->jointures_explicites) { |
| 167 | 173 | $t = trouver_champ_exterieur($nom_champ, |
| 168 | 174 | $boucles[$idb]->jointures, |
| 169 | 175 | $boucles[$idb]); |
| 170 | - if ($t) |
|
| 171 | - return index_exception($boucles[$idb], |
|
| 176 | + if ($t) { |
|
| 177 | + return index_exception($boucles[$idb], |
|
| 172 | 178 | $desc, |
| 173 | 179 | $nom_champ, |
| 174 | 180 | array($t[1]['id_table'], $nom_champ)); |
| 181 | + } |
|
| 175 | 182 | } |
| 176 | 183 | return array('',''); |
| 177 | 184 | } |
@@ -186,8 +193,9 @@ discard block |
||
| 186 | 193 | function index_exception(&$boucle, $desc, $nom_champ, $excep) |
| 187 | 194 | { |
| 188 | 195 | static $trouver_table; |
| 189 | - if (!$trouver_table) |
|
| 190 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 196 | + if (!$trouver_table) { |
|
| 197 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 198 | + } |
|
| 191 | 199 | |
| 192 | 200 | if (is_array($excep)) { |
| 193 | 201 | // permettre aux plugins de gerer eux meme des jointures derogatoire ingerables |
@@ -200,7 +208,9 @@ discard block |
||
| 200 | 208 | list($e, $x) = $excep; #PHP4 affecte de gauche a droite |
| 201 | 209 | $excep = $x; #PHP5 de droite a gauche ! |
| 202 | 210 | $j = $trouver_table($e, $boucle->sql_serveur); |
| 203 | - if (!$j) return array('',''); |
|
| 211 | + if (!$j) { |
|
| 212 | + return array('',''); |
|
| 213 | + } |
|
| 204 | 214 | $e = $j['table']; |
| 205 | 215 | if (!$t = array_search($e, $boucle->from)) { |
| 206 | 216 | $k = $j['key']['PRIMARY KEY']; |
@@ -217,11 +227,14 @@ discard block |
||
| 217 | 227 | $t = array_search($e, $boucle->from); |
| 218 | 228 | } |
| 219 | 229 | } |
| 230 | + } else { |
|
| 231 | + $t = $boucle->id_table; |
|
| 220 | 232 | } |
| 221 | - else $t = $boucle->id_table; |
|
| 222 | 233 | // demander a SQL de gerer le synonyme |
| 223 | 234 | // ca permet que excep soit dynamique (Cedric, 2/3/06) |
| 224 | - if ($excep != $nom_champ) $excep .= ' AS '. $nom_champ; |
|
| 235 | + if ($excep != $nom_champ) { |
|
| 236 | + $excep .= ' AS '. $nom_champ; |
|
| 237 | + } |
|
| 225 | 238 | return array("$t.$excep", $nom_champ); |
| 226 | 239 | } |
| 227 | 240 | |
@@ -268,16 +281,18 @@ discard block |
||
| 268 | 281 | if ($f = charger_fonction($nom, 'balise', true)) { |
| 269 | 282 | $p->balise_calculee = true; |
| 270 | 283 | $res = $f($p); |
| 271 | - if ($res !== NULL) |
|
| 272 | - return $res; |
|
| 284 | + if ($res !== NULL) { |
|
| 285 | + return $res; |
|
| 286 | + } |
|
| 273 | 287 | } |
| 274 | 288 | |
| 275 | 289 | // Certaines des balises comportant un _ sont generiques |
| 276 | 290 | if ($f = strpos($nom, '_') |
| 277 | 291 | AND $f = charger_fonction(substr($nom,0,$f+1), 'balise', true)) { |
| 278 | 292 | $res = $f($p); |
| 279 | - if ($res !== NULL) |
|
| 280 | - return $res; |
|
| 293 | + if ($res !== NULL) { |
|
| 294 | + return $res; |
|
| 295 | + } |
|
| 281 | 296 | } |
| 282 | 297 | |
| 283 | 298 | $f = charger_fonction('DEFAUT', 'calculer_balise'); |
@@ -298,8 +313,9 @@ discard block |
||
| 298 | 313 | } |
| 299 | 314 | |
| 300 | 315 | // ne pas passer le filtre securite sur les id_xxx |
| 301 | - if (strpos($nom, 'ID_') === 0) |
|
| 302 | - $p->interdire_scripts = false; |
|
| 316 | + if (strpos($nom, 'ID_') === 0) { |
|
| 317 | + $p->interdire_scripts = false; |
|
| 318 | + } |
|
| 303 | 319 | |
| 304 | 320 | // Compatibilite ascendante avec les couleurs html (#FEFEFE) : |
| 305 | 321 | // SI le champ SQL n'est pas trouve |
@@ -349,7 +365,9 @@ discard block |
||
| 349 | 365 | array_shift($c); |
| 350 | 366 | // construire la liste d'arguments comme pour un filtre |
| 351 | 367 | $param = compose_filtres_args($p, $c, ','); |
| 352 | - } else $param = ""; |
|
| 368 | + } else { |
|
| 369 | + $param = ""; |
|
| 370 | + } |
|
| 353 | 371 | $collecte = collecter_balise_dynamique($l, $p, $nom); |
| 354 | 372 | |
| 355 | 373 | $p->code = sprintf(CODE_EXECUTER_BALISE, $nom, |
@@ -440,16 +458,17 @@ discard block |
||
| 440 | 458 | function champs_traitements ($p) { |
| 441 | 459 | global $table_des_traitements; |
| 442 | 460 | |
| 443 | - if (isset($table_des_traitements[$p->nom_champ])) |
|
| 444 | - $ps = $table_des_traitements[$p->nom_champ]; |
|
| 445 | - else { |
|
| 461 | + if (isset($table_des_traitements[$p->nom_champ])) { |
|
| 462 | + $ps = $table_des_traitements[$p->nom_champ]; |
|
| 463 | + } else { |
|
| 446 | 464 | // quand on utilise un traitement catch-all * |
| 447 | 465 | // celui-ci ne s'applique pas sur les balises calculees qui peuvent gerer |
| 448 | 466 | // leur propre securite |
| 449 | - if (!$p->balise_calculee) |
|
| 450 | - $ps = $table_des_traitements['*']; |
|
| 451 | - else |
|
| 452 | - $ps = false; |
|
| 467 | + if (!$p->balise_calculee) { |
|
| 468 | + $ps = $table_des_traitements['*']; |
|
| 469 | + } else { |
|
| 470 | + $ps = false; |
|
| 471 | + } |
|
| 453 | 472 | } |
| 454 | 473 | |
| 455 | 474 | if (is_array($ps)) { |
@@ -460,19 +479,24 @@ discard block |
||
| 460 | 479 | $table_sql = isset($p->boucles[$idb]->show['table_sql'])?$p->boucles[$idb]->show['table_sql']:false; |
| 461 | 480 | |
| 462 | 481 | // le traitement peut n'etre defini que pour une table en particulier "spip_articles" |
| 463 | - if ($table_sql AND isset($ps[$table_sql])) |
|
| 464 | - $ps = $ps[$table_sql]; |
|
| 482 | + if ($table_sql AND isset($ps[$table_sql])) { |
|
| 483 | + $ps = $ps[$table_sql]; |
|
| 484 | + } |
|
| 465 | 485 | // ou pour une boucle en particulier "DATA","articles" |
| 466 | - elseif ($type_requete AND isset($ps[$type_requete])) |
|
| 467 | - $ps = $ps[$type_requete]; |
|
| 486 | + elseif ($type_requete AND isset($ps[$type_requete])) { |
|
| 487 | + $ps = $ps[$type_requete]; |
|
| 488 | + } |
|
| 468 | 489 | // ou pour indiferrement quelle que soit la boucle |
| 469 | - elseif(isset($ps[0])) |
|
| 470 | - $ps = $ps[0]; |
|
| 471 | - else |
|
| 472 | - $ps=false; |
|
| 490 | + elseif(isset($ps[0])) { |
|
| 491 | + $ps = $ps[0]; |
|
| 492 | + } else { |
|
| 493 | + $ps=false; |
|
| 494 | + } |
|
| 473 | 495 | } |
| 474 | 496 | |
| 475 | - if (!$ps) return $p->code; |
|
| 497 | + if (!$ps) { |
|
| 498 | + return $p->code; |
|
| 499 | + } |
|
| 476 | 500 | |
| 477 | 501 | // Si une boucle DOCUMENTS{doublons} est presente dans le squelette, |
| 478 | 502 | // ou si in INCLURE contient {doublons} |
@@ -487,8 +511,9 @@ discard block |
||
| 487 | 511 | (strpos($ps,'propre') !== false) |
| 488 | 512 | OR |
| 489 | 513 | (strpos($ps,'typo') !== false) |
| 490 | - )) |
|
| 491 | - $ps = 'traiter_doublons_documents($doublons, '.$ps.')'; |
|
| 514 | + )) { |
|
| 515 | + $ps = 'traiter_doublons_documents($doublons, '.$ps.')'; |
|
| 516 | + } |
|
| 492 | 517 | |
| 493 | 518 | // La protection des champs par |safehtml est assuree par les extensions |
| 494 | 519 | // dans la declaration des traitements des champs sensibles |
@@ -508,19 +533,22 @@ discard block |
||
| 508 | 533 | function applique_filtres($p) { |
| 509 | 534 | |
| 510 | 535 | // Traitements standards (cf. supra) |
| 511 | - if ($p->etoile == '') |
|
| 512 | - $code = champs_traitements($p); |
|
| 513 | - else |
|
| 514 | - $code = $p->code; |
|
| 536 | + if ($p->etoile == '') { |
|
| 537 | + $code = champs_traitements($p); |
|
| 538 | + } else { |
|
| 539 | + $code = $p->code; |
|
| 540 | + } |
|
| 515 | 541 | |
| 516 | 542 | // Appliquer les filtres perso |
| 517 | - if ($p->param) |
|
| 518 | - $code = compose_filtres($p, $code); |
|
| 543 | + if ($p->param) { |
|
| 544 | + $code = compose_filtres($p, $code); |
|
| 545 | + } |
|
| 519 | 546 | |
| 520 | 547 | // S'il y a un lien avec la session, ajouter un code qui levera |
| 521 | 548 | // un drapeau dans la structure d'invalidation $Cache |
| 522 | - if (isset($p->descr['session'])) |
|
| 523 | - $code = "invalideur_session(\$Cache, $code)"; |
|
| 549 | + if (isset($p->descr['session'])) { |
|
| 550 | + $code = "invalideur_session(\$Cache, $code)"; |
|
| 551 | + } |
|
| 524 | 552 | |
| 525 | 553 | $code = sandbox_composer_interdire_scripts($code, $p); |
| 526 | 554 | return $code; |
@@ -533,7 +561,10 @@ discard block |
||
| 533 | 561 | $image_miette = false; |
| 534 | 562 | foreach($p->param as $filtre) { |
| 535 | 563 | $fonc = array_shift($filtre); |
| 536 | - if (!$fonc) continue; // normalement qu'au premier tour. |
|
| 564 | + if (!$fonc) { |
|
| 565 | + continue; |
|
| 566 | + } |
|
| 567 | + // normalement qu'au premier tour. |
|
| 537 | 568 | $is_filtre_image = ((substr($fonc,0,6)=='image_') AND $fonc!='image_graver'); |
| 538 | 569 | if ($image_miette AND !$is_filtre_image){ |
| 539 | 570 | // il faut graver maintenant car apres le filtre en cours |
@@ -547,21 +578,25 @@ discard block |
||
| 547 | 578 | $sep = ','; |
| 548 | 579 | } else {$sep = ':'; |
| 549 | 580 | // |?{a,b} *doit* avoir exactement 2 arguments ; on les force |
| 550 | - if (count($filtre) != 2) |
|
| 551 | - $filtre = array(isset($filtre[0])?$filtre[0]:"", isset($filtre[1])?$filtre[1]:""); |
|
| 581 | + if (count($filtre) != 2) { |
|
| 582 | + $filtre = array(isset($filtre[0])?$filtre[0]:"", isset($filtre[1])?$filtre[1]:""); |
|
| 583 | + } |
|
| 552 | 584 | } |
| 553 | 585 | $arglist = compose_filtres_args($p, $filtre, $sep); |
| 554 | 586 | $logique = filtre_logique($fonc, $code, substr($arglist,1)); |
| 555 | - if ($logique) |
|
| 556 | - $code = $logique; |
|
| 557 | - else { |
|
| 587 | + if ($logique) { |
|
| 588 | + $code = $logique; |
|
| 589 | + } else { |
|
| 558 | 590 | $code = sandbox_composer_filtre($fonc,$code,$arglist,$p); |
| 559 | - if ($is_filtre_image) $image_miette = true; |
|
| 591 | + if ($is_filtre_image) { |
|
| 592 | + $image_miette = true; |
|
| 593 | + } |
|
| 560 | 594 | } |
| 561 | 595 | } |
| 562 | 596 | // ramasser les images intermediaires inutiles et graver l'image finale |
| 563 | - if ($image_miette) |
|
| 564 | - $code = "filtrer('image_graver',$code)"; |
|
| 597 | + if ($image_miette) { |
|
| 598 | + $code = "filtrer('image_graver',$code)"; |
|
| 599 | + } |
|
| 565 | 600 | |
| 566 | 601 | return $code; |
| 567 | 602 | } |
@@ -650,8 +685,9 @@ discard block |
||
| 650 | 685 | } |
| 651 | 686 | |
| 652 | 687 | // si on est hors d'une boucle de {recherche}, cette balise est vide |
| 653 | - if (!$p->code) |
|
| 654 | - $p->code = "''"; |
|
| 688 | + if (!$p->code) { |
|
| 689 | + $p->code = "''"; |
|
| 690 | + } |
|
| 655 | 691 | |
| 656 | 692 | $p->interdire_scripts = false; |
| 657 | 693 | return $p; |
@@ -11,7 +11,9 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | |
| 14 | -if (!defined("_ECRIRE_INC_VERSION")) return; |
|
| 14 | +if (!defined("_ECRIRE_INC_VERSION")) { |
|
| 15 | + return; |
|
| 16 | +} |
|
| 15 | 17 | |
| 16 | 18 | /** |
| 17 | 19 | * Fonction Page automatique a partir de contenu/xx |
@@ -38,8 +40,7 @@ discard block |
||
| 38 | 40 | $page = 'exec'; |
| 39 | 41 | $echafauder = charger_fonction('echafauder','prive',true); |
| 40 | 42 | define('_ZCORE_EXCLURE_PATH',''); |
| 41 | - } |
|
| 42 | - else { |
|
| 43 | + } else { |
|
| 43 | 44 | $prefix_path = ""; |
| 44 | 45 | $prefix_length = 0; |
| 45 | 46 | $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
@@ -78,8 +79,9 @@ discard block |
||
| 78 | 79 | } |
| 79 | 80 | if ($prepend){ |
| 80 | 81 | $squelette = substr(find_in_path($prefix_path.$prepend."$fond.$ext"), 0, - strlen(".$ext")); |
| 81 | - if ($squelette) |
|
| 82 | - $flux['data'] = $squelette; |
|
| 82 | + if ($squelette) { |
|
| 83 | + $flux['data'] = $squelette; |
|
| 84 | + } |
|
| 83 | 85 | } |
| 84 | 86 | |
| 85 | 87 | // gerer les squelettes non trouves |
@@ -95,11 +97,13 @@ discard block |
||
| 95 | 97 | // si on est sur un ?page=XX non trouve |
| 96 | 98 | // se brancher sur contenu/xx si il existe |
| 97 | 99 | // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
| 98 | - if (!isset($disponible[$fond])) |
|
| 99 | - $disponible[$fond] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,$fond,$ext,$echafauder); |
|
| 100 | + if (!isset($disponible[$fond])) { |
|
| 101 | + $disponible[$fond] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,$fond,$ext,$echafauder); |
|
| 102 | + } |
|
| 100 | 103 | |
| 101 | - if ($disponible[$fond]) |
|
| 102 | - $flux['data'] = substr(find_in_path($prefix_path."page.$ext"), 0, - strlen(".$ext")); |
|
| 104 | + if ($disponible[$fond]) { |
|
| 105 | + $flux['data'] = substr(find_in_path($prefix_path."page.$ext"), 0, - strlen(".$ext")); |
|
| 106 | + } |
|
| 103 | 107 | } |
| 104 | 108 | |
| 105 | 109 | // echafaudage : |
@@ -107,22 +111,22 @@ discard block |
||
| 107 | 111 | // generer un fond automatique a la volee pour les webmestres |
| 108 | 112 | elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu)+1)==0){ |
| 109 | 113 | $type = substr($fond,strlen($z_contenu)+1); |
| 110 | - if (($type=='page') AND isset($flux['args']['contexte'][$page])) |
|
| 111 | - $type = $flux['args']['contexte'][$page]; |
|
| 112 | - if (!isset($disponible[$type])) |
|
| 113 | - $disponible[$type] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,$type,$ext,$echafauder); |
|
| 114 | + if (($type=='page') AND isset($flux['args']['contexte'][$page])) { |
|
| 115 | + $type = $flux['args']['contexte'][$page]; |
|
| 116 | + } |
|
| 117 | + if (!isset($disponible[$type])) { |
|
| 118 | + $disponible[$type] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,$type,$ext,$echafauder); |
|
| 119 | + } |
|
| 114 | 120 | if (is_string($disponible[$type])) { |
| 115 | 121 | $flux['data'] = $disponible[$type]; |
| 116 | - } |
|
| 117 | - elseif ($echafauder |
|
| 122 | + } elseif ($echafauder |
|
| 118 | 123 | AND include_spip('inc/autoriser') |
| 119 | 124 | AND isset($GLOBALS['visiteur_session']['statut']) // performance |
| 120 | 125 | AND autoriser('echafauder',$type) |
| 121 | 126 | AND $is = $disponible[$type] |
| 122 | 127 | AND is_array($is)) { |
| 123 | 128 | $flux['data'] = $echafauder($type,$is[0],$is[1],$is[2],$ext); |
| 124 | - } |
|
| 125 | - else{ |
|
| 129 | + } else{ |
|
| 126 | 130 | $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,'404',$ext,$echafauder)); |
| 127 | 131 | } |
| 128 | 132 | } |
@@ -136,12 +140,15 @@ discard block |
||
| 136 | 140 | AND $dir !== $z_contenu |
| 137 | 141 | AND in_array($dir,$z_blocs)){ |
| 138 | 142 | $type = substr($fond,strlen("$dir/")); |
| 139 | - if (($type=='page') AND isset($flux['args']['contexte'][$page])) |
|
| 140 | - $type = $flux['args']['contexte'][$page]; |
|
| 141 | - if ($type!=='page' AND !isset($disponible[$type])) |
|
| 142 | - $disponible[$type] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,$type,$ext,$echafauder); |
|
| 143 | - if ($type=='page' OR $disponible[$type]) |
|
| 144 | - $flux['data'] = z_trouver_bloc($prefix_path.$prepend,$dir,'dist',$ext); |
|
| 143 | + if (($type=='page') AND isset($flux['args']['contexte'][$page])) { |
|
| 144 | + $type = $flux['args']['contexte'][$page]; |
|
| 145 | + } |
|
| 146 | + if ($type!=='page' AND !isset($disponible[$type])) { |
|
| 147 | + $disponible[$type] = z_contenu_disponible($prefix_path.$prepend,$z_contenu,$type,$ext,$echafauder); |
|
| 148 | + } |
|
| 149 | + if ($type=='page' OR $disponible[$type]) { |
|
| 150 | + $flux['data'] = z_trouver_bloc($prefix_path.$prepend,$dir,'dist',$ext); |
|
| 151 | + } |
|
| 145 | 152 | } |
| 146 | 153 | } |
| 147 | 154 | $squelette = $flux['data']; |
@@ -158,10 +165,10 @@ discard block |
||
| 158 | 165 | AND file_exists(($f=$squelette."-".$flux['args']['contexte']['type-page']."-".$flux['args']['contexte']['composition']).".$ext")) |
| 159 | 166 | OR |
| 160 | 167 | file_exists(($f=$squelette."-".$flux['args']['contexte']['type-page']).".$ext") |
| 161 | - )) |
|
| 162 | - $flux['data'] = $f; |
|
| 163 | - } |
|
| 164 | - elseif ($fond=='structure' |
|
| 168 | + )) { |
|
| 169 | + $flux['data'] = $f; |
|
| 170 | + } |
|
| 171 | + } elseif ($fond=='structure' |
|
| 165 | 172 | AND z_sanitize_var_zajax() |
| 166 | 173 | AND $f = find_in_path($prefix_path.$prepend.'ajax'.".$ext")) { |
| 167 | 174 | $flux['data'] = substr($f,0,-strlen(".$ext")); |
@@ -187,8 +194,9 @@ discard block |
||
| 187 | 194 | * @return array |
| 188 | 195 | */ |
| 189 | 196 | function z_blocs($espace_prive=false) { |
| 190 | - if ($espace_prive) |
|
| 191 | - return (isset($GLOBALS['z_blocs_ecrire'])?$GLOBALS['z_blocs_ecrire']:array('contenu','navigation','extra','head','hierarchie','top')); |
|
| 197 | + if ($espace_prive) { |
|
| 198 | + return (isset($GLOBALS['z_blocs_ecrire'])?$GLOBALS['z_blocs_ecrire']:array('contenu','navigation','extra','head','hierarchie','top')); |
|
| 199 | + } |
|
| 192 | 200 | return (isset($GLOBALS['z_blocs'])?$GLOBALS['z_blocs']:array('contenu')); |
| 193 | 201 | } |
| 194 | 202 | |
@@ -204,15 +212,17 @@ discard block |
||
| 204 | 212 | * @return mixed |
| 205 | 213 | */ |
| 206 | 214 | function z_contenu_disponible($prefix_path,$z_contenu,$type,$ext,$echafauder=true){ |
| 207 | - if ($d = z_trouver_bloc($prefix_path,$z_contenu,$type,$ext)) |
|
| 208 | - return $d; |
|
| 215 | + if ($d = z_trouver_bloc($prefix_path,$z_contenu,$type,$ext)) { |
|
| 216 | + return $d; |
|
| 217 | + } |
|
| 209 | 218 | return $echafauder?z_echafaudable($type):false; |
| 210 | 219 | } |
| 211 | 220 | |
| 212 | 221 | function z_fond_valide($squelette){ |
| 213 | 222 | if (!_ZCORE_EXCLURE_PATH |
| 214 | - OR !preg_match(',('._ZCORE_EXCLURE_PATH.')/,',$squelette)) |
|
| 215 | - return true; |
|
| 223 | + OR !preg_match(',('._ZCORE_EXCLURE_PATH.')/,',$squelette)) { |
|
| 224 | + return true; |
|
| 225 | + } |
|
| 216 | 226 | return false; |
| 217 | 227 | } |
| 218 | 228 | |
@@ -252,34 +262,37 @@ discard block |
||
| 252 | 262 | function z_echafaudable($type){ |
| 253 | 263 | static $pages = null; |
| 254 | 264 | static $echafaudable = array(); |
| 255 | - if (isset($echafaudable[$type])) |
|
| 256 | - return $echafaudable[$type]; |
|
| 257 | - if (preg_match(',[^\w],',$type)) |
|
| 258 | - return $echafaudable[$type] = false; |
|
| 265 | + if (isset($echafaudable[$type])) { |
|
| 266 | + return $echafaudable[$type]; |
|
| 267 | + } |
|
| 268 | + if (preg_match(',[^\w],',$type)) { |
|
| 269 | + return $echafaudable[$type] = false; |
|
| 270 | + } |
|
| 259 | 271 | |
| 260 | 272 | if (test_espace_prive()){ |
| 261 | - if (!function_exists('trouver_objet_exec')) |
|
| 262 | - include_spip('inc/pipelines_ecrire'); |
|
| 273 | + if (!function_exists('trouver_objet_exec')) { |
|
| 274 | + include_spip('inc/pipelines_ecrire'); |
|
| 275 | + } |
|
| 263 | 276 | if ($e=trouver_objet_exec($type)){ |
| 264 | 277 | return $echafaudable[$type] = array($e['table'],$e['table_objet_sql'],$e); |
| 265 | - } |
|
| 266 | - else { |
|
| 278 | + } else { |
|
| 267 | 279 | // peut etre c'est un exec=types qui liste tous les objets "type" |
| 268 | 280 | if (($t=objet_type($type,false))!==$type |
| 269 | 281 | AND $e=trouver_objet_exec($t)){ |
| 270 | 282 | return $echafaudable[$type] = array($e['table'],$e['table_objet_sql'],$t); |
| 271 | 283 | } |
| 272 | 284 | } |
| 273 | - } |
|
| 274 | - else { |
|
| 285 | + } else { |
|
| 275 | 286 | if (is_null($pages)) { |
| 276 | 287 | $pages = array(); |
| 277 | 288 | $liste = lister_tables_objets_sql(); |
| 278 | - foreach($liste as $t=>$d) |
|
| 279 | - if ($d['page']) $pages[$d['page']] = array($d['table_objet'],$t); |
|
| 289 | + foreach($liste as $t=>$d) { |
|
| 290 | + if ($d['page']) $pages[$d['page']] = array($d['table_objet'],$t); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + if (!isset($pages[$type])) { |
|
| 294 | + return $echafaudable[$type] = false; |
|
| 280 | 295 | } |
| 281 | - if (!isset($pages[$type])) |
|
| 282 | - return $echafaudable[$type] = false; |
|
| 283 | 296 | if (count($pages[$type])==2){ |
| 284 | 297 | $trouver_table = charger_fonction('trouver_table','base'); |
| 285 | 298 | $pages[$type][] = $trouver_table(reset($pages[$type])); |
@@ -310,15 +323,16 @@ discard block |
||
| 310 | 323 | $type = $desc_exec['type']; |
| 311 | 324 | $primary = $desc_exec['id_table_objet']; |
| 312 | 325 | |
| 313 | - if ($desc_exec['edition']===false) |
|
| 314 | - $fond = "objet"; |
|
| 315 | - else { |
|
| 326 | + if ($desc_exec['edition']===false) { |
|
| 327 | + $fond = "objet"; |
|
| 328 | + } else { |
|
| 316 | 329 | $trouver_table = charger_fonction('trouver_table','base'); |
| 317 | 330 | $desc = $trouver_table($table_sql); |
| 318 | - if (isset($desc['field']['id_rubrique'])) |
|
| 319 | - $fond = 'objet_edit'; |
|
| 320 | - else |
|
| 321 | - $fond = 'objet_edit.sans_rubrique'; |
|
| 331 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 332 | + $fond = 'objet_edit'; |
|
| 333 | + } else { |
|
| 334 | + $fond = 'objet_edit.sans_rubrique'; |
|
| 335 | + } |
|
| 322 | 336 | } |
| 323 | 337 | $dir = z_blocs(test_espace_prive()); |
| 324 | 338 | $dir = reset($dir); |
@@ -350,7 +364,9 @@ discard block |
||
| 350 | 364 | */ |
| 351 | 365 | function z_sanitize_var_zajax(){ |
| 352 | 366 | $z_ajax = _request('var_zajax'); |
| 353 | - if (!$z_ajax) return false; |
|
| 367 | + if (!$z_ajax) { |
|
| 368 | + return false; |
|
| 369 | + } |
|
| 354 | 370 | if (!$z_blocs = z_blocs(test_espace_prive()) |
| 355 | 371 | OR !in_array($z_ajax,$z_blocs)) { |
| 356 | 372 | set_request('var_zajax'); // enlever cette demande incongrue |
@@ -10,22 +10,28 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | function format_boucle_html ($avant, $nom, $type, $crit, $corps, $apres, $altern, $prof) |
| 16 | 18 | { |
| 17 | 19 | $avant = $avant ? "<B$nom>$avant" : ""; |
| 18 | 20 | $apres = $apres ? "$apres</B$nom>" : ""; |
| 19 | 21 | $altern = $altern ? "$altern<//B$nom>" : ""; |
| 20 | - if (!$corps) $corps = " />"; else $corps = ">$corps</BOUCLE$nom>"; |
|
| 22 | + if (!$corps) { |
|
| 23 | + $corps = " />"; |
|
| 24 | + } else { |
|
| 25 | + $corps = ">$corps</BOUCLE$nom>"; |
|
| 26 | + } |
|
| 21 | 27 | return "$avant<BOUCLE$nom($type)$crit$corps$apres$altern"; |
| 22 | 28 | } |
| 23 | 29 | |
| 24 | 30 | function format_inclure_html ($file, $args, $prof) |
| 25 | 31 | { |
| 26 | - if (strpos($file, '#')===false) |
|
| 27 | - $t = $file ? ("(" . $file . ")") : "" ; |
|
| 28 | - else { |
|
| 32 | + if (strpos($file, '#')===false) { |
|
| 33 | + $t = $file ? ("(" . $file . ")") : "" ; |
|
| 34 | + } else { |
|
| 29 | 35 | $t = "{fond=" . $file . '}'; |
| 30 | 36 | } |
| 31 | 37 | $args = !$args ? '' : ("{" . join(", ",$args) . "}"); |
@@ -35,14 +41,17 @@ discard block |
||
| 35 | 41 | function format_polyglotte_html ($args, $prof) |
| 36 | 42 | { |
| 37 | 43 | $contenu = array(); |
| 38 | - foreach($args as $l=>$t) |
|
| 39 | - $contenu[]= ($l ? "[$l]" : '') . $t; |
|
| 44 | + foreach($args as $l=>$t) { |
|
| 45 | + $contenu[]= ($l ? "[$l]" : '') . $t; |
|
| 46 | + } |
|
| 40 | 47 | return ("<multi>" . join(" ", $contenu) . "</multi>"); |
| 41 | 48 | } |
| 42 | 49 | |
| 43 | 50 | function format_idiome_html ($nom, $module, $args, $filtres, $prof) |
| 44 | 51 | { |
| 45 | - foreach ($args as $k => $v) $args[$k] = "$k=$v"; |
|
| 52 | + foreach ($args as $k => $v) { |
|
| 53 | + $args[$k] = "$k=$v"; |
|
| 54 | + } |
|
| 46 | 55 | $args = (!$args ? '' : ('{' . join(',', $args) . '}')); |
| 47 | 56 | return ("<:" . ($module ? "$module:" : "") . $nom . $args . $filtres . ":>"); |
| 48 | 57 | } |
@@ -72,8 +81,9 @@ discard block |
||
| 72 | 81 | list($type, $valeur) = $operande; |
| 73 | 82 | if ($type == 'champ' AND $valeur[0]=='[') { |
| 74 | 83 | $valeur = substr($valeur,1,-1); |
| 75 | - if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) |
|
| 76 | - $valeur = substr($valeur,1,-1); |
|
| 84 | + if (preg_match(',^[(](#[^|]*)[)]$,sS', $valeur)) { |
|
| 85 | + $valeur = substr($valeur,1,-1); |
|
| 86 | + } |
|
| 77 | 87 | } |
| 78 | 88 | $crit_s .= $valeur; |
| 79 | 89 | } |
@@ -94,21 +104,27 @@ discard block |
||
| 94 | 104 | for($i=0; $i < count($args)-1; $i++) { |
| 95 | 105 | list($texte, $type) = $args[$i]; |
| 96 | 106 | list($texte2, $type2) = $args[$i+1]; |
| 97 | - if (!$texte OR !$texte2) continue; |
|
| 107 | + if (!$texte OR !$texte2) { |
|
| 108 | + continue; |
|
| 109 | + } |
|
| 98 | 110 | $c1 = substr($texte,-1); |
| 99 | 111 | if ($type2 !== 'texte') { |
| 100 | 112 | // si un texte se termine par ( et est suivi d'un champ |
| 101 | 113 | // ou assimiles, forcer la notation pleine |
| 102 | - if ($c1 == '(' AND substr($texte2,0,1) == '#') |
|
| 103 | - $args[$i+1][0] = '[(' . $texte2 . ')]'; |
|
| 114 | + if ($c1 == '(' AND substr($texte2,0,1) == '#') { |
|
| 115 | + $args[$i+1][0] = '[(' . $texte2 . ')]'; |
|
| 116 | + } |
|
| 104 | 117 | } else { |
| 105 | - if ($type == 'texte') continue; |
|
| 118 | + if ($type == 'texte') { |
|
| 119 | + continue; |
|
| 120 | + } |
|
| 106 | 121 | // si un champ ou assimiles est suivi d'un texte |
| 107 | 122 | // et si celui-ci commence par un caractere de champ |
| 108 | 123 | // forcer la notation pleine |
| 109 | 124 | if (($c1 == '}' AND substr(ltrim($texte2),0,1) == '|') |
| 110 | - OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2))) |
|
| 111 | - $args[$i][0] = '[(' . $texte . ')]'; |
|
| 125 | + OR (preg_match('/[\w\d_*]/', $c1) AND preg_match('/^[\w\d_*{|]/', $texte2))) { |
|
| 126 | + $args[$i][0] = '[(' . $texte . ')]'; |
|
| 127 | + } |
|
| 112 | 128 | } |
| 113 | 129 | } |
| 114 | 130 | return join("", array_map('array_shift', $args)); |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | * @package SPIP\Compilateur\Compilation |
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 20 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 21 | + return; |
|
| 22 | +} |
|
| 21 | 23 | |
| 22 | 24 | /** Repérer un code ne calculant rien, meme avec commentaire */ |
| 23 | 25 | define('CODE_MONOTONE', ",^(\n//[^\n]*\n)?\(?'([^'])*'\)?$,"); |
@@ -60,11 +62,15 @@ discard block |
||
| 60 | 62 | function argumenter_inclure($params, $rejet_filtres, $p, &$boucles, $id_boucle, $echap=true, $lang = '', $fond1=false){ |
| 61 | 63 | $l = array(); |
| 62 | 64 | $erreur_p_i_i = ''; |
| 63 | - if (!is_array($params)) return $l; |
|
| 65 | + if (!is_array($params)) { |
|
| 66 | + return $l; |
|
| 67 | + } |
|
| 64 | 68 | foreach($params as $k => $couple) { |
| 65 | 69 | // la liste d'arguments d'inclusion peut se terminer par un filtre |
| 66 | 70 | $filtre = array_shift($couple); |
| 67 | - if ($filtre) break; |
|
| 71 | + if ($filtre) { |
|
| 72 | + break; |
|
| 73 | + } |
|
| 68 | 74 | foreach($couple as $n => $val) { |
| 69 | 75 | $var = $val[0]; |
| 70 | 76 | if ($var->type != 'texte') { |
@@ -73,20 +79,25 @@ discard block |
||
| 73 | 79 | array('param' => $var->nom_champ)); |
| 74 | 80 | erreur_squelette($erreur_p_i_i, $p); |
| 75 | 81 | break; |
| 82 | + } else { |
|
| 83 | + $l[1] = calculer_liste($val, $p->descr, $boucles, $id_boucle); |
|
| 76 | 84 | } |
| 77 | - else $l[1] = calculer_liste($val, $p->descr, $boucles, $id_boucle); |
|
| 78 | 85 | } else { |
| 79 | 86 | preg_match(",^([^=]*)(=?)(.*)$,m", $var->texte,$m); |
| 80 | 87 | $var = $m[1]; |
| 81 | 88 | $auto = false;; |
| 82 | 89 | if ($m[2]) { |
| 83 | 90 | $v = $m[3]; |
| 84 | - if (preg_match(',^[\'"](.*)[\'"]$,', $v, $m)) $v = $m[1]; |
|
| 91 | + if (preg_match(',^[\'"](.*)[\'"]$,', $v, $m)) { |
|
| 92 | + $v = $m[1]; |
|
| 93 | + } |
|
| 85 | 94 | $val[0] = new Texte; |
| 86 | 95 | $val[0]->texte = $v; |
| 87 | 96 | } elseif ($k OR $n OR $fond1) { |
| 88 | 97 | $auto = true; |
| 89 | - } else $var = 1; |
|
| 98 | + } else { |
|
| 99 | + $var = 1; |
|
| 100 | + } |
|
| 90 | 101 | |
| 91 | 102 | if ($var == 'lang') { |
| 92 | 103 | $lang = !$auto |
@@ -96,21 +107,29 @@ discard block |
||
| 96 | 107 | $val = $auto |
| 97 | 108 | ? index_pile($id_boucle, $var, $boucles) |
| 98 | 109 | : calculer_liste($val, $p->descr, $boucles, $id_boucle); |
| 99 | - if ($var !== 1) |
|
| 100 | - $val = ($echap?"\'$var\' => ' . argumenter_squelette(":"'$var' => ") |
|
| 110 | + if ($var !== 1) { |
|
| 111 | + $val = ($echap?"\'$var\' => ' . argumenter_squelette(":"'$var' => ") |
|
| 101 | 112 | . $val . ($echap? ") . '":" "); |
| 102 | - else $val = $echap ? "'.$val.'" : $val; |
|
| 113 | + } else { |
|
| 114 | + $val = $echap ? "'.$val.'" : $val; |
|
| 115 | + } |
|
| 103 | 116 | $l[$var] = $val; |
| 104 | 117 | } |
| 105 | 118 | } |
| 106 | 119 | } |
| 107 | 120 | } |
| 108 | - if ($erreur_p_i_i) return false; |
|
| 121 | + if ($erreur_p_i_i) { |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 109 | 124 | // Cas particulier de la langue : si {lang=xx} est definie, on |
| 110 | 125 | // la passe, sinon on passe la langue courante au moment du calcul |
| 111 | 126 | // sauf si on n'en veut pas |
| 112 | - if ($lang === false) return $l; |
|
| 113 | - if (!$lang) $lang = '$GLOBALS["spip_lang"]'; |
|
| 127 | + if ($lang === false) { |
|
| 128 | + return $l; |
|
| 129 | + } |
|
| 130 | + if (!$lang) { |
|
| 131 | + $lang = '$GLOBALS["spip_lang"]'; |
|
| 132 | + } |
|
| 114 | 133 | $l['lang'] = ($echap?"\'lang\' => ' . argumenter_squelette(":"'lang' => ") . $lang . ($echap?") . '":" "); |
| 115 | 134 | |
| 116 | 135 | return $l; |
@@ -144,9 +163,11 @@ discard block |
||
| 144 | 163 | |
| 145 | 164 | } else { |
| 146 | 165 | $code = calculer_liste($p->texte, $p->descr, $boucles, $id_boucle); |
| 147 | - if ($code AND preg_match("/^'([^']*)'/s", $code, $r)) |
|
| 148 | - $fichier = $r[1]; |
|
| 149 | - else $fichier = ''; |
|
| 166 | + if ($code AND preg_match("/^'([^']*)'/s", $code, $r)) { |
|
| 167 | + $fichier = $r[1]; |
|
| 168 | + } else { |
|
| 169 | + $fichier = ''; |
|
| 170 | + } |
|
| 150 | 171 | } |
| 151 | 172 | if (!$code OR $code === '""') { |
| 152 | 173 | $erreur_p_i_i = array('zbug_parametres_inclus_incorrects', |
@@ -173,9 +194,10 @@ discard block |
||
| 173 | 194 | } |
| 174 | 195 | |
| 175 | 196 | $_contexte = join(",\n\t", $_contexte); |
| 197 | + } else { |
|
| 198 | + return false; |
|
| 176 | 199 | } |
| 177 | - else |
|
| 178 | - return false; // j'aurais voulu toucher le fond ... |
|
| 200 | + // j'aurais voulu toucher le fond ... |
|
| 179 | 201 | |
| 180 | 202 | $contexte = 'array(' . $_contexte .')'; |
| 181 | 203 | |
@@ -188,8 +210,9 @@ discard block |
||
| 188 | 210 | $code = sandbox_composer_inclure_php($fichier, $p, $contexte); |
| 189 | 211 | } else { |
| 190 | 212 | $_options[] = "\"compil\"=>array($compil)"; |
| 191 | - if ($ajax) |
|
| 192 | - $_options[] = $ajax; |
|
| 213 | + if ($ajax) { |
|
| 214 | + $_options[] = $ajax; |
|
| 215 | + } |
|
| 193 | 216 | $code = " ' . argumenter_squelette($code) . '"; |
| 194 | 217 | $code = "echo " . sprintf(CODE_RECUPERER_FOND, $code, $contexte, implode(',',$_options), "_request(\"connect\")") . ';'; |
| 195 | 218 | } |
@@ -270,8 +293,7 @@ discard block |
||
| 270 | 293 | } |
| 271 | 294 | // trouver l'alias de la table d'arrivee qui porte le statut |
| 272 | 295 | $id = array_search($id, $boucle->from); |
| 273 | - } |
|
| 274 | - else { |
|
| 296 | + } else { |
|
| 275 | 297 | $id = $id_table; |
| 276 | 298 | $statut = preg_replace(',\W,','',$s['champ']); // securite |
| 277 | 299 | } |
@@ -325,9 +347,9 @@ discard block |
||
| 325 | 347 | |
| 326 | 348 | // en mode debug memoriser les premiers passages dans la boucle, |
| 327 | 349 | // mais pas tous, sinon ca pete. |
| 328 | - if (_request('var_mode_affiche') != 'resultat') |
|
| 329 | - $trace = ''; |
|
| 330 | - else { |
|
| 350 | + if (_request('var_mode_affiche') != 'resultat') { |
|
| 351 | + $trace = ''; |
|
| 352 | + } else { |
|
| 331 | 353 | $trace = $boucles[$id_boucle]->descr['nom'] . $id_boucle; |
| 332 | 354 | $trace = "if (count(@\$GLOBALS['debug_objets']['resultat']['$trace'])<3) |
| 333 | 355 | \$GLOBALS['debug_objets']['resultat']['$trace'][] = \$t0;"; |
@@ -427,10 +449,11 @@ discard block |
||
| 427 | 449 | |
| 428 | 450 | // faudrait expanser le foreach a la compil, car y en a souvent qu'un |
| 429 | 451 | // et puis faire un [] plutot qu'un "','." |
| 430 | - if ($boucle->doublons) |
|
| 431 | - $corps .= "\n\t\t\tforeach(" . $boucle->doublons . ' as $k) $doublons[$k] .= "," . ' . |
|
| 452 | + if ($boucle->doublons) { |
|
| 453 | + $corps .= "\n\t\t\tforeach(" . $boucle->doublons . ' as $k) $doublons[$k] .= "," . ' . |
|
| 432 | 454 | index_pile($id_boucle, $primary, $boucles) |
| 433 | 455 | . "; // doublons\n"; |
| 456 | + } |
|
| 434 | 457 | |
| 435 | 458 | // La boucle doit-elle selectionner la langue ? |
| 436 | 459 | // - par defaut, les boucles suivantes le font |
@@ -456,8 +479,7 @@ discard block |
||
| 456 | 479 | 'articles', 'rubriques', 'hierarchie', 'breves' |
| 457 | 480 | )) ? ', '.index_pile($id_boucle, 'titre', $boucles) : '') |
| 458 | 481 | . ');'; |
| 459 | - } |
|
| 460 | - else { |
|
| 482 | + } else { |
|
| 461 | 483 | $init_lang = ''; |
| 462 | 484 | $fin_lang = ''; |
| 463 | 485 | $fin_lang_select_public = ''; |
@@ -474,8 +496,9 @@ discard block |
||
| 474 | 496 | } |
| 475 | 497 | |
| 476 | 498 | // gestion optimale des separateurs et des boucles constantes |
| 477 | - if (count($boucle->separateur)) |
|
| 478 | - $code_sep = ("'" . str_replace("'","\'",join('',$boucle->separateur)) . "'"); |
|
| 499 | + if (count($boucle->separateur)) { |
|
| 500 | + $code_sep = ("'" . str_replace("'","\'",join('',$boucle->separateur)) . "'"); |
|
| 501 | + } |
|
| 479 | 502 | |
| 480 | 503 | $corps .= |
| 481 | 504 | ((!$boucle->separateur) ? |
@@ -493,17 +516,19 @@ discard block |
||
| 493 | 516 | // souhaite invalider ces elements |
| 494 | 517 | if (!$constant AND $primary) { |
| 495 | 518 | include_spip('inc/invalideur'); |
| 496 | - if (function_exists($i = 'calcul_invalideurs')) |
|
| 497 | - $corps = $i($corps, $primary, $boucles, $id_boucle); |
|
| 519 | + if (function_exists($i = 'calcul_invalideurs')) { |
|
| 520 | + $corps = $i($corps, $primary, $boucles, $id_boucle); |
|
| 521 | + } |
|
| 498 | 522 | } |
| 499 | 523 | |
| 500 | 524 | // gerer le compteur de boucle |
| 501 | 525 | // avec ou sans son utilisation par les criteres {1/3} {1,4} {n-2,1}... |
| 502 | 526 | |
| 503 | - if ($boucle->partie OR $boucle->cptrows) |
|
| 504 | - $corps = "\n\t\t\$Numrows['$id_boucle']['compteur_boucle']++;" |
|
| 527 | + if ($boucle->partie OR $boucle->cptrows) { |
|
| 528 | + $corps = "\n\t\t\$Numrows['$id_boucle']['compteur_boucle']++;" |
|
| 505 | 529 | . $boucle->partie |
| 506 | 530 | . $corps; |
| 531 | + } |
|
| 507 | 532 | |
| 508 | 533 | // depiler la lang de la boucle si besoin |
| 509 | 534 | $corps .= $fin_lang_select_public; |
@@ -512,28 +537,35 @@ discard block |
||
| 512 | 537 | |
| 513 | 538 | if (preg_match(CODE_MONOTONE,str_replace("\\'",'',$corps), $r)) { |
| 514 | 539 | if (!isset($r[2]) OR (!$r[2])) { |
| 515 | - if (!$boucle->numrows) |
|
| 516 | - return "\n\t\$t0 = '';"; |
|
| 517 | - else |
|
| 518 | - $corps = ""; |
|
| 540 | + if (!$boucle->numrows) { |
|
| 541 | + return "\n\t\$t0 = '';"; |
|
| 542 | + } else { |
|
| 543 | + $corps = ""; |
|
| 544 | + } |
|
| 519 | 545 | } else { |
| 520 | 546 | $boucle->numrows = true; |
| 521 | 547 | $corps = "\n\t\$t0 = str_repeat($corps, \$Numrows['$id_boucle']['total']);"; |
| 522 | 548 | } |
| 523 | - } else $corps = "while (\$Pile[\$SP]=\$iter->fetch()) {\n$corps\n }"; |
|
| 549 | + } else { |
|
| 550 | + $corps = "while (\$Pile[\$SP]=\$iter->fetch()) {\n$corps\n }"; |
|
| 551 | + } |
|
| 524 | 552 | |
| 525 | 553 | $count = ''; |
| 526 | 554 | if (!$boucle->select) { |
| 527 | - if (!$boucle->numrows OR $boucle->limit OR $boucle->mode_partie OR $boucle->group) |
|
| 528 | - $count = '1'; |
|
| 529 | - else $count = 'count(*)'; |
|
| 555 | + if (!$boucle->numrows OR $boucle->limit OR $boucle->mode_partie OR $boucle->group) { |
|
| 556 | + $count = '1'; |
|
| 557 | + } else { |
|
| 558 | + $count = 'count(*)'; |
|
| 559 | + } |
|
| 530 | 560 | $boucles[$id_boucle]->select[]= $count; |
| 531 | 561 | } |
| 532 | 562 | |
| 533 | - if ($flag_cpt) |
|
| 534 | - $nums = "\n\t// COMPTEUR\n\t" |
|
| 563 | + if ($flag_cpt) { |
|
| 564 | + $nums = "\n\t// COMPTEUR\n\t" |
|
| 535 | 565 | . "\$Numrows['$id_boucle']['compteur_boucle'] = 0;\n\t"; |
| 536 | - else $nums = ''; |
|
| 566 | + } else { |
|
| 567 | + $nums = ''; |
|
| 568 | + } |
|
| 537 | 569 | |
| 538 | 570 | if ($boucle->numrows OR $boucle->mode_partie) { |
| 539 | 571 | $nums .= "\$Numrows['$id_boucle']['total'] = @intval(\$iter->count());" |
@@ -600,10 +632,11 @@ discard block |
||
| 600 | 632 | $init[] = calculer_dec('having', calculer_dump_array($boucle->having)); |
| 601 | 633 | $s = $d = ""; |
| 602 | 634 | foreach ($init as $i){ |
| 603 | - if (reset($i)) |
|
| 604 | - $s .= "\n\t\t".end($i); |
|
| 605 | - else |
|
| 606 | - $d .= "\n\t".end($i); |
|
| 635 | + if (reset($i)) { |
|
| 636 | + $s .= "\n\t\t".end($i); |
|
| 637 | + } else { |
|
| 638 | + $d .= "\n\t".end($i); |
|
| 639 | + } |
|
| 607 | 640 | } |
| 608 | 641 | |
| 609 | 642 | return ($boucle->hierarchie ? "\n\t$boucle->hierarchie" : '') |
@@ -654,7 +687,9 @@ discard block |
||
| 654 | 687 | **/ |
| 655 | 688 | function reconstruire_contexte_compil($context_compil) |
| 656 | 689 | { |
| 657 | - if (!is_array($context_compil)) return $context_compil; |
|
| 690 | + if (!is_array($context_compil)) { |
|
| 691 | + return $context_compil; |
|
| 692 | + } |
|
| 658 | 693 | $p = new Contexte; |
| 659 | 694 | $p->descr = array('sourcefile' => $context_compil[0], |
| 660 | 695 | 'nom' => $context_compil[1]); |
@@ -680,8 +715,9 @@ discard block |
||
| 680 | 715 | AND $test = preg_replace(",'[^']*',UimsS","",$test) // supprimer les chaines qui peuvent contenir des fonctions SQL qui ne genent pas |
| 681 | 716 | AND preg_match(",\w+\s*\(,UimsS",$test,$regs) // tester la presence de fonctions restantes |
| 682 | 717 | )*/ |
| 683 | - ) |
|
| 684 | - $static = ""; |
|
| 718 | + ) { |
|
| 719 | + $static = ""; |
|
| 720 | + } |
|
| 685 | 721 | |
| 686 | 722 | return array($static,'$command[\''.$nom.'\'] = ' . $val . ';'); |
| 687 | 723 | } |
@@ -689,15 +725,19 @@ discard block |
||
| 689 | 725 | // http://doc.spip.org/@calculer_dump_array |
| 690 | 726 | function calculer_dump_array($a) |
| 691 | 727 | { |
| 692 | - if (!is_array($a)) return $a ; |
|
| 728 | + if (!is_array($a)) { |
|
| 729 | + return $a ; |
|
| 730 | + } |
|
| 693 | 731 | $res = ""; |
| 694 | - if ($a AND $a[0] == "'?'") |
|
| 695 | - return ("(" . calculer_dump_array($a[1]) . |
|
| 732 | + if ($a AND $a[0] == "'?'") { |
|
| 733 | + return ("(" . calculer_dump_array($a[1]) . |
|
| 696 | 734 | " ? " . calculer_dump_array($a[2]) . |
| 697 | 735 | " : " . calculer_dump_array($a[3]) . |
| 698 | 736 | ")"); |
| 699 | - else { |
|
| 700 | - foreach($a as $v) $res .= ", " . calculer_dump_array($v); |
|
| 737 | + } else { |
|
| 738 | + foreach($a as $v) { |
|
| 739 | + $res .= ", " . calculer_dump_array($v); |
|
| 740 | + } |
|
| 701 | 741 | return "\n\t\t\tarray(" . substr($res,2) . ')'; |
| 702 | 742 | } |
| 703 | 743 | } |
@@ -706,8 +746,9 @@ discard block |
||
| 706 | 746 | function calculer_dump_join($a) |
| 707 | 747 | { |
| 708 | 748 | $res = ""; |
| 709 | - foreach($a as $k => $v) |
|
| 710 | - $res .= ", '$k' => array(".implode(',',$v).")"; |
|
| 749 | + foreach($a as $k => $v) { |
|
| 750 | + $res .= ", '$k' => array(".implode(',',$v).")"; |
|
| 751 | + } |
|
| 711 | 752 | return 'array(' . substr($res,2) . ')'; |
| 712 | 753 | } |
| 713 | 754 | |
@@ -715,7 +756,9 @@ discard block |
||
| 715 | 756 | function calculer_from(&$boucle) |
| 716 | 757 | { |
| 717 | 758 | $res = ""; |
| 718 | - foreach($boucle->from as $k => $v) $res .= ",'$k' => '$v'"; |
|
| 759 | + foreach($boucle->from as $k => $v) { |
|
| 760 | + $res .= ",'$k' => '$v'"; |
|
| 761 | + } |
|
| 719 | 762 | return 'array(' . substr($res,1) . ')'; |
| 720 | 763 | } |
| 721 | 764 | |
@@ -723,7 +766,9 @@ discard block |
||
| 723 | 766 | function calculer_from_type(&$boucle) |
| 724 | 767 | { |
| 725 | 768 | $res = ""; |
| 726 | - foreach($boucle->from_type as $k => $v) $res .= ",'$k' => '$v'"; |
|
| 769 | + foreach($boucle->from_type as $k => $v) { |
|
| 770 | + $res .= ",'$k' => '$v'"; |
|
| 771 | + } |
|
| 727 | 772 | return 'array(' . substr($res,1) . ')'; |
| 728 | 773 | } |
| 729 | 774 | |
@@ -731,8 +776,9 @@ discard block |
||
| 731 | 776 | function calculer_order(&$boucle) |
| 732 | 777 | { |
| 733 | 778 | if (!$order = $boucle->order |
| 734 | - AND !$order = $boucle->default_order) |
|
| 735 | - $order = array(); |
|
| 779 | + AND !$order = $boucle->default_order) { |
|
| 780 | + $order = array(); |
|
| 781 | + } |
|
| 736 | 782 | |
| 737 | 783 | /*if (isset($boucle->modificateur['collate'])){ |
| 738 | 784 | $col = "." . $boucle->modificateur['collate']; |
@@ -750,23 +796,31 @@ discard block |
||
| 750 | 796 | |
| 751 | 797 | // http://doc.spip.org/@calculer_liste |
| 752 | 798 | function calculer_liste($tableau, $descr, &$boucles, $id_boucle='') { |
| 753 | - if (!$tableau) return "''"; |
|
| 754 | - if (!isset($descr['niv'])) $descr['niv'] = 0; |
|
| 799 | + if (!$tableau) { |
|
| 800 | + return "''"; |
|
| 801 | + } |
|
| 802 | + if (!isset($descr['niv'])) { |
|
| 803 | + $descr['niv'] = 0; |
|
| 804 | + } |
|
| 755 | 805 | $codes = compile_cas($tableau, $descr, $boucles, $id_boucle); |
| 756 | - if ($codes === false) return false; |
|
| 806 | + if ($codes === false) { |
|
| 807 | + return false; |
|
| 808 | + } |
|
| 757 | 809 | $n = count($codes); |
| 758 | - if (!$n) return "''"; |
|
| 810 | + if (!$n) { |
|
| 811 | + return "''"; |
|
| 812 | + } |
|
| 759 | 813 | $tab = str_repeat("\t", $descr['niv']); |
| 760 | 814 | if (_request('var_mode_affiche') != 'validation') { |
| 761 | - if ($n==1) |
|
| 762 | - return $codes[0]; |
|
| 763 | - else { |
|
| 815 | + if ($n==1) { |
|
| 816 | + return $codes[0]; |
|
| 817 | + } else { |
|
| 764 | 818 | $res = ''; |
| 765 | 819 | foreach($codes as $code) { |
| 766 | 820 | if (!preg_match("/^'[^']*'$/", $code) |
| 767 | - OR substr($res,-1,1)!=="'") |
|
| 768 | - $res .= " .\n$tab$code"; |
|
| 769 | - else { |
|
| 821 | + OR substr($res,-1,1)!=="'") { |
|
| 822 | + $res .= " .\n$tab$code"; |
|
| 823 | + } else { |
|
| 770 | 824 | $res = substr($res,0,-1) . substr($code,1); |
| 771 | 825 | } |
| 772 | 826 | } |
@@ -787,8 +841,9 @@ discard block |
||
| 787 | 841 | |
| 788 | 842 | $codes = array(); |
| 789 | 843 | // cas de la boucle recursive |
| 790 | - if (is_array($id_boucle)) |
|
| 791 | - $id_boucle = $id_boucle[0]; |
|
| 844 | + if (is_array($id_boucle)) { |
|
| 845 | + $id_boucle = $id_boucle[0]; |
|
| 846 | + } |
|
| 792 | 847 | $type = !$id_boucle ? '' : $boucles[$id_boucle]->type_requete; |
| 793 | 848 | $tab = str_repeat("\t", ++$descr['niv']); |
| 794 | 849 | $mode = _request('var_mode_affiche'); |
@@ -863,11 +918,16 @@ discard block |
||
| 863 | 918 | $commentaire= "?$nom"; |
| 864 | 919 | if (!$boucles[$nom]->milieu |
| 865 | 920 | AND $boucles[$nom]->type_requete <> TYPE_RECURSIF) { |
| 866 | - if ($altern != "''") $code .= "\n. $altern"; |
|
| 867 | - if ($avant<>"''" OR $apres<>"''") |
|
| 868 | - spip_log("boucle $nom toujours vide, code superflu dans $id"); |
|
| 921 | + if ($altern != "''") { |
|
| 922 | + $code .= "\n. $altern"; |
|
| 923 | + } |
|
| 924 | + if ($avant<>"''" OR $apres<>"''") { |
|
| 925 | + spip_log("boucle $nom toujours vide, code superflu dans $id"); |
|
| 926 | + } |
|
| 869 | 927 | $avant = $apres = $altern = "''"; |
| 870 | - } else if ($altern != "''") $altern = "($altern)"; |
|
| 928 | + } else if ($altern != "''") { |
|
| 929 | + $altern = "($altern)"; |
|
| 930 | + } |
|
| 871 | 931 | } |
| 872 | 932 | break; |
| 873 | 933 | |
@@ -930,8 +990,9 @@ discard block |
||
| 930 | 990 | # AND (strpos($code,'interdire_scripts') !== 0) |
| 931 | 991 | AND !preg_match(_REGEXP_COND_VIDE_NONVIDE, $code) |
| 932 | 992 | AND !preg_match(_REGEXP_COND_NONVIDE_VIDE, $code) |
| 933 | - AND !preg_match(_REGEXP_CONCAT_NON_VIDE, $code)) |
|
| 934 | - $code = "strval($code)"; |
|
| 993 | + AND !preg_match(_REGEXP_CONCAT_NON_VIDE, $code)) { |
|
| 994 | + $code = "strval($code)"; |
|
| 995 | + } |
|
| 935 | 996 | break; |
| 936 | 997 | |
| 937 | 998 | default: |
@@ -962,9 +1023,15 @@ discard block |
||
| 962 | 1023 | // http://doc.spip.org/@compile_retour |
| 963 | 1024 | function compile_retour($code, $avant, $apres, $altern, $tab, $n) |
| 964 | 1025 | { |
| 965 | - if ($avant == "''") $avant = ''; |
|
| 966 | - if ($apres == "''") $apres = ''; |
|
| 967 | - if (!$avant AND !$apres AND ($altern==="''")) return $code; |
|
| 1026 | + if ($avant == "''") { |
|
| 1027 | + $avant = ''; |
|
| 1028 | + } |
|
| 1029 | + if ($apres == "''") { |
|
| 1030 | + $apres = ''; |
|
| 1031 | + } |
|
| 1032 | + if (!$avant AND !$apres AND ($altern==="''")) { |
|
| 1033 | + return $code; |
|
| 1034 | + } |
|
| 968 | 1035 | |
| 969 | 1036 | if (preg_match(_REGEXP_CONCAT_NON_VIDE, $code)) { |
| 970 | 1037 | $t = $code; |
@@ -984,18 +1051,21 @@ discard block |
||
| 984 | 1051 | $t . |
| 985 | 1052 | (!$apres ? "" : " . $apres"); |
| 986 | 1053 | |
| 987 | - if ($res !== $t) $res = "($res)"; |
|
| 1054 | + if ($res !== $t) { |
|
| 1055 | + $res = "($res)"; |
|
| 1056 | + } |
|
| 988 | 1057 | return !$cond ? $res : "($cond ?\n\t$tab$res :\n\t$tab$altern)"; |
| 989 | 1058 | } |
| 990 | 1059 | |
| 991 | 1060 | |
| 992 | 1061 | function compile_inclure_doublons($lexemes) |
| 993 | 1062 | { |
| 994 | - foreach($lexemes as $v) |
|
| 995 | - if($v->type === 'include' AND $v->param) |
|
| 1063 | + foreach($lexemes as $v) { |
|
| 1064 | + if($v->type === 'include' AND $v->param) |
|
| 996 | 1065 | foreach($v->param as $r) |
| 997 | 1066 | if (trim($r[0]) === 'doublons') |
| 998 | 1067 | return true; |
| 1068 | + } |
|
| 999 | 1069 | return false; |
| 1000 | 1070 | } |
| 1001 | 1071 | |
@@ -1023,7 +1093,9 @@ discard block |
||
| 1023 | 1093 | |
| 1024 | 1094 | // rendre inertes les echappements de #[](){}<> |
| 1025 | 1095 | $i = 0; |
| 1026 | - while(false !== strpos($squelette, $inerte = '-INERTE'.$i)) $i++; |
|
| 1096 | + while(false !== strpos($squelette, $inerte = '-INERTE'.$i)) { |
|
| 1097 | + $i++; |
|
| 1098 | + } |
|
| 1027 | 1099 | $squelette = preg_replace_callback(',\\\\([#[()\]{}<>]),', |
| 1028 | 1100 | create_function('$a', "return '$inerte-'.ord(\$a[1]).'-';"), $squelette, -1, $esc); |
| 1029 | 1101 | |
@@ -1041,10 +1113,11 @@ discard block |
||
| 1041 | 1113 | $boucles = compiler_squelette($squelette, $boucles, $nom, $descr, $sourcefile, $connect); |
| 1042 | 1114 | |
| 1043 | 1115 | // restituer les echappements |
| 1044 | - if ($esc) |
|
| 1045 | - foreach($boucles as $i=>$boucle) { |
|
| 1116 | + if ($esc) { |
|
| 1117 | + foreach($boucles as $i=>$boucle) { |
|
| 1046 | 1118 | $boucles[$i]->return = preg_replace_callback(",$inerte-(\d+)-,", create_function('$a', 'return chr($a[1]);'), |
| 1047 | 1119 | $boucle->return); |
| 1120 | + } |
|
| 1048 | 1121 | $boucles[$i]->descr['squelette'] = preg_replace_callback(",$inerte-(\d+)-,", create_function('$a', 'return "\\\\".chr($a[1]);'), |
| 1049 | 1122 | $boucle->descr['squelette']); |
| 1050 | 1123 | } |
@@ -1053,15 +1126,17 @@ discard block |
||
| 1053 | 1126 | if ($debug) { |
| 1054 | 1127 | include_spip('public/decompiler'); |
| 1055 | 1128 | foreach($boucles as $id => $boucle) { |
| 1056 | - if ($id) |
|
| 1057 | - $decomp = "\n/* BOUCLE " . |
|
| 1129 | + if ($id) { |
|
| 1130 | + $decomp = "\n/* BOUCLE " . |
|
| 1058 | 1131 | $boucle->type_requete . |
| 1059 | 1132 | " " . |
| 1060 | 1133 | str_replace('*/', '* /', public_decompiler($boucle, $gram, 0, 'criteres')) . |
| 1061 | 1134 | " */\n"; |
| 1062 | - else $decomp = ("\n/*\n" . |
|
| 1135 | + } else { |
|
| 1136 | + $decomp = ("\n/*\n" . |
|
| 1063 | 1137 | str_replace('*/', '* /', public_decompiler($squelette, $gram)) |
| 1064 | 1138 | . "\n*/"); |
| 1139 | + } |
|
| 1065 | 1140 | $boucles[$id]->return = $decomp .$boucle->return; |
| 1066 | 1141 | $GLOBALS['debug_objets']['code'][$nom.$id] = $boucle->return; |
| 1067 | 1142 | } |
@@ -1081,8 +1156,9 @@ discard block |
||
| 1081 | 1156 | $GLOBALS['debug_objets']['squelette'][$nom] = $descr['squelette']; |
| 1082 | 1157 | $GLOBALS['debug_objets']['sourcefile'][$nom] = $sourcefile; |
| 1083 | 1158 | |
| 1084 | - if (!isset($GLOBALS['debug_objets']['principal'])) |
|
| 1085 | - $GLOBALS['debug_objets']['principal'] = $nom; |
|
| 1159 | + if (!isset($GLOBALS['debug_objets']['principal'])) { |
|
| 1160 | + $GLOBALS['debug_objets']['principal'] = $nom; |
|
| 1161 | + } |
|
| 1086 | 1162 | } |
| 1087 | 1163 | foreach ($boucles as $id => $boucle) { |
| 1088 | 1164 | $GLOBALS['debug_objets']['boucle'][$nom.$id] = $boucle; |
@@ -1093,21 +1169,26 @@ discard block |
||
| 1093 | 1169 | // et reperer si les doublons sont demandes |
| 1094 | 1170 | // pour un inclure ou une boucle document |
| 1095 | 1171 | // c'est utile a la fonction champs_traitements |
| 1096 | - if (!$trouver_table) |
|
| 1097 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1172 | + if (!$trouver_table) { |
|
| 1173 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1174 | + } |
|
| 1098 | 1175 | |
| 1099 | 1176 | foreach($boucles as $id => $boucle) { |
| 1100 | - if (!($type = $boucle->type_requete)) continue; |
|
| 1177 | + if (!($type = $boucle->type_requete)) { |
|
| 1178 | + continue; |
|
| 1179 | + } |
|
| 1101 | 1180 | if (!$descr['documents'] AND ( |
| 1102 | 1181 | (($type == 'documents') AND $boucle->doublons) OR |
| 1103 | 1182 | compile_inclure_doublons($boucle->avant) OR |
| 1104 | 1183 | compile_inclure_doublons($boucle->apres) OR |
| 1105 | 1184 | compile_inclure_doublons($boucle->milieu) OR |
| 1106 | - compile_inclure_doublons($boucle->altern))) |
|
| 1107 | - $descr['documents'] = true; |
|
| 1185 | + compile_inclure_doublons($boucle->altern))) { |
|
| 1186 | + $descr['documents'] = true; |
|
| 1187 | + } |
|
| 1108 | 1188 | if ($type != TYPE_RECURSIF) { |
| 1109 | - if (!$boucles[$id]->sql_serveur AND $connect) |
|
| 1110 | - $boucles[$id]->sql_serveur = $connect; |
|
| 1189 | + if (!$boucles[$id]->sql_serveur AND $connect) { |
|
| 1190 | + $boucles[$id]->sql_serveur = $connect; |
|
| 1191 | + } |
|
| 1111 | 1192 | |
| 1112 | 1193 | // chercher dans les iterateurs du repertoire iterateur/ |
| 1113 | 1194 | if ($g = charger_fonction( |
@@ -1141,18 +1222,20 @@ discard block |
||
| 1141 | 1222 | $boucles[$id]->descr = &$descr; |
| 1142 | 1223 | if ((!$boucles[$id]->jointures) |
| 1143 | 1224 | AND is_array($show['tables_jointures']) |
| 1144 | - AND count($x = $show['tables_jointures'])) |
|
| 1145 | - $boucles[$id]->jointures = $x; |
|
| 1225 | + AND count($x = $show['tables_jointures'])) { |
|
| 1226 | + $boucles[$id]->jointures = $x; |
|
| 1227 | + } |
|
| 1146 | 1228 | if ($boucles[$id]->jointures_explicites){ |
| 1147 | 1229 | $jointures = preg_split("/\s+/",$boucles[$id]->jointures_explicites); |
| 1148 | - while ($j=array_pop($jointures)) |
|
| 1149 | - array_unshift($boucles[$id]->jointures,$j); |
|
| 1230 | + while ($j=array_pop($jointures)) { |
|
| 1231 | + array_unshift($boucles[$id]->jointures,$j); |
|
| 1232 | + } |
|
| 1150 | 1233 | } |
| 1151 | 1234 | } else { |
| 1152 | 1235 | // Pas une erreur si la table est optionnelle |
| 1153 | - if ($boucles[$id]->table_optionnelle) |
|
| 1154 | - $boucles[$id]->type_requete = ''; |
|
| 1155 | - else { |
|
| 1236 | + if ($boucles[$id]->table_optionnelle) { |
|
| 1237 | + $boucles[$id]->type_requete = ''; |
|
| 1238 | + } else { |
|
| 1156 | 1239 | $boucles[$id]->type_requete = false; |
| 1157 | 1240 | $boucle = $boucles[$id]; |
| 1158 | 1241 | $x = (!$boucle->sql_serveur ? '' : |
@@ -1255,7 +1338,9 @@ discard block |
||
| 1255 | 1338 | _q($boucle->sql_serveur) . |
| 1256 | 1339 | ";" . |
| 1257 | 1340 | $f($id, $boucles); |
| 1258 | - } else $req = ("\n\treturn '';"); |
|
| 1341 | + } else { |
|
| 1342 | + $req = ("\n\treturn '';"); |
|
| 1343 | + } |
|
| 1259 | 1344 | |
| 1260 | 1345 | $boucles[$id]->return = |
| 1261 | 1346 | "\n\nfunction BOUCLE" . strtr($id,"-","_") . $nom . |
@@ -1266,7 +1351,9 @@ discard block |
||
| 1266 | 1351 | |
| 1267 | 1352 | // Au final, si le corps ou un critere au moins s'est mal compile |
| 1268 | 1353 | // retourner False, sinon inserer leur decompilation |
| 1269 | - if (is_bool($corps)) return false; |
|
| 1354 | + if (is_bool($corps)) { |
|
| 1355 | + return false; |
|
| 1356 | + } |
|
| 1270 | 1357 | |
| 1271 | 1358 | $principal = "\nfunction " . $nom . '($Cache, $Pile, $doublons=array(), $Numrows=array(), $SP=0) { |
| 1272 | 1359 | ' |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/texte'); |
| 16 | 18 | include_spip('inc/documents'); |
@@ -36,10 +38,13 @@ discard block |
||
| 36 | 38 | $nom = calculer_nom_fonction_squel($squelette, $mime_type, $connect); |
| 37 | 39 | |
| 38 | 40 | // si deja en memoire (INCLURE a repetition) c'est bon. |
| 39 | - if (function_exists($nom)) return $nom; |
|
| 41 | + if (function_exists($nom)) { |
|
| 42 | + return $nom; |
|
| 43 | + } |
|
| 40 | 44 | |
| 41 | - if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') |
|
| 42 | - $GLOBALS['debug_objets']['courant'] = $nom; |
|
| 45 | + if (defined('_VAR_MODE') AND _VAR_MODE == 'debug') { |
|
| 46 | + $GLOBALS['debug_objets']['courant'] = $nom; |
|
| 47 | + } |
|
| 43 | 48 | |
| 44 | 49 | $phpfile = sous_repertoire(_DIR_SKELS,'',false,true) . $nom . '.php'; |
| 45 | 50 | |
@@ -60,7 +65,9 @@ discard block |
||
| 60 | 65 | |
| 61 | 66 | // tester si le eval ci-dessus a mis le squelette en memoire |
| 62 | 67 | |
| 63 | - if (function_exists($nom)) return $nom; |
|
| 68 | + if (function_exists($nom)) { |
|
| 69 | + return $nom; |
|
| 70 | + } |
|
| 64 | 71 | |
| 65 | 72 | // charger le source, si possible, et compiler |
| 66 | 73 | if (lire_fichier ($source, $skel)) { |
@@ -69,7 +76,9 @@ discard block |
||
| 69 | 76 | } |
| 70 | 77 | |
| 71 | 78 | // Ne plus rien faire si le compilateur n'a pas pu operer. |
| 72 | - if (!$skel_code) return false; |
|
| 79 | + if (!$skel_code) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 73 | 82 | |
| 74 | 83 | foreach($skel_code as $id => $boucle) { |
| 75 | 84 | $f = $boucle->return; |
@@ -88,9 +97,9 @@ discard block |
||
| 88 | 97 | |
| 89 | 98 | if ($nom) { |
| 90 | 99 | // Si le code est bon, concatener et mettre en cache |
| 91 | - if (function_exists($nom)) |
|
| 92 | - $code = squelette_traduit($skel, $source, $phpfile, $skel_code); |
|
| 93 | - else { |
|
| 100 | + if (function_exists($nom)) { |
|
| 101 | + $code = squelette_traduit($skel, $source, $phpfile, $skel_code); |
|
| 102 | + } else { |
|
| 94 | 103 | // code semantiquement faux: bug du compilateur |
| 95 | 104 | // $boucle est en fait ici la fct principale du squelette |
| 96 | 105 | $msg = _T('zbug_erreur_compilation'); |
@@ -107,8 +116,9 @@ discard block |
||
| 107 | 116 | // si c'est ce que demande le debusqueur, lui passer la main |
| 108 | 117 | if ($GLOBALS['debug_objets']['sourcefile'] |
| 109 | 118 | AND (_request('var_mode_objet') == $nom) |
| 110 | - AND (_request('var_mode_affiche') == 'code') ) |
|
| 111 | - erreur_squelette(); |
|
| 119 | + AND (_request('var_mode_affiche') == 'code') ) { |
|
| 120 | + erreur_squelette(); |
|
| 121 | + } |
|
| 112 | 122 | } |
| 113 | 123 | return $nom ? $nom : false; |
| 114 | 124 | } |
@@ -118,18 +128,20 @@ discard block |
||
| 118 | 128 | |
| 119 | 129 | // Le dernier index est '' (fonction principale) |
| 120 | 130 | $noms = substr(join (', ', array_keys($boucles)), 0, -2); |
| 121 | - if (CODE_COMMENTE) |
|
| 122 | - $code = " |
|
| 131 | + if (CODE_COMMENTE) { |
|
| 132 | + $code = " |
|
| 123 | 133 | /* |
| 124 | 134 | * Squelette : $sourcefile |
| 125 | 135 | * Date : ".gmdate("D, d M Y H:i:s", @filemtime($sourcefile))." GMT |
| 126 | 136 | * Compile : ".gmdate("D, d M Y H:i:s", time())." GMT |
| 127 | 137 | * " . (!$boucles ? "Pas de boucle" : ("Boucles : " . $noms)) ." |
| 128 | 138 | */ " ; |
| 139 | + } |
|
| 129 | 140 | |
| 130 | 141 | $code = '<'. "?php\n" . $code . join('', $boucles) . "\n?" .'>'; |
| 131 | - if (!defined('_VAR_NOCACHE') OR !_VAR_NOCACHE) |
|
| 132 | - ecrire_fichier($phpfile, $code); |
|
| 142 | + if (!defined('_VAR_NOCACHE') OR !_VAR_NOCACHE) { |
|
| 143 | + ecrire_fichier($phpfile, $code); |
|
| 144 | + } |
|
| 133 | 145 | return $code; |
| 134 | 146 | } |
| 135 | 147 | |
@@ -140,10 +152,13 @@ discard block |
||
| 140 | 152 | // ne verifier la date de mes_fonctions et mes_options qu'une seule fois |
| 141 | 153 | // par hit |
| 142 | 154 | if (is_null($date_change)){ |
| 143 | - if (@file_exists($fonc = 'mes_fonctions.php')) |
|
| 144 | - $date_change = @filemtime($fonc); # compatibilite |
|
| 145 | - if (defined('_FILE_OPTIONS')) |
|
| 146 | - $date_change = max($date_change,@filemtime(_FILE_OPTIONS)); |
|
| 155 | + if (@file_exists($fonc = 'mes_fonctions.php')) { |
|
| 156 | + $date_change = @filemtime($fonc); |
|
| 157 | + } |
|
| 158 | + # compatibilite |
|
| 159 | + if (defined('_FILE_OPTIONS')) { |
|
| 160 | + $date_change = max($date_change,@filemtime(_FILE_OPTIONS)); |
|
| 161 | + } |
|
| 147 | 162 | } |
| 148 | 163 | return ( |
| 149 | 164 | (defined('_VAR_MODE') AND in_array(_VAR_MODE, array('recalcul','preview','debug'))) |
@@ -179,10 +194,11 @@ discard block |
||
| 179 | 194 | # $j = Content-Type, et pas content-TYPE. |
| 180 | 195 | $j = join('-', array_map('ucwords', explode('-', strtolower($r[2])))); |
| 181 | 196 | |
| 182 | - if ($j=='X-Spip-Filtre' AND isset($headers[$j])) |
|
| 183 | - $headers[$j].="|".$r[3]; |
|
| 184 | - else |
|
| 185 | - $headers[$j] = $r[3]; |
|
| 197 | + if ($j=='X-Spip-Filtre' AND isset($headers[$j])) { |
|
| 198 | + $headers[$j].="|".$r[3]; |
|
| 199 | + } else { |
|
| 200 | + $headers[$j] = $r[3]; |
|
| 201 | + } |
|
| 186 | 202 | } |
| 187 | 203 | } |
| 188 | 204 | // S'agit-il d'un resultat constant ou contenant du code php |
@@ -237,8 +253,9 @@ discard block |
||
| 237 | 253 | // http://doc.spip.org/@filtre_introduction_dist |
| 238 | 254 | function filtre_introduction_dist($descriptif, $texte, $longueur, $connect) { |
| 239 | 255 | // Si un descriptif est envoye, on l'utilise directement |
| 240 | - if (strlen($descriptif)) |
|
| 241 | - return propre($descriptif,$connect); |
|
| 256 | + if (strlen($descriptif)) { |
|
| 257 | + return propre($descriptif,$connect); |
|
| 258 | + } |
|
| 242 | 259 | |
| 243 | 260 | // De preference ce qui est marque <intro>...</intro> |
| 244 | 261 | $intro = ''; |
@@ -246,8 +263,9 @@ discard block |
||
| 246 | 263 | while ($fin = strpos($texte, "</intro>")) { |
| 247 | 264 | $zone = substr($texte, 0, $fin); |
| 248 | 265 | $texte = substr($texte, $fin + strlen("</intro>")); |
| 249 | - if ($deb = strpos($zone, "<intro>") OR substr($zone, 0, 7) == "<intro>") |
|
| 250 | - $zone = substr($zone, $deb + 7); |
|
| 266 | + if ($deb = strpos($zone, "<intro>") OR substr($zone, 0, 7) == "<intro>") { |
|
| 267 | + $zone = substr($zone, $deb + 7); |
|
| 268 | + } |
|
| 251 | 269 | $intro .= $zone; |
| 252 | 270 | } |
| 253 | 271 | |
@@ -262,34 +280,39 @@ discard block |
||
| 262 | 280 | // Cependant pour des questions de perfs on coupe quand meme, en prenant |
| 263 | 281 | // large et en se mefiant des tableaux #1323 |
| 264 | 282 | |
| 265 | - if (strlen($intro)) |
|
| 266 | - $texte = $intro; |
|
| 267 | - |
|
| 268 | - else |
|
| 283 | + if (strlen($intro)) { |
|
| 284 | + $texte = $intro; |
|
| 285 | + } else |
|
| 269 | 286 | if (strpos("\n".$texte, "\n|")===false |
| 270 | 287 | AND strlen($texte) > 2.5*$longueur){ |
| 271 | - if (strpos($texte,"<multi")!==false) |
|
| 272 | - $texte = extraire_multi($texte); |
|
| 288 | + if (strpos($texte,"<multi")!==false) { |
|
| 289 | + $texte = extraire_multi($texte); |
|
| 290 | + } |
|
| 273 | 291 | $texte = couper($texte, 2*$longueur); |
| 274 | 292 | } |
| 275 | 293 | |
| 276 | 294 | // ne pas tenir compte des notes |
| 277 | - if ($notes = charger_fonction('notes', 'inc', true)) |
|
| 278 | - $notes('','empiler'); |
|
| 295 | + if ($notes = charger_fonction('notes', 'inc', true)) { |
|
| 296 | + $notes('','empiler'); |
|
| 297 | + } |
|
| 279 | 298 | // Supprimer les modèles avant le propre afin d'éviter qu'ils n'ajoutent du texte indésirable |
| 280 | 299 | // dans l'introduction. |
| 281 | 300 | $texte = supprime_img($texte, ''); |
| 282 | 301 | $texte = propre($texte,$connect); |
| 283 | - if ($notes) |
|
| 284 | - $notes('','depiler'); |
|
| 302 | + if ($notes) { |
|
| 303 | + $notes('','depiler'); |
|
| 304 | + } |
|
| 285 | 305 | |
| 286 | - if (!defined('_INTRODUCTION_SUITE')) define('_INTRODUCTION_SUITE', ' (...)'); |
|
| 306 | + if (!defined('_INTRODUCTION_SUITE')) { |
|
| 307 | + define('_INTRODUCTION_SUITE', ' (...)'); |
|
| 308 | + } |
|
| 287 | 309 | $texte = couper($texte, $longueur, _INTRODUCTION_SUITE); |
| 288 | 310 | |
| 289 | 311 | // et reparagrapher si necessaire (coherence avec le cas descriptif) |
| 290 | - if ($GLOBALS['toujours_paragrapher']) |
|
| 291 | - // Fermer les paragraphes |
|
| 312 | + if ($GLOBALS['toujours_paragrapher']) { |
|
| 313 | + // Fermer les paragraphes |
|
| 292 | 314 | $texte = paragrapher($texte, $GLOBALS['toujours_paragrapher']); |
| 315 | + } |
|
| 293 | 316 | |
| 294 | 317 | return $texte; |
| 295 | 318 | } |
@@ -323,12 +346,13 @@ discard block |
||
| 323 | 346 | // http://doc.spip.org/@argumenter_squelette |
| 324 | 347 | function argumenter_squelette($v) { |
| 325 | 348 | |
| 326 | - if (!is_array($v)) |
|
| 327 | - return "'" . texte_script($v) . "'"; |
|
| 328 | - else { |
|
| 349 | + if (!is_array($v)) { |
|
| 350 | + return "'" . texte_script($v) . "'"; |
|
| 351 | + } else { |
|
| 329 | 352 | $out = array(); |
| 330 | - foreach($v as $k=>$val) |
|
| 331 | - $out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val); |
|
| 353 | + foreach($v as $k=>$val) { |
|
| 354 | + $out [] = argumenter_squelette($k) . '=>' . argumenter_squelette($val); |
|
| 355 | + } |
|
| 332 | 356 | return 'array(' . join(", ", $out) . ')'; |
| 333 | 357 | } |
| 334 | 358 | } |
@@ -347,8 +371,7 @@ discard block |
||
| 347 | 371 | array_unshift($args,$nom); |
| 348 | 372 | // et passer sur la fonction generique pour la suite |
| 349 | 373 | $nomfonction = $nomfonction_generique; |
| 350 | - } |
|
| 351 | - else { |
|
| 374 | + } else { |
|
| 352 | 375 | $msg = array('zbug_balise_inexistante',array('from'=>'CVT','balise'=>$nom)); |
| 353 | 376 | erreur_squelette($msg, $context_compil); |
| 354 | 377 | return ''; |
@@ -359,7 +382,9 @@ discard block |
||
| 359 | 382 | |
| 360 | 383 | $r = !function_exists($f) ? $args : $f($args, $context_compil); |
| 361 | 384 | |
| 362 | - if (!is_array($r)) return $r; |
|
| 385 | + if (!is_array($r)) { |
|
| 386 | + return $r; |
|
| 387 | + } |
|
| 363 | 388 | |
| 364 | 389 | // verifier que la fonction dyn est la, |
| 365 | 390 | // sinon se replier sur la generique si elle existe |
@@ -376,8 +401,9 @@ discard block |
||
| 376 | 401 | } |
| 377 | 402 | } |
| 378 | 403 | |
| 379 | - if (!_DIR_RESTREINT) |
|
| 380 | - $file = _DIR_RESTREINT_ABS . $file; |
|
| 404 | + if (!_DIR_RESTREINT) { |
|
| 405 | + $file = _DIR_RESTREINT_ABS . $file; |
|
| 406 | + } |
|
| 381 | 407 | return synthetiser_balise_dynamique($nomfonction, $r, $file, $context_compil); |
| 382 | 408 | } |
| 383 | 409 | |
@@ -394,8 +420,9 @@ discard block |
||
| 394 | 420 | |
| 395 | 421 | if ($d = @opendir(_DIR_LOGOS)) { |
| 396 | 422 | while($f = readdir($d)) { |
| 397 | - if (preg_match($type, $f, $r)) |
|
| 398 | - $logos[] = $r[1]; |
|
| 423 | + if (preg_match($type, $f, $r)) { |
|
| 424 | + $logos[] = $r[1]; |
|
| 425 | + } |
|
| 399 | 426 | } |
| 400 | 427 | } |
| 401 | 428 | @closedir($d); |
@@ -420,19 +447,22 @@ discard block |
||
| 420 | 447 | function lang_select_public($lang, $lang_select, $titre=null) { |
| 421 | 448 | // Cas 1. forcer_lang = true et pas de critere {lang_select} |
| 422 | 449 | if (isset($GLOBALS['forcer_lang']) AND $GLOBALS['forcer_lang'] |
| 423 | - AND $lang_select !== 'oui') |
|
| 424 | - $lang = $GLOBALS['spip_lang']; |
|
| 450 | + AND $lang_select !== 'oui') { |
|
| 451 | + $lang = $GLOBALS['spip_lang']; |
|
| 452 | + } |
|
| 425 | 453 | |
| 426 | 454 | // Cas 2. l'objet n'a pas de langue definie (ou definie a '') |
| 427 | - elseif (!strlen($lang)) |
|
| 428 | - $lang = $GLOBALS['spip_lang']; |
|
| 455 | + elseif (!strlen($lang)) { |
|
| 456 | + $lang = $GLOBALS['spip_lang']; |
|
| 457 | + } |
|
| 429 | 458 | |
| 430 | 459 | // Cas 3. l'objet est multilingue ! |
| 431 | 460 | elseif ($lang_select !== 'oui' |
| 432 | 461 | AND strlen($titre) > 10 |
| 433 | 462 | AND strpos($titre, '<multi>') !== false |
| 434 | - AND strpos(echappe_html($titre), '<multi>') !== false) |
|
| 435 | - $lang = $GLOBALS['spip_lang']; |
|
| 463 | + AND strpos(echappe_html($titre), '<multi>') !== false) { |
|
| 464 | + $lang = $GLOBALS['spip_lang']; |
|
| 465 | + } |
|
| 436 | 466 | |
| 437 | 467 | // faire un lang_select() eventuellement sur la langue inchangee |
| 438 | 468 | lang_select($lang); |
@@ -448,33 +478,43 @@ discard block |
||
| 448 | 478 | foreach ($envd as $table => $liste) { |
| 449 | 479 | $n = ''; |
| 450 | 480 | foreach(explode(',',$liste) as $val) { |
| 451 | - if ($a = intval($val) AND $val === strval($a)) |
|
| 452 | - $n.= ','.$val; |
|
| 481 | + if ($a = intval($val) AND $val === strval($a)) { |
|
| 482 | + $n.= ','.$val; |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | + if (strlen($n)) { |
|
| 486 | + $envd[$table] = $n; |
|
| 487 | + } else { |
|
| 488 | + unset($envd[$table]); |
|
| 453 | 489 | } |
| 454 | - if (strlen($n)) |
|
| 455 | - $envd[$table] = $n; |
|
| 456 | - else |
|
| 457 | - unset($envd[$table]); |
|
| 458 | 490 | } |
| 459 | 491 | return $envd; |
| 460 | 492 | } |
| 461 | 493 | |
| 462 | 494 | // http://doc.spip.org/@match_self |
| 463 | 495 | function match_self($w){ |
| 464 | - if (is_string($w)) return false; |
|
| 496 | + if (is_string($w)) { |
|
| 497 | + return false; |
|
| 498 | + } |
|
| 465 | 499 | if (is_array($w)) { |
| 466 | - if (in_array(reset($w),array("SELF","SUBSELECT"))) return $w; |
|
| 467 | - foreach(array_filter($w,'is_array') as $sw) |
|
| 468 | - if ($m=match_self($sw)) return $m; |
|
| 500 | + if (in_array(reset($w),array("SELF","SUBSELECT"))) { |
|
| 501 | + return $w; |
|
| 502 | + } |
|
| 503 | + foreach(array_filter($w,'is_array') as $sw) { |
|
| 504 | + if ($m=match_self($sw)) return $m; |
|
| 505 | + } |
|
| 469 | 506 | } |
| 470 | 507 | return false; |
| 471 | 508 | } |
| 472 | 509 | // http://doc.spip.org/@remplace_sous_requete |
| 473 | 510 | function remplace_sous_requete($w,$sousrequete){ |
| 474 | 511 | if (is_array($w)) { |
| 475 | - if (in_array(reset($w),array("SELF","SUBSELECT"))) return $sousrequete; |
|
| 476 | - foreach($w as $k=>$sw) |
|
| 477 | - $w[$k] = remplace_sous_requete($sw,$sousrequete); |
|
| 512 | + if (in_array(reset($w),array("SELF","SUBSELECT"))) { |
|
| 513 | + return $sousrequete; |
|
| 514 | + } |
|
| 515 | + foreach($w as $k=>$sw) { |
|
| 516 | + $w[$k] = remplace_sous_requete($sw,$sousrequete); |
|
| 517 | + } |
|
| 478 | 518 | } |
| 479 | 519 | return $w; |
| 480 | 520 | } |
@@ -483,8 +523,11 @@ discard block |
||
| 483 | 523 | $where_simples = array(); |
| 484 | 524 | $where_sous = array(); |
| 485 | 525 | foreach($where as $k=>$w){ |
| 486 | - if (match_self($w)) $where_sous[$k] = $w; |
|
| 487 | - else $where_simples[$k] = $w; |
|
| 526 | + if (match_self($w)) { |
|
| 527 | + $where_sous[$k] = $w; |
|
| 528 | + } else { |
|
| 529 | + $where_simples[$k] = $w; |
|
| 530 | + } |
|
| 488 | 531 | } |
| 489 | 532 | return array($where_simples,$where_sous); |
| 490 | 533 | } |
@@ -523,10 +566,16 @@ discard block |
||
| 523 | 566 | $menage = false; |
| 524 | 567 | foreach($where as $k => $v) { |
| 525 | 568 | if (is_array($v)){ |
| 526 | - if ((count($v)>=2) && ($v[0]=='REGEXP') && ($v[2]=="'.*'")) $op= false; |
|
| 527 | - elseif ((count($v)>=2) && ($v[0]=='LIKE') && ($v[2]=="'%'")) $op= false; |
|
| 528 | - else $op = $v[0] ? $v[0] : $v; |
|
| 529 | - } else $op = $v; |
|
| 569 | + if ((count($v)>=2) && ($v[0]=='REGEXP') && ($v[2]=="'.*'")) { |
|
| 570 | + $op= false; |
|
| 571 | + } elseif ((count($v)>=2) && ($v[0]=='LIKE') && ($v[2]=="'%'")) { |
|
| 572 | + $op= false; |
|
| 573 | + } else { |
|
| 574 | + $op = $v[0] ? $v[0] : $v; |
|
| 575 | + } |
|
| 576 | + } else { |
|
| 577 | + $op = $v; |
|
| 578 | + } |
|
| 530 | 579 | if ((!$op) OR ($op==1) OR ($op=='0=0')) { |
| 531 | 580 | unset($where[$k]); |
| 532 | 581 | $menage = true; |
@@ -613,13 +662,18 @@ discard block |
||
| 613 | 662 | $cle = $cledef; |
| 614 | 663 | // le format de join est : |
| 615 | 664 | // array(table depart, cle depart [,cle arrivee[,condition optionnelle and ...]]) |
| 616 | - if (count($join[$cle])==2) $join[$cle][] = $join[$cle][1]; |
|
| 617 | - if (count($join[$cle])==3) $join[$cle][] = ''; |
|
| 665 | + if (count($join[$cle])==2) { |
|
| 666 | + $join[$cle][] = $join[$cle][1]; |
|
| 667 | + } |
|
| 668 | + if (count($join[$cle])==3) { |
|
| 669 | + $join[$cle][] = ''; |
|
| 670 | + } |
|
| 618 | 671 | list($t,$c,$carr,$and) = $join[$cle]; |
| 619 | 672 | // si le nom de la jointure n'a pas ete specifiee, on prend Lx avec x sont rang dans la liste |
| 620 | 673 | // pour compat avec ancienne convention |
| 621 | - if (is_numeric($cle)) |
|
| 622 | - $cle = "L$k"; |
|
| 674 | + if (is_numeric($cle)) { |
|
| 675 | + $cle = "L$k"; |
|
| 676 | + } |
|
| 623 | 677 | if (!$menage |
| 624 | 678 | OR isset($afrom[$cle]) |
| 625 | 679 | OR calculer_jointnul($cle, $select) |
@@ -711,9 +765,9 @@ discard block |
||
| 711 | 765 | $as = '/\b'.preg_quote($nfrom[6]).'\s+(AS\s+\w+)\b/'; |
| 712 | 766 | if (preg_match($as,implode(',',$select),$m)){ |
| 713 | 767 | $alias = ""; |
| 768 | + } else { |
|
| 769 | + $alias = ", ".$nfrom[4]." AS $oldcle"; |
|
| 714 | 770 | } |
| 715 | - else |
|
| 716 | - $alias = ", ".$nfrom[4]." AS $oldcle"; |
|
| 717 | 771 | } |
| 718 | 772 | $select = remplacer_jointnul($t . $alias, $select, $e); |
| 719 | 773 | $join = remplacer_jointnul($t, $join, $e); |
@@ -738,17 +792,19 @@ discard block |
||
| 738 | 792 | * @return string |
| 739 | 793 | */ |
| 740 | 794 | function calculer_where_to_string($v, $join = 'AND'){ |
| 741 | - if (empty($v)) |
|
| 742 | - return ''; |
|
| 795 | + if (empty($v)) { |
|
| 796 | + return ''; |
|
| 797 | + } |
|
| 743 | 798 | |
| 744 | 799 | if (!is_array($v)) { |
| 745 | 800 | return $v; |
| 746 | 801 | } else { |
| 747 | 802 | $exp = ""; |
| 748 | - if (strtoupper($join) === 'AND') |
|
| 749 | - return $exp . join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 750 | - else |
|
| 751 | - return $exp . join($join, $v); |
|
| 803 | + if (strtoupper($join) === 'AND') { |
|
| 804 | + return $exp . join(" $join ", array_map('calculer_where_to_string', $v)); |
|
| 805 | + } else { |
|
| 806 | + return $exp . join($join, $v); |
|
| 807 | + } |
|
| 752 | 808 | } |
| 753 | 809 | } |
| 754 | 810 | |
@@ -759,11 +815,15 @@ discard block |
||
| 759 | 815 | function calculer_jointnul($cle, $exp, $equiv='') |
| 760 | 816 | { |
| 761 | 817 | if (!is_array($exp)) { |
| 762 | - if ($equiv) $exp = preg_replace($equiv, '', $exp); |
|
| 818 | + if ($equiv) { |
|
| 819 | + $exp = preg_replace($equiv, '', $exp); |
|
| 820 | + } |
|
| 763 | 821 | return preg_match("/\\b$cle\\./", $exp); |
| 764 | 822 | } else { |
| 765 | 823 | foreach($exp as $v) { |
| 766 | - if (calculer_jointnul($cle, $v, $equiv)) return true; |
|
| 824 | + if (calculer_jointnul($cle, $v, $equiv)) { |
|
| 825 | + return true; |
|
| 826 | + } |
|
| 767 | 827 | } |
| 768 | 828 | return false; |
| 769 | 829 | } |
@@ -776,7 +836,9 @@ discard block |
||
| 776 | 836 | foreach($from as $k=>$v){ |
| 777 | 837 | $from_synth[$k]=$from[$k]; |
| 778 | 838 | if (isset($afrom[$k])) { |
| 779 | - foreach($afrom[$k] as $kk=>$vv) $afrom[$k][$kk] = implode(' ',$afrom[$k][$kk]); |
|
| 839 | + foreach($afrom[$k] as $kk=>$vv) { |
|
| 840 | + $afrom[$k][$kk] = implode(' ',$afrom[$k][$kk]); |
|
| 841 | + } |
|
| 780 | 842 | $from_synth["$k@"]= implode(' ',$afrom[$k]); |
| 781 | 843 | unset($afrom[$k]); |
| 782 | 844 | } |
@@ -802,8 +864,9 @@ discard block |
||
| 802 | 864 | function calculer_nom_fonction_squel($skel, $mime_type='html', $connect='') |
| 803 | 865 | { |
| 804 | 866 | // ne pas doublonner les squelette selon qu'ils sont calcules depuis ecrire/ ou depuis la racine |
| 805 | - if ($l=strlen(_DIR_RACINE) AND strncmp($skel,_DIR_RACINE,$l)==0) |
|
| 806 | - $skel = substr($skel,strlen(_DIR_RACINE)); |
|
| 867 | + if ($l=strlen(_DIR_RACINE) AND strncmp($skel,_DIR_RACINE,$l)==0) { |
|
| 868 | + $skel = substr($skel,strlen(_DIR_RACINE)); |
|
| 869 | + } |
|
| 807 | 870 | return $mime_type |
| 808 | 871 | . (!$connect ? '' : preg_replace('/\W/',"_", $connect)) . '_' |
| 809 | 872 | . md5($GLOBALS['spip_version_code'] . ' * ' . $skel . (isset($GLOBALS['marqueur_skel'])?'*'.$GLOBALS['marqueur_skel']:'')); |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // http://doc.spip.org/@trace_query_start |
| 16 | 18 | function trace_query_start() |
@@ -27,11 +29,13 @@ discard block |
||
| 27 | 29 | |
| 28 | 30 | // http://doc.spip.org/@trace_query_end |
| 29 | 31 | function trace_query_end($query, $start, $result, $erreur, $serveur=''){ |
| 30 | - if ($start) |
|
| 31 | - trace_query_chrono($start, microtime(), $query, $result, $serveur); |
|
| 32 | + if ($start) { |
|
| 33 | + trace_query_chrono($start, microtime(), $query, $result, $serveur); |
|
| 34 | + } |
|
| 32 | 35 | // tracer les erreurs, sauf pour select, c'est fait dans abstract_sql |
| 33 | - if ($erreur AND !preg_match('/^select\b/i', $query)) |
|
| 34 | - erreur_squelette(array(sql_errno($serveur), $erreur, $query)); |
|
| 36 | + if ($erreur AND !preg_match('/^select\b/i', $query)) { |
|
| 37 | + erreur_squelette(array(sql_errno($serveur), $erreur, $query)); |
|
| 38 | + } |
|
| 35 | 39 | return $result; |
| 36 | 40 | } |
| 37 | 41 | |
@@ -46,12 +50,17 @@ discard block |
||
| 46 | 50 | $x = _request('var_mode_objet'); |
| 47 | 51 | if (isset($GLOBALS['debug']['aucasou'])) { |
| 48 | 52 | list(, $boucle, $serveur, $contexte) = $GLOBALS['debug']['aucasou']; |
| 49 | - if ($x AND !preg_match("/$boucle\$/", $x)) |
|
| 50 | - return; |
|
| 51 | - if ($serveur) $boucle .= " ($serveur)"; |
|
| 53 | + if ($x AND !preg_match("/$boucle\$/", $x)) { |
|
| 54 | + return; |
|
| 55 | + } |
|
| 56 | + if ($serveur) { |
|
| 57 | + $boucle .= " ($serveur)"; |
|
| 58 | + } |
|
| 52 | 59 | $boucle = "<b>$boucle</b>"; |
| 53 | 60 | } else { |
| 54 | - if ($x) return; |
|
| 61 | + if ($x) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 55 | 64 | $boucle = $contexte = ''; |
| 56 | 65 | } |
| 57 | 66 | |
@@ -80,16 +89,21 @@ discard block |
||
| 80 | 89 | $k = ($contexte[0] . " $boucle"); |
| 81 | 90 | include_spip('public/compiler'); |
| 82 | 91 | $env = reconstruire_contexte_compil($contexte); |
| 83 | - } else $k = $env = $boucle; |
|
| 92 | + } else { |
|
| 93 | + $k = $env = $boucle; |
|
| 94 | + } |
|
| 84 | 95 | |
| 85 | 96 | $total += $dt; |
| 86 | 97 | $t[$key] = $dt; |
| 87 | 98 | $q[$key] = $nb; |
| 88 | 99 | $d[$k]+= $dt; |
| 89 | - if ($k) @++$n[$k]; |
|
| 100 | + if ($k) { |
|
| 101 | + @++$n[$k]; |
|
| 102 | + } |
|
| 90 | 103 | |
| 91 | - if (!is_array($explain)) |
|
| 92 | - $explain = array(); |
|
| 104 | + if (!is_array($explain)) { |
|
| 105 | + $explain = array(); |
|
| 106 | + } |
|
| 93 | 107 | foreach($explain as $j => $v) { |
| 94 | 108 | $explain[$j] = "<tr><th>$j</th><td>" |
| 95 | 109 | . str_replace(';','<br />',$v) |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/lang'); |
| 16 | 18 | |
@@ -25,8 +27,9 @@ discard block |
||
| 25 | 27 | // chargement optimise precompile |
| 26 | 28 | include_once(_CACHE_PLUGINS_FCT); |
| 27 | 29 | } |
| 28 | -if (test_espace_prive ()) |
|
| 30 | +if (test_espace_prive ()) { |
|
| 29 | 31 | include_spip('inc/filtres_ecrire'); |
| 32 | +} |
|
| 30 | 33 | |
| 31 | 34 | # Determine le squelette associe a une requete |
| 32 | 35 | # et l'applique sur le contexte, le nom du cache et le serveur |
@@ -45,20 +48,26 @@ discard block |
||
| 45 | 48 | function public_parametrer_dist($fond, $contexte='', $cache='', $connect='') { |
| 46 | 49 | static $composer,$styliser,$notes=null; |
| 47 | 50 | $page = tester_redirection($fond, $contexte, $connect); |
| 48 | - if ($page) return $page; |
|
| 51 | + if ($page) { |
|
| 52 | + return $page; |
|
| 53 | + } |
|
| 49 | 54 | |
| 50 | - if (isset($contexte['lang'])) |
|
| 51 | - $lang = $contexte['lang']; |
|
| 52 | - elseif (!isset($lang)) |
|
| 53 | - $lang = $GLOBALS['meta']['langue_site']; |
|
| 55 | + if (isset($contexte['lang'])) { |
|
| 56 | + $lang = $contexte['lang']; |
|
| 57 | + } elseif (!isset($lang)) { |
|
| 58 | + $lang = $GLOBALS['meta']['langue_site']; |
|
| 59 | + } |
|
| 54 | 60 | |
| 55 | 61 | $select = ((!isset($GLOBALS['forcer_lang']) OR !$GLOBALS['forcer_lang']) AND $lang <> $GLOBALS['spip_lang']); |
| 56 | - if ($select) $select = lang_select($lang); |
|
| 62 | + if ($select) { |
|
| 63 | + $select = lang_select($lang); |
|
| 64 | + } |
|
| 57 | 65 | |
| 58 | 66 | $debug = (defined('_VAR_MODE') && _VAR_MODE == 'debug'); |
| 59 | 67 | |
| 60 | - if (!$styliser) |
|
| 61 | - $styliser = charger_fonction('styliser', 'public'); |
|
| 68 | + if (!$styliser) { |
|
| 69 | + $styliser = charger_fonction('styliser', 'public'); |
|
| 70 | + } |
|
| 62 | 71 | list($skel,$mime_type, $gram, $sourcefile) = |
| 63 | 72 | $styliser($fond, $contexte, $GLOBALS['spip_lang'], $connect); |
| 64 | 73 | |
@@ -74,27 +83,29 @@ discard block |
||
| 74 | 83 | // charger le squelette en specifiant les langages cibles et source |
| 75 | 84 | // au cas il faudrait le compiler (source posterieure au resultat) |
| 76 | 85 | |
| 77 | - if (!$composer) |
|
| 78 | - $composer = charger_fonction('composer', 'public'); |
|
| 86 | + if (!$composer) { |
|
| 87 | + $composer = charger_fonction('composer', 'public'); |
|
| 88 | + } |
|
| 79 | 89 | $fonc = $composer($skel, $mime_type, $gram, $sourcefile, $connect); |
| 90 | + } else { |
|
| 91 | + $fonc = ''; |
|
| 80 | 92 | } |
| 81 | - else |
|
| 82 | - $fonc = ''; |
|
| 83 | 93 | |
| 84 | 94 | if (!$fonc) { // squelette inconnu (==='') ou faux (===false) |
| 85 | 95 | $page = $fonc; |
| 86 | - } |
|
| 87 | - else { |
|
| 96 | + } else { |
|
| 88 | 97 | // Preparer l'appel de la fonction principale du squelette |
| 89 | 98 | |
| 90 | 99 | spip_timer($a = 'calcul page '.rand(0,1000)); |
| 91 | 100 | |
| 92 | 101 | // On cree un marqueur de notes unique lie a cette composition |
| 93 | 102 | // et on enregistre l'etat courant des globales de notes... |
| 94 | - if (is_null($notes)) |
|
| 95 | - $notes = charger_fonction('notes', 'inc', true); |
|
| 96 | - if ($notes) |
|
| 97 | - $notes('','empiler'); |
|
| 103 | + if (is_null($notes)) { |
|
| 104 | + $notes = charger_fonction('notes', 'inc', true); |
|
| 105 | + } |
|
| 106 | + if ($notes) { |
|
| 107 | + $notes('','empiler'); |
|
| 108 | + } |
|
| 98 | 109 | |
| 99 | 110 | // Rajouter d'office ces deux parametres |
| 100 | 111 | // (mais vaudrait mieux que le compilateur sache le simuler |
@@ -102,12 +113,16 @@ discard block |
||
| 102 | 113 | if (!isset($contexte['date'])) { |
| 103 | 114 | $contexte['date'] = date("Y-m-d H:i:s"); |
| 104 | 115 | $contexte['date_default'] = true; |
| 105 | - } else $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 116 | + } else { |
|
| 117 | + $contexte['date'] = normaliser_date($contexte['date'], true); |
|
| 118 | + } |
|
| 106 | 119 | |
| 107 | 120 | if (!isset($contexte['date_redac'])) { |
| 108 | 121 | $contexte['date_redac'] = date("Y-m-d H:i:s"); |
| 109 | 122 | $contexte['date_redac_default'] = true; |
| 110 | - } else $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 123 | + } else { |
|
| 124 | + $contexte['date_redac'] = normaliser_date($contexte['date_redac'], true); |
|
| 125 | + } |
|
| 111 | 126 | |
| 112 | 127 | // Passer le nom du cache pour produire sa destruction automatique |
| 113 | 128 | $page = $fonc(array('cache' => $cache), array($contexte)); |
@@ -117,25 +132,31 @@ discard block |
||
| 117 | 132 | // etre dans son resultat, autrement elles ne seraient pas prises en |
| 118 | 133 | // compte a chaque calcul d'un texte contenant un modele, mais seulement |
| 119 | 134 | // quand le modele serait calcule, et on aurait des resultats incoherents) |
| 120 | - if ($notes) |
|
| 121 | - $notes('','depiler'); |
|
| 135 | + if ($notes) { |
|
| 136 | + $notes('','depiler'); |
|
| 137 | + } |
|
| 122 | 138 | |
| 123 | 139 | // reinjecter en dynamique la pile des notes |
| 124 | 140 | // si il y a des inclure dynamiques |
| 125 | 141 | // si la pile n'est pas vide |
| 126 | 142 | // la generalisation de cette injection permettrait de corriger le point juste au dessus |
| 127 | 143 | // en faisant remonter les notes a l'incluant (A tester et valider avant application) |
| 128 | - if ($notes) |
|
| 129 | - $page['notes'] = $notes('','sauver_etat'); |
|
| 144 | + if ($notes) { |
|
| 145 | + $page['notes'] = $notes('','sauver_etat'); |
|
| 146 | + } |
|
| 130 | 147 | |
| 131 | 148 | // spip_log: un joli contexte |
| 132 | 149 | $infos = array(); |
| 133 | 150 | foreach (array_filter($contexte) as $var => $val) { |
| 134 | - if (is_array($val)) $val = serialize($val); |
|
| 135 | - if (strlen("$val") > 30) |
|
| 136 | - $val = substr("$val", 0,27).'..'; |
|
| 137 | - if (strstr($val,' ')) |
|
| 138 | - $val = "'$val'"; |
|
| 151 | + if (is_array($val)) { |
|
| 152 | + $val = serialize($val); |
|
| 153 | + } |
|
| 154 | + if (strlen("$val") > 30) { |
|
| 155 | + $val = substr("$val", 0,27).'..'; |
|
| 156 | + } |
|
| 157 | + if (strstr($val,' ')) { |
|
| 158 | + $val = "'$val'"; |
|
| 159 | + } |
|
| 139 | 160 | $infos[] = $var.'='.$val; |
| 140 | 161 | } |
| 141 | 162 | $profile = spip_timer($a); |
@@ -167,10 +188,11 @@ discard block |
||
| 167 | 188 | // si aucun #CACHE{} specifie |
| 168 | 189 | // le contexte implicite qui conditionne le cache assure qu'on retombe pas sur le meme |
| 169 | 190 | // entre public et prive |
| 170 | - if (test_espace_prive() OR strncmp($fond,'modeles/',8)==0) |
|
| 171 | - $page['entetes']['X-Spip-Cache'] = 0; |
|
| 172 | - else |
|
| 173 | - $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais'])?$GLOBALS['delais']:36000; |
|
| 191 | + if (test_espace_prive() OR strncmp($fond,'modeles/',8)==0) { |
|
| 192 | + $page['entetes']['X-Spip-Cache'] = 0; |
|
| 193 | + } else { |
|
| 194 | + $page['entetes']['X-Spip-Cache'] = isset($GLOBALS['delais'])?$GLOBALS['delais']:36000; |
|
| 195 | + } |
|
| 174 | 196 | } |
| 175 | 197 | |
| 176 | 198 | $page['contexte'] = $contexte; |
@@ -192,7 +214,9 @@ discard block |
||
| 192 | 214 | } |
| 193 | 215 | } |
| 194 | 216 | |
| 195 | - if ($select) lang_select(); |
|
| 217 | + if ($select) { |
|
| 218 | + lang_select(); |
|
| 219 | + } |
|
| 196 | 220 | |
| 197 | 221 | return $page; |
| 198 | 222 | } |
@@ -224,8 +248,9 @@ discard block |
||
| 224 | 248 | // etre utilisee dans un contexte d'url qui change |
| 225 | 249 | // y compris url arbo |
| 226 | 250 | $status = 302; |
| 227 | - if (defined('_STATUS_REDIRECTION_VIRTUEL')) |
|
| 228 | - $status=_STATUS_REDIRECTION_VIRTUEL; |
|
| 251 | + if (defined('_STATUS_REDIRECTION_VIRTUEL')) { |
|
| 252 | + $status=_STATUS_REDIRECTION_VIRTUEL; |
|
| 253 | + } |
|
| 229 | 254 | if (!preg_match(',^\w+:,', $url)) { |
| 230 | 255 | include_spip('inc/filtres_mini'); |
| 231 | 256 | $url = url_absolue($url); |